/* 漫阅 · 墨夜主题（深墨黑 + 琥珀金）—— 与原站黑红密网格刻意区分
   ★ 颜色分两类，别混用：
       --ac     强调色【背景用】—— 按钮渐变 / chip.on / 角标
       --ac-tx  强调色【文字用】—— 浅色主题下必须更深，否则小字对比度不够
       --on-ac  「琥珀底上的字」色 —— 两个主题都用深色（实测对比度最高） */
:root {
  --bg: #0c0d11;
  --bg2: #13151c;
  --card: #181b24;
  --card2: #212530;
  --line: #272c39;
  --line2: #333a4b;
  --tx: #e9ebf2;
  --tx2: #a7aec1;
  --tx3: #8b93a8;
  --ac: #e8b04a;
  --ac-d: #c8922f;
  --ac-tx: #e8b04a;
  --ac-soft: rgba(232, 176, 74, .12);
  --on-ac: #14161d;
  --focus-bg: #16181f;
  --red: #e2586b;
  --r: 14px;
  --r-s: 9px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .7);
  --maxw: 1280px;
  --ff: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

/* 浅色主题（默认深色；切换按钮由 app.js 注入到顶栏，状态存 localStorage: my_theme）
   ⚠️ 这里【绝对不要】再写 `html[data-theme=light] .btn { color:#fff }` 这类覆盖：
      它的优先级 (0,2,1) 会压过 `.btn.ghost{color:var(--tx)}` (0,2,0)，
      结果浅色主题下所有 ghost 按钮变成「白字白底」→ 完全看不见（2026-10-17 实测 42 项硬伤的主因）。
      琥珀底上的字统一交给 --on-ac（深色），对比度 5.05:1，比白字 3.54:1 更好。 */
html[data-theme="light"] {
  --bg: #f6f7fa;
  --bg2: #eceef4;
  --card: #ffffff;
  --card2: #f2f4f9;
  --line: #dfe3ec;
  --line2: #c9cfdd;
  --tx: #1a1d26;
  --tx2: #4a5162;
  --tx3: #5f6779;
  --ac: #b87c1c;
  --ac-d: #96610d;
  --ac-tx: #8f5c0d;
  --ac-soft: rgba(184, 124, 28, .13);
  --on-ac: #14161d;
  --focus-bg: #ffffff;
  --red: #c8404f;
  --shadow: 0 10px 30px -14px rgba(24, 28, 40, .28);
}
html[data-theme="light"] header { background: rgba(246, 247, 250, .86); }
html[data-theme="light"] .rd-bar { background: rgba(246, 247, 250, .9); }
html[data-theme="light"] .ad { background: repeating-linear-gradient(45deg, #fff, #fff 10px, var(--bg2) 10px, var(--bg2) 20px); }

* { margin: 0; padding: 0; box-sizing: border-box; }
/* scrollbar-gutter: 内容变高之前没有滚动条 → 出现时视口被挤窄 → 全站元素横向位移。
   实测这是阅读器 CLS 1.08 里贡献最大的一段（nav / main 整体位移）。stable 常驻占位。 */
html { scroll-behavior: smooth; scrollbar-gutter: stable; }
body {
  font-family: var(--ff);
  background: var(--bg);
  color: var(--tx);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
::selection { background: var(--ac); color: var(--on-ac); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #414a5e; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- 顶栏 ---------- */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(12, 13, 17, .82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.hd { display: flex; align-items: center; gap: 14px; height: 62px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; letter-spacing: .5px; white-space: nowrap; }
.logo .mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--ac), #b5761f);
  display: grid; place-items: center; color: var(--on-ac); font-size: 15px; font-weight: 900;
  box-shadow: 0 4px 14px -4px var(--ac);
}
.logo b { color: var(--ac-tx); }

.search { flex: 1; min-width: 0; max-width: 420px; position: relative; }
.search input {
  width: 100%; height: 40px; border-radius: 10px; padding: 0 14px 0 40px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--tx); font-size: 14px; outline: none;
  transition: border-color .15s, background .15s;
}
.search input:focus { border-color: var(--ac); background: var(--focus-bg); }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--tx3); pointer-events: none; }

