/* ============================================================
   氢原子百科 站点样式 v5 —— 「暖纸编辑风」设计语言
   灵感源自 HuahuaUi：暖白画布 + 衬线大标题 + 发丝边框 +
   粉彩渐变光球 + 药丸按钮 + 大圆角卡片；深浅双主题不变（data-theme）。
   断点：1280 / 960 / 640 / 480
   ============================================================ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

/* ---------- 主题令牌（浅色：暖纸画布） ---------- */
:root {
    color-scheme: light dark;
    --bg: #FDFCFC;              /* 画布：暖白 */
    --surface: #FFFFFF;
    --surface-2: #FAF9F8;       /* 软面板 */
    --surface-3: #F0EFED;       /* 强面板（悬停底） */
    --text: #292524;            /* 墨色正文 */
    --text-strong: #0C0A09;
    --muted: #6E6862;
    --faint: #A8A29E;
    --border: #E8E6E3;          /* 发丝线 */
    --border-strong: #D6D3D1;

    --brand: #292524;           /* 主按钮 = 墨色 */
    --brand-hover: #0C0A09;
    --on-brand: #FDFCFC;
    --link: #292524;            /* 链接 = 墨色 + 发丝下划线 */
    --link-line: #D6D3D1;
    --link-hover: #C2410C;      /* 锈橙强调 */
    --accent: #C2410C;
    --success: #1E7B34;
    --danger: #B91C1C;

    --btn-bg: #FFFFFF;
    --btn-border: #D6D3D1;
    --btn-hover: #F0EFED;
    --chip-bg: #F4EDE6;         /* 暖陶土色 chip */
    --chip-hover: #EBE0D4;
    --chip-text: #8C4A24;

    --header-bg: rgba(253, 252, 252, .86);
    --shadow-card: 0 1px 2px rgba(28, 25, 23, .05);
    --shadow-hover: 0 16px 40px -14px rgba(28, 25, 23, .18);
    --shadow-side: 0 1px 2px rgba(28, 25, 23, .05);
    --focus-ring: 0 0 0 3px rgba(194, 65, 12, .25);

    /* 粉彩光球（薄荷 / 蜜桃 / 薰衣草） */
    --orb-a: rgba(167, 229, 211, .55);
    --orb-b: rgba(244, 197, 168, .50);
    --orb-c: rgba(200, 184, 224, .40);

    --radius: 8px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --wrap-max: 1280px;
    --wrap-pad: clamp(16px, 3vw, 32px);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-display: Georgia, "Times New Roman", "Songti SC", "STSong", SimSun, "Noto Serif CJK SC", "Source Han Serif SC", serif;
}

/* ---------- 主题令牌（深色：暖夜炭色） ---------- */
:root[data-theme="dark"] {
    --bg: #1C1B1A;
    --surface: #242322;
    --surface-2: #282625;
    --surface-3: #34312F;
    --text: #EDEAE6;
    --text-strong: #FAF8F5;
    --muted: #A39D97;
    --faint: #7D766F;
    --border: #383531;
    --border-strong: #4B4741;

    --brand: #EDEAE6;           /* 深色下主按钮反转：奶油底墨字 */
    --brand-hover: #FAF8F5;
    --on-brand: #1C1B1A;
    --link: #EDEAE6;
    --link-line: #4B4741;
    --link-hover: #EE9A66;
    --accent: #EE9A66;
    --success: #7CBF8E;
    --danger: #F87171;

    --btn-bg: #282625;
    --btn-border: #4B4741;
    --btn-hover: #34312F;
    --chip-bg: #332F2B;
    --chip-hover: #3E3A34;
    --chip-text: #E7BFA4;

    --header-bg: rgba(28, 27, 26, .86);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow-hover: 0 16px 40px -12px rgba(0, 0, 0, .5);
    --shadow-side: 0 1px 2px rgba(0, 0, 0, .25);
    --focus-ring: 0 0 0 3px rgba(238, 154, 102, .3);

    --orb-a: rgba(95, 160, 142, .20);
    --orb-b: rgba(200, 140, 105, .16);
    --orb-c: rgba(150, 130, 180, .15);
}

