/* ============================================================
   《来自新世界》知识点手册 — 共享视觉系统
   设计基调：结界与虫鸣 Kekkai to Mushi-no-ne
   靛夜蓝 · 苔藓绿 · 稻穗米 · 呪力橙 · 灰烬红 · 墨灰
   ============================================================ */

:root {
  /* ---- 色板 ---- */
  --ink-night: #1b2a3a;       /* 靛夜蓝：背景基调，八丁标结界之夜 */
  --ink-night-deep: #131f2b;  /* 更深一阶，用于渐变收口 */
  --moss: #4c6b4f;            /* 苔藓绿：自然村落、水田 */
  --moss-soft: #6b8a6a;
  --rice: #e8dcc0;            /* 稻穗米：纸张底色，替代纯白 */
  --rice-deep: #d9c9a3;
  --jugen-orange: #d97a3d;    /* 呪力橙：强调色，发动光效 */
  --jugen-orange-soft: #eba169;
  --ember-red: #8c2f2f;       /* 灰烬红：恶鬼 / 业魔 / 战争 */
  --sumi: #3a3a38;            /* 墨灰：正文文字，替代纯黑 */
  --paper: #f3ecd8;           /* 卡片纸面，比 rice 略亮 */
  --paper-shadow: rgba(27, 42, 58, 0.18);
  --line-soft: rgba(58, 58, 56, 0.14);

  /* ---- 字体 ---- */
  --font-display: "Noto Serif SC", "Source Han Serif SC", serif;
  --font-body: "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "Sarasa Mono SC", monospace;

  /* ---- 布局节奏 ---- */
  --radius-outer: 22px;
  --radius-inner: 14px;
  --radius-pill: 999px;
  --shadow-card:
    0 1px 2px rgba(19, 31, 43, 0.14),
    0 8px 24px rgba(19, 31, 43, 0.22),
    0 24px 48px rgba(19, 31, 43, 0.12);
  --shadow-card-hover:
    0 2px 4px rgba(19, 31, 43, 0.2),
    0 14px 32px rgba(19, 31, 43, 0.28),
    0 32px 64px rgba(19, 31, 43, 0.16);
  --max-width: 1180px;
}

* { box-sizing: border-box; }

/* 仅供屏幕阅读器读取、视觉上完全隐藏但不影响布局的工具类。
   用于给 ECharts（Canvas 渲染，无障碍树默认为空）等图表补充
   文字版数据摘要，让视障读者也能获取图表传达的信息。 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 跳到正文（Skip Link）：默认视觉隐藏，用与 .sr-only 相同的裁剪
   手法（而非 display:none，后者会让键盘用户完全 Tab 不到它）；
   一旦获得键盘焦点立即在视口左上角弹出为醒目按钮。*/
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link:focus-visible {
  position: fixed;
  top: 12px;
  left: 12px;
  width: auto;
  height: auto;
  margin: 0;
  padding: 12px 20px;
  clip: auto;
  overflow: visible;
  white-space: normal;
  background: var(--jugen-orange);
  color: var(--ink-night-deep);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  border-radius: var(--radius-inner);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 200;
  text-decoration: none;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--sumi);
  background: var(--rice);
  line-height: 1.75;
  font-size: 16px;
  overflow-x: hidden;
}

::selection {
  background: var(--jugen-orange);
  color: var(--ink-night-deep);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink-night);
  margin: 0 0 0.5em;
  text-wrap: balance;
  letter-spacing: 0.01em;
}

p { text-wrap: pretty; }

