:root {
    --bg: #1c1c1d;
    --fg: #e9eaee;
    --muted: #a6a8ad;
    --accent: #5b8cff;
    --card: #242426;
    --outline: #2a2b31;
    --panel: #2a2b2f;
    --panel-border: #35363b;
    --row: #2f3034;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    --maxw: 720px;

    /* Popular Brands sizes */
    --pb-h: 70px;
    /* tile height */
    --pb-gap: 10px;
    /* space between tiles */

    /* Toggle tunables */
    --toggle-w: 66px;
    --toggle-h: 36px;
    --toggle-pad: 2px;
    --toggle-border: 2px;
    --toggle-stroke: #fff;
    --toggle-icon: #fff;
    --toggle-thumb: #fff;
    --ico: 18px;
}

[data-theme="light"] {
    --bg: #fbfbfb;
    --fg: #0f1222;
    --muted: #5b5f6a;
    --card: #f3f5f7;
    --outline: #dfe3ea;
    --panel: #ffffff;
    --panel-border: #e9edf3;
    --row: #ffffff;
    --shadow: 0 10px 30px rgba(10, 18, 32, .08);
    --toggle-stroke: #dcdcdc;
    --toggle-icon: #6b7280;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Inter, "Helvetica Neue", Arial;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Sticky footer */
main {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .3s;
}

footer {
    flex-shrink: 0;
    color: var(--muted);
    border-top: 1px solid var(--outline);
}

.hero {
    width: 100%;
}

.wrap {
    width: 100%;
    max-width: var(--maxw);
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

@media (max-width:640px) {
    .wrap {
        padding-inline: max(2vw, 10px);
    }
}

/* Logo — use your image, ready for light/dark */
.logo {
    width: min(180px, 28vw);
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    /* keep ~50px above search */
}

.logo img {
    max-width: 100%;
    height: auto;
    display: block;
    filter: none;
}

/* Search */
.search {
    width: 100%;
    position: relative;
}

.search-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .28);
    overflow: hidden;
    transition: box-shadow .3s, height .3s, max-height .3s, border-radius .3s;
    position: relative;
    z-index: 1000;
}

[data-theme="light"] .search-card {
    box-shadow: 0 16px 40px rgba(10, 18, 32, .10);
}

.search-head {
    background: var(--panel);
    border-radius: 9999px;
    transition: border-radius .3s, padding .3s;
}

.search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
}

.search.open .search-head {
    border-radius: 24px 24px 12px 12px;
}

.search-row .icon {
    width: 22px;
    height: 22px;
    opacity: .85;
    color: var(--fg);
}

/* NEW: ensure SVG paths use currentColor so icon is white in dark */
.search-row .icon path,
.search-row .icon circle,
.search-row .icon line,
.search-row .icon rect,
.search-row .icon polygon {
    fill: currentColor;
    stroke: currentColor;
}

.q {
    flex: 1;
    font: inherit;
    color: var(--fg);
    background: transparent;
    border: 0;
    outline: 0;
    padding: 8px 4px;
}

.q::placeholder {
    color: var(--muted);
}

.btn {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 8px;
    cursor: pointer;
}

.s-titlebar {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0 18px;
    transition: max-height .3s, opacity .3s;
}

.search.open .s-titlebar {
    max-height: 40px;
    opacity: 1;
}

.s-titlebar h3 {
    margin: 10px 0 4px;
    font-size: 14px;
    line-height: 1;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
}

.s-list {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height .3s, opacity .3s;
    background: var(--row);
}

.search.open .s-list {
    opacity: 1;
}

@media (min-width:641px) {
    .search.open .search-card {
        display: flex;
        flex-direction: column;
        height: 60vh;
        max-height: 60vh;
    }

    .search.open .s-list {
        max-height: none;
        overflow: auto;
        flex: 1 1 auto;
    }
}

.s-item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px 18px;
    border-top: 1px solid var(--panel-border);
    cursor: pointer;
}

.s-item:first-child {
    border-top: 0;
}

.s-item:hover {
    background: rgba(255, 255, 255, .06);
}

.s-leading {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #3a3a3f;
    display: grid;
    place-items: center;
    flex: 0 0 28px;
}

[data-theme="light"] .s-leading {
    background: #eef1f6;
}

.s-title {
    font-weight: 700;
}

.s-sub {
    color: var(--muted);
    font-size: 13px;
}

/* Popular Brands — two rows, guaranteed horizontal scroll, no scrollbar */
.popular-brands {
    width: 100%;
    max-width: var(--maxw);
    margin-top: 10px;
    transition: opacity .2s;
}

.pb-title {
    margin: 0 0 6px 6px;
    font-size: 14px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
}

