/* ChromeLoad — site stylesheet (no framework). Tokens first, then layout, then components. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #15191e;
    --muted: #5b6673;
    --faint: #8a94a1;
    --border: #e2e6eb;
    --brand: #1a73e8;
    --brand-strong: #1557b0;
    --brand-soft: #e8f0fe;
    --on-brand: #ffffff;
    --good: #188038;
    --good-soft: #e6f4ea;
    --star: #f2a600;
    --hero-a: #e8f0fe;
    --hero-b: #f3e8fd;
    --footer-bg: #101418;
    --footer-text: #c4ccd5;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 6px 20px rgba(16, 24, 40, .08);
    --radius: 14px;
    --radius-sm: 10px;
    --header-h: 64px;
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1115;
        --surface: #161a20;
        --surface-2: #1d222a;
        --text: #e8eaed;
        --muted: #a1abb8;
        --faint: #78828f;
        --border: #2a3039;
        --brand: #8ab4f8;
        --brand-strong: #aecbfa;
        --brand-soft: #1c2b44;
        --on-brand: #0e1115;
        --good: #81c995;
        --good-soft: #17301f;
        --star: #fdd663;
        --hero-a: #15233a;
        --hero-b: #26193a;
        --footer-bg: #0a0c0f;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-md: 0 6px 20px rgba(0, 0, 0, .45);
        color-scheme: dark;
    }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
main { flex: 1 0 auto; }
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem); font-weight: 750; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
button, input, textarea { font: inherit; color: inherit; }

.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }
.icon-fill { fill: currentColor; stroke: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); color: var(--brand); padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow-md); }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .container { padding: 0 24px; } }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5em;
    min-height: 44px; padding: 0 18px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface); color: var(--text);
    font-weight: 600; font-size: .95rem; line-height: 1;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background-color .15s, border-color .15s, box-shadow .15s, transform .15s;
}
.btn:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); box-shadow: var(--shadow-md); }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 1.02rem; }
.btn-block { width: 100%; }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(12px);
    -webkit-backdrop-filter: saturate(1.6) blur(12px);
    border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #1a73e8 0%, #34a853 55%, #fbbc04 100%); box-shadow: var(--shadow-sm); }
.brand-mark .icon { width: 20px; height: 20px; }
.brand-tld { color: var(--faint); font-weight: 600; }

.header-search { flex: 1; max-width: 520px; margin-left: auto; position: relative; }
.search-field { position: relative; display: flex; align-items: center; }
.search-field > .icon { position: absolute; left: 14px; color: var(--faint); pointer-events: none; }
.search-field input {
    width: 100%; height: 44px; padding: 0 16px 0 42px;
    border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface-2); outline: none;
    transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.search-field input:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-soft); }
.search-field input::-webkit-search-cancel-button { cursor: pointer; }

.main-nav { display: flex; align-items: center; gap: 4px; }
.main-nav a { color: var(--muted); font-weight: 600; font-size: .95rem; padding: 8px 12px; border-radius: 999px; }
.main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); text-decoration: none; }
.menu-toggle { display: none; width: 44px; height: 44px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; place-items: center; color: var(--text); }
.menu-toggle:hover { background: var(--surface-2); }
.menu-toggle .icon { width: 24px; height: 24px; }

@media (max-width: 860px) {
    .header-inner { gap: 8px; }
    .header-search { order: 3; flex-basis: 100%; max-width: none; margin: 0 0 12px; }
    .header-inner { flex-wrap: wrap; height: auto; padding-top: 10px; }
    .menu-toggle { display: grid; margin-left: auto; }
    .main-nav { display: none; order: 4; flex-basis: 100%; flex-direction: column; align-items: stretch; padding-bottom: 12px; }
    .main-nav.is-open { display: flex; }
    .main-nav a { padding: 12px; border-radius: var(--radius-sm); }
    .brand-tld { display: none; }
}

/* ---------- Hero ---------- */
.hero {
    background:
        radial-gradient(1200px 400px at 10% -10%, var(--hero-a), transparent 60%),
        radial-gradient(900px 400px at 100% 0%, var(--hero-b), transparent 60%);
    border-bottom: 1px solid var(--border);
    padding: 56px 0 40px;
    text-align: center;
}
.hero h1 { max-width: 760px; margin: 0 auto 12px; }
.hero-lead { color: var(--muted); font-size: 1.1rem; max-width: 620px; margin: 0 auto 28px; }
.hero-search { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; }
.hero-search .search-field { flex: 1; }
.hero-search input { height: 54px; font-size: 1.05rem; background: var(--surface); box-shadow: var(--shadow-sm); }
.hero-search .btn { min-height: 54px; }
.hero-stats { display: flex; justify-content: center; gap: 28px; flex-wrap: wrap; margin-top: 28px; color: var(--muted); font-size: .95rem; }
.hero-stats strong { color: var(--text); font-size: 1.15rem; display: block; }
@media (max-width: 600px) {
    .hero { padding: 36px 0 28px; }
    .hero-search { flex-direction: column; }
}

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hero .chips { justify-content: center; margin-top: 20px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); font-size: .9rem; font-weight: 550;
}
.chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.chip[aria-current="page"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

/* ---------- Sections ---------- */
.section { padding: 40px 0; }
.section + .section { padding-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { margin: 0; }
.section-head a { font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }

/* ---------- App cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; list-style: none; margin: 0; padding: 0; }
.app-card {
    position: relative; display: flex; gap: 14px; align-items: flex-start;
    height: 100%; padding: 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.app-card:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.app-card img { width: 56px; height: 56px; border-radius: 12px; object-fit: contain; background: var(--surface-2); flex: none; }
.app-card-body { min-width: 0; flex: 1; }
.app-card-title { margin: 0 0 6px; font-size: 1rem; font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.app-card-title a { color: var(--text); }
.app-card-title a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.app-card-title a:hover { text-decoration: none; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--muted); font-size: .85rem; }
.meta > span { display: inline-flex; align-items: center; gap: 4px; }
.meta .icon { width: 14px; height: 14px; }
.rating .icon { color: var(--star); }
.rating strong { color: var(--text); font-weight: 650; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-size: .75rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.badge-free { background: var(--good-soft); color: var(--good); }

/* Theme cards (image-led) */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 46%), 1fr)); gap: 14px; list-style: none; margin: 0; padding: 0; }
.theme-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: box-shadow .15s, transform .15s; height: 100%; }
.theme-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.theme-card .thumb { aspect-ratio: 16 / 10; width: 100%; height: auto; object-fit: cover; background: var(--surface-2); }
.theme-card-body { padding: 12px 14px 14px; }
.theme-card .app-card-title { -webkit-line-clamp: 1; }
.theme-card .app-card-title a::after { border-radius: var(--radius); }