a { color: inherit; }

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--jugen-orange);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Tab 停靠点：知识卡片(.kcard)、图表(.chart-frame)、人物卡(.person-card)、
   术语条目(.glossary-item)、信息表格(table.info-table)、提示框(.callout)
   以及每个 section.block 本身，都会在 initPageTOC() 中被标记为
   .tab-anchor 并获得 tabindex="0"——容器整体可以被连续 Tab 遍历到，
   而不是只能 Tab 到容器内部的某个小标题（早期方案的问题：图表只能
   停在一行说明文字上、人物卡只能停在人名上，表格/提示框完全无法
   Tab 到）。
   scroll-margin-top 的对齐参照物统一是"容器自身"（而不是内部的
   标题元素）——这里的偏移量必须与 script.js 里 focusin 监听补的
   scrollIntoView 精确一致（84px），否则"点击链接跳转"与"连续按 Tab"
   两条路径的停靠位置会出现偏差。之所以不用内部标题做参照：像
   .person-card 的标题（人名）前面还有一行"阵营/身份"徽标，若把
   标题顶到可视区顶部，这行徽标会被向上推出、被顶栏遮住一截——
   用容器自身对齐，容器完整的顶部内边距会保留在顶栏下方，不会有
   任何内容被遮挡。*/
.tab-anchor {
  scroll-margin-top: 84px;
  outline-offset: 6px;
}

.font-mono, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   顶部导航
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px) saturate(140%);
  background: rgba(19, 31, 43, 0.92);
  border-bottom: 1px solid rgba(232, 220, 192, 0.14);
}

.nav-wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--rice);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  flex: none;
}

.brand .brand-glyph {
  width: 28px;
  height: 28px;
  flex: none;
}

.brand small {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: var(--jugen-orange-soft);
  text-transform: uppercase;
}

/* ---- 桌面导航：正卷(六部)下拉 + 前传/辅助页平铺 ---- */

.nav-primary {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.nav-primary a,
.nav-chapters-toggle {
  flex: none;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: rgba(232, 220, 192, 0.82);
  text-decoration: none;
  white-space: nowrap;
  transition-property: background-color, color;
  transition-duration: 0.2s;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-primary a:hover,
.nav-primary a.active,
.nav-chapters-toggle:hover,
.nav-chapters-toggle.active {
  background: rgba(217, 122, 61, 0.18);
  color: var(--jugen-orange-soft);
}

.nav-chapters-toggle .chev {
  width: 9px;
  height: 9px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s;
}
.nav-chapters-toggle[aria-expanded="true"] .chev {
  transform: rotate(-135deg) translateY(1px);
}

.nav-chapters-wrap {
  position: relative;
  flex: none;
}

.nav-chapters-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 300px;
  background: var(--ink-night-deep);
  border: 1px solid rgba(232, 220, 192, 0.16);
  border-radius: var(--radius-inner);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  padding: 8px;
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  z-index: 120;
}
.nav-chapters-menu.open { display: grid; }

.nav-chapters-menu a {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: rgba(232, 220, 192, 0.85);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 44px;
  justify-content: center;
}
.nav-chapters-menu a .chap-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--jugen-orange-soft);
  letter-spacing: 0.06em;
}
.nav-chapters-menu a:hover,
.nav-chapters-menu a.active {
  background: rgba(217, 122, 61, 0.18);
  color: var(--jugen-orange-soft);
}
.nav-chapters-menu a.active .chap-num { color: var(--jugen-orange-soft); }

/* ---- 移动端汉堡菜单 ---- */

.nav-burger {
  display: none;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(232, 220, 192, 0.24);
  background: rgba(232, 220, 192, 0.06);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 3px;
  flex-direction: column;
}
.nav-burger span {
  display: block;
  width: 18px;
  height: 1.6px;
  background: var(--rice);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

.nav-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(19, 31, 43, 0.4);
  z-index: 108;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.nav-drawer-overlay.open { opacity: 1; pointer-events: auto; }

.nav-drawer {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  max-height: calc(100vh - 64px - 24px);
  background: var(--ink-night-deep);
  border-radius: 0 0 var(--radius-outer) var(--radius-outer);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.38);
  z-index: 110;
  overflow-y: auto;
  padding: 16px;
}
.nav-drawer.open { display: block; }

.nav-drawer-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(232, 220, 192, 0.5);
  margin: 18px 4px 8px;
}
.nav-drawer-label:first-child { margin-top: 4px; }

