/* ═══════════════════════════════════════════════════
   阅读 · 视觉系统 v3
   注：不使用 SVG feTurbulence 纹理与重度 backdrop-filter，
   避免非整数 DPI 缩放下的合成器渲染故障（大面积黑块）。
   ═══════════════════════════════════════════════════ */

:root {
  --wenkai: "LXGW WenKai Screen", "Kaiti SC", KaiTi, STKaiti, serif;
  --song: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  --hei: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --brush: "Ma Shan Zheng", var(--wenkai);       /* 毛笔楷书：品牌/问候 */
  --xiaowei: "ZCOOL XiaoWei", var(--song);        /* 明体标题字 */
  --longcang: "Long Cang", var(--wenkai);         /* 手写体 */
  --ui: var(--hei);
  --radius: 14px;
  --radius-lg: 20px;
  --ease: cubic-bezier(.32, .72, .28, 1);
  --spring: cubic-bezier(.34, 1.3, .5, 1);
  --side-w: 232px;
}

/* ── 主题 ── */
[data-theme="paper"] {
  color-scheme: light;
  --bg: #f5f1e8;
  --bg-deep: #ece6d8;
  --bg-raise: #fcfaf4;
  --bg-sunken: #eae4d5;
  --ink: #33302a;
  --ink-2: #746c5d;
  --ink-3: #8f8674;
  --line: rgba(64, 52, 30, .13);
  --line-soft: rgba(64, 52, 30, .07);
  --accent: #b0402b;
  --accent-ink: #8f3927;
  --accent-soft: rgba(176, 64, 43, .09);
  --gold: #a8823c;
  --sel: rgba(176, 64, 43, .16);
  --shadow-sm: 0 1px 2px rgba(46, 36, 18, .05), 0 2px 10px rgba(46, 36, 18, .05);
  --shadow-md: 0 3px 8px rgba(46, 36, 18, .08), 0 12px 32px rgba(46, 36, 18, .11);
  --shadow-lg: 0 8px 22px rgba(46, 36, 18, .13), 0 16px 40px rgba(46, 36, 18, .17);
  --cover-shadow: 0 2px 4px rgba(46, 36, 18, .12), 0 8px 22px rgba(46, 36, 18, .16);
  --hero-grad: linear-gradient(120deg, #fcf8ef 0%, #f6ecd9 55%, #efdfc2 100%);
}
[data-theme="sepia"] {
  color-scheme: light;
  --bg: #f2e7d3;
  --bg-deep: #e9dbc0;
  --bg-raise: #faf3e4;
  --bg-sunken: #e6d7ba;
  --ink: #453a2c;
  --ink-2: #83735b;
  --ink-3: #98876b;
  --line: rgba(84, 62, 30, .15);
  --line-soft: rgba(84, 62, 30, .08);
  --accent: #9c5220;
  --accent-ink: #82441b;
  --accent-soft: rgba(156, 82, 32, .11);
  --gold: #9c7a35;
  --sel: rgba(156, 82, 32, .18);
  --shadow-sm: 0 1px 2px rgba(66, 46, 16, .06), 0 2px 10px rgba(66, 46, 16, .06);
  --shadow-md: 0 3px 8px rgba(66, 46, 16, .09), 0 12px 32px rgba(66, 46, 16, .12);
  --shadow-lg: 0 8px 22px rgba(66, 46, 16, .14), 0 16px 40px rgba(66, 46, 16, .18);
  --cover-shadow: 0 2px 4px rgba(66, 46, 16, .13), 0 8px 22px rgba(66, 46, 16, .17);
  --hero-grad: linear-gradient(120deg, #f9f0dd 0%, #f0e0c2 55%, #e7d2a8 100%);
}
[data-theme="green"] {
  color-scheme: light;
  --bg: #e3eddd;
  --bg-deep: #d6e3cd;
  --bg-raise: #f2f8ee;
  --bg-sunken: #d3e0ca;
  --ink: #2c362e;
  --ink-2: #64735f;
  --ink-3: #7f9179;
  --line: rgba(36, 66, 40, .14);
  --line-soft: rgba(36, 66, 40, .07);
  --accent: #33684b;
  --accent-ink: #2a563e;
  --accent-soft: rgba(51, 104, 75, .1);
  --gold: #6f7d3c;
  --sel: rgba(51, 104, 75, .18);
  --shadow-sm: 0 1px 2px rgba(24, 46, 28, .05), 0 2px 10px rgba(24, 46, 28, .05);
  --shadow-md: 0 3px 8px rgba(24, 46, 28, .08), 0 12px 32px rgba(24, 46, 28, .11);
  --shadow-lg: 0 8px 22px rgba(24, 46, 28, .13), 0 16px 40px rgba(24, 46, 28, .17);
  --cover-shadow: 0 2px 4px rgba(24, 46, 28, .12), 0 8px 22px rgba(24, 46, 28, .16);
  --hero-grad: linear-gradient(120deg, #f0f7ea 0%, #dfeccf 55%, #cfe2b8 100%);
}
[data-theme="mist"] {
  color-scheme: light;
  --bg: #e9edf2;
  --bg-deep: #dce3ec;
  --bg-raise: #f7f9fb;
  --bg-sunken: #d9e0e9;
  --ink: #2e3440;
  --ink-2: #68717f;
  --ink-3: #8b95a4;
  --line: rgba(38, 50, 72, .14);
  --line-soft: rgba(38, 50, 72, .07);
  --accent: #3b5a86;
  --accent-ink: #314b70;
  --accent-soft: rgba(59, 90, 134, .1);
  --gold: #5d7191;
  --sel: rgba(59, 90, 134, .18);
  --shadow-sm: 0 1px 2px rgba(24, 34, 52, .05), 0 2px 10px rgba(24, 34, 52, .05);
  --shadow-md: 0 3px 8px rgba(24, 34, 52, .08), 0 12px 32px rgba(24, 34, 52, .11);
  --shadow-lg: 0 8px 22px rgba(24, 34, 52, .13), 0 16px 40px rgba(24, 34, 52, .17);
  --cover-shadow: 0 2px 4px rgba(24, 34, 52, .12), 0 8px 22px rgba(24, 34, 52, .16);
  --hero-grad: linear-gradient(120deg, #f5f8fb 0%, #e4ebf4 55%, #d3dfee 100%);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #262a31;
  --bg-deep: #1f232a;
  --bg-raise: #2f343d;
  --bg-sunken: #1d2026;
  --ink: #cbc7be;
  --ink-2: #8d8a82;
  --ink-3: #6b6961;
  --line: rgba(255, 250, 235, .1);
  --line-soft: rgba(255, 250, 235, .05);
  --accent: #d99a62;
  --accent-ink: #e2ab7b;
  --accent-soft: rgba(217, 154, 98, .11);
  --gold: #b3925c;
  --sel: rgba(217, 154, 98, .22);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 10px rgba(0, 0, 0, .25);
  --shadow-md: 0 3px 8px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 22px rgba(0, 0, 0, .45), 0 16px 40px rgba(0, 0, 0, .5);
  --cover-shadow: 0 2px 4px rgba(0, 0, 0, .4), 0 8px 22px rgba(0, 0, 0, .45);
  --hero-grad: linear-gradient(120deg, #2f353f 0%, #2a2f38 55%, #23272e 100%);
}
[data-theme="black"] {
  color-scheme: dark;
  --bg: #0b0b0d;
  --bg-deep: #070709;
  --bg-raise: #17171b;
  --bg-sunken: #050506;
  --ink: #c6c2ba;
  --ink-2: #827f78;
  --ink-3: #605e58;
  --line: rgba(255, 250, 235, .09);
  --line-soft: rgba(255, 250, 235, .045);
  --accent: #cf8f56;
  --accent-ink: #dba26e;
  --accent-soft: rgba(207, 143, 86, .11);
  --gold: #a98a55;
  --sel: rgba(207, 143, 86, .22);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5), 0 2px 10px rgba(0, 0, 0, .4);
  --shadow-md: 0 3px 8px rgba(0, 0, 0, .5), 0 12px 32px rgba(0, 0, 0, .55);
  --shadow-lg: 0 8px 22px rgba(0, 0, 0, .6), 0 16px 40px rgba(0, 0, 0, .65);
  --cover-shadow: 0 2px 4px rgba(0, 0, 0, .5), 0 8px 22px rgba(0, 0, 0, .55);
  --hero-grad: linear-gradient(120deg, #1a1a20 0%, #141418 55%, #0e0e12 100%);
}

/* ── 基础 ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--ui);
  background: var(--bg);
  color: var(--ink);
  transition: background-color .25s var(--ease), color .25s var(--ease);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--sel); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { font: inherit; color: inherit; }
.view[hidden] { display: none !important; }
/* hidden 一律真隐藏（.comic-body/.chapter-nav 等自带 display:flex 会覆盖 UA 规则） */
[hidden] { display: none !important; }
/* 键盘可达性焦点环（主题色，替代 UA 黑框） */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible), input:focus:not(:focus-visible) { outline: none; }
kbd {
  font-family: var(--ui); font-size: 11px;
  padding: 2px 6px; border-radius: 5px;
  background: var(--bg-sunken); border: 1px solid var(--line);
  border-bottom-width: 2px; color: var(--ink-2);
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--ink-3) 55%, transparent); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ═══════════════════════════════════════════════════
   书架 · 侧栏布局
   ═══════════════════════════════════════════════════ */

#shelf { display: flex; min-height: 100vh; }

.side {
  width: var(--side-w); flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: calc(26px + env(safe-area-inset-top)) 18px 22px;
  background: var(--bg-deep);
  border-right: 1px solid var(--line-soft);
}

.side-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; user-select: none; }
.seal {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent) 55%, color-mix(in srgb, var(--accent) 75%, #000));
  color: #f7f2e8;
  font-family: var(--brush); font-size: 27px;
  box-shadow: inset 0 0 0 1.5px rgba(255, 245, 225, .3), var(--shadow-sm);
  transform: rotate(-3deg);
}
.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand { font-family: var(--brush); font-size: 26px; font-weight: 400; letter-spacing: .18em; line-height: 1; }
.brand-sub { font-size: 10.5px; letter-spacing: .4em; color: var(--ink-3); padding-left: 2px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
#filterTabs {
  position: relative; isolation: isolate;
  --indicator-x: 0px; --indicator-y: 0px;
  --indicator-w: 100%; --indicator-h: 42px;
}
#filterTabs::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  left: 0; top: 0;
  width: var(--indicator-w); height: var(--indicator-h);
  border-radius: 11px;
  background: var(--bg-raise); box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translate3d(var(--indicator-x), var(--indicator-y), 0);
}
#filterTabs.indicator-ready::before {
  opacity: 1;
  transition: transform .26s var(--spring), width .26s var(--spring), height .26s var(--spring), opacity .12s var(--ease);
}
.side-nav .tab {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 11px;
  font-size: 14px; color: var(--ink-2);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
  text-align: left;
}
.side-nav .tab svg { flex-shrink: 0; opacity: .75; }
.side-nav .tab span { flex: 1; }
.side-nav .tab em {
  font-style: normal; font-size: 12px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.side-nav .tab:hover { background: var(--accent-soft); color: var(--ink); }
.side-nav .tab:active { transform: scale(.97); }
.side-nav .tab.active {
  background: var(--bg-raise); color: var(--ink);
  font-weight: 600; box-shadow: var(--shadow-sm);
}
#filterTabs .tab.active { background: transparent; box-shadow: none; }
.side-nav .tab.active svg { opacity: 1; color: var(--accent); }
.side-nav .tab.active em { color: var(--accent); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.theme-flip {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; border-radius: 11px;
  font-size: 13.5px; color: var(--ink-2);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.theme-flip:hover { background: var(--accent-soft); color: var(--accent); }
[data-theme="paper"] .ic-moon, [data-theme="sepia"] .ic-moon, [data-theme="green"] .ic-moon, [data-theme="mist"] .ic-moon { display: none; }
[data-theme="dark"] .ic-sun, [data-theme="black"] .ic-sun { display: none; }
.side-lib { font-size: 11.5px; color: var(--ink-3); padding: 0 14px; line-height: 1.8; }
.side-lib code { background: var(--bg-sunken); border-radius: 4px; padding: 1px 5px; font-size: 10.5px; }

/* ── 主区 ── */
.shelf-main {
  flex: 1; min-width: 0;
  padding: calc(26px + env(safe-area-inset-top)) clamp(24px, 3.5vw, 56px) 90px;
  max-width: 1900px;
}

.shelf-top {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 30px;
}
.greet { font-family: var(--brush); font-size: clamp(26px, 2.4vw, 34px); line-height: 1.25; letter-spacing: .06em; }
.greet-sub { font-size: 13px; color: var(--ink-2); margin-top: 6px; letter-spacing: .05em; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-raise);
  border: 1px solid var(--line-soft);
  border-radius: 999px; padding: 9px 18px;
  color: var(--ink-3);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
  min-width: 250px;
  box-shadow: var(--shadow-sm);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--accent); }
.search-box input { border: 0; outline: 0; background: none; width: 100%; color: var(--ink); font-size: 16px; }
.search-box input::placeholder { color: var(--ink-3); }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; }