/* Category tiles */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; list-style: none; margin: 0; padding: 0; }
.cat-tile { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-weight: 600; }
.cat-tile:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.cat-tile .count { color: var(--faint); font-weight: 500; font-size: .85rem; }

/* ---------- Page head / breadcrumbs ---------- */
.page-head { padding: 22px 0 8px; }
.crumbs { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: .88rem; color: var(--muted); }
.crumbs li { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.crumbs li + li::before { content: "/"; color: var(--faint); margin: 0 4px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brand); }
.crumbs [aria-current] { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50vw; }
.page-head p { color: var(--muted); margin: 0; }

.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); margin: 16px 0 0; flex-wrap: wrap; }
.tabs a { padding: 7px 16px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .92rem; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Catalog layout ---------- */
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; align-items: start; padding: 20px 0 48px; }
.filters { position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100vh - var(--header-h) - 32px); overflow: auto; padding-right: 4px; scrollbar-width: thin; }
.filters h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 0 0 8px; }
.filter-list { list-style: none; margin: 0 0 20px; padding: 0; }
.filter-list a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--text); font-size: .93rem; }
.filter-list a:hover { background: var(--surface-2); text-decoration: none; }
.filter-list a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.filters-mobile { display: none; }

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; gap: 12px; padding-top: 8px; }
    .filters { display: none; }
    .filters-mobile { display: block; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
    .filters-mobile summary { padding: 12px 16px; font-weight: 650; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
    .filters-mobile summary::-webkit-details-marker { display: none; }
    .filters-mobile[open] summary .icon { transform: rotate(90deg); }
    .filters-mobile .filter-list { max-height: 50vh; overflow: auto; padding: 0 8px 8px; margin: 0; }
}

.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: .9rem; margin-bottom: 14px; }