/* 卷册网格：按宽度在 2 栏与 3 栏（正卷组）/ 2 栏与 4 栏（辅助阅读组）间自动切换 */
.nav-drawer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.nav-drawer-grid a {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  font-size: 14px;
  color: rgba(232, 220, 192, 0.88);
  text-decoration: none;
  border-radius: var(--radius-inner);
  background: rgba(232, 220, 192, 0.05);
  min-height: 52px;
  justify-content: center;
}
.nav-drawer-grid a .chap-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--jugen-orange-soft);
  letter-spacing: 0.06em;
}
.nav-drawer-grid a.active,
.nav-drawer-grid a:active {
  background: rgba(217, 122, 61, 0.18);
  color: var(--jugen-orange-soft);
}

/* 正卷组(3列)每列所需宽度更窄，可以更早从2列切到3列；
   辅助阅读组(4列)每列更窄小，但总列数更多，需要更宽的视口才切到4列 */
@media (min-width: 420px) {
  .nav-drawer-grid.chapters-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 560px) {
  .nav-drawer-grid.others-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 860px) {
  .nav-primary { display: none; }
  .nav-burger { display: inline-flex; }
}

/* ============================================================
   Hero
   ============================================================ */

.hero {
  max-width: none;
  width: 100%;
  color: var(--rice);
  position: relative;
  background:
    radial-gradient(1200px 800px at 12% -10%, rgba(76, 107, 79, 0.35), transparent 60%),
    radial-gradient(900px 700px at 100% 0%, rgba(217, 122, 61, 0.14), transparent 55%),
    linear-gradient(180deg, var(--ink-night) 0%, var(--ink-night-deep) 100%);
}

.hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 32px;
  position: relative;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--jugen-orange-soft);
  border: 1px solid rgba(217, 122, 61, 0.4);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  margin-bottom: 22px;
}

.hero-eyebrow .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--jugen-orange);
  box-shadow: 0 0 8px 2px rgba(217, 122, 61, 0.7);
}

.hero h1 {
  color: var(--rice);
  font-size: clamp(32px, 5.4vw, 56px);
  line-height: 1.16;
  max-width: 20ch;
}

.hero .hero-sub {
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: rgba(232, 220, 192, 0.74);
  font-family: var(--font-mono);
  margin-top: -4px;
}

.hero p.lede {
  max-width: 860px;
  font-size: 17px;
  color: rgba(232, 220, 192, 0.86);
  margin-top: 18px;
}

.hero-note {
  margin-top: 22px;
  max-width: 860px;
  font-size: 13.5px;
  color: rgba(232, 220, 192, 0.78);
  border-left: 2px solid rgba(217, 122, 61, 0.5);
  padding-left: 14px;
}

/* ---- 数据仪表盘卡 ---- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 36px;
  max-width: 720px;
}

.stat-card {
  background: rgba(232, 220, 192, 0.06);
  border: 1px solid rgba(232, 220, 192, 0.14);
  border-radius: var(--radius-inner);
  padding: 14px 16px;
}

.stat-card .stat-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 700;
  color: var(--jugen-orange-soft);
  line-height: 1;
}

.stat-card .stat-label {
  margin-top: 6px;
  font-size: 11.5px;
  color: rgba(232, 220, 192, 0.76);
  letter-spacing: 0.04em;
}

/* ============================================================
   主内容区
   ============================================================ */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 8px 24px 100px;
  position: relative;
}

section.block { margin-top: 48px; scroll-margin-top: 84px; }
section.block:first-child { margin-top: 32px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--moss);
  background: rgba(76, 107, 79, 0.12);
  border: 1px solid rgba(76, 107, 79, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.section-head h2 { font-size: clamp(22px, 3vw, 30px); margin: 0; }

.section-desc {
  max-width: 900px;
  color: rgba(58, 58, 56, 0.78);
  margin-bottom: 32px;
  font-size: 15px;
}

/* ============================================================
   知识卡片组件（三栏对照）
   ============================================================ */

.kcard {
  position: relative;
  scroll-margin-top: 84px;
  background: var(--paper);
  border-radius: var(--radius-outer);
  box-shadow: var(--shadow-card);
  padding: 28px 28px 28px 34px;
  margin-bottom: 28px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px);
  /* visibility 而非仅靠 opacity 隐藏：opacity:0 的元素在视觉上
     完全不可见，但内部的链接/按钮默认仍可被 Tab 键聚焦到——纯键盘
     用户会遇到一串"选中了却看不见跳到哪"的幽灵焦点。visibility
     天然会把整个子树排除出 Tab 顺序，且可以配合 transition-delay
     让它在淡入开始的瞬间才切回 visible，不影响原有的渐显视觉效果。*/
  visibility: hidden;
  transition: opacity 0.5s cubic-bezier(0.2, 0, 0, 1), transform 0.5s cubic-bezier(0.2, 0, 0, 1), visibility 0s linear 0.5s;
}