.section-title {
  font-family: var(--xiaowei);
  font-size: 19px; font-weight: 400; letter-spacing: .2em;
  color: var(--ink); margin: 34px 0 20px;
  display: flex; align-items: center; gap: 10px;
}
.st-mark { width: 4px; height: 18px; border-radius: 2px; background: var(--accent); display: inline-block; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); margin-left: 8px; }

/* ── 继续阅读：主卡 + 队列 ── */
.continue-area { display: grid; grid-template-columns: minmax(380px, 1.25fr) 1fr; gap: 20px; align-items: stretch; }
/* 只有一本在读：队列为空时 hero 占满整行 */
.continue-row:empty { display: none; }
.continue-area:has(.continue-row:empty) { grid-template-columns: 1fr; }
.continue-area:has(.continue-row:empty) .hero-card { max-width: 880px; }

.hero-card {
  position: relative; overflow: hidden;
  display: flex; gap: clamp(18px, 2vw, 30px); align-items: center;
  padding: clamp(20px, 2.2vw, 32px);
  border-radius: var(--radius-lg);
  background: var(--hero-grad);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-md);
  text-align: left;
  transition: transform .25s var(--ease), border-color .25s var(--ease);
  width: 100%;
}
.hero-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
/* 大字水印 */
.hero-card::before {
  content: attr(data-glyph);
  position: absolute; right: -12px; bottom: -46px;
  font-family: var(--brush); font-size: 200px; line-height: 1;
  color: var(--ink); opacity: .05;
  pointer-events: none;
}
.hero-cover {
  width: clamp(108px, 10vw, 148px); aspect-ratio: 5/7; flex-shrink: 0;
  border-radius: 8px 12px 12px 8px; overflow: hidden; position: relative;
  box-shadow: var(--cover-shadow);
}
.hero-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-meta { min-width: 0; flex: 1; position: relative; }
.hero-tag {
  display: inline-block; font-size: 11px; letter-spacing: .3em; color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  padding: 3px 10px 3px 12px; border-radius: 999px; margin-bottom: 12px;
}
.hero-title {
  font-family: var(--xiaowei); font-size: clamp(22px, 2vw, 30px);
  line-height: 1.3; letter-spacing: .04em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hero-ch { font-size: 13.5px; color: var(--ink-2); margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-time { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.hero-bottom { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.hero-bar { flex: 1; max-width: 260px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 12%, transparent); overflow: hidden; }
.hero-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; min-width: 6px; }
.hero-pct { font-size: 13px; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.hero-go {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: 999px;
  background: var(--accent); color: #f8f3ea; font-size: 13.5px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s var(--spring), box-shadow .2s;
}
.hero-card:hover .hero-go { transform: translateX(2px); box-shadow: var(--shadow-md); }

.continue-row {
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto; max-height: 320px;
  padding: 2px;
  scrollbar-width: thin;
}
.continue-card {
  display: flex; gap: 13px; align-items: center;
  background: var(--bg-raise); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 11px 13px; text-align: left;
  transition: transform .22s var(--ease), border-color .22s var(--ease);
  box-shadow: var(--shadow-sm);
}
.continue-card:hover { transform: translateX(3px); box-shadow: var(--shadow-md); border-color: var(--line); }
.cc-cover-box { width: 46px; flex-shrink: 0; border-radius: 6px; overflow: hidden; position: relative; box-shadow: var(--cover-shadow); aspect-ratio: 5/7; }
.cc-cover-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cc-cover-box .cover-fallback.cover-fallback { padding: 5px 4px; }
.cc-cover-box .cover-fallback .cf-title { font-size: 9.5px; letter-spacing: .03em; line-height: 1.35; margin: 1px auto 0 0; padding-left: 2px; text-shadow: none; }
.cc-cover-box .cover-fallback .cf-frame { inset: 3px; border-radius: 2px; }
.cc-cover-box .cover-fallback .cf-seal { display: none; }
.continue-card .cc-meta { min-width: 0; flex: 1; }
.continue-card .cc-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-card .cc-sub { font-size: 12px; color: var(--ink-2); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-card .cc-right { flex-shrink: 0; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.continue-card .cc-pct { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.continue-card.has-progress .cc-pct { color: var(--accent); font-weight: 600; }
.continue-card .cc-time { font-size: 11px; color: var(--ink-3); }

/* ── 书籍网格 ── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 32px 24px;
}
@media (min-width: 1600px) {
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 38px 28px; }
}
.book-card { text-align: left; display: flex; flex-direction: column; gap: 11px; perspective: 900px; }
.book-cover-wrap {
  position: relative; aspect-ratio: 5 / 7;
  border-radius: 6px 10px 10px 6px;
  background: var(--bg-sunken);
  box-shadow: var(--cover-shadow);
  transition: transform .3s var(--ease);
  transform-origin: left center;
  overflow: hidden;
}
.book-card:hover .book-cover-wrap {
  transform: translateY(-6px) rotateY(-5deg);
  box-shadow: var(--shadow-lg);
}
.book-card:active .book-cover-wrap { transform: translateY(-2px) rotateY(-2deg) scale(.985); }
.book-cover-wrap::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,0) 4%, rgba(0,0,0,.1) 5.5%, rgba(0,0,0,0) 9%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), inset 0 1px 0 rgba(255,255,255,.18);
}
.book-cover-wrap img.cover-img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }

/* 生成式封面 */
.cover-fallback {
  position: absolute; inset: 0; padding: 16px 14px;
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 90% at 85% -10%, var(--cf-hi) 0%, transparent 55%),
    linear-gradient(160deg, var(--cf-a) 0%, var(--cf-b) 100%);
}
.cover-fallback .cf-frame {
  position: absolute; inset: 9px; border: 1px solid rgba(255, 250, 240, .3); border-radius: 4px;
  pointer-events: none;
}
.cover-fallback .cf-title {
  font-family: var(--xiaowei); font-weight: 400; color: rgba(255, 253, 246, .97);
  font-size: 20px; line-height: 1.5; letter-spacing: .14em;
  writing-mode: vertical-rl; max-height: 82%;
  margin: 8px auto 0 0; padding-left: 10px;
  overflow: hidden;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.cover-fallback .cf-seal {
  margin-top: auto; align-self: flex-end;
  width: 27px; height: 27px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 252, 245, .92);
  color: var(--cf-b); font-family: var(--brush); font-size: 15px;
}
.book-badge {
  position: absolute; top: 9px; right: 9px; z-index: 2;
  font-size: 10px; letter-spacing: .12em; padding: 3.5px 9px; border-radius: 999px;
  background: rgba(14, 11, 8, .5); color: rgba(248, 243, 232, .95);
  border: 1px solid rgba(255, 255, 255, .14);
}
.book-progress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px; z-index: 2;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, .18));
}
.book-progress i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff));
  box-shadow: 0 0 0 .5px rgba(0, 0, 0, .15);
}
.book-title-line { font-size: 13.5px; font-weight: 600; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-sub-line { font-size: 11.5px; color: var(--ink-2); margin-top: -5px; font-variant-numeric: tabular-nums; }

/* ── 空状态 ── */
.empty-state { text-align: center; padding: 80px 20px; color: var(--ink-2); }
.empty-art { color: var(--ink-3); margin-bottom: 20px; }
.empty-main { font-family: var(--xiaowei); font-size: 22px; color: var(--ink); margin-bottom: 12px; letter-spacing: .12em; }
.empty-sub { font-size: 13.5px; line-height: 2.2; }
.empty-sub code { background: var(--bg-sunken); border: 1px solid var(--line-soft); border-radius: 5px; padding: 1.5px 7px; font-size: 12.5px; }

/* ═══════════════════════════════════════════════════
   阅读器（布局不变，只统一新字体变量）
   ═══════════════════════════════════════════════════ */

#reader { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
#reader.comic-mode { background: var(--comic-bg, #000); }

.reader-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: calc(9px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 9px max(16px, env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
  transition: transform .25s var(--ease), opacity .18s var(--ease);
  will-change: transform;
}
#reader.comic-mode .reader-top {
  background: var(--comic-bg, #000);
  border-bottom-color: rgba(255, 255, 255, .07);
  color: rgba(225, 220, 210, .9);
}
#reader.comic-mode .reader-top .icon-btn { color: rgba(190, 185, 175, .8); }
#reader.comic-mode .reader-top .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
#reader.comic-mode .rt-book { color: rgba(235, 230, 220, .95); }
#reader.comic-mode .rt-chapter { color: rgba(170, 165, 155, .8); }

.reader-bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 7px max(18px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: var(--bg);
  border-top: 1px solid var(--line-soft);
  font-size: 12px; color: var(--ink-2);
  transition: transform .25s var(--ease), opacity .18s var(--ease);
  will-change: transform;
}
#reader.comic-mode .reader-bottom {
  background: var(--comic-bg, #000);
  border-top-color: rgba(255, 255, 255, .07);
  color: rgba(170, 165, 155, .85);
}
#reader.chrome-hidden .reader-top { transform: translateY(-105%); opacity: 0; pointer-events: none; }
#reader.chrome-hidden .reader-bottom { transform: translateY(105%); opacity: 0; pointer-events: none; }

.reader-title { min-width: 0; text-align: center; max-width: min(60vw, 640px); }
.reader-top > .icon-btn { justify-self: start; }
.reader-top-actions { justify-self: end; display: flex; gap: 2px; }
.rt-book { font-family: var(--xiaowei); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: .06em; }
.rt-chapter { font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px; color: var(--ink-2);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn:active { transform: scale(.9); }
#reader.comments-open .reader-top { z-index: 60; }
.paragraph-comments-toggle[aria-pressed="true"] .ic-comments-enable,
.paragraph-comments-toggle[aria-pressed="false"] .ic-comments-disable { display: none; }
.paragraph-comments-toggle[aria-pressed="false"] {
  color: var(--accent);
  background: var(--accent-soft);
}
.ic-comic-set { display: none; }
#reader.comic-mode .ic-text-set { display: none; }
#reader.comic-mode .ic-comic-set { display: block; }

.rb-info { white-space: nowrap; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; max-width: 34%; }
.rb-nav { width: 34px; height: 34px; border-radius: 8px; position: relative; }
.rb-nav::before { content: ""; position: absolute; inset: -6px; }
#reader.comic-mode .rb-nav { color: rgba(190, 185, 175, .8); }
#reader.comic-mode .rb-nav:hover { background: rgba(255,255,255,.08); color: #fff; }
.rb-track { flex: 1; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 12%, transparent); cursor: pointer; position: relative; touch-action: none; }
/* 触屏设备常显滑块 */
@media (pointer: coarse) {
  .rb-thumb { transform: translate(-50%, -50%) scale(1); }
}
#reader.comic-mode .rb-track { background: rgba(255, 255, 255, .12); }
.rb-track::before { content: ""; position: absolute; inset: -10px 0; }
.rb-fill { height: 100%; width: 100%; border-radius: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; }
.rb-thumb {
  position: absolute; top: 50%; left: 0; width: 13px; height: 13px;
  border-radius: 50%; background: var(--accent);
  transform: translate(-50%, -50%) scale(0);
  transition: transform .2s var(--spring);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.rb-track:hover .rb-thumb, .rb-track.dragging .rb-thumb { transform: translate(-50%, -50%) scale(1); }
.rb-pct { min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

.reader-scroll {
  position: relative;
  flex: 1; overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

/* ── 小说正文 ── */
.novel-body {
  --fs: 19px; --lh: 2.0; --ls: 0.04em; --ps: 1.0em; --pw: 700px; --indent: 2em;
  font-family: var(--song);
  font-size: var(--fs); line-height: var(--lh);
  letter-spacing: var(--ls);
  max-width: calc(var(--pw) + 64px);
  margin: 0 auto;
  padding: calc(96px + env(safe-area-inset-top)) 32px 60px;
  color: var(--ink);
  word-break: break-word;
  text-align: justify;
}
.novel-body[data-font="wenkai"] { font-family: var(--wenkai); }
.novel-body[data-font="song"] { font-family: var(--song); }
.novel-body[data-font="hei"] { font-family: var(--hei); }
.novel-body[data-font="xiaowei"] { font-family: var(--xiaowei); }
.novel-body[data-font="longcang"] { font-family: var(--longcang); }
.novel-body[data-justify="off"] { text-align: initial; }
.novel-body h2.ch-title {
  font-family: var(--xiaowei);
  font-size: 1.45em; font-weight: 400; text-align: center;
  margin: 1.4em 0 2.4em; letter-spacing: .1em;
  line-height: 1.65; text-indent: 0;
}
.novel-body h2.ch-title::after {
  content: ""; display: block; width: 2.2em; height: 3px;
  background: var(--accent); margin: .55em auto 0; border-radius: 2px; opacity: .8;
}
.novel-body p { margin: 0 0 var(--ps); text-indent: var(--indent); }
.paragraph-comments-layer {
  position: absolute; top: 0; left: 0; z-index: 4;
  width: 100%; height: 0; pointer-events: none;
}
.paragraph-comments {
  position: absolute; pointer-events: auto;
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 26px; padding: 3px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
  border: 1px solid var(--line-soft);
  font-family: var(--hei); font-size: 11px; line-height: 1;
  font-variant-numeric: tabular-nums; text-indent: 0;
  box-shadow: var(--shadow-sm);
  transition: transform .16s var(--ease), background-color .16s var(--ease), border-color .16s var(--ease);
}
.paragraph-comments:hover { transform: translateY(-1px); border-color: var(--accent); }
.paragraph-comments:active { transform: scale(.96); }
.novel-body[data-indent="off"] p { text-indent: 0; }
.novel-body img { max-width: 100%; height: auto; display: block; margin: 1.4em auto; border-radius: 6px; }
.novel-body svg { max-width: 100%; height: auto; }
.novel-body h1, .novel-body h3, .novel-body h4 { line-height: 1.65; margin: 1.5em 0 1em; text-indent: 0; }
.novel-body a { color: var(--accent); text-underline-offset: 3px; }
.novel-body blockquote { border-left: 3px solid var(--accent); padding-left: 1em; margin: 1.2em 0; color: var(--ink-2); }
.novel-body hr { border: 0; text-align: center; margin: 2.4em 0; }
.novel-body hr::after { content: "❧"; color: var(--ink-3); font-size: 1.1em; }
.novel-body table { border-collapse: collapse; max-width: 100%; margin: 1em auto; }
.novel-body td, .novel-body th { border: 1px solid var(--line); padding: .4em .8em; }
.novel-body .ch-end {
  text-align: center; text-indent: 0; color: var(--ink-3);
  margin: 3.5em 0 1em; font-size: .85em; letter-spacing: .5em;
  user-select: none;
}

/* ── 漫画 ── */
.comic-body {
  --cw: 85; --cgap: 0px;
  min-height: 100vh;
  padding: calc(54px + env(safe-area-inset-top)) 0 30px;
  display: flex; flex-direction: column; align-items: center;
  gap: var(--cgap);
}
.comic-page {
  width: min(calc(var(--cw) * 1%), 100%);
  position: relative;
  min-height: 180px;
}
.comic-page img { width: 100%; height: auto; display: block; }
.comic-page .ph {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center;
  color: rgba(150, 148, 143, .55); font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  background: rgba(128, 128, 128, .06);
}
.ph-spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(150, 148, 143, .25);
  border-top-color: rgba(150, 148, 143, .7);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.comic-ch-divider {
  width: 100%; text-align: center; padding: 38px 20px 30px;
  color: rgba(168, 163, 153, .7); font-size: 13px; letter-spacing: .3em;
  font-family: var(--xiaowei);
  display: flex; align-items: center; justify-content: center; gap: 18px;
}
.comic-ch-divider::before, .comic-ch-divider::after {
  content: ""; width: 60px; height: 1px; background: currentColor; opacity: .35;
}
.comic-ch-divider b { color: rgba(205, 200, 190, .95); font-weight: 600; }
#reader.comic-light .comic-ch-divider { color: rgba(110, 100, 85, .7); }
#reader.comic-light .comic-ch-divider b { color: rgba(70, 62, 50, .95); }
#reader.comic-light .comic-page .ph { color: rgba(120, 112, 98, .6); background: rgba(90, 80, 60, .05); }

.chapter-nav {
  display: flex; justify-content: center; gap: 14px;
  padding: 16px 20px 120px;
  max-width: 720px; margin: 0 auto;
}
.chapter-nav button {
  padding: 12px 34px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-raise); color: var(--ink-2);
  font-size: 14.5px; transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
  box-shadow: var(--shadow-sm);
}
.chapter-nav button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.chapter-nav button:disabled { opacity: .3; cursor: default; }
#reader.comic-mode .chapter-nav button { background: rgba(128,128,128,.13); border-color: rgba(128,128,128,.28); color: rgba(200,195,185,.9); }
#reader.comic-mode.comic-light .chapter-nav button { background: rgba(255,255,255,.6); border-color: rgba(90,80,60,.25); color: rgba(90,80,62,.9); }

/* ═══ 目录抽屉 ═══ */
.toc-drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
  width: min(360px, 84vw);
  background: var(--bg-raise);
  border-right: 1px solid var(--line-soft);
  box-shadow: var(--shadow-lg);
  transform: translateX(-103%);
  transition: transform .24s cubic-bezier(.22, .61, .36, 1);
  will-change: transform;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.toc-drawer.open { transform: translateX(0); transition-duration: .3s; }
.toc-head {
  padding: 20px 18px 14px 16px;
  display: flex; align-items: center; gap: 10px;
}
.toc-title { font-family: var(--xiaowei); font-size: 19px; letter-spacing: .25em; }
.toc-count { font-size: 12px; color: var(--ink-3); flex: 1; }
.toc-filter {
  margin: 0 16px 10px; display: flex; align-items: center; gap: 8px;
  background: var(--bg-sunken); border-radius: 9px; padding: 8px 12px;
  color: var(--ink-3);
}
.toc-filter input { border: 0; outline: 0; background: none; width: 100%; font-size: 13.5px; color: var(--ink); }
@media (pointer: coarse) { .toc-filter input, .src-filter input { font-size: 16px; } }
.toc-list { flex: 1; overflow-y: auto; padding: 4px 16px 30px; }
.toc-item {
  content-visibility: auto; contain-intrinsic-size: auto 42px;
  display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left;
  padding: 10px 13px; border-radius: 9px;
  font-size: 13.5px; color: var(--ink-2); line-height: 1.5;
  transition: background .15s, color .15s;
}
.toc-item .ti-no { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 26px; text-align: right; flex-shrink: 0; }
.toc-item .ti-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-item .ti-pages { font-size: 11px; color: var(--ink-3); flex-shrink: 0; }
.toc-item:hover { background: var(--accent-soft); color: var(--ink); }
.toc-item.current { color: var(--accent-ink); font-weight: 600; background: var(--accent-soft); }
.toc-item.current .ti-no { color: var(--accent); }

/* ═══ 设置面板 ═══ */
.settings-panel {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 50;
  width: min(360px, 84vw);
  background: var(--bg-raise);
  border-left: 1px solid var(--line-soft);
  box-shadow: var(--shadow-lg);
  transform: translateX(103%);
  transition: transform .24s cubic-bezier(.22, .61, .36, 1);
  will-change: transform;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: calc(24px + env(safe-area-inset-top)) 24px 44px;
}
.settings-panel.open { transform: translateX(0); transition-duration: .3s; }
.sp-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.sp-head > span { font-family: var(--xiaowei); font-size: 18px; letter-spacing: .18em; }
.sp-head-actions { display: flex; align-items: center; gap: 6px; }
.sp-reset {
  font-size: 12px; color: var(--ink-2); padding: 5px 12px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--ink-3) 45%, transparent); transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.sp-reset:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.panel-close { width: 32px; height: 32px; border-radius: 9px; }
.sp-section { margin-bottom: 24px; }
.sp-section[hidden] { display: none; }
.sp-label {
  font-size: 12px; letter-spacing: .14em; color: var(--ink-2); font-weight: 600;
  margin-bottom: 11px; display: flex; justify-content: space-between; align-items: baseline;
}
.sp-label output { color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: 0; font-size: 12.5px; }

.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-chip {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 10px 6px 9px; border-radius: 12px;
  border: 1.5px solid var(--line-soft);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.theme-chip:hover { border-color: var(--line); transform: translateY(-1px); }
.theme-chip.active { border-color: var(--accent); background: var(--accent-soft); }
.tc-swatch {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--xiaowei); font-size: 17px;
  box-shadow: inset 0 0 0 1px rgba(120, 100, 70, .22), var(--shadow-sm);
}
.tc-name { font-size: 11.5px; color: var(--ink-2); }
.theme-chip.active .tc-name { color: var(--accent-ink); font-weight: 600; }

.font-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.font-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 13px 6px 11px; border-radius: 12px;
  border: 1.5px solid var(--line-soft);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.font-card:hover { border-color: var(--line); transform: translateY(-1px); }
.font-card.active { border-color: var(--accent); background: var(--accent-soft); }
.fc-glyph { font-size: 26px; line-height: 1.2; color: var(--ink); }
.fc-name { font-size: 11px; color: var(--ink-2); }
.font-card.active .fc-name { color: var(--accent-ink); font-weight: 600; }

.seg { display: flex; background: var(--bg-sunken); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1; padding: 8px 4px; border-radius: 8px; font-size: 13px; color: var(--ink-2);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.seg button.active { background: var(--bg-raise); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }
[data-theme="dark"] .seg button.active, [data-theme="black"] .seg button.active {
  background: rgba(255, 255, 255, .14);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}

/* 滑杆：iOS 风格 */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 28px; background: none; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 50%), var(--bg-sunken) var(--fill, 50%));
  box-shadow: inset 0 0.5px 1.5px rgba(0, 0, 0, .06);
}
[data-theme="dark"] input[type="range"]::-webkit-slider-runnable-track,
[data-theme="black"] input[type="range"]::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, var(--accent) var(--fill, 50%), rgba(255, 255, 255, .16) var(--fill, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%; margin-top: -8px;
  background: #fff;
  box-shadow: 0 .5px 2px rgba(0, 0, 0, .18), 0 3px 8px rgba(0, 0, 0, .16), inset 0 0 0 .5px rgba(0, 0, 0, .04);
  transition: transform .18s var(--spring), box-shadow .18s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.08); }
