:root {
    --window: #17130a;
    --surface: #241c0b;
    --surface-raised: #36280e;
    --surface-soft: #4a3714;
    --text: #fff8e3;
    --muted: #d8c58a;
    --accent: #f4c542;
    --accent-strong: #ffdd6e;
    --line: rgba(255, 248, 227, 0.14);
    --shadow: rgba(0, 0, 0, 0.36);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        linear-gradient(145deg, rgba(244, 197, 66, 0.22), transparent 34%),
        radial-gradient(circle at 76% 10%, rgba(255, 221, 110, 0.2), transparent 24%),
        var(--window);
    font-family: Aptos, "Segoe UI", sans-serif;
}

button,
input {
    font: inherit;
}

.page {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.home-page {
    grid-template-rows: 1fr;
    place-items: center;
}

.search-shell {
    display: grid;
    justify-items: center;
    gap: 20px;
    width: min(820px, calc(100% - 32px));
    padding: 20px;
}

.brand {
    width: min(301px, 76vw);
    height: auto;
    filter: drop-shadow(0 18px 26px var(--shadow));
}

.search-form {
    width: min(760px, 100%);
    min-height: 62px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 8px;
    border: 1px solid rgba(244, 197, 66, 0.42);
    border-radius: 8px;
    background: rgba(16, 13, 7, 0.78);
    box-shadow: 0 18px 44px var(--shadow);
}

.search-form.compact {
    width: min(720px, 100%);
    min-height: 54px;
    padding: 6px;
    box-shadow: none;
}

#search-input {
    min-width: 0;
    height: 46px;
    border: 0;
    outline: 0;
    border-radius: 6px;
    padding: 0 16px;
    color: var(--text);
    background: transparent;
    font-size: 18px;
}

#search-input::placeholder {
    color: rgba(216, 197, 138, 0.72);
}

#search-input::-webkit-search-cancel-button {
    width: 18px;
    height: 18px;
    cursor: pointer;
    background: var(--accent);
    -webkit-appearance: none;
    appearance: none;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18'/%3E%3Cpath d='m6 6 12 12'/%3E%3C/svg%3E") center / 18px 18px no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18'/%3E%3Cpath d='m6 6 12 12'/%3E%3C/svg%3E") center / 18px 18px no-repeat;
}

.search-field {
    position: relative;
    min-width: 0;
}

#search-input {
    width: 100%;
}

#search-input::-webkit-search-cancel-button {
    display: none;
}

.clear-search {
    position: absolute;
    top: 50%;
    right: 6px;
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    color: var(--accent);
    background: transparent;
    cursor: pointer;
    transform: translateY(-50%);
}

.clear-search[hidden] {
    display: none;
}

.clear-search svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.search-submit {
    height: 46px;
    border: 1px solid rgba(244, 197, 66, 0.35);
    border-radius: 6px;
    color: var(--text);
    background: var(--surface-soft);
    cursor: pointer;
}

.search-submit {
    width: 52px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    color: #241600;
    border-color: var(--accent);
    background: linear-gradient(180deg, var(--accent-strong), var(--accent));
    font-weight: 700;
}

.search-submit img {
    width: 22px;
    height: 22px;
    filter: brightness(0) saturate(100%) invert(10%) sepia(51%) saturate(1175%) hue-rotate(4deg) brightness(96%) contrast(107%);
}

.results-header {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    padding: 22px clamp(16px, 4vw, 42px);
    border-bottom: 1px solid var(--line);
    background: rgba(23, 19, 10, 0.88);
}

.results-header .search-form {
    justify-self: center;
}

.brand-link {
    position: absolute;
    left: clamp(16px, 4vw, 42px);
    display: inline-flex;
    align-items: center;
}

.brand-small {
    width: 132px;
}

.search-tabs-bar {
    display: grid;
    justify-items: center;
    padding: 0 clamp(16px, 4vw, 42px);
    border-bottom: 1px solid var(--line);
    background: rgba(23, 19, 10, 0.72);
}