/* ---------- 导航（桌面：横向 + 分类▾ 分组下拉；手机：全屏抽屉） ---------- */
.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nav > a, .ndrop-btn {
  padding: 8px 12px; border-radius: 9px; font-size: 14px; color: var(--tx2);
  transition: .15s; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px;
}
.nav > a:hover, .ndrop-btn:hover { color: var(--tx); background: var(--card); }
.nav > a.on { color: var(--ac-tx); background: var(--ac-soft); font-weight: 700; }

.ndrop { position: relative; }
.ndrop-btn i { font-style: normal; font-size: 9px; transition: transform .18s; }
.ndrop.open .ndrop-btn { color: var(--tx); background: var(--card); }
.ndrop.open .ndrop-btn i { transform: rotate(180deg); }
.ndrop-menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 120;
  display: none; grid-template-columns: repeat(3, minmax(104px, 1fr)); gap: 4px 10px;
  padding: 14px; background: var(--card); border: 1px solid var(--line2);
  border-radius: 14px; box-shadow: var(--shadow);
}
.ndrop.open .ndrop-menu { display: grid; }
.ndrop-col { display: flex; flex-direction: column; gap: 2px; }
.ndrop-hd { font-size: 11px; color: var(--tx3); padding: 2px 10px 6px; letter-spacing: .5px; }
.ndrop-menu a { padding: 7px 10px; border-radius: 8px; font-size: 13px; color: var(--tx2); white-space: nowrap; transition: .15s; }
.ndrop-menu a:hover { background: var(--bg2); color: var(--ac-tx); }

.burger { display: none; }
.tbtn {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 10px; background: var(--card); border: 1px solid var(--line);
  color: var(--tx2); font-size: 15px; line-height: 1; transition: .15s;
}
.tbtn:hover { color: var(--ac-tx); border-color: var(--ac); }

/* ---------- 区块 ---------- */
.sec { margin: 34px 0; }
.sec-hd { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.sec-hd h2, .sec-hd h1 { font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.sec-hd h2::before, .sec-hd h1::before { content: ""; display: inline-block; width: 4px; height: 17px; background: var(--ac); border-radius: 2px; margin-right: 10px; vertical-align: -2px; }
/* ★ 键盘焦点可见（WCAG 2.4.7）—— 2026-10-17 补。
   原来只有 .search input 和 .bsearch input 两个 focus 样式，按钮/链接/chip
   全靠浏览器默认轮廓；而我们给不少元素设了自定义边框/背景，默认轮廓在深色主题下
   几乎看不见 → 键盘用户（Tab 导航）根本不知道焦点在哪。
   用 :focus-visible：只在键盘导航时出现，鼠标点击不出现（不会误伤视觉）。 */
:focus-visible {
  outline: 2px solid var(--ac-tx);
  outline-offset: 2px;
  border-radius: 4px;
}
/* 鼠标点击不要焦点圈（:focus-visible 已经只在键盘时出现，这里是双保险） */
:focus:not(:focus-visible) { outline: none; }
/* 跳到主要内容：键盘用户第一个 Tab 就该能跳过导航 */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 300;
  background: var(--ac); color: var(--on-ac);
  padding: 10px 18px; border-radius: 0 0 10px 0; font-size: 14px; font-weight: 600;
}
.skip:focus { left: 0; }

/* 只给爬虫/读屏器看的标题（SEO 需要 h1，但版面不想被它占） */
.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;
}

