/* ==========================================================================
   国学读本 · 版式系统 v3 —— 「刻本纸页」
   规范：docs/product-ia-visual.md §4/§8
   纸 #F6F1E7 · 墨 #2E2C28 · 朱砂 #A23B2E（纪律：落款印/朱批线/朱字标记/激活态）
   竖排原文入「版框」：文武双边 + 乌丝栏界行（按 字号×行距 刻线）+ 落款钤印于列末地脚
   ========================================================================== */

:root {
  /* —— 纸墨 · 昼 —— */
  --paper: #F6F1E7;
  --paper-2: #F1EADC;
  --paper-3: #E9E0CE;
  --ink: #2E2C28;
  --ink-strong: #23211D;
  --ink-2: #77705F;
  --ink-3: #9C9284;
  --cinnabar: #A23B2E;
  --line: rgba(119, 112, 95, 0.26);
  --line-strong: rgba(119, 112, 95, 0.52);
  --rule: rgba(119, 112, 95, 0.22);      /* 界行（乌丝栏） */
  --frame: rgba(94, 86, 74, 0.6);        /* 版框外边 */
  --scrim: rgba(28, 25, 21, 0.56);
  --shadow-panel: 0 1px 2px rgba(43, 40, 35, 0.05), 0 16px 44px rgba(43, 40, 35, 0.07);
  --shadow-pop: 0 30px 90px rgba(20, 18, 15, 0.4);

  /* —— 字 ——
     正文用「朱雀仿宋」：仿宋刻书体，笔画瘦劲挺秀，古籍雕版气；思源宋体兜底 */
  --serif: "Zhuque Fangsong", "Noto Serif SC", "Songti SC", "STSong", serif;
  --kai: "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", var(--serif);

  /* 字号刻度（≤8） */
  --fs-xs: 12px;      /* 小注码 / 计数 */
  --fs-sm: 13.5px;    /* 辅文 */
  --fs-md: 15px;      /* 导航 / 按钮 / 注体 */
  --fs-base: 17.5px;  /* 正文（白话 / 心解） */
  --fs-lg: 19px;      /* 横排原文 */
  --fs-xl: 22px;      /* 书脊 / 页题 */

  /* 竖排原文字号与列距（界行刻线依赖这两个值） */
  --v-size: 27px;
  --v-lh: 1.9;
  --v-h: min(72vh, 700px);  /* 列高（= 版心高）· 随视口，短句也像一整张纸 */

  /* —— 间距刻度 —— */
  --sp-1: 8px;
  --sp-2: 14px;
  --sp-3: 20px;
  --sp-4: 32px;
  --sp-5: 56px;
  --sp-6: 88px;

  /* —— 版心 —— */
  --measure: 660px;   /* 阅读窄栏 */
  --wide: 880px;      /* 页眉 / 列表宽栏 */

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* —— 夜读：暖墨底 · 纸色字 —— */
html[data-theme="night"] {
  --paper: #26221C;
  --paper-2: #2C2721;
  --paper-3: #332E26;
  --ink: #D9D1C2;
  --ink-strong: #EAE3D3;
  --ink-2: #958C7E;
  --ink-3: #6E675C;
  --cinnabar: #B65742;
  --line: rgba(217, 209, 194, 0.14);
  --line-strong: rgba(217, 209, 194, 0.34);
  --rule: rgba(217, 209, 194, 0.12);
  --frame: rgba(217, 209, 194, 0.4);
  --scrim: rgba(10, 8, 6, 0.68);
  --shadow-panel: 0 1px 2px rgba(0, 0, 0, 0.25), 0 16px 44px rgba(0, 0, 0, 0.3);
  --shadow-pop: 0 30px 90px rgba(0, 0, 0, 0.55);
}

/* —— 大字两档 —— */
html[data-fs="lg"] {
  --fs-base: 19.5px;
  --fs-md: 16px;
  --fs-lg: 21px;
  --fs-xl: 24px;
  --v-size: 29px;
  --v-h: min(76vh, 760px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--fs-base);
  line-height: 2;
  letter-spacing: 0.01em;
  /* Safari 26 起 UA 默认 text-wrap:pretty，实现为整段缩行（右缘大片留白），显式关掉 */
  text-wrap: wrap;
  min-height: 100vh;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

/* 纸面：暖灰光晕 + 极淡纸纹（feTurbulence 噪点，2.6%） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 18% -4%, var(--paper-2), transparent 52%),
              radial-gradient(ellipse at 94% 104%, var(--paper-3), transparent 46%);
  opacity: 0.5;
  pointer-events: none;
  z-index: -2;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.026;
  pointer-events: none;
  z-index: -1;
}

/* 夜读：暖光坐实 —— 暗色宣纸 + 左下烛光晕 + 纸纹略现 */
html[data-theme="night"] body::before {
  background: radial-gradient(ellipse at 78% -6%, var(--paper-2), transparent 50%),
              radial-gradient(ellipse at 12% 108%, var(--paper-3), transparent 55%);
  opacity: 0.75;
}
html[data-theme="night"] body::after { opacity: 0.045; }

a { color: inherit; text-decoration: none; }

::selection { background: rgba(46, 44, 40, 0.14); }

:focus-visible {
  outline: 1.5px solid var(--ink-2);
  outline-offset: 3px;
  border-radius: 1px;
}

button { -webkit-tap-highlight-color: transparent; font: inherit; }

/* ==========================================================================
   引子：进入首页时的纯视觉开场（无交互，约 3.2s）
   纸色覆层，中央一句竖排引导语：淡入(0.9s)——驻留(1.4s)——淡出(0.9s)
   ========================================================================== */
.intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  opacity: 1;
  pointer-events: none;   /* 无交互：覆层不挡任何操作 */
  animation: intro-out 0.9s var(--ease) 2.3s forwards;
}
.intro-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}
/* 引子引导语：单字栈竖排（.vs），绕开 writing-mode 行盒在 WebKit 的画偏怪癖 */
.intro-text {
  font-family: var(--kai);
  font-size: 23px;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink-2);
  animation: intro-in 0.9s var(--ease) 0.18s forwards;
}
.intro-text .vs {
  display: block;
  width: 1em;
  height: 1em;
  line-height: 1;
  text-align: center;
}
.intro-text .vs + .vs { margin-top: 0.34em; }   /* 字距与题签同式 */
.intro-seal {   /* 引子红印：一点朱砂，落在句下，静中有收 */
  width: 34px;
  height: 34px;
  opacity: 0;
  animation: intro-in 0.9s var(--ease) 1.6s forwards;
}
@keyframes intro-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes intro-out {
  from { opacity: 1; }
  to   { opacity: 0; visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .intro { animation: none; display: none; }
}

/* 入场：整页一次淡入上移 */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
main > * { animation: rise-in 0.55s var(--ease) both; }
main > *:nth-child(2) { animation-delay: 0.06s; }
main > *:nth-child(3) { animation-delay: 0.12s; }

/* ==========================================================================
   基件
   ========================================================================== */
.shell { max-width: var(--wide); margin: 0 auto; padding: 0 var(--sp-3); }

/* 栏目标题：楷题 + 汉字计数 + 细线 */
.sec-label {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: var(--sp-5) 0 var(--sp-3);
}
.sec-label::before {
  content: "";
  align-self: center;
  width: 3px; height: 3px;
  background: var(--cinnabar);   /* 朱砂：栏目标题短标 */
  transform: rotate(45deg);
}
.sec-label .sec-name {
  font-family: var(--kai);
  font-size: var(--fs-md);
  font-weight: 400;
  letter-spacing: 0.34em;
  color: var(--ink-strong);
  white-space: nowrap;
}
.sec-label .sec-meta {
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  color: var(--ink-3);
  white-space: nowrap;
}
.sec-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--line), transparent 86%);
  transform: translateY(-0.3em);
}
main > .sec-label:first-child { margin-top: 0; }