.kcard.in-view {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  transition: opacity 0.5s cubic-bezier(0.2, 0, 0, 1), transform 0.5s cubic-bezier(0.2, 0, 0, 1), visibility 0s linear 0s;
}
/* 作为锚点跳转目标时，跳过渐现过渡动画直接以最终视觉态出现：
   若仍保留 0.5s 的 transition，浏览器锚点定位会在过渡播放中途完成，
   随后卡片继续缓慢移动到最终位置，导致视觉落点比 scroll-margin-top
   设定的间距少了一段“过渡尚未播完的位移量”。 */
.kcard:target {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  transition: none;
}

/* 呪力刻度尺：signature 装饰竖线，模拟注连绳纸垂 */
.kcard::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  background: repeating-linear-gradient(
    180deg,
    var(--jugen-orange) 0px,
    var(--jugen-orange) 10px,
    var(--rice-deep) 10px,
    var(--rice-deep) 18px
  );
}

.kcard[data-accent="science"]::before { background: repeating-linear-gradient(180deg, var(--moss) 0px, var(--moss) 10px, var(--rice-deep) 10px, var(--rice-deep) 18px); }
.kcard[data-accent="history"]::before { background: repeating-linear-gradient(180deg, var(--jugen-orange) 0px, var(--jugen-orange) 10px, var(--rice-deep) 10px, var(--rice-deep) 18px); }
.kcard[data-accent="danger"]::before { background: repeating-linear-gradient(180deg, var(--ember-red) 0px, var(--ember-red) 10px, var(--rice-deep) 10px, var(--rice-deep) 18px); }

/* .kcard 设有 overflow:hidden（用于裁出左侧呪力刻度尺的圆角），
   这会导致标准 outline 描边被一并裁掉、锚点跳转到此处时视觉上
   看不到任何焦点指示。改用 box-shadow 模拟一圈"外描边"——
   box-shadow 渲染在元素自身的层叠层，不受 overflow:hidden 影响，
   可以在裁切边界之外正常显示。
   同样的裁切问题也存在于 table.info-table（overflow:hidden，用于
   裁出圆角表头）、以及部分 .chart-frame（含 Mermaid 图的版本设有
   overflow:hidden 以处理横向滚动淡出遮罩）——统一用 box-shadow
   处理这几类"整卡片/整表格/整图表"级别的 Tab 容器，比逐个判断
   是否 overflow:hidden 更省心也更不容易遗漏。*/
.kcard:focus-visible,
.chart-frame:focus-visible,
table.info-table:focus-visible {
  outline: none;
  box-shadow: var(--shadow-card), 0 0 0 3px var(--jugen-orange);
}

/* .person-card / .glossary-item / .callout 均无 overflow:hidden，
   标准 outline 描边可以正常显示，沿用页面通用的
   a:focus-visible/button:focus-visible/[tabindex]:focus-visible 规则
   即可，此处仅按各自的圆角做一点描边贴合度微调。*/
.person-card:focus-visible,
.glossary-item:focus-visible,
.callout:focus-visible {
  outline-offset: 2px;
}

.kcard-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.kcard-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--moss);
  letter-spacing: 0.08em;
}

.kcard-head h3 {
  font-size: 22px;
  margin: 2px 0 2px;
}

.kcard-jp {
  font-size: 13px;
  color: rgba(58, 58, 56, 0.68);
  font-style: normal;
}

.kcard-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 18px;
}