input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.16);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .22), 0 5px 14px rgba(0, 0, 0, .2), inset 0 0 0 .5px rgba(0, 0, 0, .04);
}
[data-theme="dark"] input[type="range"]::-webkit-slider-thumb,
[data-theme="black"] input[type="range"]::-webkit-slider-thumb {
  background: #e8e4dc;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 10px rgba(0, 0, 0, .45);
}
input[type="range"]::-moz-range-track {
  height: 6px; border-radius: 3px; background: var(--bg-sunken);
  box-shadow: inset 0 0.5px 1.5px rgba(0, 0, 0, .06);
}
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: #fff;
  box-shadow: 0 .5px 2px rgba(0, 0, 0, .18), 0 3px 8px rgba(0, 0, 0, .16);
}

.sp-switches { display: flex; flex-direction: column; gap: 4px; }
.switch-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 2px; font-size: 13.5px; color: var(--ink); cursor: pointer;
}
.switch {
  width: 42px; height: 24px; border-radius: 999px;
  background: var(--bg-sunken); position: relative;
  transition: background .25s var(--ease);
  border: 1px solid var(--line-soft);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-raise); box-shadow: var(--shadow-sm);
  transition: transform .25s var(--spring);
}
.switch.on { background: var(--accent); border-color: transparent; }
.switch.on::after { transform: translateX(18px); background: #fff; }

.sp-keys { border-top: 1px solid var(--line-soft); padding-top: 20px; margin-top: 4px; }
.key-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 6px; font-size: 12px; color: var(--ink-2); }
.key-grid kbd { margin-right: 3px; }

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(12, 9, 4, .38);
  opacity: 0; pointer-events: none;
  transition: opacity .25s cubic-bezier(.22, .61, .36, 1);
}
.scrim.show { opacity: 1; pointer-events: auto; }