/* 按钮：实心墨钮（主） / 描边幽灵钮（次） */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 2px;
  background: none;
  cursor: pointer;
  font-family: var(--serif);
  font-size: var(--fs-md);
  letter-spacing: 0.14em;
  line-height: 1;
  padding: 12px 24px;
  color: var(--ink);
  transition: color 0.25s var(--ease), background-color 0.25s var(--ease),
              border-color 0.25s var(--ease), box-shadow 0.25s var(--ease),
              transform 0.15s var(--ease);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink-strong);
  color: var(--paper);
  border-color: var(--ink-strong);
  box-shadow: 0 2px 10px rgba(35, 33, 29, 0.18);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(35, 33, 29, 0.24); }

.btn-ghost { border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink-2); background: color-mix(in srgb, var(--paper-3) 55%, transparent); }

/* 已藏 / 已读：前置一枚朱点（印记语言） */
.btn-ghost.on { color: var(--ink-strong); border-color: var(--ink-2); }
.btn-ghost.on::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--cinnabar);   /* 朱砂：收藏印记 */
  vertical-align: 2px;
}

/* 按压动效：墨点于钮心晕开，钮体下沉回弹（0.5s 单次） */
.btn { position: relative; overflow: hidden; }
.btn.pressed::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 50%,
    color-mix(in srgb, var(--cinnabar) 26%, transparent) 0%,
    transparent 68%);
  animation: btn-ink 0.55s var(--ease) forwards;
  pointer-events: none;
}
.btn.pressed { animation: btn-press 0.4s var(--ease); }
@keyframes btn-press {
  0%   { transform: translateY(0); }
  34%  { transform: translateY(2px) scale(0.985); }
  100% { transform: translateY(0); }
}
@keyframes btn-ink {
  0%   { opacity: 0; transform: scale(0.4); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.12); }
}