.pill {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(27, 42, 58, 0.08);
  color: var(--ink-night);
  white-space: nowrap;
  border: 1px solid rgba(27, 42, 58, 0.12);
}
.pill.tag-science { background: rgba(76, 107, 79, 0.14); border-color: rgba(76, 107, 79, 0.3); color: #2f4a32; }
.pill.tag-culture { background: rgba(217, 122, 61, 0.16); border-color: rgba(217, 122, 61, 0.35); color: #7a4620; }
.pill.tag-danger  { background: rgba(140, 47, 47, 0.14); border-color: rgba(140, 47, 47, 0.32); color: #6c2222; }

.kcard-lede {
  font-size: 15px;
  color: var(--sumi);
  margin-bottom: 20px;
}

.tri-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 860px) {
  .tri-grid { grid-template-columns: 1fr; }
}

.tri-col {
  background: rgba(27, 42, 58, 0.035);
  border-radius: var(--radius-inner);
  padding: 16px 16px 18px;
  border: 1px solid var(--line-soft);
}

.tri-col h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tri-col.fiction h4 { color: var(--ink-night); }
.tri-col.science h4 { color: #2f4a32; }
.tri-col.culture h4 { color: #7a4620; }

.tri-col p { font-size: 13.6px; margin: 0 0 8px; color: rgba(58, 58, 56, 0.9); }
.tri-col p:last-child { margin-bottom: 0; }

.kcard-quote {
  margin-top: 18px;
  padding: 14px 18px;
  border-left: 3px solid var(--jugen-orange);
  background: rgba(217, 122, 61, 0.06);
  font-size: 13.6px;
  border-radius: 0 var(--radius-inner) var(--radius-inner) 0;
}
.kcard-quote cite {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 12px;
  color: rgba(58, 58, 56, 0.72);
}

.kcard-links {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.kcard-links a {
  font-size: 12.5px;
  text-decoration: none;
  color: var(--ink-night);
  background: rgba(27, 42, 58, 0.06);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  transition: background-color 0.15s;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
}
.kcard-links a:hover { background: rgba(217, 122, 61, 0.18); }

/* ============================================================
   通用组件：图表容器 / 时间线 / 表格 / 引言块
   ============================================================ */

.chart-frame {
  scroll-margin-top: 84px;
  background: var(--paper);
  border-radius: var(--radius-outer);
  box-shadow: var(--shadow-card);
  padding: 22px;
  margin-bottom: 28px;
}
.chart-frame .chart-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--moss);
  margin-bottom: 14px;
  text-transform: uppercase;
}
.chart-canvas { width: 100%; min-height: 320px; }

/* Mermaid：按图表自然尺寸渲染并居中，超出容器宽度时横向滚动，
   不强制压缩到容器宽度以内（避免文字缩到不可读） */
.chart-frame:has(.mermaid-canvas) {
  position: relative;
  overflow: hidden;
}
.mermaid-canvas {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 122, 61, 0.5) transparent;
}
.mermaid-canvas::-webkit-scrollbar { height: 8px; }
.mermaid-canvas::-webkit-scrollbar-thumb {
  background: rgba(217, 122, 61, 0.45);
  border-radius: 4px;
}
.mermaid-canvas::-webkit-scrollbar-track { background: transparent; }

.mermaid-canvas svg {
  display: block;
  max-width: none !important;
  height: auto !important;
}
.mermaid-canvas .mermaid {
  display: table;
  margin: 0 auto;
}

/* 图表溢出时，两侧加淡出渐变提示可横向滚动 */
.chart-frame.mermaid-scrollable::before,
.chart-frame.mermaid-scrollable::after {
  content: "";
  position: absolute;
  top: 52px;
  bottom: 18px;
  width: 32px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s;
}
.chart-frame.mermaid-scrollable::before {
  left: 0;
  background: linear-gradient(90deg, var(--paper), transparent);
}
.chart-frame.mermaid-scrollable::after {
  right: 0;
  background: linear-gradient(270deg, var(--paper), transparent);
}
.chart-frame.mermaid-scrollable.at-start::after { opacity: 1; }
.chart-frame.mermaid-scrollable.at-end::before { opacity: 1; }
.chart-frame.mermaid-scrollable.mid::before,
.chart-frame.mermaid-scrollable.mid::after { opacity: 1; }

.callout {
  background: rgba(140, 47, 47, 0.07);
  border: 1px solid rgba(140, 47, 47, 0.24);
  border-radius: var(--radius-inner);
  padding: 16px 20px;
  font-size: 13.8px;
  margin: 24px 0;
}
.callout.info {
  background: rgba(76, 107, 79, 0.08);
  border-color: rgba(76, 107, 79, 0.26);
}
.callout strong { color: var(--ink-night); }

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-soft) 20%, var(--line-soft) 80%, transparent);
  margin: 8px 0;
  border: none;
}