/* 可见面包屑（SEO 内链 + 用户导航） */
.crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--tx3); margin: 22px 0 14px; }
.crumb a { color: var(--tx3); transition: .15s; }
.crumb a:hover { color: var(--ac-tx); }
.crumb i { font-style: normal; opacity: .5; }
.crumb .cur { color: var(--tx2); max-width: 62vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-hd .more:hover { color: var(--ac-tx); }

/* ---------- Hero ---------- */
.hero { padding: 54px 0 30px; text-align: center; }
.hero h1 { font-size: clamp(28px, 5vw, 44px); font-weight: 800; letter-spacing: 1px; }
.hero h1 span { color: var(--ac-tx); }
.hero p { color: var(--tx2); margin-top: 12px; font-size: 15px; }
.hero .stats { display: flex; justify-content: center; gap: 30px; margin-top: 22px; flex-wrap: wrap; }
.hero .stats div { text-align: center; }
.hero .stats b { display: block; font-size: 22px; color: var(--ac-tx); font-weight: 800; }
.hero .stats span { font-size: 12px; color: var(--tx3); }

/* ---------- 分类 ---------- */
.cats { display: flex; gap: 10px; flex-wrap: wrap; }
.cat {
  display: flex; align-items: center; gap: 8px; padding: 11px 16px; border-radius: var(--r-s);
  background: var(--card); border: 1px solid var(--line); font-size: 14px; transition: .16s;
}
.cat:hover { border-color: var(--ac); background: var(--card2); transform: translateY(-2px); }
.cat b { color: var(--ac-tx); font-weight: 700; }
.cat i { font-style: normal; color: var(--tx3); font-size: 12px; }

/* ---------- 卡片网格 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; transition: .18s; position: relative; }
.card:hover { transform: translateY(-4px); border-color: var(--ac); box-shadow: var(--shadow); }
.card .cover { position: relative; aspect-ratio: 5 / 7; overflow: hidden; background: var(--bg2); }
.card .cover img { width: 100%; height: 100%; object-fit: cover; transition: .35s; }
.card:hover .cover img { transform: scale(1.05); }
/* ★ 角标底永远是深色半透明 → 字色必须写死浅色；用 var(--tx2) 会在浅色主题下变成「深底深字」 */
.card .badge {
  position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 6px;
  background: rgba(12,13,17,.78); backdrop-filter: blur(4px); font-size: 11px; font-weight: 600; color: #e9ebf2;
}
.card .badge.n { color: var(--on-ac); background: var(--ac); font-weight: 800; }
.card .pg {
  position: absolute; bottom: 8px; right: 8px; padding: 3px 8px; border-radius: 6px;
  background: rgba(12,13,17,.78); backdrop-filter: blur(4px); font-size: 11px; font-weight: 600; color: #e9ebf2;
}
.card .info { padding: 10px 11px 12px; }
.card .ttl { font-size: 13.5px; font-weight: 600; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.card .tags { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; height: 20px; overflow: hidden; }
.card .tags span { font-size: 11px; color: var(--tx3); background: var(--bg2); padding: 2px 7px; border-radius: 5px; white-space: nowrap; }

/* ---------- 索引筛选框 ---------- */
.bsearch { position: relative; max-width: 340px; margin-bottom: 18px; }
.bsearch svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; stroke: var(--tx3); }
.bsearch input { width: 100%; height: 40px; border-radius: 10px; padding: 0 92px 0 38px; background: var(--bg2); border: 1px solid var(--line); color: var(--tx); font-size: 14px; outline: none; transition: border-color .15s; }
.bsearch input:focus { border-color: var(--ac); }
.bsearch #browse-count { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--tx3); }

/* ---------- 标签云 ---------- */
.cloud { display: flex; flex-wrap: wrap; gap: 9px; }
.cloud a { padding: 7px 13px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); font-size: 13px; color: var(--tx2); transition: .15s; }
.cloud a:hover { color: var(--ac-tx); border-color: var(--ac); }
.cloud a b { color: var(--tx3); font-weight: 400; font-size: 11px; margin-left: 4px; }

/* ---------- 筛选栏 ---------- */
.filters { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 22px; }
.frow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 0; }
.frow > label { font-size: 13px; color: var(--tx3); min-width: 44px; }
.chip { padding: 6px 13px; border-radius: 20px; background: var(--bg2); border: 1px solid var(--line); font-size: 13px; color: var(--tx2); transition: .15s; display: inline-block; text-decoration: none; }
.chip:hover { color: var(--tx); border-color: var(--line2); }
.chip.on { background: var(--ac); border-color: var(--ac); color: var(--on-ac); font-weight: 700; }
.fcount { font-size: 13px; color: var(--tx3); margin: 4px 0 16px; }
.fcount b { color: var(--ac-tx); }