/* ═══ 登录页 ═══ */
#authView {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(90% 70% at 75% -10%, var(--accent-soft) 0%, transparent 60%),
    var(--bg);
  overflow-y: auto; padding: 30px 16px;
}
.auth-wrap { width: min(400px, 94vw); }
.auth-card {
  background: var(--bg-raise);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 38px 36px 34px;
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.auth-brand .seal { width: 52px; height: 52px; font-size: 30px; border-radius: 14px; }
.auth-title { font-family: var(--brush); font-size: 32px; letter-spacing: .16em; line-height: 1.1; }
.auth-sub { font-size: 11px; letter-spacing: .42em; color: var(--ink-3); margin-top: 3px; }
.auth-greet { font-size: 13px; color: var(--ink-2); margin: 14px 0 24px; line-height: 1.8; min-height: 1.5em; }
.auth-setup-hint {
  font-size: 12.5px; color: var(--accent-ink); background: var(--accent-soft);
  border-radius: 10px; padding: 9px 14px; margin-bottom: 18px;
  letter-spacing: .05em;
}
.auth-field { display: block; margin-bottom: 16px; }
.auth-field[hidden], .auth-setup-hint[hidden], .auth-err[hidden] { display: none; }
.auth-field span { display: block; font-size: 12px; letter-spacing: .12em; color: var(--ink-2); margin-bottom: 7px; }
.auth-field input {
  width: 100%; padding: 12px 15px; border-radius: 12px;
  background: var(--bg); border: 1.5px solid var(--line);
  font-size: 16px; outline: none; color: var(--ink);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.auth-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--bg-raise); }
