/* ===== 基础变量与主题 ===== */
:root {
    --bg: #f6f7fb;
    --bg-soft: #ffffff;
    --surface: rgba(255, 255, 255, 0.78);
    --border: rgba(17, 24, 39, 0.08);
    --text: #16192b;
    --text-soft: #5b6178;
    --brand: #6366f1;
    --brand-2: #ec4899;
    --brand-soft: rgba(99, 102, 241, 0.12);
    --shadow: 0 10px 30px rgba(23, 25, 50, 0.08);
    --shadow-lg: 0 24px 60px rgba(23, 25, 50, 0.18);
    --radius: 16px;
    --radius-sm: 10px;
}

[data-theme="dark"] {
    --bg: #0d0f18;
    --bg-soft: #141826;
    --surface: rgba(23, 27, 42, 0.82);
    --border: rgba(255, 255, 255, 0.1);
    --text: #eef0f7;
    --text-soft: #a3a9c2;
    --brand: #818cf8;
    --brand-2: #f472b6;
    --brand-soft: rgba(129, 140, 248, 0.16);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    transition: background .25s ease, color .25s ease;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.container {
    width: min(1360px, 100% - 3rem);
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

/* ===== 顶部导航 ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(18px);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    width: min(1360px, 100% - 3rem);
    margin: 0 auto;
    height: 66px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; }
.brand-mark {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 10px;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}

.search-box {
    flex: 1;
    max-width: 520px;
    position: relative;
    display: flex;
    align-items: center;
}
.search-box .icon {
    position: absolute; left: 12px;
    width: 18px; height: 18px;
    fill: var(--text-soft);
    pointer-events: none;
}
.search-box input {
    width: 100%;
    height: 42px;
    padding: 0 38px 0 38px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    font-size: .92rem;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.search-box input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-soft);
}
.search-clear {
    position: absolute; right: 10px;
    border: 0; background: transparent;
    color: var(--text-soft);
    font-size: 1.2rem; cursor: pointer;
    line-height: 1;
}

.header-actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }

.icon-btn {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
    transition: transform .15s, border-color .2s;
}
.icon-btn:hover { transform: translateY(-1px); border-color: var(--brand); }

.ghost-btn {
    height: 38px;
    padding: 0 1rem;
    display: inline-flex; align-items: center;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    font-size: .88rem;
    cursor: pointer;
    transition: border-color .2s, background .2s, transform .15s;
}
.ghost-btn:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }

.primary-btn {
    height: 42px;
    padding: 0 1.5rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(99, 102, 241, .32);
    transition: transform .15s, box-shadow .2s, opacity .2s;
}
.primary-btn:hover { transform: translateY(-1px); }
.primary-btn:disabled { opacity: .55; cursor: default; transform: none; }

.select {
    height: 36px;
    padding: 0 .6rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    font-size: .85rem;
    cursor: pointer;
}

/* ===== 筛选条 ===== */
.filter-bar {
    width: min(1360px, 100% - 3rem);
    margin: 0 auto;
    padding-bottom: .9rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow-x: auto;
}
.chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip {
    padding: .35rem .85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text-soft);
    font-size: .82rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all .18s;
}
.chip:hover { color: var(--text); border-color: var(--brand); }
.chip.active {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}
.chip .count { opacity: .7; margin-left: .25rem; font-size: .75rem; }
.filter-right { margin-left: auto; }

/* ===== Hero ===== */
.hero { padding: 1.2rem 0 1.6rem; }
.hero h1 {
    margin: 0 0 .4rem;
    font-size: clamp(1.6rem, 3vw, 2.3rem);
    background: linear-gradient(120deg, var(--brand), var(--brand-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero p { margin: 0; color: var(--text-soft); font-size: .95rem; }

.result-meta { color: var(--text-soft); font-size: .85rem; margin-bottom: 1rem; }

/* ===== 瀑布流 ===== */
.masonry { column-count: 4; column-gap: 18px; }
@media (max-width: 1200px) { .masonry { column-count: 3; } }
@media (max-width: 860px) { .masonry { column-count: 2; } }
@media (max-width: 520px) { .masonry { column-count: 1; } }

.card {
    break-inside: avoid;
    margin: 0 0 18px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    cursor: zoom-in;
    transition: transform .22s ease, box-shadow .22s ease;
    animation: fadeUp .35s ease both;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

.card-media { position: relative; background: var(--brand-soft); overflow: hidden; }
.card-media img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform .5s ease;
}
.card:hover .card-media img { transform: scale(1.04); }
.card-media .skeleton {
    width: 100%;
    height: 220px;
    background: linear-gradient(100deg, var(--brand-soft) 30%, rgba(255,255,255,.15) 50%, var(--brand-soft) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.card-badge {
    position: absolute; top: 10px; left: 10px;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    background: rgba(15, 17, 24, .62);
    color: #fff;
    backdrop-filter: blur(6px);
}
.card-body { padding: .75rem .85rem .9rem; }
.card-title {
    margin: 0 0 .35rem;
    font-size: .95rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.card-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.tag {
    font-size: .72rem;
    padding: .12rem .5rem;
    border-radius: 6px;
    background: var(--brand-soft);
    color: var(--brand);
}
.card-foot {
    margin-top: .5rem;
    display: flex;
    justify-content: space-between;
    font-size: .74rem;
    color: var(--text-soft);
}

/* ===== 状态 ===== */
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text-soft); }
.empty-emoji { font-size: 3rem; }
.empty-state h2 { color: var(--text); margin: .5rem 0 .3rem; }
.empty-state a { color: var(--brand); }

.load-more-wrap { display: flex; justify-content: center; padding: 1.5rem 0; }
.loading { display: flex; align-items: center; justify-content: center; gap: .5rem; color: var(--text-soft); font-size: .9rem; }
.loading.center { min-height: 40vh; }
.spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 详情页 ===== */
.detail-page { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 2rem; }
@media (max-width: 900px) { .detail-page { grid-template-columns: 1fr; } }

.detail-media {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.detail-media img { width: 100%; height: auto; }

.detail-info h1 { margin: 0 0 .5rem; font-size: 1.5rem; }
.detail-desc { color: var(--text-soft); line-height: 1.7; margin: .5rem 0 1rem; }
.meta-list { list-style: none; padding: 0; margin: 0 0 1.2rem; }
.meta-list li {
    display: flex; justify-content: space-between;
    padding: .5rem 0;
    border-bottom: 1px dashed var(--border);
    font-size: .86rem;
}
.meta-list span:first-child { color: var(--text-soft); }

.link-box {
    display: flex; gap: .5rem; align-items: center;
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    margin-bottom: .6rem;
}
.link-box input {
    flex: 1; min-width: 0;
    border: 0; background: transparent; color: var(--text);
    font-size: .8rem; outline: none;
}
.link-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; margin-top: 1.5rem; }
.related-grid a { border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--bg-soft); }
.related-grid img { aspect-ratio: 1/1; object-fit: cover; width: 100%; }

/* ===== 灯箱 ===== */
.lightbox {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(8, 9, 14, .88);
    backdrop-filter: blur(6px);
    display: grid; place-items: center;
    padding: 2rem 4rem;
    animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.lightbox[hidden] { display: none; }
.lightbox-figure { margin: 0; max-width: min(1100px, 100%); text-align: center; color: #fff; }
.lightbox-figure img {
    max-height: 74vh; max-width: 100%;
    margin: 0 auto;
    border-radius: 12px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
    background: #111;
}
.lightbox-figure figcaption { padding-top: 1rem; }
.lightbox-title { font-size: 1.05rem; font-weight: 600; }
.lightbox-desc { font-size: .86rem; color: rgba(255,255,255,.7); margin-top: .3rem; }
.lightbox-actions { display: flex; gap: .6rem; justify-content: center; margin-top: .8rem; }
.lightbox-actions .ghost-btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: #fff; }
.lightbox-close, .lightbox-nav {
    position: absolute;
    border: 0; cursor: pointer;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    border-radius: 50%;
    width: 44px; height: 44px;
    font-size: 1.6rem;
    line-height: 1;
    transition: background .2s;
}
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255, 255, 255, .24); }
.lightbox-close { top: 20px; right: 24px; }
.lightbox-nav.prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lightbox-nav.next { right: 18px; top: 50%; transform: translateY(-50%); }

/* ===== Toast ===== */
.toast {
    position: fixed;
    left: 50%; bottom: 40px;
    transform: translateX(-50%) translateY(12px);
    padding: .7rem 1.2rem;
    border-radius: 999px;
    background: rgba(17, 20, 32, .92);
    color: #fff;
    font-size: .88rem;
    z-index: 200;
    opacity: 0;
    transition: opacity .2s, transform .2s;
}
.toast[hidden] { display: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 页脚 ===== */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.2rem 0;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    color: var(--text-soft);
    font-size: .8rem;
}
.site-footer code {
    background: var(--brand-soft);
    color: var(--brand);
    padding: .1rem .35rem;
    border-radius: 5px;
}