.pb-rail {
    position: relative;
    height: calc(var(--pb-h) * 2 + var(--pb-gap));
    /* exactly two rows */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox: hide scrollbar */
}

.pb-rail::-webkit-scrollbar {
    display: none;
}

/* WebKit: hide scrollbar */

.pb-rows {
    display: inline-flex;
    flex-direction: column;
    gap: var(--pb-gap);
}

.pb-row {
    display: flex;
    gap: var(--pb-gap);
    flex-wrap: nowrap;
    align-items: center;
    height: var(--pb-h);
}

.pb-card {
    background: var(--row);
    border: 0.5px solid var(--panel-border);
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    height: var(--pb-h);
    width: max-content;
    max-width: 480px;
    white-space: nowrap;
}

.pb-logo {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #e9edf3;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #333;
    flex: 0 0 30px;
}

.pb-img {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    object-fit: contain;
    background: #fff;
    display: none;
    flex: 0 0 30px;
}

.pb-card.has-logo .pb-img {
    display: block;
}

.pb-card.has-logo .pb-logo {
    display: none;
}

.pb-name {
    font-weight: 700;
    color: var(--fg);
}

/* Hide brands when search panel is open */
.search.open~.popular-brands {
    display: none;
}

/* Footer */
.foot {
    max-width: var(--maxw);
    margin: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 18px;
    padding: 14px 12px;
    font-size: .8rem;
    line-height: 1.1rem;
}

.foot-links {
    display: flex;
    gap: 18px;
}

.foot a {
    color: inherit;
    text-decoration: none;
}

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

@media(max-width:640px) {
    .foot {
        flex-direction: column;
        gap: 8px;
    }

    .foot-links {
        display: flex;
        gap: 16px 18px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .copyright {
        text-align: center;
    }
}

/* THEME TOGGLE (lower z-index; hidden while mobile search open) */
.theme-toggle {
    position: fixed;
    right: 16px;
    top: 16px;
    z-index: 400;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.theme-track {
    width: var(--toggle-w);
    height: var(--toggle-h);
    padding: var(--toggle-pad);
    border: var(--toggle-border) solid var(--toggle-stroke);
    border-radius: 9999px;
    position: relative;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.theme-ico {
    width: var(--ico);
    height: var(--ico);
    margin: 0 8px;
    color: var(--toggle-icon);
    opacity: .9;
    pointer-events: none;
}

.theme-thumb {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: calc(var(--toggle-h) - 2*var(--toggle-pad) - 2*var(--toggle-border));
    height: calc(var(--toggle-h) - 2*var(--toggle-pad) - 2*var(--toggle-border));
    border-radius: 9999px;
    background: var(--toggle-thumb);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
    left: calc(var(--toggle-pad) + var(--toggle-border));
    transition: left .22s ease;
}

[data-theme="light"] .theme-thumb {
    left: calc(var(--toggle-w) - (var(--toggle-pad) + var(--toggle-border)) - (var(--toggle-h) - 2*var(--toggle-pad) - 2*var(--toggle-border)));
}

[data-theme="light"] .sun {
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, .7));
}

/* Mobile full-screen on focus */
body.mobile-active main {
    align-items: flex-start;
    justify-content: flex-start;
}

body.mobile-active .logo {
    display: none;
}

body.mobile-active .search-card {
    position: fixed;
    inset: 0;
    height: 100svh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    z-index: 1000;
}

body.mobile-active .search-head {
    position: sticky;
    top: 0;
    z-index: 2;
    border-radius: 0;
}

body.mobile-active .s-titlebar {
    padding-top: 4px;
}

body.mobile-active .s-list {
    flex: 1 1 auto;
    overflow: auto;
    max-height: none;
}

body.mobile-active .theme-toggle {
    display: none;
}

/* hide toggle while search overlay is active */

/* DISCLAIMER PILL */
.pill {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 16px;
    z-index: 450;
    background: var(--panel);
    color: var(--fg);
    border: 1px solid var(--panel-border);
    border-radius: 9999px;
    padding: 10px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: min(92vw, var(--maxw));
    pointer-events: auto;
    font-size: .9rem;
    white-space: normal;
}

@media (max-width:640px) {
    .pill {
        left: auto;
        right: 1vw;
        transform: none;
        width: 98vw;
        max-width: 98vw;
        border-radius: 12px;
    }
}

.pill a {
    color: var(--accent);
    text-decoration: underline;
}

.pill .pill-btn {
    border: 0;
    background: transparent;
    color: var(--fg);
    padding: 6px 10px;
    border-radius: 9999px;
    cursor: pointer;
    white-space: nowrap;
}

.pill.hidden {
    display: none;
}

body.mobile-active .pill {
    display: none;
}