.auth-err {
  font-size: 12.5px; color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 10px; padding: 9px 14px; margin-bottom: 14px; line-height: 1.7;
}
.auth-submit {
  width: 100%; padding: 13px; border-radius: 999px;
  background: var(--accent); color: #f8f3ea; font-size: 15px; letter-spacing: .2em;
  box-shadow: var(--shadow-sm);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
  margin-top: 6px;
}
.auth-submit:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.auth-submit:active { transform: none; }
.auth-submit:disabled { opacity: .6; pointer-events: none; }
.auth-foot { text-align: center; font-size: 12px; color: var(--ink-3); letter-spacing: .3em; text-indent: .3em; margin-top: 22px; font-family: var(--xiaowei); }

/* ═══ 侧栏用户徽章 ═══ */
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 11px;
  background: var(--bg-raise); border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-sm);
}
.uc-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #f8f3ea;
  font-family: var(--xiaowei); font-size: 14px;
}
.uc-name { font-size: 13px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uc-role { font-size: 10px; letter-spacing: .08em; color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); border-radius: 999px; padding: 1px 7px; flex-shrink: 0; }
.uc-logout { width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--ink-3); transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease); flex-shrink: 0; }
.uc-logout:hover { background: var(--accent-soft); color: var(--accent); }