/* ---------- 搜索建议（分类维度跳转） ---------- */
.suggest:empty { display: none; }
.suggest {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 12px 14px; margin: 0 0 16px;
}
.sg-hd { font-size: 12px; color: var(--tx3); margin-bottom: 9px; }
.sg-list { display: flex; flex-wrap: wrap; gap: 8px; }
.sg {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px;
  background: var(--bg2); border: 1px solid var(--line); font-size: 13px; color: var(--tx);
  transition: .15s;
}
.sg:hover { border-color: var(--ac); color: var(--ac-tx); }
.sg b { color: var(--tx3); font-weight: 400; font-size: 11px; }

/* ---------- 分页 ---------- */
.pager { display: flex; justify-content: center; gap: 7px; margin: 34px 0; flex-wrap: wrap; }
.pager button { min-width: 38px; height: 38px; padding: 0 12px; border-radius: 9px; background: var(--card); border: 1px solid var(--line); font-size: 14px; color: var(--tx2); transition: .15s; }
.pager button:hover:not(:disabled) { border-color: var(--ac); color: var(--tx); }
.pager button.on { background: var(--ac); border-color: var(--ac); color: var(--on-ac); font-weight: 700; }
.pager button:disabled { opacity: .35; cursor: default; }

/* ---------- 详情 ---------- */
.detail { display: grid; grid-template-columns: 300px 1fr; gap: 32px; margin: 28px 0; align-items: start; }
/* 左栏 = 封面 + 操作按钮，整体 sticky：
   右侧内容再长，「开始阅读」也永远贴着封面底边、始终在视野里（2026-10-17 截图问题②）。 */
.detail .dside { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 14px; }
.detail .cov {
  border-radius: var(--r); overflow: hidden; border: 1px solid var(--line);
  box-shadow: var(--shadow); aspect-ratio: 350 / 486; background: var(--bg2);
}
/* ★ 封面必须铺满。cover.jpg 的比例并不总是 350:486（AI 图集等会不一样），
   只用 max-width:100% 会让图片撑不满容器 → 下方露出一块空白（截图问题①）。 */
.detail .cov img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.detail .dinfo { display: flex; flex-direction: column; min-width: 0; }
.detail .dinfo .block:last-of-type { margin-bottom: 0; }
.detail .acts { padding-top: 0; }
.detail .acts .btn { flex: 1; justify-content: center; }
.detail h1 { font-size: 25px; font-weight: 800; line-height: 1.35; }
.detail .sub { color: var(--tx3); font-size: 14px; margin-top: 8px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.meta span { font-size: 13px; color: var(--tx2); background: var(--card); border: 1px solid var(--line); padding: 5px 12px; border-radius: 8px; }
.meta span b { color: var(--ac-tx); }
.block { margin: 18px 0; }
.block > .k { font-size: 13px; color: var(--tx3); margin-bottom: 9px; }
.block .vals { display: flex; flex-wrap: wrap; gap: 8px; }
.block .vals a { font-size: 13px; padding: 6px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); color: var(--tx2); transition: .15s; }
.block .vals a:hover { color: var(--ac-tx); border-color: var(--ac); }
.btn {
  display: inline-flex; align-items: center; gap: 9px; padding: 13px 26px; border-radius: 11px;
  background: linear-gradient(135deg, var(--ac), var(--ac-d)); color: var(--on-ac); font-weight: 800; font-size: 15px;
  transition: .16s; box-shadow: 0 8px 22px -10px var(--ac);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px -10px var(--ac); }
.btn.ghost { background: var(--card); color: var(--tx); border: 1px solid var(--line); box-shadow: none; font-weight: 600; }
.btn.ghost:hover { border-color: var(--ac); color: var(--ac-tx); }
.btn.ghost.on { border-color: var(--ac); color: var(--ac-tx); background: var(--ac-soft); }
.acts { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 22px; }