table.info-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  border-radius: var(--radius-outer);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  font-size: 13.6px;
}
table.info-table th, table.info-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
}
table.info-table th {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(27, 42, 58, 0.05);
  color: var(--ink-night);
}
table.info-table tr:last-child td { border-bottom: none; }
table.info-table tr:hover td { background: rgba(217, 122, 61, 0.05); }

/* 人物卡片 */
.person-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.person-card {
  scroll-margin-top: 84px;
  background: var(--paper);
  border-radius: var(--radius-outer);
  box-shadow: var(--shadow-card);
  padding: 20px;
  transition: box-shadow 0.2s, transform 0.2s cubic-bezier(0.2, 0, 0, 1);
}
.person-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-3px); }
.person-card .p-role {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--jugen-orange);
  text-transform: uppercase;
}
.person-card h3 { font-size: 18px; margin: 6px 0 2px; }
.person-card .p-jp { font-size: 12px; color: rgba(58,58,56,0.66); margin-bottom: 10px; }
.person-card p { font-size: 13.4px; margin: 6px 0; }

/* 术语条目 */
.glossary-item {
  scroll-margin-top: 84px;
  background: var(--paper);
  border-radius: var(--radius-inner);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(19,31,43,0.08), 0 4px 12px rgba(19,31,43,0.08);
}
.glossary-item h3 {
  font-size: 16px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.glossary-item .g-jp { font-size: 12px; color: rgba(58,58,56,0.66); font-weight: 400; }
.glossary-item p { font-size: 13.6px; margin: 6px 0 0; }

/* ============================================================
   页脚 / 顶部按钮 / 目录页卡片
   ============================================================ */

footer.site-footer {
  background: var(--ink-night-deep);
  color: rgba(232, 220, 192, 0.62);
  padding: 40px 24px 60px;
  font-size: 12.6px;
  text-align: center;
}
footer.site-footer a { color: var(--jugen-orange-soft); text-decoration: none; }

/* ============================================================
   部卷翻页导航（正卷六册 + 前传，衔接连续阅读）
   ============================================================ */

.part-pager {
  margin-top: 48px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .part-pager { grid-template-columns: 1fr; }
}

.part-pager-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 24px;
  border-radius: var(--radius-outer);
  background: var(--paper);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: var(--sumi);
  transition: box-shadow 0.2s, transform 0.15s cubic-bezier(0.2,0,0,1);
}
.part-pager-item:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.part-pager-next { justify-content: flex-end; text-align: right; }
.part-pager-next .pp-text { align-items: flex-end; }

.pp-arrow {
  flex: none;
  font-size: 20px;
  color: var(--jugen-orange);
  font-family: var(--font-mono);
  line-height: 1.5;
}
.pp-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.pp-label {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(58,58,56,0.55);
  font-family: var(--font-mono);
}
.pp-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink-night);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.pp-desc {
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(58,58,56,0.68);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--jugen-orange);
  color: var(--ink-night-deep);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(217, 122, 61, 0.4);
  opacity: 0;
  pointer-events: none;
  /* 页面刚加载、尚未滚动过 480px 时按钮理应完全退出交互与 Tab
     顺序，而非只是视觉透明——同样用 visibility 兜底。 */
  visibility: hidden;
  transition: opacity 0.25s, transform 0.15s cubic-bezier(0.2,0,0,1), visibility 0s linear 0.25s;
  z-index: 90;
}
.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition: opacity 0.25s, transform 0.15s cubic-bezier(0.2,0,0,1), visibility 0s linear 0s;
}
.back-to-top:active { transform: scale(0.96); }