/* ==========================================================================
   页眉
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  transition: background-color 0.4s var(--ease);
}

.header-in {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-top: 16px;
  padding-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--kai);
  font-size: var(--fs-xl);
  letter-spacing: 0.14em;
  color: var(--cinnabar);   /* 朱砂：与站标印章同色 */
  white-space: nowrap;
}
.brand-seal {
  width: 1.22em; height: 1.22em;
  flex: none;
  border-radius: 2.5px;
  box-shadow: 0 1px 4px rgba(46, 44, 40, 0.22);   /* 印章浮在纸面上的微投影 */
}

.nav {
  display: flex;
  gap: var(--sp-3);
  margin-left: auto;
  font-size: var(--fs-md);
  color: var(--ink-2);
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.nav a {
  position: relative;
  padding: 4px 1px;
  transition: color 0.25s var(--ease);
}
.nav a:hover { color: var(--ink-strong); }
.nav a.active { color: var(--ink-strong); }
.nav a.active::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -3px;
  width: 4px; height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--ink-2);
}

.tools {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: var(--sp-2);
  padding-left: var(--sp-3);
  border-left: 1px solid var(--line);
  white-space: nowrap;
}
.tools button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--serif);
  font-size: var(--fs-sm);
  letter-spacing: 0.1em;
  color: var(--ink-2);
  padding: 6px 10px;
  border-radius: 2px;
  transition: color 0.25s var(--ease), background-color 0.25s var(--ease);
}
.tools button:hover { color: var(--ink-strong); background: color-mix(in srgb, var(--paper-3) 60%, transparent); }
.tools button[aria-pressed="true"] { color: var(--ink-strong); }

/* ==========================================================================
   版框 · 竖排原文（首页与详情同构）
   ========================================================================== */
main { max-width: var(--measure); margin: 0 auto; padding: var(--sp-5) var(--sp-3) var(--sp-6); }