/* ---------- 18+ 门 ---------- */
.gate { position: fixed; inset: 0; z-index: 999; background: rgba(8, 9, 12, .94); backdrop-filter: blur(10px); display: grid; place-items: center; padding: 20px; }
.gate-box { max-width: 470px; text-align: center; background: var(--card); border: 1px solid var(--line2); border-radius: 20px; padding: 40px 32px; box-shadow: var(--shadow); }
.gate-logo { display: inline-flex; align-items: center; gap: 10px; font-size: 25px; font-weight: 800; margin-bottom: 20px; }
.gate-logo .mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--ac), #b5761f); display: grid; place-items: center; color: var(--on-ac); font-weight: 900; }
.gate-logo b { color: var(--ac-tx); }
.gate-box h3 { font-size: 20px; margin-bottom: 12px; }
.gate-box p { color: var(--tx2); font-size: 14px; line-height: 1.85; }
.gate-box p b { color: var(--ac-tx); }
.gate-btns { display: flex; gap: 12px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.prev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 9px; }
.prev-grid a { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 5/7; background: var(--bg2); transition: .15s; }
.prev-grid a:hover { border-color: var(--ac); transform: translateY(-2px); }
.prev-grid img { width: 100%; height: 100%; object-fit: cover; }
.prev-grid .pn { position: absolute; bottom: 0; left: 0; right: 0; padding: 2px 0; text-align: center; font-size: 10px; color: #e9ebf2; background: rgba(12,13,17,.62); }
.sec-hd .morebtn { padding: 7px 14px; border-radius: 9px; background: var(--card); border: 1px solid var(--line); color: var(--tx2); font-size: 13px; transition: .15s; white-space: nowrap; }
.sec-hd .morebtn:hover { border-color: var(--ac); color: var(--ac-tx); }
.sec-hd .morebtn[hidden] { display: none; }

/* ---------- 大图预览（lightbox）：不进阅读器就能翻页看大图 ---------- */
.lb { position: fixed; inset: 0; z-index: 300; background: rgba(8,9,12,.95); display: grid; place-items: center; }
.lb[hidden] { display: none; }
.lb-img { max-width: 96vw; max-height: 90vh; object-fit: contain; }
.lb-bar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.lb-bar .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e9ebf2; font-size: 14px; }
.lb-bar .n { color: #e9ebf2; font-size: 14px; font-variant-numeric: tabular-nums; }
.lb-bar button, .lb-bar a { color: #e9ebf2; padding: 7px 12px; border-radius: 8px; background: rgba(255,255,255,.12); font-size: 13px; transition: .15s; }
.lb-bar button:hover, .lb-bar a:hover { background: rgba(255,255,255,.24); }
.lb-zone { position: absolute; top: 0; bottom: 0; cursor: pointer; }
.lb-zone.prv { left: 0; width: 30%; }
.lb-zone.nxt { right: 0; width: 70%; }
.lb-zone::after {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px;
  border-radius: 50%; display: grid; place-items: center; font-size: 22px; font-weight: 700;
  line-height: 1; color: var(--on-ac); background: var(--ac); opacity: 0; transition: opacity .18s; pointer-events: none;
}
.lb-zone.prv::after { content: '‹'; left: 16px; }
.lb-zone.nxt::after { content: '›'; right: 16px; }
.lb-zone:hover::after { opacity: .92; }
@media (hover: none) { .lb-zone::after { display: none; } }

/* ---------- 阅读器（单页 · 对齐 nhentai.xxx：点图 = 下一页） ---------- */
.reader { max-width: 1400px; margin: 0 auto; padding: 18px 12px 60px; }
.rd-bar {
  position: sticky; top: 62px; z-index: 50; display: flex; align-items: center; gap: 10px;
  background: rgba(12,13,17,.88); backdrop-filter: blur(12px); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 12px; margin-bottom: 14px; font-size: 13px;
}
.rd-bar .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tx2); }
.rd-bar a, .rd-bar button { color: var(--tx2); padding: 6px 9px; border-radius: 8px; transition: .15s; font-size: 13px; line-height: 1; }
.rd-bar a:hover, .rd-bar button:hover { color: var(--ac-tx); background: var(--card); }
.rd-bar button:disabled { opacity: .3; cursor: default; }
.rd-bar button:disabled:hover { color: var(--tx2); background: none; }
.rd-count { display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.rd-count .p { color: var(--ac-tx); font-weight: 700; }
/* 页码按钮：点开就地变输入框（原站是 prompt 弹窗，这里不弹窗） */
.rd-jump { min-width: 76px; text-align: center; font-variant-numeric: tabular-nums; }
.rd-jump input {
  width: 46px; height: 26px; text-align: center; border-radius: 6px;
  background: var(--bg2); border: 1px solid var(--ac); color: var(--tx); font-size: 13px; outline: none;
}
.rd-set { font-size: 14px; line-height: 1; }

/* ---------- 阅读设置面板 ---------- */
.rd-panel {
  position: fixed; right: 16px; top: 78px; z-index: 200; width: 240px;
  background: var(--card); border: 1px solid var(--line2); border-radius: 14px;
  padding: 14px; box-shadow: var(--shadow); display: grid; gap: 12px;
}
.rd-panel[hidden] { display: none; }
.rd-panel .row { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--tx2); flex-wrap: wrap; }
.rd-panel .row > span { min-width: 32px; }
.rd-panel .row button {
  padding: 6px 11px; border-radius: 8px; background: var(--bg2);
  border: 1px solid var(--line); color: var(--tx2); font-size: 13px; transition: .15s;
}
.rd-panel .row button:hover { border-color: var(--line2); color: var(--tx); }
.rd-panel .row button.on { background: var(--ac); border-color: var(--ac); color: var(--on-ac); font-weight: 700; }
.rd-panel .tip { font-size: 11px; color: var(--tx3); line-height: 1.6; }