/* ---------- 基础 ---------- */
body {
    margin: 0;
    overflow-x: clip;   /* hero 全宽突破（100vw bleed）防横向滚动 */
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.75;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 500;
    line-height: 1.3;
    margin: 0;
    color: var(--text-strong);
}
img { max-width: 100%; }
::selection { background: #292524; color: #FDFCFC; }
:root[data-theme="dark"] ::selection { background: #EDEAE6; color: #1C1B1A; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }
/* 词条内链 / 正文链接：发丝下划线，悬停转锈橙 */
.entry-main a.ilink, .section-body a.ilink, .summary-text a,
.search-item h3 a, .card-title a {
    text-decoration-line: underline;
    text-decoration-color: var(--link-line);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
.entry-main a.ilink:hover, .section-body a.ilink:hover, .summary-text a:hover,
.search-item h3 a:hover, .card-title a:hover { text-decoration-color: currentColor; }
/* 正文内链：高亮强调色（锈橙），下划线随文字色 */
.section-body a.ilink, .entry-main a.ilink {
    color: var(--accent);
    text-decoration-color: currentColor;
}

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius); }

.wrap { width: 100%; max-width: var(--wrap-max); margin: 0 auto; padding-inline: var(--wrap-pad); }

/* ---------- 顶栏（毛玻璃悬浮） ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 64px; }
.logo {
    display: inline-flex; align-items: center; gap: 10px;
    font-family: var(--font-display);
    font-size: 17px; font-weight: 600; letter-spacing: .02em; color: var(--text-strong);
}
.logo:hover { color: var(--text-strong); text-decoration: none; }
.logo .logo-mark { flex: none; width: 28px; height: 28px; border-radius: 6px; }
.logo span { font-family: var(--font); font-size: 12px; font-weight: 400; letter-spacing: .06em; color: var(--faint); }
.site-nav, .main-nav { display: flex; align-items: center; gap: 2px; }
.site-nav a, .main-nav a {
    padding: 7px 14px; border-radius: 999px; font-size: 14px; color: var(--text);
    transition: background-color .15s ease, color .15s ease;
}
.site-nav a:hover, .main-nav a:hover { background: var(--surface-3); color: var(--text-strong); text-decoration: none; }
.header-inner > .site-search { margin-left: auto; }

/* 顶栏搜索：药丸容器 */
.site-search {
    display: flex; align-items: center; gap: 6px;
    padding: 3px 3px 3px 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.site-search:focus-within { border-color: var(--border-strong); box-shadow: var(--focus-ring); }
.site-search input[type="search"] {
    width: clamp(140px, 22vw, 300px); height: 30px; padding: 0;
    font: inherit; font-size: 14px; color: var(--text);
    background: transparent; border: none; outline: none;
}
.site-search input[type="search"]::placeholder { color: var(--faint); }
.site-search button {
    height: 30px; padding: 0 16px; font: inherit; font-size: 13px; font-weight: 500;
    color: var(--on-brand); background: var(--brand);
    border: none; border-radius: 999px; cursor: pointer;
    transition: background-color .15s ease, transform .15s ease;
}
.site-search button:hover { background: var(--brand-hover); transform: translateY(-1px); }

.theme-toggle {
    flex: none; width: 34px; height: 34px; font-size: 15px; line-height: 1;
    color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 999px;
    cursor: pointer; transition: background-color .15s ease;
}
.theme-toggle:hover { background: var(--surface-3); color: var(--text); }
:root[data-theme="dark"] .theme-toggle::before { content: "☀️"; }
:root:not([data-theme="dark"]) .theme-toggle::before { content: "🌙"; }

/* ---------- 页脚（编辑风收尾） ---------- */
.site-footer {
    margin-top: 72px; padding: 44px 0 56px;
    border-top: 1px solid var(--border);
    text-align: center; color: var(--muted); font-size: 13px;
}
.foot-logo { display: block; margin: 0 auto 14px; height: 128px; }
.foot-copy { margin: 0 0 10px; font-family: var(--font-display); font-size: 14px; letter-spacing: .02em; color: var(--muted); }
.foot-links { margin: 0; }
.foot-links a {
    display: inline-block; padding: 5px 12px; margin: 0 2px;
    border-radius: 999px; color: var(--muted);
    transition: background-color .15s ease, color .15s ease;
}
.foot-links a:hover { background: var(--surface-3); color: var(--link-hover); }

/* ---------- 面包屑 / 词条元信息（预览与兜底） ---------- */
.tpl-breadcrumb { margin: 18px 0 4px; font-size: 13px; color: var(--faint); }
.tpl-breadcrumb a { color: var(--muted); }
.tpl-breadcrumb .sep { margin: 0 8px; }
.tpl-breadcrumb em { font-style: normal; color: var(--text); }
.entry-meta { margin: 6px 0 0; font-size: 12px; color: var(--faint); }
.entry-meta span + span::before { content: "·"; margin: 0 8px; }
.tpl-meta { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--faint); }
.tpl-meta span + span::before { content: "·"; margin: 0 8px; }

/* ---------- 词条标题区 ---------- */
.tpl-title { padding: 36px 0 20px; margin-bottom: 24px; }
.entry-title { font-size: clamp(1.75rem, 4vw, 2.5rem); line-height: 1.25; letter-spacing: .01em; }
.entry-subtitle { margin: 8px 0 0; font-size: 15px; color: var(--muted); font-weight: 400; }

/* ---------- 摘要面板 ---------- */
.tpl-summary {
    margin: 0 0 24px;
    display: flex; gap: 24px; align-items: flex-start;
}
.summary-text { margin: 0; color: color-mix(in srgb, var(--text) 75%, var(--bg)); font-size: 14px; line-height: 1.8; }
.summary-text b { font-weight: 600; }
.summary-cover { flex: none; width: 132px; text-align: center; }
.summary-cover img { border-radius: 4px; display: block; margin: 0 auto; }
.summary-cover-cap { margin-top: 8px; font-size: 12px; color: var(--faint); }
/* 新结构（DOM 在 tpl-title 内）：小屏流式回退，标题下方居中 */
.tpl-title .summary-cover { width: min(400px, 100%); margin: 16px auto 0; }
/* ≥786px：首图定于词条标题右侧，宽度与 entry-side 侧栏列同步（786-960: 264px / >960: 300px）
   —— 新结构（title 内）为主；旧骨架缓存（cover 在 summary 内）走兼容层 */
@media (min-width: 786px) {
    .tpl-title { position: relative; }
    .tpl-title:has(.summary-cover) { padding-right: 292px; }   /* 264 + gap 28 */
    .tpl-title .summary-cover { position: absolute; top: 36px; right: 0; width: 264px; margin: 0; }
    .tpl-title:has(.summary-cover) + .tpl-summary { padding-right: 292px; }
    /* 兼容层：存量词条骨架（cover 仍渲染在 tpl-summary 内） */
    .tpl-title:has(+ .tpl-summary .summary-cover) { padding-right: 292px; }
    .tpl-summary:has(.summary-cover) {
        position: relative;
        padding-right: 292px;
        min-height: 330px;
    }
    .tpl-summary .summary-cover {
        position: absolute; right: 0; top: -24px;
        width: 264px; flex: none;
    }
    .summary-cover img { width: 100%; height: auto; }   /* 不裁剪：无 max-height、无 object-fit，完整显示原始比例 */
}
/* >960px：侧栏列 300px + gap 40，首图与让位同步放宽 */
@media (min-width: 961px) {
    .tpl-title:has(.summary-cover) { padding-right: 340px; }
    .tpl-title .summary-cover { width: 300px; }
    .tpl-title:has(.summary-cover) + .tpl-summary { padding-right: 340px; }
    .tpl-title:has(+ .tpl-summary .summary-cover) { padding-right: 340px; }
    .tpl-summary:has(.summary-cover) { padding-right: 340px; }
    .tpl-summary .summary-cover { width: 300px; }
}

/* ---------- 词条双栏 ---------- */
.entry-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; align-items: start; }
.entry-main { min-width: 0; }
.entry-side { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 88px; }