.empty { text-align: center; padding: 48px 16px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty h2 { font-size: 1.2rem; }

.prose-block { margin-top: 36px; padding: 22px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted); }
.prose-block h2 { color: var(--text); font-size: 1.1rem; }
.prose-block p:last-child { margin: 0; }

/* ---------- Pagination ---------- */
.pager { display: flex; justify-content: center; margin: 32px 0 0; }
.pager ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.pager a, .pager span { display: inline-grid; place-items: center; min-width: 42px; height: 42px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: .92rem; }
.pager a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pager [aria-current="page"] span { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.pager .disabled span { color: var(--faint); background: transparent; }
.pager .gap span { border-color: transparent; background: transparent; }

/* ---------- Item page ---------- */
.item-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 24px; align-items: center; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.item-icon { width: 112px; height: 112px; border-radius: 22px; object-fit: contain; background: var(--surface-2); padding: 8px; }
.item-hero h1 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); margin-bottom: 10px; overflow-wrap: anywhere; }
.item-hero .meta { font-size: .92rem; gap: 8px 16px; }
.item-cta { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 230px; }
.item-cta small { color: var(--faint); text-align: center; font-size: .8rem; }
@media (max-width: 760px) {
    .item-hero { grid-template-columns: 1fr; text-align: center; justify-items: center; padding: 20px 16px; }
    .item-hero .meta { justify-content: center; }
    .item-cta { width: 100%; min-width: 0; }
    .item-icon { width: 96px; height: 96px; }
}

.item-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; padding: 24px 0 48px; }
@media (max-width: 960px) { .item-layout { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; }
.panel + .panel { margin-top: 20px; }
.panel h2 { font-size: 1.15rem; }
.screenshot { border-radius: var(--radius-sm); border: 1px solid var(--border); width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; background: var(--surface-2); margin-bottom: 18px; }
.prose { overflow-wrap: anywhere; color: var(--text); }
.prose.is-clamped { max-height: 18em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.prose-toggle { margin-top: 12px; }

.aside { position: sticky; top: calc(var(--header-h) + 16px); display: grid; gap: 20px; }
@media (max-width: 960px) { .aside { position: static; } }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; font-size: .93rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; }
.share-row .btn { min-height: 38px; padding: 0 14px; font-size: .88rem; }
.note { font-size: .85rem; color: var(--muted); margin: 14px 0 0; display: flex; gap: 8px; }
.note .icon { color: var(--good); margin-top: 2px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; max-width: 640px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.field label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.field input, .field textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); outline: none; }
.field textarea { min-height: 160px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.alert { padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-error { background: #fdecea; border-color: #f5c2bd; color: #8a1c12; }
.alert-ok { background: var(--good-soft); border-color: transparent; color: var(--good); font-weight: 600; }
@media (prefers-color-scheme: dark) { .alert-error { background: #3a1714; border-color: #5c2420; color: #f6aea9; } }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Footer ---------- */
.site-footer { background: var(--footer-bg); color: var(--footer-text); padding: 48px 0 28px; margin-top: 40px; font-size: .93rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 2fr; gap: 32px; }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr; gap: 24px; } }
.site-footer .brand { color: #fff; }
.site-footer h2 { color: #fff; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer-cats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); column-gap: 16px; }
.site-footer a { color: var(--footer-text); }
.site-footer a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .1); margin-top: 32px; padding-top: 20px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; color: #8b95a1; font-size: .85rem; }

/* ---------- Error pages ---------- */
.error-page { text-align: center; padding: 72px 0; }
.error-code { font-size: 5rem; font-weight: 800; line-height: 1; background: linear-gradient(135deg, #1a73e8, #34a853); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 8px; }
.error-page .hero-search { margin: 24px auto; }
.error-page .chips { justify-content: center; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
    .site-header, .site-footer, .filters, .filters-mobile, .share-row, .item-cta { display: none !important; }
}
.footer-about { margin-top: 14px; }
.section-flush { padding-top: 0; }

.theme-card .thumb.is-missing {
    background: linear-gradient(135deg, var(--hero-a), var(--hero-b));
}