/* 日课头：栏名 + 日期 / 出处 */
.daily-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: var(--sp-4);
}
.daily-head .dh-name {
  font-family: var(--kai);
  font-size: var(--fs-xl);
  letter-spacing: 0.3em;
  color: var(--ink-strong);
  white-space: nowrap;
}
.daily-head .dh-meta {
  margin-left: auto;
  text-align: right;
  font-size: var(--fs-sm);
  letter-spacing: 0.1em;
  color: var(--ink-2);
  line-height: 1.9;
}
.daily-head .dh-meta .dh-src { color: var(--ink-3); font-size: var(--fs-xs); letter-spacing: 0.14em; }

.daily-hero { display: flex; justify-content: center; }

/* 版框：外粗内细（文武边），天头 > 地脚 */
.panel {
  position: relative;
  border: 1.5px solid var(--frame);
  border-radius: 2px;
  background: color-mix(in srgb, var(--paper-2) 42%, transparent);
  box-shadow: var(--shadow-panel);
  padding: 44px 38px 36px;
  max-width: 100%;
  transition: background-color 0.4s var(--ease), border-color 0.4s var(--ease);
}
.panel::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid var(--line);
  border-radius: 1px;
  pointer-events: none;
}

.panel-body {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: var(--sp-3);
  position: relative;
  z-index: 1;
  /* 落款绝对定位在左下角（不参与 flex 宽度计算），
     vo 独占居中；左缘预留落款位由 JS 按需缩放 vo 保证 */
  padding-left: 0;
}

/* 竖排短句：版框保底宽度（一整张纸的观感），列少时文字在版心居中 */
.panel:has(.vertical-original) { min-width: min(var(--measure), 82vw); }

/* 竖排原文 = 逐字列栈：每段一列（.vcol flex column 逐字竖叠），列间 gap 界行。
   不用 writing-mode：绕开 WebKit 竖排「字面画在行盒右半格」的怪癖
   （墨迹质心偏右 ~0.5em，乌丝栏对不上字）——普通流下 .vs span 的
   text-align/justify-content 真正让字面居中，双引擎一致。
   分列由 JS 自愈式控制（渲染后校验列底，超了自动移字重排），不依赖 vh 换算。 */
.vertical-original {
  display: flex;
  flex-direction: row-reverse;  /* 竖排读序右→左：DOM 首列（正文开头）渲染在最右，末列（落款侧）在最左 */
  justify-content: center;
  align-items: flex-start;      /* 顶对齐：短列独立，长列到底 */
  gap: calc(var(--v-size) * 0.34);   /* 列间距 = 字距节奏 */
  height: var(--v-h);
  width: max-content;
  align-self: flex-start;       /* 防 .panel-body(flex) stretch 撑宽 */
  flex: none;
  padding: 0 2px;
  color: var(--ink-strong);
  font-family: var(--kai);
  font-size: var(--v-size);
}
.vertical-original .vcol {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  position: relative;
}
.vertical-original .vs {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  line-height: 1;
  text-align: center;
  flex: 0 0 auto;
}
/* 列内字距 = 竖排行距（--v-lh），刻本节奏 */
.vertical-original .vs + .vs { margin-top: calc(var(--v-size) * (var(--v-lh) - 1)); }
/* 竖排句读：占整字位（1em×1em 全格、正字号），与文字同大排进格线；
   列轴居中（字形本身挂左，flex center 拉回格心） */
.vertical-original .vp {
  width: 1em;
  height: 1em;
  font-size: 1em;
  line-height: 1;
}
/* 列间乌丝栏：线画在列缝正中（gap 中点）。
   row-reverse 下列序反转：DOM 后列视觉在左，其右侧才是邻列，
   故必须用 right（物理 left ≠ 视觉邻侧） */
.vertical-original .vcol + .vcol::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  right: calc(-1 * var(--v-size) * 0.34 / 2 - 0.5px);
  width: 1px;
  background: var(--rule);
}
/* 落款：列末（左）· 地脚（下）· 下来钤印。
   与竖排正文同处 flex 流（整组一起居中）；竖排正文超宽时由
   renderHero 的宽度适配缩放正文，落款永不挤压正文、不重叠 */
