/* ============================================================
   阅读页 v2 · 极简沉浸，正文是唯一核心
   无进度条、无状态行；进度静默保存
   ============================================================ */

/* 阅读主题由 body[data-read-theme] 控制，独立于站点模式 */
body[data-read-theme="paper"]  { --r-bg: #FFFFFF; --r-ink: #26282E; --r-soft: #61666F; --r-faint: #A0A5B0; --r-line: #EDEEF2; --r-card: #FFFFFF; }
body[data-read-theme="sepia"]  { --r-bg: #F5EFDC; --r-ink: #3A352B; --r-soft: #6E6552; --r-faint: #9E9272; --r-line: #E4D9BC; --r-card: #FBF7EA; }
body[data-read-theme="green"]  { --r-bg: #CBE6CD; --r-ink: #26302A; --r-soft: #5A685E; --r-faint: #87988C; --r-line: #B4D3B8; --r-card: #D6EDD8; }
body[data-read-theme="night"]  { --r-bg: #16171B; --r-ink: #C6CBD6; --r-soft: #8A90A0; --r-faint: #5C6270; --r-line: #272830; --r-card: #1B1C22; }

body { background: var(--r-bg); color: var(--r-ink); }

/* 顶栏 · 极简 */
.reader-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  height: 48px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px;
  background: color-mix(in srgb, var(--r-bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--r-line);
  transition: transform .3s ease, opacity .3s ease;
}
.reader-top .rt-title {
  flex: 1; min-width: 0; text-align: center;
  font-size: 13px; color: var(--r-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reader-top .rt-title b { color: var(--r-ink); font-weight: 600; }
.reader-top .reader-account .account-trigger { color: var(--r-soft); }
.reader-top .reader-account .account-trigger:hover,
.reader-top .reader-account .account-trigger.signed-in { color: var(--r-ink); background: rgba(127,127,140,.1); }
.reader-top .icon-btn { color: var(--r-soft); width: 36px; height: 36px; border-radius: 10px; }
.reader-top .icon-btn:hover { background: rgba(127,127,140,.1); color: var(--r-ink); }

.reader-top.hidden { transform: translateY(-100%); opacity: 0; }

/* ============================================================
   正文
   ============================================================ */
.reader-body {
  padding: 88px 24px 120px;
  display: flex; justify-content: center;
}
.chapter {
  width: 100%;
  max-width: 680px;            /* 桌面限宽 */
  font-family: var(--font-serif);
}
.chapter-head { text-align: center; margin-bottom: 42px; }
.chapter-head .vol-name {
  font-family: var(--font-ui);
  font-size: 11.5px; font-weight: 600; letter-spacing: .22em;
  color: var(--r-faint);
  margin-bottom: 12px;
}
.chapter-head h1 {
  font-size: 23px; font-weight: 700; letter-spacing: .03em;
  line-height: 1.5;
}
.chapter-head .ch-meta {
  margin-top: 13px;
  font-family: var(--font-ui);
  font-size: 11.5px; color: var(--r-faint);
  display: flex; align-items: center; justify-content: center; gap: 12px;
}
.chapter-head .ch-meta::before, .chapter-head .ch-meta::after {
  content: ""; width: 24px; height: 1px; background: var(--r-line);
}

/* 正文段落 */
.chapter .p {
  font-size: var(--read-size, 18px);
  line-height: var(--read-lh, 2);
  text-indent: 2em;
  margin-bottom: 1.1em;
  color: var(--r-ink);
  text-align: justify;
}
.chapter .p.dialog { text-indent: 0; }

/* 章末 · 三个小圆点，极简 */
.chapter-end { text-align: center; margin: 44px 0 8px; color: var(--r-faint); }
.chapter-end .waves { display: inline-flex; gap: 7px; align-items: center; }
.chapter-end .waves i { width: 4px; height: 4px; border-radius: 50%; background: var(--r-faint); opacity: .75; }
.chapter-end .waves i:nth-child(2) { opacity: .5; }
.chapter-end .waves i:nth-child(3) { opacity: .28; }
.chapter-end .lbl {
  margin-top: 10px;
  font-family: var(--font-ui);
  font-size: 11px; letter-spacing: .2em; color: var(--r-faint);
}

/* 上一章 / 下一章 */
.ch-nav {
  display: flex; justify-content: space-between; gap: 14px;
  margin-top: 36px;
}
.ch-nav a {
  flex: 1; max-width: 280px;
  display: flex; flex-direction: column; gap: 4px;
  border-radius: 12px;
  background: var(--r-card);
  box-shadow: inset 0 0 0 1px var(--r-line);
  padding: 13px 16px;
  font-family: var(--font-ui);
  transition: box-shadow .18s ease;
}
.ch-nav a:hover { box-shadow: inset 0 0 0 1.5px var(--brand); }
.ch-nav a .k { font-size: 11px; color: var(--r-faint); letter-spacing: .06em; }
.ch-nav a .t { font-family: var(--font-serif); font-size: 14px; font-weight: 600; color: var(--r-ink); }
.ch-nav a.next { text-align: right; align-items: flex-end; margin-left: auto; }
.ch-nav a.placeholder { visibility: hidden; }

/* 未录入章节的提示卡 */
.placeholder-card {
  border-radius: 12px;
  padding: 32px 26px;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 13px; line-height: 2; color: var(--r-soft);
  background: var(--r-card);
  box-shadow: inset 0 0 0 1px var(--r-line);
}
.placeholder-card b { display: block; font-family: var(--font-serif); font-size: 15px; color: var(--r-ink); margin-bottom: 6px; }

/* ============================================================
   手机底部工具栏（≤720px）
   ============================================================ */
.mobile-bar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 56;
  background: var(--r-card);
  border-top: 1px solid var(--r-line);
  height: 60px;
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-bar button, .mobile-bar a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 10.5px; font-weight: 500; color: var(--r-soft);
  position: relative;
}
.mobile-bar .mb-ic { width: 21px; height: 21px; color: var(--r-soft); }

/* ============================================================
   抽屉通用（目录 / 设置）
   ============================================================ */
.mask {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(15,16,20,.42);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.mask.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 90;
  width: min(420px, 92vw);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-drawer);
  transform: translateX(102%);
  transition: transform .28s cubic-bezier(.32,.72,.24,1);
  display: flex; flex-direction: column;
}
.drawer.show { transform: none; }
.drawer .dw-head {
  padding: 15px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.drawer .dw-head .row1 { display: flex; align-items: center; gap: 10px; }
.drawer .dw-head h3 {
  font-size: 15.5px; font-weight: 700; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer .dw-head .count { font-size: 11.5px; color: var(--ink-faint); }
.drawer .dw-tools { display: flex; gap: 8px; margin-top: 11px; }
.drawer .dw-tools input {
  flex: 1; height: 34px;
  border: none; border-radius: 10px;
  background: var(--card-deep);
  padding: 0 13px; font-size: 13px; outline: none;
}
.drawer .dw-tools input:focus { box-shadow: inset 0 0 0 1.5px var(--brand); }
.drawer .dw-tools button {
  height: 34px; padding: 0 12px;
  border-radius: 10px;
  font-size: 12px; font-weight: 500; color: var(--ink-soft);
  background: var(--card-deep);
  display: inline-flex; align-items: center; gap: 5px;
}
.drawer .dw-tools button.on { color: var(--brand); background: var(--brand-wash); }

/* 目录列表 */
.toc-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.vol-block { border-bottom: 1px solid var(--line); }
.vol-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--paper);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13.5px; font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.vol-head .v-meta { font-size: 11px; font-weight: 400; color: var(--ink-faint); }
.vol-head .chev { margin-left: auto; transition: transform .22s ease; color: var(--ink-faint); }
.vol-block.open .vol-head .chev { transform: rotate(180deg); }
.vol-list { display: none; }
.vol-block.open .vol-list { display: block; }

.toc-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px 10px 18px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .12s ease;
  border-left: 3px solid transparent;
}
.toc-item:hover { background: var(--brand-wash); }
.toc-item .st {
  flex: none; width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
}
.toc-item.read .st::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--brand); }
.toc-item .st::before { content: ""; width: 5px; height: 5px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.toc-item .no { flex: none; width: 50px; color: var(--ink-faint); font-variant-numeric: tabular-nums; font-size: 12px; }
.toc-item .t { flex: 1; font-family: var(--font-serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc-item.read .t { color: var(--ink); }
.toc-item.cur {
  background: var(--brand-wash);
  border-left-color: var(--brand);
}
.toc-item.cur .t, .toc-item.cur .no { color: var(--brand-ink); font-weight: 600; }
.toc-item.cur .st::before { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }

.toc-foot {
  border-top: 1px solid var(--line);
  padding: 12px 16px;
}
.toc-foot .btn { width: 100%; }

/* ============================================================
   设置面板
   ============================================================ */
.settings {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 90;
  width: min(320px, 92vw);
  background: var(--paper); color: var(--ink);
  box-shadow: var(--shadow-drawer);
  transform: translateX(102%);
  transition: transform .28s cubic-bezier(.32,.72,.24,1);
  display: flex; flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}
.settings.show { transform: none; }
.settings h3 {
  font-size: 15.5px; font-weight: 700;
  padding-bottom: 13px; border-bottom: 1px solid var(--line);
}
.set-group { padding: 17px 0; border-bottom: 1px solid var(--line); }
.set-group .g-label {
  font-size: 12px; font-weight: 600; color: var(--ink-faint); letter-spacing: .08em;
  margin-bottom: 11px;
}
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; height: 38px;
  border: none; border-radius: 10px;
  background: var(--card-deep); color: var(--ink-soft);
  font-size: 12.5px;
  transition: all .15s ease;
}
.seg button:hover { color: var(--brand); }
.seg button.on { background: var(--brand); color: #fff; font-weight: 600; }
.seg button .demo { font-family: var(--font-serif); }

/* 字号步进器 */
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button {
  width: 44px; height: 40px;
  border: none; border-radius: 10px;
  background: var(--card-deep); color: var(--ink-soft);
  font-size: 17px;
}
.stepper button:hover { color: var(--brand); }
.stepper .val {
  flex: 1; text-align: center;
  font-family: var(--font-serif); font-size: 15px;
}
.stepper .val small { font-family: var(--font-ui); color: var(--ink-faint); font-size: 11px; margin-left: 4px; }

/* 背景色板 */
.swatches { display: flex; gap: 14px; padding-bottom: 26px; }
.swatch {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  position: relative;
  transition: all .15s ease;
  flex: none;
  cursor: pointer;
}
.swatch:hover { transform: scale(1.06); }
.swatch .sw-lbl {
  position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
  font-size: 10.5px; color: var(--ink-faint); white-space: nowrap;
  font-family: var(--font-ui);
}
.sw-p1 { background: #FFFFFF; }
.sw-p2 { background: #F5EFDC; }
.sw-p3 { background: #CBE6CD; }
.sw-p4 { background: #16171B; border-color: #2E3039; }
.swatch.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }
.swatch.on::after {
  content: "✓"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #6B7080;
}
.sw-p4.on::after { color: #7C8CFF; }

/* 自动保存状态 · 静默一行 */
.save-state {
  font-size: 11.5px; color: var(--ink-faint);
  display: flex; align-items: center; gap: 6px;
}
.save-state .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--brand); animation: breathe 2.4s ease infinite; }
@keyframes breathe { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

.set-tip {
  margin-top: auto; padding-top: 16px;
  font-size: 11px; line-height: 1.8; color: var(--ink-faint);
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 720px) {
  .reader-body { padding: 70px 18px 126px; }
  .chapter-head h1 { font-size: 19px; }
  .chapter-head .ch-meta { font-size: 11px; }
  .chapter .p { text-align: left; }

  .mobile-bar { display: flex; }

  .ch-nav { flex-direction: column; gap: 10px; }
  .ch-nav a, .ch-nav a.next { max-width: none; align-items: stretch; text-align: left; }

  .drawer { width: min(390px, 86vw); }
  .settings {
    top: auto; left: 0; right: 0; width: auto;
    max-height: 76vh; height: auto;
    border-radius: 18px 18px 0 0;
    transform: translateY(105%);
    padding-bottom: 24px;
  }
  .settings.show { transform: none; }
  .swatches { justify-content: space-between; padding: 0 4px 30px; }
  .set-tip { display: none; }
}

/* ============================================================
   连续滚动阅读（按需加载相邻章节，无进度条）
   ============================================================ */
body.continuous-reader .reader-body { padding-bottom: 140px; }
.chapter-loading {
  text-align: center; padding: 80px 0; color: var(--r-faint);
  font-size: 13px; letter-spacing: .1em;
}
.scroll-chapter { padding: 6px 0 20px; }
.scroll-chapter + .scroll-chapter { margin-top: 30px; }
.scroll-chapter-head { text-align: center; margin: 24px 0 28px; }
.scroll-chapter-head > div {
  font-family: var(--font-ui); font-size: 11.5px; font-weight: 600;
  letter-spacing: .22em; color: var(--r-faint); margin-bottom: 10px;
}
.scroll-chapter-head h2 { font-size: 22px; font-weight: 700; letter-spacing: .03em; line-height: 1.5; }
.chapter-sentinel {
  text-align: center; padding: 24px 0; color: var(--r-faint);
  font-size: 12px; letter-spacing: .08em;
}
.chapter-sentinel span { opacity: .8; }

/* 全屏专注模式 */
body.reader-focus .reader-top { opacity: 0; pointer-events: none; transform: translateY(-100%); }
body.reader-focus .mobile-bar { display: none; }

/* 打印：纯正文 */
@media print {
  .reader-top, .mobile-bar, .drawer, .mask, .ch-nav { display: none !important; }
  .reader-body { padding: 0; }
}