/* 阅读区：图片按【原始比例】排布（不写死宽高）；左右点击区叠在上面 */
.rd-stage {
  position: relative; display: grid; place-items: center; margin-bottom: 14px;
  /* ★ 初始就预留约一屏高度。图片是 JS 异步插进来的，若初始只有 45vh，
     图一到就把下面的 .rd-nav / .ad / .rd-foot 整个推走 —— 实测 CLS 0.2242（差）。
     预留一屏后这些元素一开始就在首屏外，位移不计分 → CLS 0.0443（良好）。 */
  min-height: calc(100vh - 190px);
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.rd-stage.loading::after {
  content: ''; position: absolute; width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line2); border-top-color: var(--ac); animation: sp .7s linear infinite;
}
.rd-img { display: block; margin: 0 auto; height: auto; }
.rd-stage.loading .rd-img { visibility: hidden; }
/* 三种模式：宽度（默认，铺满）/ 高度（整页塞进视口）/ 原始尺寸（按真实像素，超宽才缩） */
.rd-stage.mode-width .rd-img { width: 100%; }
.rd-stage.mode-height .rd-img { width: auto; max-width: 100%; max-height: calc(100vh - 200px); }
.rd-stage.mode-natural .rd-img { width: auto; max-width: 100%; }

/* 左右点击区：左 25% = 上一页，其余 75% = 下一页（点图即翻页，对齐原站 .fw_img 行为） */
.rd-zone { position: absolute; top: 0; bottom: 0; z-index: 2; cursor: pointer; }
.rd-zone.prv { left: 0; width: 25%; }
.rd-zone.nxt { right: 0; width: 75%; }
.rd-zone::after {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 22px; font-weight: 700; line-height: 1; color: var(--on-ac);
  background: var(--ac); opacity: 0; transition: opacity .18s; pointer-events: none;
}
.rd-zone.prv::after { content: '‹'; left: 14px; }
.rd-zone.nxt::after { content: '›'; right: 14px; }
.rd-zone:hover::after { opacity: .92; }
@media (hover: none) { .rd-zone::after { display: none; } }   /* 触屏没有 hover，别留箭头 */

.rd-nav { display: flex; gap: 12px; justify-content: center; margin: 0 0 18px; flex-wrap: wrap; }
.rd-nav .btn { min-width: 132px; justify-content: center; }
.rd-nav .btn:disabled { opacity: .35; cursor: default; }
.rd-nav .btn:disabled:hover { transform: none; box-shadow: none; border-color: var(--line); color: var(--tx); }
.rd-foot { display: flex; gap: 12px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }
.ad {
  margin: 18px 0; padding: 26px; text-align: center; border: 1px dashed var(--line2); border-radius: 12px;
  color: var(--tx3); font-size: 12px; letter-spacing: 2px; background: repeating-linear-gradient(45deg, var(--card), var(--card) 10px, var(--bg2) 10px, var(--bg2) 20px);
}