/* ---------- 章节正文 ---------- */
.tpl-sections .section-heading, .section-flow .section-heading, .tpl-sections h2.section-heading {
    margin: 32px 0 14px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-display); font-size: 21px; font-weight: 500; color: var(--text-strong);
}
.tpl-sections .section-heading a, .section-flow .section-heading a { color: inherit; }
.entry-main > .section-heading:first-child { margin-top: 4px; }
.entry-main p { margin: 0 0 15px; font-size: 15px; line-height: 1.85; }
.entry-main ul, .entry-main ol { margin: 0 0 15px; padding-left: 24px; }
.entry-main li { margin: 3px 0; }
.entry-main blockquote {
    margin: 0 0 15px; padding: 8px 18px; color: var(--muted);
    border-left: 2px solid var(--border-strong);
    background: var(--surface-2);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.note-ref, .ref { font-size: 11px; vertical-align: super; color: var(--accent); }
.note-ref:hover, .ref:hover { text-decoration: none; }

/* 封面环绕 */
.tpl-cover { float: left; margin: 6px 22px 14px 0; max-width: 260px; }
.tpl-cover img { border: 1px solid var(--border); border-radius: var(--radius-lg); }
.tpl-cover .summary-cover-cap { text-align: center; }

/* ---------- 作品墙页签（药丸分段控件） ---------- */
.section-tabs { clear: both; margin: 6px 0 24px; }
.tab-bar {
    display: inline-flex; gap: 4px; flex-wrap: wrap;
    padding: 4px; margin: 0 0 20px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
}
.tab-btn {
    padding: 7px 18px; font-size: 14px; color: var(--muted);
    background: none; border: none; border-radius: 999px;
    cursor: pointer; white-space: nowrap;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.tab-btn:hover { color: var(--text-strong); }
.tab-btn.active {
    color: var(--text-strong); font-weight: 500;
    background: var(--surface); box-shadow: var(--shadow-card);
}
.section-tabs .tab-panel { display: none; }
.section-tabs .tab-panel.active { display: block; }
.tab-panel[hidden] { display: none; }
.section-tabs .tab-panel .section-heading { margin-top: 18px; }

/* 作品墙稳定卡片：海报上 + 字段下（div/stable-field 结构） */
.stable-card {
    display: flex; flex-direction: column; gap: 14px;
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: var(--surface); padding: 18px; margin: 14px 0;
    box-shadow: var(--shadow-card);
}
.stable-poster { flex: none; width: 120px; }
.stable-poster .bk-image { margin: 0; }   /* 清 figure 默认 40px 侧边距，否则海报被挤成十余像素 */
.stable-poster img { display: block; width: 100%; height: auto; border-radius: var(--radius); }
.stable-fields { flex: 1; min-width: 0; font-size: 13px; }
.stable-field { display: flex; gap: 12px; padding: 3px 0; }
.stable-field .k { flex: none; color: var(--muted); }
.stable-field .v { min-width: 0; word-break: break-word; }
.bk-table-wrap { overflow-x: auto; margin: 0 0 15px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.bk-table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bk-table-wrap th { background: var(--surface-2); text-align: left; font-weight: 600; }
.bk-table-wrap th, .bk-table-wrap td { padding: 8px 14px; border-bottom: 1px solid var(--border); }
.bk-table-wrap tr:last-child td { border-bottom: none; }
.bk-image img, .bk-atlas img { border: 1px solid var(--border); border-radius: var(--radius-lg); }
.atlas-title { font-size: 13px; color: var(--muted); text-align: center; margin: 6px 0 14px; }
.atlas-images { display: flex; flex-wrap: wrap; gap: 14px; }
.bk-video { max-width: 100%; border-radius: var(--radius-lg); }
.video-missing { color: var(--faint); font-size: 12px; }
.bk-stable { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 16px 0; }
.stable-field { display: flex; gap: 6px; font-size: 12.5px; margin: 2px 0; }
.stable-field .k { color: var(--faint); flex-shrink: 0; }
.stable-field .v { color: var(--text); overflow: hidden; text-overflow: ellipsis; }

/* ---------- 侧栏卡片（信息框 / 目录 / 相关） ---------- */
.tpl-infobox, .tpl-toc, .tpl-related {
    border: 1px solid var(--border); border-radius: var(--radius-xl);
    background: var(--surface); box-shadow: var(--shadow-card); overflow: hidden;
}
.tpl-infobox { padding: 0; }
/* 卡片标题（ib-title）与分组标题（ib-group）统一：淡色小标、无分隔线 */
.ib-title, .ib-group { font-size: 12px; color: var(--faint); padding: 10px 18px 0; letter-spacing: .1em; }
/* 信息框键值对：dl/dt/dd 结构 → grid 两列（dt 左列键、dd 右列值），行间发丝线 */
.ib-list {
    display: grid; grid-template-columns: minmax(4.5em, 26%) 1fr;
    margin: 0; padding: 0 0 6px; font-size: 12px;
}
.ib-list dt { padding: 4px 2px 4px 18px; color: var(--muted); opacity: .5; font-weight: 500; line-height: 1.6; }
.ib-list dd { margin: 0; padding: 4px 18px 4px 6px; line-height: 1.6; word-break: break-word; }

.tpl-toc, .tpl-related { padding: 16px 18px; }
.tpl-toc .ib-title, .tpl-related .ib-title { padding: 0 0 8px; margin-bottom: 8px; }
.tpl-toc ol { margin: 0; padding-left: 18px; font-size: 13px; }
.tpl-toc li { margin: 5px 0; }
.tpl-toc a { color: var(--muted); }
.tpl-toc a:hover { color: var(--link-hover); }

/* 相关词条 chips（暖陶土药丸） */
.related-chips, .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-block; padding: 4px 13px; font-size: 12.5px; border-radius: 999px;
    background: var(--chip-bg); color: var(--chip-text);
    transition: background-color .15s ease, color .15s ease;
}
a.chip:hover { background: var(--chip-hover); color: var(--chip-text); text-decoration: none; }

/* ---------- 义项导航 ---------- */
.sense-nav { margin: 14px 0 18px; font-size: 13px; line-height: 2; }
.sense-nav .cap { color: var(--faint); margin-right: 6px; letter-spacing: .1em; }
.sense-nav a {
    display: inline-block; margin: 3px 8px 3px 0; padding: 3px 14px; white-space: nowrap;
    color: var(--muted); background: none; border: 1px solid var(--border); border-radius: 999px;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.sense-nav a:hover { background: var(--surface-3); color: var(--text-strong); text-decoration: none; }
.sense-nav a.cur {
    font-weight: 500; color: var(--on-brand); background: var(--brand);
    border-color: var(--brand);
}

/* ---------- 参考资料 / 注释 ---------- */
.tpl-references, .tpl-notes { margin: 32px 0 0; }
.tpl-references .section-heading, .tpl-notes .section-heading { font-size: 17px; }
.tpl-references ol {
    margin: 0; padding-left: 22px; max-height: 26em; overflow-y: auto;
    font-size: 13px; color: var(--muted); line-height: 1.8;
    scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.tpl-references li { margin: 5px 0; word-break: break-all; }
.ref-site { color: var(--faint); font-size: 12px; margin-left: 4px; }
.tpl-notes ol { margin: 0; padding-left: 22px; font-size: 13px; color: var(--muted); }

/* ---------- 首页主视觉（光球 + 衬线大标题） ---------- */
.home-hero {
    position: relative; overflow: clip; text-align: center;
    padding: clamp(64px, 10vw, 120px) 0 48px;
    width: 100vw; margin-left: calc(50% - 50vw);   /* 全宽突破 1280 容器 */
}
/* compact 变体不再缩减留白：与首页主视觉完全一致 */
.orb { position: absolute; border-radius: 9999px; pointer-events: none; filter: blur(70px); }
.orb-a {
    width: min(560px, 72vw); aspect-ratio: 1; top: -220px; left: -140px;
    background: radial-gradient(circle, var(--orb-a) 0%, transparent 68%);
    animation: orb-float 22s ease-in-out infinite;
}
.orb-b {
    width: min(440px, 60vw); aspect-ratio: 1; top: -160px; right: -120px;
    background: radial-gradient(circle, var(--orb-b) 0%, transparent 68%);
    animation: orb-float 26s ease-in-out -8s infinite reverse;
}
.orb-c {
    width: min(360px, 50vw); aspect-ratio: 1; bottom: -180px; left: 30%;
    background: radial-gradient(circle, var(--orb-c) 0%, transparent 68%);
    animation: orb-float 30s ease-in-out -15s infinite;
}
.hero-eyebrow {
    position: relative; margin: 0 0 18px;
    font-size: 12px; font-weight: 600; letter-spacing: .3em;
    text-transform: uppercase; color: var(--faint);
    animation: fade-in-up .7s ease-out both;
}
.home-hero h1 {
    position: relative;
    font-size: clamp(2.4rem, 6vw, 3.75rem); line-height: 1.15; letter-spacing: .02em;
    margin-bottom: 14px;
    animation: fade-in-up .7s ease-out .08s both;
}
.hero-sub {
    position: relative; color: var(--muted);
    font-size: clamp(14px, 1.6vw, 17px); line-height: 1.8;
    margin: 0 auto 32px; max-width: 560px;
    animation: fade-in-up .7s ease-out .16s both;
}
.home-hero > form.hero-search { animation: fade-in-up .7s ease-out .24s both; }

/* 主搜索：大药丸 */
.hero-search {
    display: flex; align-items: center; gap: 8px;
    max-width: 620px; margin: 0 auto;
    padding: 6px 6px 6px 24px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
    box-shadow: var(--shadow-card);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.hero-search:focus-within { border-color: var(--border); box-shadow: var(--shadow-card); }
.hero-search input:focus-visible { box-shadow: none; }
.hero-search input[type="search"] {
    flex: 1; height: 44px; min-width: 0; padding: 0;
    font: inherit; font-size: 16px; color: var(--text);
    background: transparent; border: none; outline: none;
}
.hero-search input[type="search"]::placeholder { color: var(--faint); }
.hero-search button {
    height: 44px; padding: 0 28px; font: inherit; font-size: 14px; font-weight: 500;
    color: var(--on-brand); background: var(--brand);
    border: none; border-radius: 999px; cursor: pointer;
    transition: background-color .15s ease, transform .15s ease;
}
.hero-search button:hover { background: var(--brand-hover); transform: translateY(-1px); }

.home-cards-slot { position: relative; }

/* ---------- 卡片网格 / 瀑布流 ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; margin: 28px 0; }
.card-grid.masonry { display: block; column-count: 4; column-gap: 18px; }
.card-grid.masonry .entry-card { break-inside: avoid; margin: 0 0 18px; }
.entry-card {
    border: 1px solid var(--border); border-radius: var(--radius-xl);
    background: var(--surface); overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.entry-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-hover);
}
.card-cover { display: block; aspect-ratio: 16/9; width: 100%; object-fit: cover; background: var(--surface-2); }
.card-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-cover.ratio { aspect-ratio: auto; }
.card-cover.ratio img { height: auto; }
/* 瀑布流封面不裁剪：无 aspect-ratio、无 object-fit，保留原始宽高比（参差高度是多列瀑布流的自然形态） */
.card-grid.masonry .card-cover { aspect-ratio: auto; }
.card-grid.masonry .card-cover img { height: auto; object-fit: none; }
.card-body { padding: 16px 18px 18px; }
a.entry-card { color: inherit; text-decoration: none; display: block; }
a.entry-card:hover { text-decoration: none; }
.card-title {
    font-family: var(--font-display); font-size: 1.125rem; font-weight: 500;
    margin: 0 0 6px; color: var(--text-strong); line-height: 1.4;
    transition: color .15s ease;
}
.entry-card:hover .card-title { color: var(--accent); }
.card-title a { color: inherit; }
.card-subtitle { font-size: 12.5px; color: var(--faint); margin: 0 0 8px; }
.card-summary { font-size: 13.5px; color: var(--muted); line-height: 1.7; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.empty-tip { grid-column: 1 / -1; text-align: center; color: var(--faint); padding: 56px 0; }
.card-grid-h { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.card-grid-h .entry-card { display: flex; flex-direction: row; align-items: stretch; }
.card-grid-h .card-cover { width: clamp(150px, 20vw, 230px); height: auto; aspect-ratio: auto; flex-shrink: 0; }
.card-grid-h .card-cover img { height: 100%; }

/* ---------- 搜索页 ---------- */
.search-results { padding-bottom: clamp(36px, 5vw, 56px); }
.result-meta { font-size: 13px; color: var(--muted); margin: 20px 0 4px; }
.result-meta .count, .tpl-references .count { font-weight: 600; color: var(--text); }
.search-page .search-list { margin: 20px 0; }
.search-item { padding: 18px 0; border-bottom: 1px solid var(--border); }
.search-item h3 { font-family: var(--font-display); font-size: 18px; margin: 0 0 6px; font-weight: 500; }
.search-item h3 a { color: var(--text-strong); }
.search-item h3 a:hover { color: var(--accent); }
.result-count { font-size: 12px; color: var(--faint); margin: 12px 0 0; }

/* ---------- 分页（药丸组） ---------- */
.pager { display: flex; gap: 6px; margin: 32px 0; flex-wrap: wrap; justify-content: center; }
.pager:has(.pg:only-child) { display: none; }   /* 兜底：仅一个页码时隐藏 */
.pager a, .pager .current, .pager .pg {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 14px;
    font-size: 13.5px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
    transition: background-color .15s ease, border-color .15s ease;
}
.pager a:hover, .pager .pg:hover { background: var(--surface-3); border-color: var(--border-strong); text-decoration: none; }
.pager .current, .pager .pg.current { font-weight: 500; color: var(--on-brand); background: var(--brand); border-color: var(--brand); }

/* ---------- 待采集 / 错误页 ---------- */
.pending-notice, .error-page { max-width: 560px; margin: 12vh auto 0; text-align: center; padding: 0 16px; }
.pending-icon { font-size: 44px; line-height: 1; margin-bottom: 20px; }
.pending-title { font-size: clamp(1.5rem, 3vw, 1.9rem); margin-bottom: 10px; }
.pending-message, .error-page p { color: var(--muted); margin: 0 0 24px; line-height: 1.8; }
.pending-queue { font-size: 13px; color: var(--faint); margin: 0 0 24px; }
.pending-queue b { color: var(--muted); font-weight: 600; }
.pending-actions { display: flex; justify-content: center; gap: 10px; }
.pending-actions a {
    display: inline-flex; align-items: center; height: 38px; padding: 0 22px;
    font-size: 13.5px; font-weight: 500;
    color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 999px;
    transition: background-color .15s ease, border-color .15s ease;
}
.pending-actions a:hover { background: var(--surface-3); border-color: var(--border-strong); text-decoration: none; }

/* ---------- 广告位 ---------- */
.ad-slot { margin: 18px 0; color: rgba(41, 37, 36, .1); }
:root[data-theme="dark"] .ad-slot { color: rgba(237, 234, 230, .1); }
.ad-missing { padding: 12px; text-align: center; color: var(--faint); font-size: 12px; border: 1px dashed var(--border); border-radius: var(--radius-lg); }

/* ---------- 旧类名兼容层 ---------- */
.section-body { font-size: 15px; color: var(--text); line-height: 1.85; }
.section-body p { margin: 10px 0; }
.section-flow .section-heading:first-child { margin-top: 4px; }

/* ---------- 动画 ---------- */
@keyframes orb-float {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(0, -26px, 0) scale(1.05); }
}
@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(22px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .orb, .hero-eyebrow, .home-hero h1, .hero-sub, .hero-search { animation: none !important; }
    .entry-card, .entry-card:hover { transition: none; transform: none; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1280px) {
    .entry-layout { grid-template-columns: minmax(0, 1fr) 264px; gap: 28px; }
    .card-grid.masonry { column-count: 3; }
}
@media (max-width: 960px) {
    .entry-layout { grid-template-columns: 1fr; }
    .entry-side { position: static; flex-direction: row; flex-wrap: wrap; }
    .entry-side > * { flex: 1 1 264px; }
    .card-grid.masonry { column-count: 2; }
}
@media (max-width: 640px) {
    .header-inner { height: auto; flex-wrap: nowrap; padding: 10px 14px; }
    .site-nav a:first-child { display: none; }   /* 手机隐藏「首页」链接（logo 本身即回首页） */
    .header-inner > .site-search { display: none; }   /* 手机版隐藏导航搜索框（hero 里已有大搜索框） */
    .site-search { flex: 1; }
    .site-search input[type="search"] { flex: 1; width: auto; min-width: 0; }
    .tpl-cover { float: none; margin: 0 0 16px; max-width: 100%; }
    .tpl-summary { flex-direction: column; }
    .summary-cover { width: 100%; }
    .tab-bar { display: flex; overflow-x: auto; border-radius: var(--radius-lg); }
    .home-hero { padding: 48px 20px 32px; }
}
@media (max-width: 480px) {
    .card-grid { grid-template-columns: 1fr; }
    .card-grid.masonry { column-count: 1; }
    .pager { flex-wrap: wrap; row-gap: 6px; }
    .bk-stable { grid-template-columns: 1fr; }
    .card-grid-h { grid-template-columns: 1fr; }
    .card-grid-h .card-cover { width: 132px; }
}