/* ============================================================
   页内大纲目录（自动生成，浮动面板）
   ============================================================ */

.toc-toggle {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 95;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px 0 14px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: var(--ink-night-deep);
  color: var(--rice);
  border: 1px solid rgba(232, 220, 192, 0.22);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  /* 默认视觉隐藏但仍保留在 Tab 顺序中（不用 display:none）：
     鼠标/触摸用户要滚动过一定距离才需要看到这个按钮，但纯键盘
     用户从页面顶部开始就应该能 Tab 到它——若一直等到 .visible
     才 display:inline-flex，键盘用户在没有滚轮/触摸的情况下永远
     无法把焦点移动到这里，"跳转到任意标题/卡片"的整条路径入口
     就被切断了。做法参考 .skip-link：默认透明且不可点击，一旦
     获得键盘焦点立即弹出可见，效果等同于一个"次要的跳转入口"。 */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.15s cubic-bezier(0.2,0,0,1), background-color 0.2s;
}
.toc-toggle.visible,
.toc-toggle:focus-visible {
  opacity: 1;
  pointer-events: auto;
}
.toc-toggle:hover { background: rgba(217, 122, 61, 0.22); }
.toc-toggle:active { transform: scale(0.96); }
.toc-toggle svg { width: 15px; height: 15px; flex: none; }

.toc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(19, 31, 43, 0.45);
  backdrop-filter: blur(2px);
  z-index: 106;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toc-overlay.open { opacity: 1; pointer-events: auto; }

.toc-panel {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 300px;
  max-width: 84vw;
  background: var(--paper);
  z-index: 107;
  box-shadow: 12px 0 36px rgba(0, 0, 0, 0.22);
  transform: translateX(-100%);
  /* 面板关闭时用 transform 移出视口，但 transform 不会像
     display:none 那样自动把内部元素排除出 Tab 顺序——关闭按钮、
     大纲链接此前在面板收起、肉眼完全看不到的情况下依然可以被
     Tab 键聚焦到。加入 visibility 并让它的切换比位移动画稍慢
     半拍：收起时立即隐藏、展开时动画播放完毕后才能被聚焦，
     两种方向都不会露出"看不见却能选中"的中间态。*/
  visibility: hidden;
  transition: transform 0.28s cubic-bezier(0.2, 0, 0, 1), visibility 0s linear 0.28s;
  display: flex;
  flex-direction: column;
}
.toc-panel.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.28s cubic-bezier(0.2, 0, 0, 1), visibility 0s linear 0s;
}

.toc-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.toc-panel-head h3 {
  margin: 0;
  font-size: 15px;
  color: var(--ink-night);
}
.toc-panel-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(27, 42, 58, 0.08);
  color: var(--ink-night);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}
.toc-panel-close:active { transform: scale(0.94); }

.toc-panel-list {
  overflow-y: auto;
  padding: 8px 10px 24px;
  flex: 1 1 auto;
}

.toc-h2 {
  display: block;
  padding: 10px 12px;
  margin-top: 4px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-night);
  text-decoration: none;
  line-height: 1.4;
}
.toc-h2:hover { background: rgba(217, 122, 61, 0.1); }
.toc-h2.active { background: rgba(217, 122, 61, 0.16); color: #7a4620; }

.toc-h3 {
  display: block;
  padding: 8px 12px 8px 26px;
  border-radius: 8px;
  font-size: 12.5px;
  color: rgba(58, 58, 56, 0.82);
  text-decoration: none;
  line-height: 1.4;
  position: relative;
}
.toc-h3::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--jugen-orange);
  opacity: 0.6;
  transform: translateY(-50%);
}
.toc-h3:hover { background: rgba(76, 107, 79, 0.1); }
.toc-h3.active { background: rgba(76, 107, 79, 0.14); color: #2f4a32; }

/* 部卷导航网格（用于总览页） */
.part-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.part-card {
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--sumi);
  background: var(--paper);
  border-radius: var(--radius-outer);
  box-shadow: var(--shadow-card);
  padding: 22px 22px 24px;
  transition: transform 0.2s cubic-bezier(0.2,0,0,1), box-shadow 0.2s;
  overflow: hidden;
}
.part-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-card-hover); }
.part-card .p-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--jugen-orange);
  letter-spacing: 0.1em;
}
.part-card h3 { font-size: 19px; margin: 8px 0 4px; }
.part-card .p-jp-title { font-size: 12.5px; color: rgba(58,58,56,0.66); margin-bottom: 10px; }
.part-card p.p-desc { font-size: 13.2px; color: rgba(58,58,56,0.8); margin-bottom: 12px; }
.part-card .p-tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* stagger animation helper */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  visibility: hidden;
  transition: opacity 0.55s cubic-bezier(0.2,0,0,1), transform 0.55s cubic-bezier(0.2,0,0,1), visibility 0s linear 0.55s;
}
.reveal.in-view { opacity: 1; transform: translateY(0); visibility: visible; transition: opacity 0.55s cubic-bezier(0.2,0,0,1), transform 0.55s cubic-bezier(0.2,0,0,1), visibility 0s linear 0s; }
.reveal:target { opacity: 1; transform: translateY(0); visibility: visible; transition: none; }