/* ---------- 书架 ---------- */
.tabs { display: flex; gap: 8px; margin: 22px 0; }
.tabs button { padding: 9px 20px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); color: var(--tx2); font-size: 14px; }
.tabs button.on { background: var(--ac); border-color: var(--ac); color: var(--on-ac); font-weight: 700; }
.hist { display: flex; flex-direction: column; gap: 10px; }
.hist .row { display: flex; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px; }
.hist .row img { width: 52px; height: 72px; object-fit: cover; border-radius: 7px; flex: none; }
.hist .row .h-t { flex: 1; min-width: 0; }
.hist .row .h-t b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .row .h-t span { font-size: 12px; color: var(--tx3); }
.bar { height: 4px; background: var(--bg2); border-radius: 3px; margin-top: 7px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ac); }

/* ---------- 文档页 ---------- */
.doc { max-width: 780px; margin: 30px auto; line-height: 1.9; }
.doc h1 { font-size: 27px; margin-bottom: 18px; }
.doc h2 { font-size: 17px; margin: 26px 0 10px; color: var(--ac-tx); }
.doc p, .doc li { color: var(--tx2); font-size: 14.5px; }
.doc ul { margin: 8px 0 8px 22px; }
.doc li { margin: 5px 0; }
.doc strong { color: var(--tx); }
.doc a { color: var(--ac-tx); }
.doc-note { margin-top: 32px; color: var(--tx3) !important; font-size: 13px !important; }

/* ---------- 空态 / 页脚 ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--tx3); }
.empty b { display: block; font-size: 17px; color: var(--tx2); margin-bottom: 8px; }
footer { border-top: 1px solid var(--line); margin-top: 50px; padding: 30px 0; color: var(--tx3); font-size: 13px; }
footer .fnav { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
footer .fnav a:hover { color: var(--ac-tx); }
footer .disc { line-height: 1.8; font-size: 12px; color: var(--tx3); }

/* ---------- 加载 ---------- */
.sk { background: linear-gradient(90deg, var(--card) 25%, var(--card2) 50%, var(--card) 75%); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: var(--r); }
@keyframes sk { to { background-position: -200% 0; } }
.spin { width: 30px; height: 30px; border: 3px solid var(--line2); border-top-color: var(--ac); border-radius: 50%; animation: sp .7s linear infinite; margin: 50px auto; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .hd { gap: 8px; }
  .detail { grid-template-columns: 1fr; }
  .detail .dside { position: static; }
  .detail .cov { max-width: 230px; margin: 0 auto; }
  .detail .acts { padding-top: 4px; }

  /* 导航 → 全屏抽屉（原先是个矮下拉，8 个链接挤成一坨）
     ⚠️ 这里【必须用 absolute，不能用 fixed】：header 上有 backdrop-filter: blur()，
        它会让 fixed 后代以 **header** 为包含块（不是视口）→ top:62px + bottom:0 在
        62px 高的盒子里算出负高度，抽屉直接塌掉（2026-10-17 截图实测踩到）。
        absolute 的包含块本来就是 header，配显式高度即可铺满。 */
  .nav { display: none; }
  .nav.open {
    display: flex; flex-direction: column; align-items: stretch; gap: 2px; margin-left: 0;
    position: absolute; top: 62px; left: 0; right: 0; z-index: 99;
    height: calc(100vh - 62px); height: calc(100dvh - 62px);
    background: var(--bg2); border-top: 1px solid var(--line);
    padding: 12px 14px 40px; overflow-y: auto;
  }
  .nav.open > a, .nav.open .ndrop-btn { padding: 13px 14px; font-size: 15px; border-radius: 10px; justify-content: space-between; }
  .ndrop { position: static; }
  .ndrop-menu {
    position: static; display: none; grid-template-columns: repeat(2, 1fr); gap: 2px 8px;
    padding: 2px 0 10px 10px; background: none; border: none; box-shadow: none;
  }
  .ndrop.open .ndrop-menu { display: grid; }
  .ndrop-hd { padding: 8px 10px 4px; }

  .burger { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; background: var(--card); border: 1px solid var(--line); }
  .search { max-width: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 13px; }
  .reader { padding: 14px 10px 50px; }
  .rd-stage.mode-height .rd-img { max-height: calc(100vh - 185px); }
}
@media (max-width: 520px) {
  .wrap { padding: 0 13px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 11px; }
  .hero { padding: 34px 0 20px; }
  .card .ttl { font-size: 12.5px; }
  .reader { padding: 12px 8px 48px; }
  .rd-stage { min-height: calc(100vh - 170px); border-radius: 10px; }   /* 同桌面：初始预留一屏，防 CLS */
  .rd-stage.mode-height .rd-img { max-height: calc(100vh - 170px); }
  .rd-nav { gap: 8px; }
  .rd-nav .btn { min-width: 0; flex: 1; padding: 12px 10px; }
  .rd-panel { right: 10px; left: 10px; width: auto; }
  .rd-bar { gap: 4px; padding: 7px 9px; }
  .rd-bar .t { display: none; }                 /* 手机上标题挤不下，让位给页码 */
  #rd-first, #rd-last { display: none; }        /* 首末页按钮手机上收起来 */
  .rd-zone.prv { width: 30%; }
  .rd-zone.nxt { width: 70%; }
}

