/*
 * 就在今生 · 全站共用阅读器样式
 * 合并自 B/C 族各书 assets/style.css
 * 不含 A 族：Power-Awareness、divine-matrix/en、divine-matrix/html-zh
 *
 * 各书特有组件通过专属 class 区分，未使用的 class 不影响页面渲染。
 */

/* ══════════════════════════════════════════════
   设计令牌
══════════════════════════════════════════════ */

:root {
  /* 背景 */
  --bg:          #fbfaf6;
  --bg-soft:     #f3f1e9;
  --card-bg:     #ffffff;

  /* 文字 */
  --ink:         #1a1a1a;
  --ink-soft:    #4a4a4a;
  --text:        #1a1a1a;     /* 兼容旧变量名 */

  /* 标题色 */
  --heading:     #5a3a1e;

  /* 分隔线 */
  --rule:        #d9d4c3;

  /* 主题色 */
  --accent:      #7a5a2e;
  --accent-soft: #c7a76a;

  /* 阴影 */
  --shadow:      0 2px 12px rgba(0, 0, 0, 0.06);

  /* 字体栈 */
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  --sans:  "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Helvetica Neue", system-ui, sans-serif;

  /* 批注变量 */
  --comment-color:      #6b4c1e;
  --comment-bg:         #fdf6e3;
  --comment-border:     #c8a050;
  --comment-icon-color: #a07838;
}

[data-theme="dark"] {
  --bg:          #161413;
  --bg-soft:     #1f1c1a;
  --card-bg:     #1f1c1a;
  --ink:         #e8e3d6;
  --ink-soft:    #a8a194;
  --text:        #e8e3d6;
  --heading:     #d3b07a;
  --rule:        #3a3530;
  --accent:      #d3b07a;
  --accent-soft: #8a6a3b;
  --shadow:      0 2px 12px rgba(0, 0, 0, 0.4);
  --comment-color:      #d4a855;
  --comment-bg:         #1e1a0c;
  --comment-border:     #8a6028;
  --comment-icon-color: #c89040;
}

/* ══════════════════════════════════════════════
   Reset
══════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--reader-size, 18px);
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

/* 等宽字体（zhiguan/xishuorulaizang/yaoshifo） */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

/* ══════════════════════════════════════════════
   顶栏
══════════════════════════════════════════════ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: rgba(251, 250, 246, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
}

[data-theme="dark"] .topbar {
  background: rgba(22, 20, 19, 0.92);
}

.topbar .title {
  flex: 1;
  font-size: 14px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .title a { color: inherit; text-decoration: none; }
.topbar .title .sep { opacity: 0.55; }

.topbar button {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 13px;
  white-space: nowrap;
}

.topbar button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.topbar .group { display: inline-flex; gap: 4px; }

/* ══════════════════════════════════════════════
   进度条
══════════════════════════════════════════════ */

.progress {
  height: 3px;
  background: var(--bg-soft);
  position: sticky;
  top: 49px;
  z-index: 49;
}

.progress .bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s;
}

/* ══════════════════════════════════════════════
   抽屉目录
══════════════════════════════════════════════ */

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 80;
}

.drawer-mask.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(340px, 86vw);
  background: var(--bg);
  border-right: 1px solid var(--rule);
  transform: translateX(-100%);
  transition: transform 0.25s;
  z-index: 90;
  overflow-y: auto;
  padding: 22px 22px 60px;
  font-family: var(--sans);
  box-shadow: var(--shadow);
}

.drawer.open { transform: translateX(0); }

.drawer .book {
  font-family: var(--serif);
  font-size: 18px;
  margin: 0 0 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.drawer .book a { text-decoration: none; }

/* 目录分组标签（becoming-supernatural / xishuorulaizang） */
.drawer h3 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
  letter-spacing: 0.08em;
}

.drawer .group-label {
  margin: 18px 0 6px;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.1em;
}

.drawer ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.drawer ol li { margin: 2px 0; }

.drawer ol a,
.drawer .placeholder {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
}

.drawer .placeholder {
  color: var(--ink-soft);
  opacity: 0.7;
}

.drawer ol a:hover {
  background: var(--bg-soft);
  color: var(--accent);
}