.colophon {
  align-self: flex-end;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-bottom: 2px;
  flex: 0 0 auto;
}
/* 落款小字：单字栈竖排（.vs），绕开 WebKit 行盒画偏；列居中，字距同题签 */
.colophon-src {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--kai);
  font-size: var(--fs-sm);
  line-height: 1;
  letter-spacing: 0;
  color: var(--ink-2);
}
.colophon-src .vs {
  display: block;
  width: 1em;
  height: 1em;
  line-height: 1;
  text-align: center;
}
.colophon-src .vs + .vs { margin-top: 0.34em; }

.seal {
  width: 40px; height: 40px;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(162, 59, 46, 0.28));
}

/* 题名：版框之下，居中 */
.daily-title {
  margin-top: var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-family: var(--kai);
  font-size: var(--fs-md);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--ink-2);
}
.daily-title::before,
.daily-title::after {
  content: "";
  width: 5px; height: 5px;
  background: var(--ink-2);
  opacity: 0.5;
  transform: rotate(45deg);
  flex: 0 0 auto;
}

/* 横排原文（长文 ≥150 字）：同版框，读文页式 */
.orig-h {
  font-size: var(--fs-lg);
  line-height: 2.15;
  color: var(--ink-strong);
}
.orig-h p { text-indent: 2em; white-space: pre-wrap; }
.orig-h p + p { margin-top: var(--sp-1); }
.panel-colophon {
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: var(--fs-sm);
  letter-spacing: 0.22em;
  color: var(--ink-2);
}
.panel-colophon .seal { width: 34px; height: 34px; }

/* ==========================================================================
   六件套
   ========================================================================== */

/* 白话：说话分段 */
.baihua p {
  text-indent: 2em;
  white-space: pre-wrap;
  color: var(--ink);
}
.baihua p + p { margin-top: var(--sp-1); }

/* 注释：词条式（词 600 · 释 次色），不用点线 */
.notes-list { list-style: none; }
.notes-list li {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 11px 0;
  font-size: var(--fs-md);
  line-height: 1.95;
}
.notes-list li + li { border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.notes-list .n-term {
  flex: 0 0 auto;
  min-width: 4.5em;
  font-weight: 600;
  color: var(--ink-strong);
  letter-spacing: 0.04em;
}
.notes-list .n-note { flex: 1; color: var(--ink-2); min-width: 0; }

/* 心解：朱批 —— 楷体另立一格，左朱线（批语语义） */
.xinxin-block {
  position: relative;
  border-left: 1.5px solid var(--ink-3);
  padding: 2px 0 2px var(--sp-3);
}
.xinxin-text {
  font-family: var(--kai);
  font-size: var(--fs-base);
  line-height: 2.1;
  color: var(--ink);
  text-indent: 2em;
  white-space: pre-wrap;
}

/* ==========================================================================
   操作条
   ========================================================================== */
.actions {
  margin-top: var(--sp-5);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
/* 操作条按钮：固定宽度，状态文字切换（标记已读↔已读 / 收藏↔已藏）宽度恒定 */
.actions .btn {
  width: 120px;
  justify-content: center;
  white-space: nowrap;
  text-align: center;
}
.actions .btn-primary { width: 128px; }

/* ==========================================================================
   日签弹层
   ========================================================================== */
.overlay {
  position: fixed; inset: 0;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: var(--sp-3);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--ease), visibility 0.28s;
}
.overlay.open { visibility: visible; opacity: 1; pointer-events: auto; }

.overlay-inner {
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: var(--sp-3);
  max-height: 94vh;
  overflow: auto;
  text-align: center;
  box-shadow: var(--shadow-pop);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.3s var(--ease), background-color 0.4s var(--ease);
}
.overlay.open .overlay-inner { transform: none; }

.overlay-inner canvas {
  display: block;
  max-width: min(72vw, 380px);
  height: auto;
  box-shadow: 0 6px 30px rgba(43, 43, 43, 0.22);
}

.overlay-actions {
  margin-top: var(--sp-3);
  display: flex;
  gap: var(--sp-2);
  justify-content: center;
}
.overlay-actions .btn { padding: 11px 22px; font-size: var(--fs-sm); }

/* ==========================================================================
   书房 · 页头（书脊）
   ========================================================================== */
main.wide-page { max-width: var(--wide); }

.study-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: var(--sp-4);
}
.study-head .sh-name {
  font-family: var(--kai);
  font-size: var(--fs-xl);
  letter-spacing: 0.3em;
  color: var(--ink-strong);
  white-space: nowrap;
}
.study-head .sh-meta {
  margin-left: auto;
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  color: var(--ink-3);
  text-align: right;
  line-height: 1.9;
}