/* ==========================================================================
   异步填充容器的「预留高度」—— 防 CLS
   --------------------------------------------------------------------------
   这些容器是 JS 异步填的：空着时下方的 section / 广告位 / footer 会浮在首屏内，
   填完内容长高就把它们整个推下去 → 计入 CLS。
   给空容器预留高度后，这些元素一开始就在首屏外，位移不计分。

   ★ 铁律 1：预留值必须 ≤ 填充后的真实高度，否则容器会「先撑大、再收缩」→ 反向位移。
     曾经用一条全局 `.grid:empty { min-height: 72vh }` 修，首页/库页好了，
     详情页反而从 0.3595 变 0.4493 —— 因为 #related 也是 .grid，但它由 poolFor()
     最后才填、真实高度不够 72vh。所以这里按容器分别给值。

   ★ 铁律 2：:empty 只在「完全没有任何子节点」时匹配 —— 各容器必须保证
     连加载失败时也塞个占位元素进去，别留 ''，否则预留高度会永久生效（见 app.js 的 put()）。

   实测（web-vitals.mjs §⑥，1440×940）：
     首页 0.2917 → 0.0109 · 库页 0.3815 → 0.0231 · 详情页 0.3595 → 0.0090
     （阅读器 0.0443 · 索引 0.0071 本来就合格）

   ★ 2026-10-17 线上复测发现的漏网之鱼：库页 0.0231 是【本地预览】测的 ——
     本地毫秒返回，筛选栏赶在首绘之前填好，测不出位移。
     真网络下 #filters 要等 meta.json + 列表分片，5.7s 后才从预留的 180px
     长到真实的 296px → 线上 CLS 0.1166（需改进）。
     已用【构建期预渲染】根治（build.mjs 3c，首绘即有正确高度）；
     这里把预留值抬到实测最小值作为兜底（chip 从 <button> 改 <a> 后是 319）——
     319 是所有视口/所有筛选态下的最小值（桌面 ≥1280 正好 319，窄屏更大），
     所以取 319 永不会「先撑大再收缩」（铁律 1）。
   ========================================================================== */
.detail:empty    { min-height: 480px; }   /* 封面 300×417 + 操作按钮 */
.grid:empty      { min-height: 560px; }   /* 卡片网格：24 张 ≥4 行（桌面）/ ≥12 行（手机）*/
.filters:empty   { min-height: 319px; }   /* 库页筛选栏：实测最小 319（桌面 ≥1280，chip 改 <a> 后）*/
/* 面包屑也是 JS 注入的（首绘时为空 → 填好后 21px，把下方整体下推）——
   2026-10-17 线上复测：筛选栏预渲染后剩下的唯一位移就是它（21px / CLS 0.0396）。 */
.crumb:empty     { min-height: 21px; }    /* 单行面包屑：13px 字号 → 21px */
/* 库页「共 N 本」计数行也是 JS 注入的（0 → 21px，把下面广告位/网格推下去 39px）——
   2026-10-17 线上复测：面包屑修好后剩下的唯一位移就是它。 */
.fcount:empty    { min-height: 21px; }    /* 单行计数：13px 字号 → 21px（margin 4/16 另计） */
.prev-grid:empty { min-height: 260px; }   /* 详情页内容预览 */