/* 响应式微调 */
@media (max-width: 640px) {
  .hero { padding: 44px 18px 36px; }
  main { padding: 8px 18px 80px; }
  .kcard { padding: 22px 18px 22px 24px; }
}

/* ============================================================
   打印样式
   目标：正文内容（知识卡片/图表/表格）完整可读，同时去掉纯屏幕
   交互元素与大面积深色背景，避免打印机耗费大量墨水/碳粉打出
   实心色块，也避免粘性导航栏在多页文档中反复出现。
   ============================================================ */
@media print {
  /* 纯交互控件，纸面上没有意义，一律不打印 */
  .nav-burger,
  .nav-drawer,
  .nav-drawer-overlay,
  .toc-toggle,
  .toc-panel,
  .toc-overlay,
  .back-to-top,
  .part-pager,
  .nav-chapters-menu {
    display: none !important;
  }

  /* 导航栏：脱离 sticky，改为随文档流出现一次，深色底改为浅色+
     底部细线，避免每一页顶部都重复出现一块深色横条 */
  .site-header {
    position: static;
    background: #fff;
    backdrop-filter: none;
    border-bottom: 1px solid #ccc;
  }
  .brand,
  .brand small {
    color: #1b2a3a !important;
  }
  .nav-primary { display: none !important; }

  /* Hero：深色渐变改为浅色+边框，文字改回深色正文色，
     避免整块背景被打印机渲染成实心黑块 */
  .hero {
    background: #fff !important;
    color: #1b2a3a !important;
    border-bottom: 1px solid #ccc;
  }
  .hero h1,
  .hero-eyebrow,
  .hero-sub,
  .hero-note,
  .lede,
  .lede strong {
    color: #1b2a3a !important;
  }
  .shimenawa-deco { display: none !important; }
  .stat-card {
    border: 1px solid #ccc;
    background: #fff !important;
  }
  .stat-card .stat-num,
  .stat-card .stat-label {
    color: #1b2a3a !important;
  }

  /* 页脚：深色底改为浅色，避免大片实心黑块收尾 */
  footer.site-footer {
    background: #fff !important;
    color: #3a3a38 !important;
    border-top: 1px solid #ccc;
  }
  footer.site-footer a { color: #3a3a38 !important; }

  /* 知识卡片/图表：始终保持最终可见态，不受渐现动画影响，
     阴影在纸面上没有意义，改为细边框以保留视觉分隔 */
  .kcard,
  .glossary-item,
  .person-card,
  .chart-frame,
  .reveal {
    opacity: 1 !important;
    transform: none !important;
    box-shadow: none !important;
    background: #fff !important;
    border: 1px solid #ddd;
  }

  /* Mermaid 图表在纸面上不需要横向滚动机制，超宽时允许自然换行显示 */
  .mermaid-canvas { overflow: visible !important; }
  .chart-frame.mermaid-scrollable::before,
  .chart-frame.mermaid-scrollable::after {
    display: none !important;
  }

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

  body { background: #fff !important; }
}