/* 书脊：古书函套式竖签 —— 等高、同宽，如架上三部旧书 */
.shelf {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: var(--sp-4);
  padding: var(--sp-2) 0 var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.spine {
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 1px 1px 3px 3px;
  background:
    linear-gradient(to bottom,
      color-mix(in srgb, var(--paper-3) 70%, transparent) 0 6px,
      transparent 6px calc(100% - 6px),
      color-mix(in srgb, var(--paper-3) 70%, transparent) calc(100% - 6px));
  cursor: pointer;
  /* 书名 = 单字栈（.spine-label flex column 竖叠），不用 writing-mode ——
     绕开 WebKit 竖排字面画偏（横向不居中的根因） */
  font-family: var(--kai);
  font-size: var(--fs-xl);
  color: var(--ink-2);
  width: 64px;
  height: 168px;                 /* 三签等高：题签式 */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--frame) 30%, transparent),
              0 4px 12px rgba(43, 40, 35, 0.12);
  transition: color 0.25s var(--ease), background-color 0.3s var(--ease),
              border-color 0.3s var(--ease), transform 0.25s var(--ease),
              box-shadow 0.3s var(--ease);
}
/* 书脊单字栈：逐字竖叠、逐字居中（普通流，双引擎一致） */
.spine-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  letter-spacing: 0;
}
.spine-label .vs {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  line-height: 1;
  text-align: center;
  flex: 0 0 auto;
}
.spine-label .vs + .vs { margin-top: 0.34em; }   /* 字距与题签同式 */
/* 签面夹线：上下两道细线，如题签纸的两道眉线 */
.spine::before,
.spine::after {
  content: "";
  position: absolute;
  left: 50%; right: 50%;
  height: 1px;
  margin-left: -13px; margin-right: -13px;
  background: var(--line);
}
.spine::before { top: 17px; }
.spine::after { bottom: 17px; }
.spine:hover {
  color: var(--ink-strong);
  transform: translateY(-4px);
  box-shadow: 0 10px 22px rgba(43, 40, 35, 0.18);
}
.spine.active {
  background:
    linear-gradient(to bottom,
      color-mix(in srgb, var(--ink-strong) 96%, var(--paper-3)) 0 6px,
      var(--ink-strong) 6px calc(100% - 6px),
      color-mix(in srgb, var(--ink-strong) 96%, var(--paper-3)) calc(100% - 6px));
  border-color: var(--ink-strong);
  color: var(--paper);
  box-shadow: 0 8px 24px rgba(35, 33, 29, 0.28);
}
.spine.active::before,
.spine.active::after { background: rgba(246, 241, 231, 0.4); }

