/* Site UI. One stylesheet for home, category, detail and text pages. */

:root {
    --bg: #f4f5fb;
    --glass: rgba(244, 245, 251, .86);
    --surface: #ffffff;
    --surface-2: #eceefa;
    --text: #12142b;
    --muted: #666b8f;
    --line: rgba(18, 20, 43, .09);
    --primary: #5b4cf5;
    --primary-2: #8f6bff;
    --ring: rgba(91, 76, 245, .28);
    --shadow: 0 1px 2px rgba(18, 20, 43, .06), 0 10px 26px rgba(18, 20, 43, .07);
    --radius: 20px;
    --maxw: 1200px;
    --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0d0f1f;
    --glass: rgba(13, 15, 31, .86);
    --surface: #171a33;
    --surface-2: #20244a;
    --text: #f1f2ff;
    --muted: #a0a5cc;
    --line: rgba(255, 255, 255, .09);
    --ring: rgba(143, 107, 255, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px rgba(0, 0, 0, .35);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d0f1f;
        --glass: rgba(13, 15, 31, .86);
        --surface: #171a33;
        --surface-2: #20244a;
        --text: #f1f2ff;
        --muted: #a0a5cc;
        --line: rgba(255, 255, 255, .09);
        --ring: rgba(143, 107, 255, .4);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px rgba(0, 0, 0, .35);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 8px; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-left: 16px; padding-right: 16px; }

/* ---- top bar ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--glass);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .2px; flex: none; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 6px 16px rgba(91, 76, 245, .35);
}
.brand-name { white-space: nowrap; font-size: 17px; }

.search { position: relative; flex: 1; max-width: 480px; margin-left: auto; }
.search input {
    width: 100%;
    height: 40px;
    padding: 0 16px 0 42px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    outline: none;
    transition: box-shadow .15s, border-color .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.search-icon { position: absolute; left: 14px; top: 11px; color: var(--muted); pointer-events: none; }
.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 60;
    max-height: 70vh;
    overflow: auto;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.search-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; }
.search-item img { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); object-fit: cover; }
.search-item span { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item:hover, .search-item[aria-selected="true"] { background: var(--surface-2); }
.search-empty { padding: 14px; color: var(--muted); font-size: 14px; }

.icon-btn {
    display: grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-sun { display: block; }
    :root:not([data-theme="light"]) .icon-moon { display: none; }
}

.chips {
    display: flex;
    gap: 8px;
    padding-top: 2px;
    padding-bottom: 22px;
    overflow-x: auto;
    scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: none;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    transition: color .15s, background .15s;
}
.chip:hover { color: var(--text); }
.chip[aria-current="page"] {
    border-color: transparent;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
}

/* ---- buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 8px 20px rgba(91, 76, 245, .35);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(91, 76, 245, .42); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 14px 36px; font-size: 18px; }

/* ---- home hero ---- */
.hero { padding: 22px 0 6px; }
.hero h1 { font-size: clamp(26px, 4.6vw, 42px); line-height: 1.1; letter-spacing: -.02em; font-weight: 900; }
.hero p { margin: 8px 0 18px; color: var(--muted); max-width: 560px; }
.rail {
    display: flex;
    gap: 14px;
    margin: 0 -16px;
    padding: 4px 16px 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 16px;
    scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.feature, .detail-hero { position: relative; isolation: isolate; overflow: hidden; color: #fff; }
.feature::before, .detail-hero::before {
    content: "";
    position: absolute;
    inset: -30%;
    z-index: -2;
    background: var(--icon) center / cover;
    filter: blur(30px) saturate(1.5);
}
.feature::after, .detail-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(135deg, rgba(14, 16, 40, .62), rgba(14, 16, 40, .28));
}
.feature {
    display: flex;
    flex: 0 0 min(80%, 340px);
    align-items: center;
    gap: 14px;
    min-height: 124px;
    padding: 16px;
    border-radius: 24px;
    background: #1b1d3a;
    box-shadow: var(--shadow);
    scroll-snap-align: start;
    transition: transform .2s;
}
.feature:hover { transform: translateY(-3px); }
.feature-icon { flex: none; width: 82px; height: 82px; border-radius: 20px; object-fit: cover; box-shadow: 0 8px 20px rgba(0, 0, 0, .35); }
.feature-body { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.feature-body strong { font-size: 17px; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---- sections and cards ---- */
.section { padding-top: 22px; scroll-margin-top: 120px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.more { display: inline-flex; align-items: center; gap: 4px; color: var(--primary); font-size: 14px; font-weight: 800; }
:root[data-theme="dark"] .more { color: var(--primary-2); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 16px 12px; }
/* Home sections hold 9 picks: 3x3 on phones, whole rows of 4 or 8 on larger screens. */
.grid-home { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { display: block; min-width: 0; text-align: center; transition: transform .18s; content-visibility: auto; contain-intrinsic-size: auto 170px; }
.card:hover { transform: translateY(-3px); }
.card-img {
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 22%;
    background: var(--surface-2);
    box-shadow: var(--shadow);
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-title {
    display: -webkit-box;
    margin-top: 8px;
    overflow: hidden;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.about { margin-top: 34px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.about h2 { margin-bottom: 6px; font-size: 18px; }
.about p { color: var(--muted); }

/* ---- category page ---- */
.page-head { display: flex; align-items: baseline; gap: 12px; padding: 22px 0 4px; }
.page-head h1 { font-size: clamp(24px, 4vw, 34px); font-weight: 900; letter-spacing: -.02em; }
.count { color: var(--muted); font-weight: 700; font-size: 14px; }
.empty { padding: 48px 0; color: var(--muted); text-align: center; }

/* ---- detail page ---- */
.detail-hero {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-top: 18px;
    padding: 28px 26px;
    border-radius: 28px;
    background: #1b1d3a;
    box-shadow: var(--shadow);
}
.detail-icon { flex: none; width: 136px; height: 136px; border-radius: 30px; object-fit: cover; box-shadow: 0 14px 34px rgba(0, 0, 0, .4); }
.detail-info { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; min-width: 0; }
.detail-info h1 { font-size: clamp(24px, 5vw, 38px); line-height: 1.1; font-weight: 900; letter-spacing: -.02em; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    font-size: 13px;
    font-weight: 700;
}
a.tag:hover { background: rgba(255, 255, 255, .3); }
.panel { margin-top: 18px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel h2 { margin-bottom: 8px; font-size: 18px; }
.clamp { display: -webkit-box; overflow: hidden; color: var(--muted); -webkit-line-clamp: 4; -webkit-box-orient: vertical; }
.clamp.open { display: block; }
.link-btn { margin-top: 8px; padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 800; cursor: pointer; }

/* ---- text pages ---- */
.prose { max-width: 780px; margin: 24px auto 0; padding: 28px clamp(18px, 4vw, 36px); border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.prose h1 { margin-bottom: 14px; font-size: clamp(26px, 5vw, 34px); font-weight: 900; letter-spacing: -.02em; }
.prose h2 { margin: 26px 0 8px; font-size: 20px; }
.prose p, .prose li { color: var(--muted); line-height: 1.75; }
.prose p + p { margin-top: 12px; }
.prose ul { padding-left: 22px; }
.prose a { color: var(--primary); font-weight: 700; }
.prose b, .prose strong { color: var(--text); }

/* ---- footer ---- */
.footer { margin-top: 44px; padding: 26px 0 44px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-bottom: 10px; }
.footer-links a { font-weight: 700; }
.footer-links a:hover { color: var(--text); }

.ad-slot { display: flex; justify-content: center; margin-top: 22px; }

@media (min-width: 640px) {
    .wrap { padding-left: 24px; padding-right: 24px; }
    .rail { margin: 0 -24px; padding: 4px 24px 16px; scroll-padding: 0 24px; }
    .grid-home { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .grid-home .card:nth-child(n+9) { display: none; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 22px 16px; }
    .card-title { font-size: 14px; }
    .feature { flex-basis: 360px; }
}

@media (min-width: 1000px) {
    .grid-home { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
    .brand-name { display: none; }
    .detail-hero { flex-direction: column; padding: 26px 18px; text-align: center; }
    .detail-info { align-items: center; }
    .tags { justify-content: center; }
}

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