:root {
  --bg: #faf8f3;
  --fg: #2b2b2b;
  --muted: #888;
  --panel: #f0ece2;
  --accent: #7a5c3a;
  --hairline: #e5e0d2;
}
html[data-theme="dark"] {
  --bg: #16181d;
  --fg: #cfd2d8;
  --muted: #6a6f78;
  --panel: #20242c;
  --accent: #c29867;
  --hairline: #2a2e36;
}
html[data-theme="sepia"] {
  --bg: #f4ecd8;
  --fg: #4a3f2e;
  --muted: #8a7a5f;
  --panel: #e9dfc5;
  --accent: #8c5a2b;
  --hairline: #dccfb1;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", Georgia, serif;
  transition: background .2s, color .2s;
}

/* 顶栏 */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: 48px; display: flex; align-items: center; gap: 8px;
  padding: 0 12px; background: var(--bg); border-bottom: 1px solid var(--hairline);
}
.book-title { flex: 1; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  border: none; background: transparent; color: var(--fg); font-size: 16px;
  padding: 6px 10px; cursor: pointer; border-radius: 6px;
}
.icon-btn:hover { background: var(--panel); }

/* 目录抽屉 */
.toc {
  position: fixed; top: 0; bottom: 0; left: 0; width: 280px; z-index: 40;
  background: var(--bg); border-right: 1px solid var(--hairline);
  transform: translateX(-100%); transition: transform .2s; overflow-y: auto;
}
.toc.open { transform: translateX(0); }
.toc-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--hairline); }
.toc-head span { font-weight: 600; }
.toc ol { list-style: none; margin: 0; padding: 8px; }
.toc li { padding: 9px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; line-height: 1.4; }
.toc li:hover { background: var(--panel); }
.toc li.active { background: var(--panel); color: var(--accent); font-weight: 600; }
.mask { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.25); display: none; }
.mask.show { display: block; }

/* 正文 */
.reader {
  max-width: 38rem; margin: 0 auto; padding: 72px 20px 96px;
  font-size: var(--fs, 18px); line-height: var(--lh, 1.9);
}
.ch-title { font-size: 1.5em; margin: 0 0 1.2em; font-weight: 700; }
.ch-body p { margin: 0 0 1em; text-align: justify; text-indent: 2em; }
.ch-body p.quote {
  text-indent: 0; background: var(--panel); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 4px; font-size: .92em; margin: 1.2em 0; color: var(--fg);
}
.genre-badge { color: var(--muted); font-size: .9em; margin-bottom: 1em; }

/* 底部分页 */
.pager {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  height: 56px; display: flex; align-items: center; justify-content: center; gap: 16px;
  background: var(--bg); border-top: 1px solid var(--hairline);
}
.pg-btn { border: 1px solid var(--hairline); background: var(--bg); color: var(--fg);
  padding: 8px 18px; border-radius: 6px; cursor: pointer; }
.pg-btn:hover { background: var(--panel); }
.pg-btn:disabled { color: var(--muted); cursor: default; background: transparent; }
.pos { color: var(--muted); font-size: 13px; }

@media (max-width: 520px) {
  .reader { padding: 64px 16px 80px; }
  .ch-body p { text-indent: 1.5em; }
}