:root {
  --bg: #0d0d0f;
  --text: #d6d2c8;
  --gold: #c9a86a;
  --gold-soft: #d8b878;
  --line: #2b2620;
  --nav-bg: rgba(18, 18, 21, 0.96);
  --card: #161518;
  --muted: #8f8a80;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Serif SC", "Songti SC", "Source Han Serif SC", serif;
  line-height: 1.95;
  -webkit-text-size-adjust: 100%;
  padding-bottom: 110px;
}
.wrap { max-width: 700px; margin: 0 auto; padding: 0 20px; }

/* ===== 顶部 ===== */
header.site {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(13, 13, 15, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.site-inner {
  max-width: 700px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.book-name { color: var(--gold); font-weight: 700; font-size: 1.06em; letter-spacing: 0.04em; }
.now-title { display: block; color: var(--muted); font-size: 0.78em; margin-top: 2px; font-weight: 400; }
.head-actions { display: flex; gap: 8px; flex: none; }
.mini-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--gold-soft);
  font-family: inherit;
  font-size: 0.84em;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
}
.mini-btn:active { border-color: var(--gold); }
.mini-btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1610; font-weight: 700; }
.mini-btn[hidden] { display: none; }

/* ===== 章节 ===== */
h2.ch-title {
  color: var(--gold-soft);
  font-size: 1.3em;
  font-weight: 700;
  margin: 1.8em 0 1.3em;
  letter-spacing: 0.03em;
}
p { font-size: 1.03em; margin: 1.05em 0; text-align: justify; }
.placeholder { margin: 52px 0; text-align: center; color: var(--muted); }

/* ===== 评论 ===== */
.comments { margin: 3em 0 1em; border-top: 1px solid var(--line); padding-top: 1.4em; }
.cm-title { color: var(--gold); font-size: 1.02em; font-weight: 700; margin: 0 0 12px; }
.cm-count { color: var(--muted); font-weight: 400; font-size: 0.85em; }
.comment-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.comment-item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; }
.comment-meta { display: flex; justify-content: space-between; color: var(--gold-soft); font-size: 0.86em; margin-bottom: 4px; }
.comment-meta .time { color: var(--muted); }
.comment-body { font-size: 0.97em; line-height: 1.8; white-space: pre-wrap; word-break: break-word; text-align: left; }
.comment-empty { color: var(--muted); font-size: 0.92em; padding: 6px 0 14px; }
.comment-form { display: flex; flex-direction: column; gap: 10px; }
.cm-input, .cm-text {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.96em;
  padding: 10px 12px;
}
.cm-text { resize: vertical; line-height: 1.8; }
.cm-input:focus, .cm-text:focus { outline: none; border-color: var(--gold); }
.cm-send-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cm-hint { color: var(--muted); font-size: 0.82em; }

/* ===== 底部翻页 ===== */
nav.pager { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--nav-bg); border-top: 1px solid var(--line); }
.pager-inner {
  max-width: 700px;
  margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.page-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95em;
  padding: 11px 8px;
  border-radius: 10px;
  cursor: pointer;
  min-width: 96px;
}
.page-btn:active:not(:disabled) { border-color: var(--gold); color: var(--gold-soft); }
.page-btn:disabled { opacity: 0.32; cursor: not-allowed; }
.page-count { flex: none; color: var(--gold); font-size: 0.9em; min-width: 78px; text-align: center; }

/* ===== 弹层 ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.66);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.overlay.show { display: flex; }
.overlay-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  max-height: 82vh;
  overflow-y: auto;
}
.overlay-card.small { max-width: 360px; }
.overlay-card.wide { max-width: 560px; }
.overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 14px;
}
.overlay-close { background: none; border: none; color: var(--muted); font-size: 1.4em; line-height: 1; cursor: pointer; padding: 0 4px; }
#tocList .toc-volume { padding: 16px 6px 8px; color: var(--gold); font-size: 0.9em; letter-spacing: 0.14em; }
#tocList .toc-volume:first-child { padding-top: 4px; }
.toc-item {
  display: flex;
  align-items: baseline;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 0.98em;
  padding: 13px 6px;
  cursor: pointer;
}
.toc-item:active { color: var(--gold-soft); }
.toc-item.current { color: var(--gold-soft); }
.toc-item .idx { display: inline-block; min-width: 3em; color: var(--muted); }
.toc-item .toc-name { flex: 1; }
.toc-item .toc-words { margin-left: 12px; color: var(--muted); font-size: 0.82em; white-space: nowrap; }

/* ===== 编辑器 ===== */
.edit-label { display: block; color: var(--muted); font-size: 0.86em; margin-bottom: 12px; }
.edit-text {
  width: 100%;
  min-height: 46vh;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.98em;
  line-height: 1.9;
  padding: 12px;
  resize: vertical;
}
.edit-text:focus { outline: none; border-color: var(--gold); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(16px);
  z-index: 60;
  background: #22201c;
  border: 1px solid var(--gold);
  color: var(--gold-soft);
  font-size: 0.9em;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 768px) {
  .wrap { padding: 0 28px; }
  .site-inner { padding: 16px 28px; }
  p { font-size: 1.08em; }
}