.search-tabs {
    width: min(1138px, calc(100% - 76px));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.search-tabs::-webkit-scrollbar {
    display: none;
}

.search-tabs button {
    position: relative;
    min-width: max-content;
    height: 34px;
    padding: 0 14px;
    border: 0;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.search-tabs button::after {
    content: '';
    position: absolute;
    right: 12px;
    bottom: 0;
    left: 12px;
    height: 3px;
    border-radius: 999px 999px 0 0;
    background: transparent;
}

.search-tabs button:hover,
.search-tabs button[aria-current='page'] {
    color: var(--accent-strong);
}

.search-tabs button[aria-current='page']::after {
    background: var(--accent);
}

.results-region {
    width: min(1138px, calc(100% - 76px));
    justify-self: center;
    margin-left: 0;
    padding: 28px 0 60px;
}

.state {
    min-height: 26px;
    color: var(--muted);
    font-size: 14px;
}

.state.is-loading {
    display: grid;
    align-items: center;
    justify-items: center;
}

.loading-bar {
    position: relative;
    width: min(620px, 100%);
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(244, 197, 66, 0.16);
    box-shadow: 0 0 24px rgba(244, 197, 66, 0.18);
}

.loading-bar span {
    position: absolute;
    inset: 0 auto 0 0;
    width: 42%;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, var(--accent), var(--accent-strong), transparent);
    animation: loadingSweep 1.05s ease-in-out infinite;
}

.results {
    list-style: none;
    display: grid;
    gap: 14px;
    margin: 0;
    padding: 0;
}

.results--images {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    align-items: start;
}

.load-more {
    height: 44px;
    margin-top: 22px;
    padding: 0 18px;
    border: 1px solid rgba(244, 197, 66, 0.38);
    border-radius: 8px;
    color: #241600;
    background: linear-gradient(180deg, var(--accent-strong), var(--accent));
    font-weight: 700;
    cursor: pointer;
}

.load-more[hidden] {
    display: none;
}

.result {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(36, 28, 11, 0.78);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.result--new {
    animation: resultReveal 420ms cubic-bezier(0.2, 0.85, 0.25, 1) both;
    animation-delay: var(--result-delay, 0ms);
}

.result-favicon {
    width: 24px;
    height: 24px;
    margin-top: 2px;
    border-radius: 6px;
    background: rgba(255, 248, 227, 0.12);
}

.result-body {
    min-width: 0;
}

.result a {
    color: var(--accent-strong);
    text-decoration: none;
}

.result a:hover {
    text-decoration: underline;
}

.result-title {
    margin: 0 0 7px;
    font-size: 20px;
    line-height: 1.25;
}

.result-url {
    display: block;
    margin-bottom: 9px;
    color: var(--muted);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.result-snippet {
    margin: 0;
    color: var(--text);
    line-height: 1.5;
}

.image-result {
    display: block;
    padding: 10px;
    overflow: hidden;
}

.image-result-preview {
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 6px;
    background: rgba(255, 248, 227, 0.08);
}

.image-result-preview img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.image-result-body {
    padding: 10px 2px 2px;
}

.image-result .result-title {
    margin-bottom: 6px;
    font-size: 15px;
    line-height: 1.28;
}

.image-result .result-url {
    margin-bottom: 0;
}

@keyframes loadingSweep {
    0% {
        transform: translateX(-115%);
    }

    100% {
        transform: translateX(260%);
    }
}

@keyframes resultReveal {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.985);
        border-color: rgba(244, 197, 66, 0.36);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        border-color: var(--line);
    }
}

@media (prefers-reduced-motion: reduce) {
    .loading-bar span,
    .result--new {
        animation: none;
    }
}

@media (max-width: 640px) {
    body {
        background:
            linear-gradient(160deg, rgba(244, 197, 66, 0.2), transparent 42%),
            var(--window);
    }

    .search-shell {
        gap: 18px;
        width: min(100%, 390px);
        padding: 20px 14px;
    }

    .home-page .brand {
        width: min(258px, 78vw);
    }

    .search-form,
    .search-form.compact {
        width: 100%;
        min-height: 56px;
        grid-template-columns: minmax(0, 1fr) 46px;
        gap: 6px;
        padding: 6px;
        border-radius: 10px;
    }

    #search-input {
        height: 42px;
        padding: 0 12px;
        font-size: 16px;
    }

    .search-submit {
        width: 46px;
        height: 42px;
        border-radius: 8px;
    }

    .results-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        gap: 12px;
        min-height: 0;
        padding: 16px 14px 14px;
    }

    .results-header .search-form,
    .brand-link {
        position: static;
    }

    .results-header .search-form {
        width: min(100%, 420px);
    }

    .search-tabs-bar {
        padding: 0 14px;
    }

    .search-tabs {
        width: min(100%, 420px);
        justify-content: flex-start;
        padding: 0 2px;
    }

    .search-tabs button {
        height: 32px;
        padding: 0 12px;
        font-size: 14px;
    }

    .brand-small {
        width: 116px;
    }

    .results-region {
        width: min(100% - 20px, 520px);
        justify-self: center;
        margin-left: 0;
        padding: 16px 0 42px;
    }

    .state {
        min-height: 22px;
        padding: 0 4px;
        font-size: 13px;
    }

    .results {
        gap: 10px;
    }

    .results--images {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .result {
        grid-template-columns: 26px minmax(0, 1fr);
        gap: 10px;
        padding: 14px;
        border-radius: 10px;
    }

    .result-favicon {
        width: 22px;
        height: 22px;
        border-radius: 5px;
    }

    .result-title {
        margin-bottom: 6px;
        font-size: 17px;
        line-height: 1.28;
    }

    .result-url {
        margin-bottom: 7px;
        font-size: 12px;
    }

    .result-snippet {
        font-size: 14px;
        line-height: 1.45;
    }

    .image-result {
        padding: 8px;
    }

    .image-result .result-title {
        font-size: 13px;
    }

    .load-more {
        width: 100%;
        height: 46px;
        margin-top: 16px;
    }
}