/* 卷签 */
.volume-tabs {
  margin-top: var(--sp-4);
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: var(--sp-4);
}
.volume-tabs button {
  background: none; border: none; cursor: pointer;
  font-family: var(--serif);
  font-size: var(--fs-md);
  color: var(--ink-2);
  letter-spacing: 0.18em;
  padding: 4px 2px;
  border-bottom: 1px solid transparent;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.volume-tabs button:hover { color: var(--ink-strong); }
.volume-tabs button.active { color: var(--ink-strong); border-bottom-color: var(--ink-2); }
.volume-tabs .vt-count {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  letter-spacing: 0.1em;
  margin-left: 6px;
}

.volume-note {
  margin-top: var(--sp-2);
  text-align: center;
  font-size: var(--fs-xs);
  letter-spacing: 0.28em;
  color: var(--ink-3);
}

/* ==========================================================================
   书房 · 目录（节折叠 + 条目行）
   ========================================================================== */
.vol-group { margin-top: var(--sp-4); }

.sec-head {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 12px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  padding: 14px 2px;
  font-family: var(--serif);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ink-strong);
  text-align: left;
  transition: color 0.25s var(--ease);
}
.sec-head:hover { color: var(--ink-strong); }
.sec-head .sec-count {
  font-weight: 400;
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  color: var(--ink-3);
}

/* 折叠指示：细 chevron */
.sec-tick {
  margin-left: auto;
  align-self: center;
  width: 8px; height: 8px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(45deg);
  transition: transform 0.35s var(--ease);
}
.vol-group.open .sec-tick { transform: rotate(-135deg); }

.fold {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.4s var(--ease);
}
.fold > .fold-inner { overflow: hidden; min-height: 0; }
.vol-group:not(.open) .fold { grid-template-rows: 0fr; }

/* 条目行：目录式 */
.row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: 14px 6px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 62%, transparent);
  cursor: pointer;
  position: relative;
  transition: background-color 0.25s var(--ease);
}
.row:hover { background: color-mix(in srgb, var(--paper-3) 66%, transparent); }
.row::before {
  content: "";
  position: absolute;
  left: 0; top: 22%;
  bottom: 22%;
  width: 2px;
  background: var(--ink-3);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}
.row:hover::before { opacity: 1; }