/* 用户管理 */
.user-add-form { display: flex; gap: 10px; flex-wrap: wrap; }
.user-add-form input, .user-add-form select {
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 13px; font-size: 14px; outline: none; color: var(--ink);
}
.user-add-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.user-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-raise); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 12px 16px;
  max-width: 920px;
}
.user-row .ur-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-sunken); color: var(--ink-2);
  font-family: var(--xiaowei); font-size: 16px;
}
.user-row.is-admin .ur-avatar { background: var(--accent); color: #f8f3ea; }
.user-row .ur-name { font-weight: 600; font-size: 14px; }
.user-row .ur-meta { flex: 1; font-size: 12px; color: var(--ink-3); }
.user-row .ur-self { font-size: 10.5px; color: var(--gold); }
.src-list { display: flex; flex-direction: column; gap: 10px; }

/* ═══ 侧栏分隔与书源入口 ═══ */
.side-sep { height: 1px; background: var(--line-soft); margin: 14px 8px; }

/* ═══ 网络搜索结果 ═══ */
.net-status { font-size: 13px; color: var(--ink-2); margin-bottom: 14px; line-height: 1.8; }
.net-status .err { color: var(--accent); }
.net-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.net-card {
  display: flex; gap: 14px; text-align: left;
  background: var(--bg-raise); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow-sm);
  transition: transform .22s var(--ease);
}
.net-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.net-card .nc-cover { width: 56px; aspect-ratio: 5/7; border-radius: 6px; object-fit: cover; background: var(--bg-sunken); flex-shrink: 0; box-shadow: var(--cover-shadow); }
.net-card .nc-meta { min-width: 0; flex: 1; }
.net-card .nc-name { font-weight: 600; font-size: 15px; }
.net-card .nc-line { font-size: 12px; color: var(--ink-2); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.net-card .nc-intro { font-size: 12px; color: var(--ink-3); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.6; }
.net-card .nc-src { font-size: 11px; color: var(--gold); margin-top: 6px; }
.net-card .nc-add {
  align-self: center; flex-shrink: 0;
  padding: 8px 16px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--accent); color: var(--accent);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.net-card .nc-add:hover { background: var(--accent); color: #f8f3ea; }
.net-card .nc-add:disabled { opacity: .5; pointer-events: none; }

/* ═══ 管理后台 ═══ */
#sourcesView { position: fixed; inset: 0; background: var(--bg); overflow: hidden; }
.admin-shell { display: flex; height: 100%; }
.admin-side {
  width: var(--side-w); flex-shrink: 0;
  background: var(--bg-deep); border-right: 1px solid var(--line-soft);
  padding: calc(18px + env(safe-area-inset-top)) 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.admin-back {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 10px; font-size: 13px; color: var(--ink-2);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
  margin-bottom: 10px;
}
.admin-back:hover { background: var(--accent-soft); color: var(--accent); }
.admin-brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 18px; }
.admin-brand .seal { width: 38px; height: 38px; font-size: 21px; border-radius: 10px; }
.ab-title { font-family: var(--xiaowei); font-size: 17px; letter-spacing: .1em; }
.ab-sub { font-size: 10px; color: var(--ink-3); letter-spacing: .14em; margin-top: 2px; }
.admin-nav {
  display: flex; flex-direction: column; gap: 4px;
  position: relative; isolation: isolate;
  --indicator-x: 0px; --indicator-y: 0px;
  --indicator-w: 100%; --indicator-h: 42px;
}
.admin-nav::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  left: 0; top: 0;
  width: var(--indicator-w); height: var(--indicator-h);
  border-radius: 11px;
  background: var(--bg-raise); box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translate3d(var(--indicator-x), var(--indicator-y), 0);
}
.admin-nav.indicator-ready::before {
  opacity: 1;
  transition: transform .26s var(--spring), width .26s var(--spring), height .26s var(--spring), opacity .12s var(--ease);
}
.admin-nav button {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; border-radius: 11px; font-size: 14px; color: var(--ink-2);
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease); text-align: left;
}
.admin-nav button svg { opacity: .7; }
.admin-nav button:hover { background: var(--accent-soft); color: var(--ink); }
.admin-nav button:active { transform: scale(.97); }
.admin-nav button.active { background: transparent; color: var(--ink); font-weight: 600; box-shadow: none; }
.admin-nav button.active svg { color: var(--accent); opacity: 1; }
.admin-main {
  flex: 1; min-width: 0; overflow-y: auto;
  padding: calc(28px + env(safe-area-inset-top)) clamp(22px, 3vw, 48px) 60px;
}
.admin-h { font-family: var(--xiaowei); font-size: 24px; letter-spacing: .1em; margin-bottom: 22px; }
.admin-h3 { font-size: 13px; letter-spacing: .16em; color: var(--ink-2); font-weight: 600; margin: 30px 0 14px; }
.admin-h-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.admin-h-row .admin-h { margin-bottom: 0; }
.admin-h-actions { display: flex; gap: 8px; }
.admin-desc { font-size: 13px; color: var(--ink-2); line-height: 1.8; margin: -8px 0 18px; max-width: 58ch; text-wrap: pretty; }
.btn-primary.sm, .btn-ghost.sm { padding: 8px 18px; font-size: 13px; }

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--bg-raise); border: 1px solid var(--line-soft); border-radius: 14px;
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat-card .sc-num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.stat-card .sc-num em { font-style: normal; font-size: 13px; color: var(--ink-3); font-weight: 400; margin-left: 3px; }
.stat-card .sc-label { font-size: 12px; color: var(--ink-2); margin-top: 5px; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-card.accent .sc-num { color: var(--accent); }

.admin-reading { display: flex; flex-direction: column; gap: 8px; }
.ar-item {
  display: flex; align-items: baseline; gap: 12px;
  background: var(--bg-raise); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 10px 14px; font-size: 13px;
}
.ar-item .ar-title { font-weight: 600; }
.ar-item .ar-ch { color: var(--ink-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-item .ar-time { color: var(--ink-3); font-size: 12px; flex-shrink: 0; }

.admin-log { font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--ink-2); line-height: 2; max-height: 300px; overflow-y: auto; background: var(--bg-raise); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px 16px; }
.admin-log .al-t { color: var(--ink-3); margin-right: 10px; }
.admin-log .al-m { color: var(--gold); margin-right: 8px; }

/* 下载页 */
.dl-books { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.dl-book {
  display: flex; align-items: center; gap: 13px;
  background: var(--bg-raise); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 13px 15px;
}
.dl-book .db-meta { flex: 1; min-width: 0; }
.dl-book .db-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-book .db-sub { font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.dl-book .db-actions { display: flex; gap: 6px; flex-shrink: 0; }
.dl-empty {
  grid-column: 1 / -1;
  color: var(--ink-2); font-size: 13.5px; padding: 44px 20px; text-align: center;
  border: 1.5px dashed var(--line); border-radius: var(--radius); line-height: 2.1;
}
.dl-tasks { display: flex; flex-direction: column; gap: 10px; }
.dl-task {
  background: var(--bg-raise); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 13px 16px;
}
.dl-task .dt-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.dl-task .dt-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-task .dt-state { font-size: 12px; color: var(--ink-2); flex-shrink: 0; }
.dl-task .dt-state.ok { color: #3a7d44; }
.dl-task .dt-state.bad { color: var(--accent); }
.dl-task .dt-bar { margin-top: 9px; height: 5px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden; }
.dl-task .dt-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s var(--ease); }

/* 数据页 */
.data-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.data-card {
  background: var(--bg-raise); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.data-card .dc-title { font-weight: 600; font-size: 14px; }
.data-card .dc-desc { font-size: 12px; color: var(--ink-2); margin: 6px 0 12px; line-height: 1.7; }
.pass-row { display: flex; gap: 10px; max-width: 560px; }
.pass-row input {
  flex: 1; min-width: 0;
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px; font-size: 14px; outline: none;
}
.pass-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-primary, .btn-ghost { white-space: nowrap; flex-shrink: 0; }

.src-import { margin-bottom: 18px; }

/* 文件拖拽导入 */
.src-drop {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 26px 20px;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  color: var(--ink-3);
  cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
  text-align: center;
  background: var(--bg-raise);
}
.src-drop:hover, .src-drop.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.src-drop .sd-main { font-size: 13.5px; color: var(--ink-2); }
.src-drop .sd-main b { color: var(--accent); font-weight: 600; }
.src-drop .sd-sub { font-size: 11.5px; color: var(--ink-3); }
.src-drop.dragover .sd-main, .src-drop.dragover .sd-sub { color: var(--accent-ink); }
.lib-drop { min-height: 190px; justify-content: center; }
.lib-upload-actions {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 12px;
}
.lib-upload-summary { flex: 1; min-width: 0; color: var(--ink-2); font-size: 13px; }
.lib-upload-list { display: flex; flex-direction: column; gap: 9px; }
.lib-upload-item {
  background: var(--bg-raise); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-sm);
}
.lib-upload-item.done { border-color: color-mix(in srgb, #4c9960 38%, var(--line-soft)); }
.lib-upload-item.error { border-color: color-mix(in srgb, var(--accent) 42%, var(--line-soft)); }
.lu-main { display: flex; align-items: baseline; gap: 10px; min-width: 0; font-size: 13px; }
.lu-name {
  min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink); font-weight: 600;
}
.lu-size { flex-shrink: 0; color: var(--ink-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.lu-state {
  flex-shrink: 0; max-width: min(46%, 430px);
  color: var(--ink-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lu-state.active { color: var(--gold); font-variant-numeric: tabular-nums; }
.lu-state.ok { color: #3a7d44; }
.lu-state.bad { color: var(--accent); }
[data-theme="dark"] .lu-state.ok, [data-theme="black"] .lu-state.ok { color: #7dc492; }
.lu-bar {
  height: 4px; margin-top: 9px; overflow: hidden;
  border-radius: 999px; background: var(--bg-sunken);
}
.lu-bar i {
  display: block; height: 100%; border-radius: inherit; background: var(--gold);
  transition: width .16s linear;
}
.lib-upload-item.done .lu-bar i { background: #4c9960; }
.lib-upload-item.error .lu-bar i { background: var(--accent); }
.src-or {
  display: flex; align-items: center; gap: 14px;
  margin: 14px 0 10px; color: var(--ink-3); font-size: 11.5px; letter-spacing: .1em;
}
.src-or::before, .src-or::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }

.src-import textarea {
  width: 100%; min-height: 150px; resize: vertical;
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; font-size: 12.5px; font-family: ui-monospace, monospace;
  color: var(--ink); outline: none; line-height: 1.7;
}
.src-import textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.src-import textarea::placeholder { color: var(--ink-3); opacity: 1; font-family: var(--ui); }
.src-import-actions { display: flex; gap: 10px; margin-top: 12px; }
.btn-primary {
  padding: 10px 26px; border-radius: 999px; background: var(--accent); color: #f8f3ea;
  font-size: 14px; box-shadow: var(--shadow-sm); transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.btn-primary:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-ghost {
  padding: 10px 22px; border-radius: 999px; font-size: 14px;
  border: 1px solid var(--line); color: var(--ink-2); transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
/* 书源工具行 */
.src-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.src-summary { font-size: 13px; color: var(--ink-2); }
.src-summary b { color: var(--ink); font-variant-numeric: tabular-nums; }
.src-filter {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-raise); border: 1px solid var(--line-soft);
  border-radius: 999px; padding: 7px 14px; color: var(--ink-3);
  min-width: 220px;
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.src-filter:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.src-filter input { border: 0; outline: 0; background: none; width: 100%; font-size: 13.5px; color: var(--ink); }

/* 书源卡片网格 */
.src-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.src-card {
  position: relative;
  background: var(--bg-raise); border: 1px solid var(--line-soft); border-radius: 14px;
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s, border-color .25s, opacity .25s;
  display: flex; flex-direction: column; gap: 10px;
}
.src-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line); }
.src-card.disabled { opacity: .55; }
.src-card.disabled:hover { opacity: .8; }
/* 左侧状态色条 */
.src-card::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--line);
  transition: background .25s;
}
.src-card.enabled::before { background: #4c9960; }
.src-card.testing::before { background: var(--gold); }
.src-card.test-bad::before { background: var(--accent); }

.src-card .sc-top { display: flex; align-items: flex-start; gap: 12px; }
.src-card .sc-favicon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-sunken);
  font-family: var(--xiaowei); font-size: 17px; color: var(--ink-2);
  overflow: hidden;
}
.src-card .sc-favicon img { width: 20px; height: 20px; object-fit: contain; }
.src-card .sc-title-box { flex: 1; min-width: 0; }
.src-card .sc-name {
  font-weight: 600; font-size: 15px;
  display: flex; align-items: center; gap: 8px;
  overflow: hidden;
}
.src-card .sc-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-card .sc-group {
  flex-shrink: 0; font-size: 10.5px; font-weight: 400; letter-spacing: .06em;
  color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  border-radius: 999px; padding: 1.5px 8px;
}
.src-card .sc-url { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; font-family: ui-monospace, monospace; }
/* 启用开关复用 .switch */
.src-card .sc-switch { flex-shrink: 0; margin-top: 2px; }

.src-card .sc-caps { display: flex; gap: 6px; flex-wrap: wrap; }
.src-card .sc-cap {
  font-size: 10.5px; letter-spacing: .05em; padding: 2.5px 9px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--ink-2);
}
.src-card .sc-cap.warn { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-ink); }

.src-card .sc-test {
  font-size: 12px; line-height: 1.7; color: var(--ink-2);
  background: var(--bg-sunken); border-radius: 9px; padding: 8px 11px;
  display: flex; align-items: flex-start; gap: 7px;
}
.src-card .sc-test[hidden] { display: none; }
.src-card .sc-test.ok { background: rgba(76, 153, 96, .1); color: #35714a; }
[data-theme="dark"] .src-card .sc-test.ok, [data-theme="black"] .src-card .sc-test.ok { color: #7dc492; }
.src-card .sc-test.bad { background: color-mix(in srgb, var(--accent) 9%, transparent); color: var(--accent-ink); }
.src-card .sc-health {
  display: flex; align-items: flex-start; gap: 7px;
  padding: 8px 11px; border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  color: var(--accent-ink); font-size: 12px; line-height: 1.7;
}
.src-card .sc-health > :first-child { flex-shrink: 0; font-weight: 700; }
.sc-spin {
  width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
  border: 2px solid var(--line); border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}

.src-card .sc-foot {
  display: flex; align-items: center; gap: 4px;
  border-top: 1px solid var(--line-soft); padding-top: 10px; margin-top: auto;
}
.src-card .sc-act {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 9px; font-size: 13px; color: var(--ink-2);
  transition: background-color .18s, color .18s;
}
.src-card .sc-act:hover { background: var(--accent-soft); color: var(--accent); }
.src-card .sc-act.danger:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-ink); }
.src-card .sc-act svg { opacity: .8; }

.src-empty {
  grid-column: 1 / -1;
  color: var(--ink-2); font-size: 13.5px; padding: 60px 20px; text-align: center;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  line-height: 2.1;
}
.src-empty b { color: var(--ink); }

/* 次级小按钮：统一形制（等同 .btn-ghost.sm 的縮小版胶囊） */
.si-btn {
  padding: 7px 15px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--line); color: var(--ink-2); transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
  white-space: nowrap; flex-shrink: 0;
}
.si-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.si-btn.danger { color: var(--accent-ink); }
.si-btn.danger:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* ═══ 书内搜索/书签抽屉 ═══ */
.find-drawer {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 50;
  width: min(380px, 88vw);
  background: var(--bg-raise);
  border-left: 1px solid var(--line-soft);
  box-shadow: var(--shadow-lg);
  transform: translateX(103%);
  transition: transform .24s cubic-bezier(.22, .61, .36, 1);
  will-change: transform;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.find-drawer.open { transform: translateX(0); transition-duration: .3s; }
.find-tabs { display: flex; gap: 2px; background: var(--bg-sunken); border-radius: 10px; padding: 3px; margin: 0 16px 12px; }
.find-tabs button { flex: 1; padding: 7px; border-radius: 8px; font-size: 13px; color: var(--ink-2); transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease); }
.find-tabs button.active { background: var(--bg-raise); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.find-hit {
  display: block; width: 100%; text-align: left;
  padding: 11px 13px; border-radius: 9px;
  transition: background .15s;
}
.find-hit:hover { background: var(--accent-soft); }
.find-hit .fh-ch { font-size: 11.5px; color: var(--accent); margin-bottom: 4px; }
.find-hit .fh-text { font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.find-hit .fh-text mark { background: var(--sel); color: var(--ink); border-radius: 2px; padding: 0 1px; }
.find-hit .fh-del { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.find-hit .fh-del:hover { color: var(--accent); }
.find-note { padding: 14px; font-size: 12.5px; color: var(--ink-3); text-align: center; }

/* ═══ 番茄段落章说 ═══ */
.comments-panel {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 50;
  width: min(420px, 92vw);
  background: var(--bg-raise);
  border-left: 1px solid var(--line-soft);
  box-shadow: var(--shadow-lg);
  transform: translateX(103%);
  transition: transform .24s cubic-bezier(.22, .61, .36, 1);
  will-change: transform;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  overscroll-behavior: contain;
}
.comments-panel.open { transform: translateX(0); transition-duration: .3s; }
.comments-head {
  min-height: 58px; padding: 10px 12px 8px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--line-soft); flex-shrink: 0;
}
.comments-heading { min-width: 0; display: flex; align-items: baseline; gap: 9px; }
.comments-title {
  color: var(--ink); font-family: var(--xiaowei); font-size: 18px;
  letter-spacing: .08em; white-space: nowrap;
}
.comments-meta { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.comments-excerpt {
  margin: 12px 16px 4px; padding: 10px 12px;
  border: 0; border-left: 3px solid var(--accent);
  border-radius: 0 9px 9px 0; background: var(--bg-sunken);
  color: var(--ink-2); font-size: 12px; line-height: 1.65;
  max-height: 86px; overflow: auto; flex-shrink: 0;
}
.comments-excerpt:empty { display: none; }
.comments-list {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 8px 14px 14px; overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.comment-card {
  display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px;
  padding: 14px 4px; border-bottom: 1px solid var(--line-soft);
}
.comment-avatar {
  position: relative; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  background: var(--accent-soft); color: var(--accent-ink);
  font-family: var(--xiaowei); font-size: 15px;
}
.comment-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.comment-main { min-width: 0; }
.comment-byline { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.comment-author {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink); font-size: 13px; font-weight: 600;
}
.comment-byline time { color: var(--ink-3); font-size: 10.5px; white-space: nowrap; }
.comment-text {
  margin-top: 6px; color: var(--ink-2); font-size: 13.5px; line-height: 1.72;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.comment-stats { display: flex; gap: 13px; margin-top: 7px; color: var(--ink-3); font-size: 11px; }
.comments-state {
  min-height: 150px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  padding: 26px 14px; color: var(--ink-3); font-size: 12.5px; text-align: center;
}
.comments-spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.comments-retry, .comments-more {
  min-height: 34px; padding: 7px 18px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--accent);
  background: var(--bg-raise); font-size: 12.5px;
}
.comments-retry:hover, .comments-more:hover { border-color: var(--accent); background: var(--accent-soft); }
.comments-more-wrap {
  flex-shrink: 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft); text-align: center;
}
.comments-more { min-width: 120px; }
.comments-more:disabled { opacity: .55; cursor: wait; }

/* ═══ TTS 朗读（融入底栏，不遮正文） ═══ */
.rb-mode { display: flex; align-items: center; gap: 10px; width: 100%; }
.rb-mode[hidden] { display: none; }
.rb-mode-tts { gap: 6px; }
.tts-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: .08em;
  padding: 4px 10px 4px 8px; border-radius: 999px;
  background: var(--accent-soft);
  flex-shrink: 0;
}
.tts-wave { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.tts-wave i { width: 2.5px; background: var(--accent); border-radius: 1px; animation: ttswave 1s ease-in-out infinite; }
.tts-wave i:nth-child(1) { height: 55%; animation-delay: 0s; }
.tts-wave i:nth-child(2) { height: 100%; animation-delay: .18s; }
.tts-wave i:nth-child(3) { height: 70%; animation-delay: .36s; }
@keyframes ttswave { 0%, 100% { transform: scaleY(.5); } 50% { transform: scaleY(1); } }
.rb-mode-tts.paused .tts-wave i { animation-play-state: paused; opacity: .45; }
.tts-pos { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tts-rate-wrap { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; }
.tts-rate-btn {
  width: 26px; height: 26px; border-radius: 8px; font-size: 14px; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .15s, color .15s;
}
.tts-rate-btn:hover { background: var(--accent-soft); color: var(--accent); }
.tts-rate-out { font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; min-width: 36px; text-align: center; font-weight: 600; }
.tts-voice {
  max-width: 130px; border: 1px solid var(--line-soft); border-radius: 8px;
  background: var(--bg-sunken); color: var(--ink-2); font-size: 12px; padding: 5px 7px;
  outline: none; flex-shrink: 0;
}
.tts-close { margin-left: 2px; }
/* 朗读句高亮：下划线式，比整段色块轻 */
.novel-body .tts-current {
  background: linear-gradient(transparent 78%, var(--sel) 78%);
  border-radius: 2px;
}
@media (max-width: 680px) {
  .tts-voice { display: none; }
  .tts-pos { display: none; }
}

.toast {
  position: fixed; left: 50%; bottom: 72px; z-index: 90;
  transform: translateX(-50%) translateY(16px) scale(.95);
  background: color-mix(in srgb, var(--ink) 93%, transparent);
  color: var(--bg); padding: 11px 24px; border-radius: 999px;
  font-size: 13.5px; opacity: 0; pointer-events: none;
  transition: opacity .32s var(--spring), transform .32s var(--spring);
  box-shadow: var(--shadow-md);
  max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

@keyframes shimmer { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.loading-hint {
  text-align: center; padding: 140px 20px; color: var(--ink-3);
  font-size: 13.5px; letter-spacing: .35em; text-indent: 0;
  opacity: 0;
  animation: fadeIn .2s var(--ease) .15s both, shimmer 1.5s .35s infinite;
}
.chapter-load-error {
  min-height: 360px; padding: 120px 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 22px; text-align: center; color: var(--ink-2);
}
.chapter-load-error-title { font-size: 15px; letter-spacing: .08em; }
.chapter-retry {
  padding: 9px 20px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink); background: var(--bg-raise);
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.chapter-retry:hover { border-color: var(--accent); background: var(--accent-soft); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
/* 筛选/搜索切换：只让本次新节点短淡入，不复用首次入场类，避免重播闪烁 */
.book-grid.swap .book-card { animation: swapIn .16s var(--ease) both; }
@keyframes swapIn { from { opacity: .42; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.book-grid.enter .book-card { animation: fadeUp .45s var(--ease) both; }
.book-grid.enter .book-card:nth-child(2) { animation-delay: .04s; } .book-grid.enter .book-card:nth-child(3) { animation-delay: .08s; }
.book-grid.enter .book-card:nth-child(4) { animation-delay: .12s; } .book-grid.enter .book-card:nth-child(5) { animation-delay: .16s; }
.book-grid.enter .book-card:nth-child(6) { animation-delay: .2s; } .book-grid.enter .book-card:nth-child(7) { animation-delay: .24s; }
.book-grid.enter .book-card:nth-child(n+8) { animation-delay: .27s; }
.continue-area.enter .hero-card { animation: fadeUp .45s var(--ease) both; }
.continue-area.enter .continue-card { animation: fadeUp .45s var(--ease) both; }
.continue-area.enter .continue-card:nth-child(2) { animation-delay: .06s; }
.continue-area.enter .continue-card:nth-child(3) { animation-delay: .12s; }
.novel-body.entering { animation: fadeIn .22s var(--ease) both; }
/* 视图切换 crossfade */
.view-in { animation: fadeIn .18s var(--ease); }
/* 主题切换瞬时应用，避免全页 400ms 补间风暴 */
.theme-snap *, .theme-snap *::before, .theme-snap *::after { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ═══ 中屏：继续阅读纵排改横排 ═══ */
@media (max-width: 1080px) {
  .continue-area { grid-template-columns: 1fr; }
  .continue-row { flex-direction: row; max-height: none; overflow-x: auto; overflow-y: hidden; padding: 4px 2px 12px; }
  .continue-card { min-width: 270px; flex-shrink: 0; }
}

/* ═══ 移动端 ═══ */
@media (max-width: 680px) {
  .admin-shell { flex-direction: column; }
  .admin-side {
    width: 100%; padding: calc(10px + env(safe-area-inset-top)) 12px 9px;
    border-right: 0; border-bottom: 1px solid var(--line-soft); gap: 6px;
  }
  .admin-back { margin: 0; padding: 7px 10px; }
  .admin-brand { display: none; }
  .admin-nav {
    flex-direction: row; overflow-x: auto; gap: 3px; scrollbar-width: none;
    padding-bottom: 2px;
  }
  .admin-nav::-webkit-scrollbar { display: none; }
  .admin-nav::before { display: none; }
  .admin-nav button {
    flex: 0 0 auto; white-space: nowrap; padding: 9px 12px; border-radius: 999px;
  }
  .admin-nav button.active { background: var(--bg-raise); box-shadow: var(--shadow-sm); }
  .admin-main { padding: 22px 16px calc(50px + env(safe-area-inset-bottom)); }
  .admin-h { font-size: 22px; margin-bottom: 17px; }
  .lib-drop { min-height: 160px; padding-inline: 14px; }
  .lib-upload-actions { flex-wrap: wrap; }
  .lib-upload-summary { flex-basis: 100%; }
  .lu-main { flex-wrap: wrap; }
  .lu-name { flex-basis: calc(100% - 78px); }
  .lu-state { order: 3; max-width: 100%; flex-basis: 100%; white-space: normal; }

  #shelf { flex-direction: column; }
  /* 两行头部：行1 = 品牌 + 主题切换 + 用户；行2 = 通栏可横滑导航 */
  .side {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center; flex-wrap: wrap;
    gap: 8px; row-gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    border-right: 0; border-bottom: 1px solid var(--line-soft);
  }
  .side-brand { padding: 0; margin-right: auto; order: 1; }
  .seal { width: 36px; height: 36px; font-size: 21px; border-radius: 10px; }
  .brand { font-size: 21px; }
  .brand-sub { display: none; }
  .side-foot { order: 2; margin: 0; flex-direction: row; align-items: center; gap: 4px; flex-shrink: 0; }
  .side-sep { display: none; }
  /* 全部导航合成一条可横滑胶囊栏，书源管理同排右侧 */
  .side-nav {
    order: 3; flex: 1 1 auto; min-width: 0;
    flex-direction: row; gap: 2px;
    background: var(--bg-sunken); border-radius: 999px; padding: 3px;
    overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-nav + .side-nav { order: 4; flex: 0 0 auto; background: var(--bg-sunken); }
  .side-nav .tab { padding: 9px 13px; border-radius: 999px; font-size: 13px; gap: 0; white-space: nowrap; flex-shrink: 0; min-height: 38px; }
  #filterTabs::before { border-radius: 999px; }
  .side-nav .tab svg { display: none; }
  .side-nav .tab em { display: none; }
  /* 书源管理入口保留图标、藏文字，占位更小 */
  .side-nav + .side-nav .tab { padding: 9px 12px; }
  .side-nav + .side-nav .tab svg { display: block; }
  .side-nav + .side-nav .tab span { display: none; }
  .side-lib { display: none; }
  .theme-flip { padding: 9px; }
  .tf-label { display: none; }
  /* 用户徽章折叠为头像 + 登出 */
  .user-chip { padding: 3px; gap: 5px; background: none; border: 0; box-shadow: none; }
  .uc-name, .uc-role { display: none; }
  .uc-avatar { width: 32px; height: 32px; }
  .uc-logout { width: 36px; height: 36px; }

  .shelf-main { padding: 16px 16px 80px; }
  .shelf-top { margin-bottom: 18px; }
  .greet { font-size: 24px; }
  .greet-sub { display: none; }
  .search-box { min-width: 0; width: 100%; padding: 8px 14px; }

  .continue-area { grid-template-columns: 1fr; gap: 14px; }
  .hero-card { padding: 16px; gap: 14px; border-radius: 16px; }
  .hero-cover { width: 88px; }
  .hero-title { font-size: 19px; }
  .hero-go { padding: 8px 14px; font-size: 12.5px; }
  .hero-card::before { font-size: 130px; bottom: -30px; }

  .book-grid { grid-template-columns: repeat(auto-fill, minmax(106px, 1fr)); gap: 22px 14px; }
  .book-title-line { font-size: 12.5px; }
  .cover-fallback .cf-title { font-size: 15px; }
  .novel-body { padding: calc(86px + env(safe-area-inset-top)) 24px 50px; }
  .comic-body { padding-top: calc(54px + env(safe-area-inset-top)); }
  .rb-info { display: none; }
  .rb-nav { width: 42px; height: 42px; }
  .icon-btn { width: 42px; height: 42px; }
  .toc-item { padding: 12px 13px; }
  .paragraph-comments { min-height: 28px; padding-inline: 8px; }
  .comments-panel {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; height: min(76svh, 620px); max-height: calc(100svh - 36px);
    padding-top: 0; padding-bottom: env(safe-area-inset-bottom);
    border-left: 0; border-top: 1px solid var(--line-soft);
    border-radius: 18px 18px 0 0;
    transform: translateY(103%);
  }
  .comments-panel.open { transform: translateY(0); }
  .comments-panel::before {
    content: ""; width: 38px; height: 4px; border-radius: 999px;
    background: var(--line); margin: 8px auto 0; flex-shrink: 0;
  }
  .comments-head { min-height: 50px; padding-top: 4px; }
  .comments-list { padding-inline: 12px; }
  .comments-more-wrap { padding-bottom: 10px; }
  .section-title { margin: 24px 0 15px; font-size: 17px; }
  .chapter-nav button { padding: 12px 28px; }
  /* 阅读器顶栏：左对齐标题，防右侧按钮群挤歪居中列 */
  .reader-top { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; }
  .reader-title { text-align: left; max-width: none; }
  .reader-top-actions { gap: 0; }
  /* 登录卡收窄内距 */
  .auth-card { padding: 32px 22px 28px; border-radius: 18px; }
}

@media print {
  .reader-top, .reader-bottom, .chapter-nav, .toc-drawer, .settings-panel,
  .find-drawer, .comments-panel, .paragraph-comments, .scrim, .side { display: none !important; }
}