.drawer ol a.current {
  background: var(--bg-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

/* ── details/summary 折叠 ── */

.drawer details { margin: 2px 0; }

.drawer > ol > li > details > summary,
.drawer ol > li > details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  user-select: none;
}

.drawer details > summary::-webkit-details-marker { display: none; }

.drawer details > summary::before {
  content: "›";
  display: inline-block;
  width: 14px;
  flex-shrink: 0;
  color: var(--ink-soft);
  transition: transform 0.15s;
  font-size: 14px;
  margin-top: 2px;
}

.drawer details[open] > summary::before { transform: rotate(90deg); }

.drawer details > summary:hover {
  background: var(--bg-soft);
  color: var(--accent);
}

/* 当前章节激活（zhiguan/xishuorulaizang/yaoshifo） */
.drawer details.current > summary {
  background: var(--bg-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.drawer details > summary .summary-link {
  flex: 1;
  color: inherit;
  text-decoration: none;
}

/* 无子项：隐藏箭头保持对齐 */
.drawer details.no-children > summary::before {
  visibility: hidden;
  pointer-events: none;
}

.drawer details.no-children > summary { cursor: default; }

/* ── h2 子列表 ── */
.drawer ol.sub {
  list-style: none;
  padding: 2px 0 4px 0;
  margin: 0 0 0 24px;
  border-left: 1px dashed var(--rule);
}

.drawer ol.sub > li > a:hover {
  color: var(--accent);
  background: var(--bg-soft);
}

.drawer ol.sub > li > details > summary {
  padding: 5px 8px 5px 4px;
  font-size: 13px;
  color: var(--ink-soft);
}

.drawer ol.sub > li > details > summary::before {
  width: 12px;
  font-size: 12px;
}

/* 子目录编号（becoming-supernatural / xishuorulaizang / yaoshifo） */
.drawer ol.sub a {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 5px 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.drawer ol.sub a .sub-num {
  color: var(--accent);
  font-family: var(--sans);
  font-size: 11px;
  min-width: 2.8em;
  letter-spacing: 0.03em;
}

.drawer ol.sub a:hover,
.drawer ol.sub a.current {
  color: var(--accent);
  background: var(--bg-soft);
}

/* ── h3 子列表 ── */
.drawer ol.sub.sub-h3 {
  margin-left: 16px;
  border-left: 1px dashed var(--rule);
}

.drawer ol.sub.sub-h3 > li > details > summary {
  font-size: 12px;
  padding: 4px 6px 4px 4px;
  color: var(--ink-soft);
}

.drawer ol.sub.sub-h3 > li > details > summary::before {
  width: 10px;
  font-size: 11px;
}

.drawer ol.sub.sub-h3 > li > details.no-children > summary { cursor: default; }

/* ── h4 子列表 ── */
.drawer ol.sub.sub-h4 {
  margin-left: 14px;
  border-left: 1px dashed var(--rule);
}

.drawer ol.sub.sub-h4 > li > a {
  display: block;
  font-size: 11px;
  padding: 3px 6px 3px 10px;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 3px;
  line-height: 1.4;
  opacity: 0.85;
}

.drawer ol.sub.sub-h4 > li > a:hover {
  color: var(--accent);
  background: var(--bg-soft);
  opacity: 1;
}

/* ══════════════════════════════════════════════
   正文区
══════════════════════════════════════════════ */

.content,
.reader {
  max-width: 42em;
  margin: 0 auto;
  padding: 48px 24px 100px;
}

/* ── 标题层级（C 族 .h-level-N） ── */

.reader h1, .reader h2, .reader h3,
.reader h4, .reader h5, .reader h6 {
  font-family: var(--serif);
  color: var(--heading);
  line-height: 1.5;
  margin: 2em 0 0.6em;
}

.reader h1.h-level-1 {
  font-size: 1.55em;
  font-weight: 600;
  border-bottom: 2px solid var(--accent-soft);
  padding-bottom: 0.3em;
  margin-top: 1em;
}

.reader h2.h-level-2 { font-size: 1.25em; font-weight: 600; }
.reader h3.h-level-3 { font-size: 1.1em;  font-weight: 600; }
.reader h4.h-level-4 { font-size: 1em;    font-weight: 600; color: var(--ink); }

.reader h5.h-level-5,
.reader h6.h-level-6 {
  font-size: 0.95em;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ── B 族标题（无 h-level-N，直接用语义标签） ── */

.reader .eyebrow {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.reader h1:not([class]) {
  font-size: 1.9em;
  line-height: 1.35;
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.reader h2:not([class]) {
  font-size: 1.25em;
  line-height: 1.4;
  margin: 2em 0 0.8em;
  font-family: var(--sans);
  font-weight: 600;
  color: var(--ink);
}

.reader h3:not([class]) {
  margin: 2.4em 0 0.8em;
  font-size: 1.15em;
  line-height: 1.5;
  font-family: var(--sans);
  font-weight: 600;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.35em;
}

.reader h3:not([class]) .sec-num {
  display: inline-block;
  color: var(--accent);
  margin-right: 0.5em;
  font-feature-settings: "tnum";
}

/* 导读段落（B 族） */
.reader .lead {
  color: var(--ink-soft);
  margin: 0 0 36px;
  border-left: 3px solid var(--accent-soft);
  padding-left: 14px;
}

/* ── 正文段落 ── */

.reader p {
  margin: 0 0 1em;
  text-indent: 2em;
}

/* 不缩进变体（B 族使用） */
.reader p.no-indent,
.reader .verse p {
  text-indent: 0;
}

/* ── 特殊段落（kongxingchanxiucidi） ── */

/* 保留 Word 空段落间距 */
.reader p.blank {
  height: 1em;
  text-indent: 0;
  margin: 0;
}

/* 命名分节线 */
.reader hr.section-rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 1em 0;
}

/* 居中变体 */
.reader p.p-center { text-align: center; }

/* 章节导读段（kongxing / mingming） */
.reader p.summary-para {
  text-indent: 0;
  margin: 1.2em 0;
  padding: 1em 1.2em;
  background: var(--bg-soft);
  border-left: 3px solid var(--accent-soft);
  border-radius: 0 6px 6px 0;
  color: var(--ink-soft);
  font-size: 0.95em;
  line-height: 1.8;
}

/* 页码标记（xishuorulaizang / yaoshifo） */
.page-marker {
  margin: 26px 0 18px;
  padding-top: 20px;
  border-top: 1px dashed var(--rule);
  color: var(--ink-soft);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  font-family: var(--sans);
}

/* 小节聚合框（xishuorulaizang） */
.reader .section-cluster {
  margin: 1.4em 0 1.8em;
  padding: 0.8em 1em;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.reader .section-cluster h2 {
  margin: 0;
  padding: 0.35em 0;
  font-size: 1.05em;
  font-weight: 500;
  border-bottom: 1px dashed var(--rule);
}

.reader .section-cluster h2:last-child { border-bottom: 0; }

/* ── 偈颂 ── */

/* C 族：段落式偈颂 */
.reader p.verse {
  text-indent: 0;
  margin: 0.15em 0;
  padding-left: 2em;
  color: var(--ink-soft);
  font-style: normal;
}

/* 居中偈颂（kongxingchanxiucidi） */
.reader p.verse.p-center { padding-left: 0; }

/* B 族：块级偈颂容器（xishuorulaizang / yaoshifo） */
.verse:not(p) {
  margin: 18px 0;
  padding: 16px 20px;
  background: rgba(122, 90, 46, 0.05);
  border: 1px solid var(--rule);
  border-radius: 10px;
}

/* ── 引用块 ── */

/* 默认引用（左竖线式，大多数书） */
.reader blockquote {
  margin: 1.4em 0;
  padding: 0.2em 1em;
  border-left: 3px solid var(--accent);
  color: var(--ink-soft);
  font-style: italic;
}

.reader blockquote p { text-indent: 0; margin: 0.35em 0; }
.reader blockquote p:first-child { margin-top: 0; }
.reader blockquote p:last-child  { margin-bottom: 0; }

/* 教言引用块（shuimengyujia） */
.reader blockquote.teaching {
  margin: 1.5em 0;
  padding: 1em 1.2em;
  border-left: 3px solid var(--accent-soft);
  background: var(--bg-soft);
  border-radius: 0 6px 6px 0;
  font-size: 0.95em;
  color: var(--ink-soft);
  line-height: 2;
  font-style: normal;
}

.reader blockquote.teaching p { margin: 0 0 0.4em; text-indent: 0; }
.reader blockquote.teaching p:last-child { margin-bottom: 0; }

/* 居中引用块（xishuorulaizang） */
.reader blockquote.centered {
  margin: 1.8em auto;
  padding: 1em 1.4em;
  max-width: 28em;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  background: var(--bg-soft);
  text-align: center;
  box-shadow: var(--shadow);
}

.reader blockquote.centered p { text-align: center; }

/* ── 分隔线 ── */
.reader hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.4em 0;
}

.reader a { color: var(--accent); }

/* ── 图片 ── */

/* C 族 */
.reader .book-image,
.cover-block .cover-image {
  margin: 1.5em auto;
  text-align: center;
}

.reader .book-image img,
.cover-block .cover-image img {
  max-width: 100%;
  border-radius: 4px;
  box-shadow: var(--shadow);
}

/* becoming-supernatural：行内 img */
.reader p:has(img) { text-indent: 0; text-align: center; }

.reader img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
  background: var(--bg-soft);
}

/* 图例说明（becoming-supernatural） */
.reader p.figure-caption {
  text-indent: 0;
  text-align: center;
  font-family: var(--sans);
  font-size: 0.85em;
  color: var(--ink-soft);
  margin: -6px auto 1.8em;
  max-width: 92%;
  line-height: 1.7;
  letter-spacing: 0.02em;
}

/* 编者注（becoming-supernatural） */
.reader aside.editor-note {
  margin: 1.4em 0;
  padding: 12px 16px;
  background: var(--bg-soft);
  border-left: 3px solid var(--accent-soft);
  font-family: var(--sans);
  font-size: 0.88em;
  line-height: 1.75;
  color: var(--ink-soft);
  border-radius: 0 6px 6px 0;
  text-indent: 0;
}

.reader aside.editor-note .en-label {
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.reader aside.editor-note .en-sep {
  color: var(--accent);
  margin: 0 6px 0 2px;
}

/* ── 表格（shuimengyujia） ── */

.reader table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5em 0;
  font-family: var(--sans);
  font-size: 0.9em;
}

.reader table th,
.reader table td {
  border: 1px solid var(--rule);
  padding: 8px 12px;
  text-align: left;
  line-height: 1.6;
}

.reader table th {
  background: var(--bg-soft);
  color: var(--heading);
  font-weight: 600;
}

.reader table tr:nth-child(even) td { background: var(--bg-soft); }

/* ══════════════════════════════════════════════
   封面页
══════════════════════════════════════════════ */

.cover-block {
  text-align: center;
  padding: 2em 0 1em;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.5em;
}

.cover-block .cover-meta {
  margin: 0.3em 0;
  font-size: 1em;
  color: var(--ink-soft);
  text-indent: 0;
  line-height: 1.7;
}

.cover-block .cover-meta:first-of-type {
  font-size: 1.5em;
  color: var(--heading);
  font-weight: 600;
  margin-bottom: 0.2em;
}

/* 独立封面标题块（xiuxin） */
.cover-title { margin-bottom: 1.8em; }

.cover-title h1 {
  font-size: 2.6em;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 0.15em;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.cover-title .cover-subtitle {
  font-size: 1.25em;
  color: var(--ink-soft);
  margin: 0 0 0.6em;
}

.cover-title .cover-author {
  font-size: 0.95em;
  color: var(--accent);
  margin: 0;
}

/* ══════════════════════════════════════════════
   章节列表（默认：C 族简洁版）
══════════════════════════════════════════════ */

.chapter-list { display: grid; gap: 10px; }

.chapter-card {
  display: block;
  padding: 16px 20px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  background: var(--card-bg);
  font-family: var(--sans);
  font-size: 15px;
  transition: border-color 0.15s, color 0.15s;
}

.chapter-card:hover { border-color: var(--accent); color: var(--accent); }
.chapter-card .chapter-title { display: block; }

/* 章节卡片网格（xishuorulaizang / yaoshifo） */
.chapter-grid { display: grid; gap: 12px; margin-top: 18px; }

.chapter-grid .chapter-card {
  display: flex;
  gap: 10px;
  align-items: baseline;
  background: var(--bg-soft);
}

.chapter-grid .chapter-card .ch-num {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.chapter-grid .chapter-card .ch-title { flex: 1; font-size: 1.05em; }

/* ══════════════════════════════════════════════
   首页（B 族：xishuorulaizang / yaoshifo / becoming-supernatural）
══════════════════════════════════════════════ */

.home {
  max-width: 42em;
  margin: 0 auto;
  padding: 80px 24px 120px;
}

.home .cover {
  text-align: center;
  margin-bottom: 56px;
  padding: 48px 24px;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.home .cover .sub {
  font-family: var(--sans);
  letter-spacing: 0.25em;
  color: var(--accent);
  font-size: 12px;
}

.home .cover h1 { font-size: 2.6em; margin: 18px 0 8px; line-height: 1.25; }
.home .cover .en { color: var(--ink-soft); font-style: italic; }

.home .cover .author {
  margin-top: 18px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-soft);
}

.home .cta {
  display: inline-block;
  margin-top: 28px;
  padding: 12px 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0.1em;
}

.home .cta:hover { background: var(--ink); }

.home h2 {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
  margin: 48px 0 14px;
  font-weight: 500;
}

.home .toc { list-style: none; padding: 0; margin: 0; }
.home .toc li { border-bottom: 1px dashed var(--rule); }

.home .toc a {
  display: flex;
  gap: 16px;
  align-items: baseline;
  padding: 16px 6px;
  text-decoration: none;
  color: var(--ink);
}

.home .toc a:hover { color: var(--accent); background: var(--bg-soft); }

.home .toc .num {
  font-family: var(--sans);
  color: var(--accent);
  font-size: 13px;
  min-width: 3.2em;
  letter-spacing: 0.05em;
}

.home .toc .t   { flex: 1; font-size: 1.05em; }
.home .toc .meta { font-family: var(--sans); font-size: 12px; color: var(--ink-soft); }

/* 统计 chips（xishuorulaizang） */
.home .stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.home .chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(122, 90, 46, 0.08);
  border: 1px solid rgba(122, 90, 46, 0.18);
  font-family: var(--sans);
  font-size: 13px;
}

/* 说明框（xishuorulaizang） */
.home .note-box {
  margin-top: 18px;
  padding: 18px 20px;
  background: rgba(122, 90, 46, 0.05);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
}

.home .note-box ul { margin: 10px 0 0 18px; padding: 0; }
.home .note-box li { margin: 4px 0; }
.home p { text-align: justify; }
.home p.no-indent { text-indent: 0; }

/* ══════════════════════════════════════════════
   脚注系统（C 族）
══════════════════════════════════════════════ */

.fn-ref {
  font-size: 0.72em;
  vertical-align: super;
  line-height: 0;
  margin-left: 1px;
}

.fn-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  position: relative;
}

.fn-link:hover { text-decoration: underline; }

/* Tooltip（桌面端悬停） */
.fn-link::after {
  content: attr(data-fn);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  width: max-content;
  max-width: min(340px, 80vw);
  white-space: pre-wrap;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 20;
  font-family: var(--sans);
  font-style: normal;
  vertical-align: baseline;
}

/* 小箭头 */
.fn-link::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--rule);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 21;
}

.fn-link:hover::after,
.fn-link:hover::before { opacity: 1; }

/* 章末注释区 */
.footnotes {
  margin-top: 3em;
  padding-top: 1.5em;
  border-top: 1px solid var(--rule);
}

.footnotes-title {
  font-size: 0.9em;
  font-family: var(--sans);
  color: var(--ink-soft);
  font-weight: 500;
  letter-spacing: 0.08em;
  margin: 0 0 1em;
}

.fn-list { list-style: none; padding: 0; margin: 0; }

.fn-item {
  display: flex;
  gap: 10px;
  margin: 0.6em 0;
  font-size: 0.85em;
  font-family: var(--sans);
  line-height: 1.7;
  color: var(--ink-soft);
}

.fn-num {
  flex-shrink: 0;
  color: var(--accent);
  font-size: 0.85em;
  min-width: 1.8em;
  padding-top: 0.15em;
}

.fn-back {
  margin-left: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9em;
}

.fn-back:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════
   批注（shuimengyujia 编者按）
══════════════════════════════════════════════ */

.comment-ref {
  position: relative;
  display: inline;
  margin-left: 2px;
}

.comment-icon {
  font-size: 0.82em;
  color: var(--comment-icon-color);
  cursor: default;
  user-select: none;
  vertical-align: baseline;
  font-style: normal;
}

.comment-ref::after {
  content: attr(data-comment);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--comment-bg);
  color: var(--comment-color);
  border: 1px solid var(--comment-border);
  border-left: 3px solid var(--comment-border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.7;
  width: max-content;
  max-width: min(420px, 82vw);
  white-space: pre-wrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 22;
  font-family: var(--sans);
  font-style: normal;
  vertical-align: baseline;
  text-indent: 0;
}

.comment-ref::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--comment-border);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 23;
}

.comment-ref:hover::after,
.comment-ref:hover::before { opacity: 1; }

/* ══════════════════════════════════════════════
   翻页导航
══════════════════════════════════════════════ */

.nav-foot {
  max-width: 42em;
  margin: 0 auto 80px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  font-family: var(--sans);
}

.nav-foot a,
.nav-foot span {
  display: block;
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  background: var(--bg-soft);
}

.nav-foot a:hover { border-color: var(--accent); color: var(--accent); }

.nav-foot .label {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.nav-foot .center  { text-align: center; }
.nav-foot .right   { text-align: right; }
.nav-foot .disabled { opacity: 0.4; }

/* ══════════════════════════════════════════════
   zhiguan/chapter.css 旧容器（兼容旧 HTML）
══════════════════════════════════════════════ */

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 0 40px;
}

.container h1,
.main-wrap h1 {
  font-size: 1.8em;
  color: var(--heading);
  text-align: center;
  margin: 0.5em 0 0.3em;
  line-height: 1.4;
  font-weight: 700;
}

.container .subtitle,
.main-wrap .subtitle {
  display: block;
  font-size: 0.55em;
  font-weight: 400;
  color: var(--accent);
  margin-top: 6px;
}

.container p,
.main-wrap p { text-indent: 2em; }

/* ══════════════════════════════════════════════
   响应式
══════════════════════════════════════════════ */

@media (max-width: 720px) {
  body { font-size: var(--reader-size, 17px); }

  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar button { padding: 5px 8px; font-size: 12px; }
  .topbar .title { font-size: 12px; }

  .progress { top: 41px; }

  .content, .reader { padding: 28px 18px 60px; }

  /* B 族 reader */
  .reader h1:not([class]) { font-size: 1.5em; line-height: 1.3; }
  .reader h3:not([class]) { font-size: 1.05em; margin: 1.8em 0 0.6em; }

  .home {
    padding: 40px 16px 60px;
  }

  .home .cover { padding: 32px 16px; margin-bottom: 36px; }
  .home .cover h1 { font-size: 1.8em; }
  .home .cover .en { font-size: 0.9em; }
  .home .toc a { padding: 14px 4px; gap: 10px; }
  .home .toc .num { min-width: 2.8em; font-size: 12px; }
  .home .toc .t { font-size: 1em; }

  .nav-foot {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 0 auto 60px;
  }

  .nav-foot a, .nav-foot span { padding: 12px 14px; }
  .nav-foot .right { text-align: left; }

  .drawer { width: min(320px, 88vw); padding: 18px 16px 60px; }

  /* 移动端 tooltip 不显示 */
  .fn-link::after,
  .fn-link::before { display: none; }

  .comment-ref::after,
  .comment-ref::before { display: none; }

  .reader aside.editor-note { padding: 10px 12px; font-size: 0.9em; }
  .reader p.figure-caption  { font-size: 0.82em; max-width: 100%; }
}

@media (max-width: 380px) {
  .topbar .title .book-title { display: none; }
  .topbar button { padding: 4px 6px; font-size: 11px; }
}

/* 触屏：取消 hover 残留态 */
@media (hover: none) {
  .topbar button:hover,
  .drawer ol a:hover,
  .nav-foot a:hover,
  .home .toc a:hover,
  .home .cta:hover {
    color: inherit;
    border-color: var(--rule);
    background: inherit;
  }

  .home .cta:hover {
    color: #fff;
    background: var(--accent);
  }
}