.row-no {
  flex: 0 0 72px;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
.row-tx {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-md);
  color: var(--ink);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.row-tags { flex: 0 0 auto; display: flex; gap: 10px; align-items: center; }

/* 墨字「注译」：该条备有白话注释心解（印记语言，不用徽章框） */
.mark-full {
  font-family: var(--kai);
  font-size: var(--fs-xs);
  letter-spacing: 0.22em;
  color: var(--ink-2);
}
.mark-dot { width: 6px; height: 6px; border-radius: 50%; }
.mark-dot.read { background: var(--ink-3); }
.mark-dot.fav { background: var(--cinnabar); }   /* 朱砂：收藏印记 */

/* ==========================================================================
   详情
   ========================================================================== */
.crumb {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  font-size: var(--fs-sm);
  letter-spacing: 0.1em;
  color: var(--ink-2);
  margin-bottom: var(--sp-4);
}
.crumb a { transition: color 0.25s var(--ease); }
.crumb a:hover { color: var(--ink-strong); }
.crumb .sep { color: var(--ink-3); }
.crumb .here { color: var(--ink-strong); }

.detail-empty {
  margin-top: var(--sp-5);
  text-align: center;
  color: var(--ink-3);
  font-size: var(--fs-sm);
  letter-spacing: 0.18em;
  line-height: 2.2;
}

.detail-nav {
  margin-top: var(--sp-6);
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  border-top: 1px solid var(--line);
  padding-top: var(--sp-3);
  font-size: var(--fs-md);
}
.detail-nav a {
  max-width: 46%;
  transition: color 0.25s var(--ease);
}
.detail-nav a:hover { color: var(--ink-strong); }
.detail-nav .nav-label {
  display: block;
  font-size: var(--fs-xs);
  letter-spacing: 0.28em;
  color: var(--ink-3);
  margin-bottom: 2px;
}
.detail-nav .nav-next { margin-left: auto; text-align: right; }

/* ==========================================================================
   关于
   ========================================================================== */
.about-mast {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-5);
}
/* 题签式版框：窄框居中，竖排题字 + 句下钤印，同轴一条气 */
.about-mast .panel {
  min-width: 0;
  width: fit-content;
  padding: 44px 60px 36px;
}
.about-mast .panel-body {
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.about-mast .vertical-original {
  font-size: 30px;
  line-height: 1;           /* 字栈行盒=字身框 */
  width: 1em;               /* 单字宽 */
  max-width: none;
  height: calc(4em + 3 * 0.34em);   /* 四字列 + 三处字距，撑满居中 */
  background: none;
  /* 纯标准盒模型：列栈（flex column）天然竖排、逐字居中，无 writing-mode */
  writing-mode: horizontal-tb;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
}
/* 题签竖排字：每个字一个 span（.vs），标准盒模型逐字居中，跨引擎一致 */
.about-mast .vertical-original .vs {
  display: block;
  width: 1em;
  height: 1em;
  line-height: 1;
  text-align: center;
  flex: 0 0 auto;
}
.about-mast .vertical-original .vs + .vs { margin-top: 0.34em; }
.about-mast .colophon { align-self: center; }
.about h2 { font-size: var(--fs-base); }

.about .block { margin-bottom: var(--sp-4); }
.about p { margin-bottom: var(--sp-2); font-size: var(--fs-base); text-align: justify; }
.about .fine { font-size: var(--fs-sm); color: var(--ink-2); }

/* ==========================================================================
   页脚
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--line);
}
.site-footer .shell {
  padding-top: var(--sp-4);
  padding-bottom: var(--sp-5);
  text-align: center;
  font-size: var(--fs-xs);
  letter-spacing: 0.32em;
  color: var(--ink-3);
}
.foot-seal {   /* 整页收束：印落页脚中轴 */
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.foot-seal .seal { width: 34px; height: 34px; }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 760px) {
  :root {
    --v-size: 19px;
    --v-lh: 1.8;
    --v-h: 64vh;
  }
  html[data-fs="lg"] { --v-size: 21px; --v-h: 68vh; }

  .header-in { flex-wrap: wrap; row-gap: 2px; padding-top: 12px; padding-bottom: 10px; }
  .brand { font-size: var(--fs-lg); gap: 9px; }
  .nav { gap: var(--sp-2); margin-left: 0; order: 3; width: 100%; justify-content: flex-start; font-size: var(--fs-sm); }
  .tools { margin-left: auto; padding-left: var(--sp-2); }

  main { padding-top: var(--sp-4); }

  .daily-head { flex-wrap: wrap; gap: 6px 14px; margin-bottom: var(--sp-3); }
  .daily-head .dh-name { font-size: var(--fs-lg); }
  .daily-head .dh-meta { margin-left: 0; width: 100%; text-align: left; display: flex; gap: 12px; align-items: baseline; }

  .panel { padding: 30px 20px 24px; }
  .panel-body { gap: var(--sp-2); }
  .seal { width: 32px; height: 32px; }
  .colophon { gap: 10px; }
  .colophon-src { font-size: var(--fs-xs); }

  .sec-label { margin: var(--sp-4) 0 var(--sp-2); }

  .actions { margin-top: var(--sp-4); gap: 10px; }
  .actions .btn { padding: 11px 16px; font-size: var(--fs-sm); flex: 1 1 auto; }

  .study-head { flex-wrap: wrap; gap: 4px 14px; }
  .shelf { gap: var(--sp-2); padding-bottom: var(--sp-3); }
  .spine { font-size: var(--fs-lg); width: 52px; height: 136px; }
  .spine::before, .spine::after { margin-left: -11px; margin-right: -11px; }
  .volume-tabs { gap: var(--sp-3); flex-wrap: nowrap; }
  .volume-tabs button { white-space: nowrap; }
  .volume-tabs .vt-count { display: none; }   /* 移动端藏计数（总条数在下方卷注），三卷签保一横排 */

  .row { padding: 12px 4px; }
  .row-no { flex-basis: 58px; }
  .row-tags .mark-full { letter-spacing: 0.14em; }

  .detail-nav { margin-top: var(--sp-5); }
  .detail-nav a { max-width: 48%; }
}

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