/* ===========================================================================
   main.css — 学术排版样式系统
   调性参考：Cambridge University Press 网页版专著
   对齐 build.py 生成的标记（2026-07-31）。
    1. Tokens        2. Reset          3. Layout         4. Typography
    5. Sidebar/TOC   6. Front lists    7. Figures        8. Tables
    9. Lists/notes  10. Bibliography  11. Inline refs   12. Controls
   13. Responsive   14. Print
   =========================================================================== */

/* --- 1. Tokens ----------------------------------------------------------- */
:root {
  /* 字体 */
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
                Georgia, "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  /* 尺度 */
  --measure: 34em;            /* ≈ 68 字符行宽 */
  --wide: 52rem;              /* 图表允许超出正文行宽 */
  --sidebar-w: 17.5rem;
  --fs-base: 1.0625rem;       /* 17px */
  --lh-base: 1.72;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* 色彩：克制的暖灰纸面 + 剑桥深红作唯一强调色 */
  --paper: #fbfaf8;
  --paper-sunk: #f3f1ed;
  --ink: #1c1b19;
  --ink-soft: #4a4844;
  --ink-faint: #77746e;
  --rule: #ddd9d2;
  --rule-strong: #bfbab1;
  --accent: #8a1c26;
  --accent-soft: #f0e2e2;
  --highlight: #fbeeb8;

  /* 网络图阶段配色（与原文图 4.1 一致，第 4 轮 d3 图表沿用） */
  --stage-looting: #ffffff;
  --stage-market: #3d3d3d;
  --stage-both: #a8a8a8;
  --node-stroke: #2a2926;
  --edge: #b4b0a8;
}

/* --- 2. Reset ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
/* 本表多处用 display 覆盖了元素默认值，会盖掉浏览器给 [hidden] 的 display:none。
   统一在此兜底，避免 el.hidden = true 之后元素仍然可见。 */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 2rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; }
a { color: inherit; text-decoration-thickness: 0.5px; text-underline-offset: 2px; }
button { font: inherit; color: inherit; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper); padding: var(--space-3) var(--space-4);
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* --- 3. Layout ----------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: var(--space-16);
  max-width: 78rem;
  margin: 0 auto;
  padding: 0 var(--space-8);
}
.content { min-width: 0; padding: var(--space-16) 0; }
/* 行宽限制加在文字块上而不是容器上，这样图表可以插在段落之间并撑到更宽 */
.prose { max-width: none; }
.prose > p,
.prose > ul,
.prose > ol,
.prose > blockquote,
.prose > h3 { max-width: var(--measure); }

.masthead { border-bottom: 1px solid var(--rule); background: var(--paper); }
.masthead__inner { max-width: 78rem; margin: 0 auto; padding: var(--space-12) var(--space-8) var(--space-8); }
.masthead__eyebrow {
  font-family: var(--font-sans); font-size: 0.75rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-faint); margin: 0 0 var(--space-4);
}
.masthead__title {
  font-size: clamp(1.85rem, 4vw, 2.75rem); line-height: 1.18; font-weight: 500;
  margin: 0 0 var(--space-3); max-width: 22em; letter-spacing: -0.01em;
}
.masthead__subtitle {
  font-size: 1.05rem; color: var(--ink-soft); font-style: italic;
  margin: 0 0 var(--space-6); max-width: 40em;
}
.masthead__meta {
  font-family: var(--font-sans); font-size: 0.8125rem; color: var(--ink-faint);
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); margin: 0;
}
.masthead__meta dt { display: none; }
.masthead__meta dd { margin: 0; }

.colophon {
  border-top: 1px solid var(--rule); margin-top: var(--space-16);
  padding: var(--space-8); font-family: var(--font-sans); font-size: 0.8125rem;
  color: var(--ink-faint); text-align: center;
}

/* --- 4. Typography ------------------------------------------------------- */
.chapter { scroll-margin-top: var(--space-8); }
.chapter + .chapter { margin-top: var(--space-16); padding-top: var(--space-12); border-top: 1px solid var(--rule); }

.chapter__number {
  font-family: var(--font-sans); font-size: 0.75rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-faint); margin: 0 0 var(--space-2);
}
h1.chapter__title {
  font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 500; line-height: 1.24;
  margin: 0 0 var(--space-8); letter-spacing: -0.005em;
}
.section { scroll-margin-top: var(--space-8); margin-top: var(--space-12); }
h2.section__title { font-size: 1.25rem; font-weight: 500; line-height: 1.3; margin: 0 0 var(--space-4); }
h3 { font-size: 1.0625rem; font-weight: 600; margin: var(--space-8) 0 var(--space-3); }

p { margin: 0 0 var(--space-4); hyphens: auto; }

blockquote {
  margin: var(--space-6) 0; padding-left: var(--space-6);
  border-left: 2px solid var(--rule-strong); color: var(--ink-soft); font-size: 0.97em;
}

/* --- 5. Sidebar / TOC ---------------------------------------------------- */
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--space-16) 0 var(--space-8);
  font-family: var(--font-sans); font-size: 0.8125rem; line-height: 1.5;
  scrollbar-width: thin;
}
.toc__heading {
  font-size: 0.6875rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 var(--space-4);
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc__link {
  display: block; padding: 0.3rem 0 0.3rem 0.75rem; color: var(--ink-soft);
  text-decoration: none; border-left: 2px solid var(--rule);
  transition: color 0.12s, border-color 0.12s;
}
.toc__link:hover { color: var(--ink); border-left-color: var(--rule-strong); }
.toc__link.is-active { color: var(--accent); border-left-color: var(--accent); }
.toc__link--sub { padding-left: 1.5rem; font-size: 0.78125rem; color: var(--ink-faint); }
.toc__num { display: inline-block; min-width: 1.4em; color: var(--ink-faint); }
.toc__toggle { display: none; }

/* --- 6. Front lists (List of Tables / Figures) --------------------------- */
.frontlist { list-style: none; padding: 0; margin: 0; font-size: 0.9375rem; }
.frontlist li {
  display: flex; gap: var(--space-3); align-items: baseline;
  padding: var(--space-2) 0; border-bottom: 1px dotted var(--rule);
}
.frontlist a { text-decoration: none; }
.frontlist a:hover { color: var(--accent); }
.frontlist__label {
  font-family: var(--font-sans); font-size: 0.8125rem;
  color: var(--ink-faint); white-space: nowrap; min-width: 5.5em;
}
.frontlist__page { margin-left: auto; font-family: var(--font-sans); font-size: 0.8125rem; color: var(--ink-faint); }

/* --- 7. Figures ---------------------------------------------------------- */
.figure {
  margin: var(--space-12) 0;
  max-width: var(--wide);
  scroll-margin-top: var(--space-8);
}

/* 面板网格：data-panels 决定列数。1 张独占一行，3–4 张用网格。 */
.figure__panels {
  display: grid;
  gap: var(--space-3);
  align-items: start;
}
.figure__panels[data-panels="1"] { grid-template-columns: 1fr; }
.figure__panels[data-panels="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.figure__panels[data-panels="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.figure__panels[data-panels="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.figure__panels img {
  display: block; width: 100%; height: auto;
  background: #fff; border: 1px solid var(--rule); border-radius: 2px;
}
/* 单图不拉伸到超过原始尺寸，避免位图放大发虚 */
.figure__panels[data-panels="1"] img { width: auto; max-width: 100%; margin: 0 auto; }

.figure--static { /* 静态位图 */ }

/* 图 3.1 是纯黑线稿配白底。用 multiply 让白色融进纸色，
   不必修改图片文件；线条与文字保持全黑不受影响。 */
#figure-3-1 .figure__panels img {
  mix-blend-mode: multiply;
  background: transparent;
  border: none;
  border-radius: 0;
}

.figure__caption {
  font-family: var(--font-sans); font-size: 0.8125rem; line-height: 1.5;
  color: var(--ink-soft); margin-top: var(--space-3); max-width: 46rem;
}

/* 图例（跟在图 4.1 之后） */
.legend {
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  font-family: var(--font-sans); font-size: 0.75rem; color: var(--ink-soft);
  margin-top: var(--space-3);
}
.legend__swatch {
  display: inline-block; width: 0.7em; height: 0.7em;
  border: 1px solid var(--node-stroke); border-radius: 50%; margin-right: 0.4em;
}

/* --- 8. Tables ----------------------------------------------------------- */
.table-wrap {
  margin: var(--space-12) 0;
  max-width: var(--wide);
  scroll-margin-top: var(--space-8);
  overflow-x: auto;              /* 宽表在自己的容器里横向滚动，页面本身不横向滚动 */
  -webkit-overflow-scrolling: touch;
}
.table__caption {
  font-family: var(--font-sans); font-size: 0.8125rem; line-height: 1.5;
  color: var(--ink-soft); margin: 0 0 var(--space-3);
}
.table__caption .xref { font-weight: 600; color: var(--ink); border: none; }

.data-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-sans); font-size: 0.8125rem; line-height: 1.45;
  font-variant-numeric: tabular-nums lining-nums;
}
.data-table th, .data-table td {
  padding: var(--space-2) var(--space-3);
  text-align: right; vertical-align: top;
  border-bottom: 1px solid var(--rule);
}
.data-table th:first-child, .data-table td:first-child {
  text-align: left; min-width: 10em;
}
.data-table thead th {
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  font-weight: 600; color: var(--ink); white-space: nowrap;
}
.data-table thead th strong { font-weight: 600; }
.data-table tbody tr:hover { background: var(--paper-sunk); }
.data-table tbody tr:last-child td { border-bottom: 1px solid var(--rule-strong); }

/* 可排序表头（第 4 轮由 app.js 加上 data-sort / aria-sort） */
.data-table thead th[data-sort] { cursor: pointer; user-select: none; }
.data-table thead th[data-sort]::after { content: " ⇅"; color: var(--ink-faint); font-size: 0.85em; }
.data-table thead th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }
.data-table thead th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }

.table__note {
  font-family: var(--font-sans); font-size: 0.75rem; line-height: 1.5;
  color: var(--ink-faint); margin: var(--space-3) 0 0;
  max-width: 46rem;
}

/* --- 9. Lists and notes -------------------------------------------------- */
/* 假设清单（H1–H4） */
.hyp-list {
  list-style: none; margin: var(--space-6) 0; padding: 0 0 0 var(--space-6);
  border-left: 2px solid var(--rule-strong);
  max-width: var(--measure);
}
.hyp-list li { margin-bottom: var(--space-4); font-size: 0.97em; color: var(--ink-soft); }
.hyp-list li:last-child { margin-bottom: 0; }

/* 章末脚注 */
.footnotes {
  margin-top: var(--space-12); padding-top: var(--space-6);
  border-top: 1px solid var(--rule);
  max-width: var(--measure);
}
.footnotes[hidden] { display: none; }
.footnote {
  font-size: 0.8125rem; line-height: 1.6; color: var(--ink-soft);
  padding-left: 1.6em; text-indent: -1.6em; margin: 0 0 var(--space-2);
  scroll-margin-top: 4rem;
}
.footnote sup { font-size: 0.75em; vertical-align: super; line-height: 0; margin-right: 0.35em; }
a.fn-ref {
  text-decoration: none; color: var(--accent); font-size: 0.75em;
  vertical-align: super; line-height: 0; padding: 0 0.15em;
}

/* --- 10. Bibliography ---------------------------------------------------- */
.bib-entry {
  padding-left: 2em; text-indent: -2em; margin: 0 0 var(--space-3);
  font-size: 0.9375rem; line-height: 1.6;
  scroll-margin-top: 4rem;
}
/* 条目内的长 URL 无断行机会，会撑破页面宽度；只在必要时断开 */
.bib-entry a { overflow-wrap: anywhere; }
.bib-entry:target { background: var(--highlight); }

/* --- 11. Inline references ----------------------------------------------- */
/* 交叉引用与文献引用：保持原文措辞，仅加可点击提示 */
a.xref {
  color: var(--accent); text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
}
a.xref:hover { border-bottom-color: var(--accent); }

/* 被告编号。本轮只做 hover / focus 视觉高亮；
   点击行为待第 4 轮网络图上线后接入，届时 cursor 改为 pointer。 */
.actor-ref {
  font-family: var(--font-mono); font-size: 0.86em; letter-spacing: 0.01em;
  background: var(--paper-sunk); border: 1px solid var(--rule);
  border-radius: 2px; padding: 0.05em 0.32em;
  color: var(--ink); white-space: nowrap; cursor: default;
  transition: background-color 0.12s, border-color 0.12s;
}
.actor-ref:hover,
.actor-ref:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.actor-ref[aria-current="true"] { background: var(--highlight); border-color: var(--rule-strong); }

/* 锚点跳转高亮 */
@keyframes flash-target {
  0%, 100% { background-color: transparent; }
  20%, 60% { background-color: var(--highlight); }
}
:target { animation: flash-target 1.6s ease-in-out 1; }
.flash { animation: flash-target 1.6s ease-in-out 1; }

/* --- 12. Controls (第 4 轮图表交互使用) ---------------------------------- */
.controls {
  display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-6);
  align-items: center; margin-bottom: var(--space-4);
  font-family: var(--font-sans); font-size: 0.8125rem;
}
.controls[hidden] { display: none; }
.control-group { display: flex; align-items: center; gap: var(--space-2); }
.control-group__label { color: var(--ink-faint); }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--rule); }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: var(--space-2) var(--space-4); cursor: pointer; color: var(--ink-faint);
  font-family: var(--font-sans); font-size: 0.8125rem;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab:hover { color: var(--ink); }

select, .btn {
  font-family: var(--font-sans); font-size: 0.8125rem;
  background: #fff; color: var(--ink); border: 1px solid var(--rule-strong);
  border-radius: 2px; padding: 0.25rem 0.5rem; cursor: pointer;
}
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 50;
  background: var(--ink); color: var(--paper); border-radius: 2px;
  padding: var(--space-2) var(--space-3); font-family: var(--font-sans);
  font-size: 0.75rem; line-height: 1.45; max-width: 16rem; opacity: 0;
  transition: opacity 0.1s;
}
.tooltip.is-visible { opacity: 1; }

/* --- 12b. 交互网络图（图 4.1，charts.js 注入） ---------------------------- */
.netchart { margin-bottom: var(--space-3); }
.netchart__toolbar {
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4);
  align-items: center; justify-content: space-between;
  margin-bottom: var(--space-2);
  font-family: var(--font-sans); font-size: 0.75rem; color: var(--ink-faint);
}
.netchart__hint { flex: 1 1 18em; }
.netchart__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.netchart__dl { display: inline-flex; align-items: center; gap: var(--space-2); }
a.btn { text-decoration: none; display: inline-block; }
a.btn:hover { border-color: var(--accent); color: var(--accent); }
.netchart__canvas {
  border: 1px solid var(--rule); border-radius: 2px; background: #fff;
  overflow: hidden;
}
.netchart__svg { display: block; width: 100%; height: auto; touch-action: none; }
.netchart__label { pointer-events: none; font-family: var(--font-sans); user-select: none; }

/* 图例画在 SVG 左上角，不随缩放变化 */
.netchart__legend { pointer-events: none; user-select: none; font-family: var(--font-sans); }
.netchart__legend-title { font-size: 11px; font-weight: 600; fill: var(--ink); }
.netchart__legend-sub { font-size: 9.5px; fill: var(--ink-faint); }
.netchart__legend-item { font-size: 10px; fill: var(--ink-soft); }

.node { cursor: pointer; }
.node circle {
  stroke: var(--node-stroke); stroke-width: 1px;
  transition: opacity 0.15s, stroke-width 0.15s;
}
.node:focus { outline: none; }
.node:focus-visible circle { stroke: var(--accent); stroke-width: 2.5px; }
.link { stroke: var(--edge); transition: opacity 0.15s; }
.is-dimmed { opacity: 0.12; }
.is-focus circle { stroke-width: 2.5px; stroke: var(--accent); }

/* 网络图上线后被告编号才真正可点 */
body.has-network .actor-ref { cursor: pointer; }

/* --- 12c. 衰减曲线（图 4.2） -------------------------------------------- */
.decay { margin-bottom: var(--space-3); }
.decay__canvas {
  border: 1px solid var(--rule); border-radius: 2px; background: #fff; overflow: hidden;
}
.decay__svg { display: block; width: 100%; height: auto; }
.decay__tabs { border-bottom: none; margin-left: auto; }
.decay__tabs .tab { padding: var(--space-1) var(--space-3); }

.decay__grid line { stroke: var(--rule); stroke-width: 0.5px; }
.decay__axis path, .decay__axis line { stroke: var(--rule-strong); }
.decay__axis text { font-family: var(--font-sans); font-size: 10px; fill: var(--ink-soft); }
.decay__axis-title { font-family: var(--font-sans); font-size: 10.5px; fill: var(--ink-soft); }
.decay__line { stroke-width: 1.6px; stroke-linejoin: round; stroke-linecap: round; }
.decay__point { cursor: default; }
.decay__point:focus { outline: none; }
.decay__point:focus-visible .decay__marker { stroke: var(--accent); stroke-width: 2px; }
.decay__point:hover .decay__marker { stroke: var(--ink); stroke-width: 1.5px; }

/* --- 12d. 角色柱状图（图 4.3，2×2 小倍数） ------------------------------- */
.roles { margin-bottom: var(--space-3); }
.roles__grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
/* 共享图例：同一角色在四格中同色 */
.roles__legend {
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4);
  font-family: var(--font-sans); font-size: 0.75rem; color: var(--ink-soft);
  margin-bottom: var(--space-3);
}
.roles__key { display: inline-flex; align-items: center; gap: 0.4em; }
.roles__swatch {
  display: inline-block; width: 0.72em; height: 0.72em; border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.18);
}
.roles__cell {
  border: 1px solid var(--rule); border-radius: 2px; background: #fff;
  padding: var(--space-3);
}
.roles__svg { display: block; width: 100%; height: auto; overflow: visible; }
.roles__title { font-family: var(--font-sans); font-size: 11px; font-weight: 600; fill: var(--ink); }
.roles__sub { font-family: var(--font-sans); font-size: 9.5px; fill: var(--ink-faint); }
.roles__rolelabel { font-family: var(--font-sans); font-size: 10px; fill: var(--ink-soft); }
.roles__value {
  font-family: var(--font-sans); font-size: 10px; fill: var(--ink-faint);
  font-variant-numeric: tabular-nums lining-nums;
}
.roles__axis path, .roles__axis line { stroke: var(--rule-strong); }
.roles__axis text { font-family: var(--font-sans); font-size: 9px; fill: var(--ink-faint); }

/* 悬停：柱子微微变粗并提亮，数值加重。transform-box 让缩放以柱子自身为原点 */
.rolebar { cursor: default; }
.rolebar rect {
  transform-box: fill-box; transform-origin: left center;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.rolebar:hover rect,
.rolebar:focus-visible rect { transform: scaleY(1.18); filter: brightness(1.35); }
.rolebar:hover .roles__value,
.rolebar:focus-visible .roles__value { fill: var(--ink); font-weight: 600; }
.rolebar:hover .roles__rolelabel,
.rolebar:focus-visible .roles__rolelabel { fill: var(--ink); font-weight: 600; }
.rolebar:focus { outline: none; }

@media (max-width: 46rem) {
  .roles__grid { grid-template-columns: 1fr; }
}

/* --- 12e. 散点图（图 4.4 学历×刑期、图 4.5 阶段数×刑期） ---------------- */
.scatter { margin-bottom: var(--space-3); }
.scatter__canvas {
  border: 1px solid var(--rule); border-radius: 2px; background: #fff; overflow: hidden;
}
.scatter__svg { display: block; width: 100%; height: auto; }

.scatter__pt {
  cursor: default; fill-opacity: 0.72;
  transition: r 0.12s ease, fill-opacity 0.12s ease, stroke-width 0.12s ease;
  stroke: #fff; stroke-width: 0.8px;
}
.scatter__pt:hover, .scatter__pt:focus-visible {
  fill-opacity: 1; r: 6.5; stroke: var(--ink); stroke-width: 1.2px; outline: none;
}
.scatter__mean { cursor: default; stroke: #fff; stroke-width: 1.2px; }
.scatter__mean:hover { stroke: var(--ink); }
.scatter__meanline { stroke-width: 1.3px; stroke-dasharray: 5 4; opacity: 0.85; }

/* 图 4.5 的点用环形（浅填充 + 深描边），与论文原图观感一致 */
.scatter__pt--ring {
  fill: #6B9FCE; fill-opacity: 0.85;
  stroke: #185FA5; stroke-width: 1px;
}
.scatter__pt--ring:hover, .scatter__pt--ring:focus-visible {
  fill: #185FA5; fill-opacity: 1; stroke: var(--ink); stroke-width: 1.4px;
}

/* --- 12f. 分层柱状图（图 4.6） ------------------------------------------ */
.stratbars { margin-bottom: var(--space-3); }
.stratbars__legend {
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4);
  font-family: var(--font-sans); font-size: 0.75rem; color: var(--ink-soft);
  margin-bottom: var(--space-3);
}
.stratbars__canvas {
  border: 1px solid var(--rule); border-radius: 2px; background: #fff; overflow: hidden;
}
.stratbars__svg { display: block; width: 100%; height: auto; }
.stratbar { cursor: default; }
.stratbar:focus { outline: none; }
.stratbar rect {
  transform-box: fill-box; transform-origin: center bottom;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.stratbar:hover rect,
.stratbar:focus-visible rect { transform: scaleX(1.06); filter: brightness(1.18); }
.stratbar:hover .roles__value,
.stratbar:focus-visible .roles__value { fill: var(--ink); font-weight: 600; }
.stratbar__n { font-size: 9px; }

.scatter__band { fill: #185FA5; fill-opacity: 0.10; }
.scatter__fit { fill: none; stroke: #185FA5; stroke-width: 1.8px; }
.scatter__note {
  font-family: var(--font-sans); font-size: 11px; fill: var(--ink-soft);
  font-style: italic; font-variant-numeric: tabular-nums lining-nums;
}

/* --- 13. Responsive ------------------------------------------------------ */
@media (max-width: 60rem) {
  .layout { grid-template-columns: 1fr; gap: 0; padding: 0 var(--space-6); }
  .sidebar { position: static; height: auto; padding: var(--space-6) 0; border-bottom: 1px solid var(--rule); }
  .toc__toggle {
    display: block; width: 100%; text-align: left; background: none;
    border: none; padding: var(--space-2) 0; cursor: pointer;
    font-family: var(--font-sans); font-size: 0.8125rem; color: var(--ink-soft);
  }
  .toc__toggle::after { content: " ▾"; }
  .toc__toggle[aria-expanded="false"]::after { content: " ▸"; }
  .toc[hidden] { display: none; }
  .content { padding: var(--space-8) 0; }
  .masthead__inner { padding: var(--space-8) var(--space-6) var(--space-6); }
  /* 三联图在中等屏幕降为两列，避免每格过窄看不清坐标轴 */
  .figure__panels[data-panels="3"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 40rem) {
  :root { --fs-base: 1rem; }
  .layout { padding: 0 var(--space-4); }
  .figure, .table-wrap { margin: var(--space-8) 0; }
  /* 窄屏下所有多面板图改为单列纵向堆叠 */
  .figure__panels[data-panels="2"],
  .figure__panels[data-panels="3"],
  .figure__panels[data-panels="4"] { grid-template-columns: 1fr; }
  .data-table th, .data-table td { padding: var(--space-2); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* --- 14. Print ----------------------------------------------------------- */
@media print {
  @page { margin: 22mm 20mm; }
  :root { --fs-base: 11pt; --measure: none; --wide: none; }
  body { background: #fff; color: #000; font-size: 11pt; line-height: 1.5; }
  .sidebar, .controls, .tabs, .toc__toggle, .skip-link, .colophon, .tooltip,
  .netchart__toolbar { display: none !important; }
  /* 打印时输出网络图当前视图；论文原图不再内联，改由下载按钮提供 */
  .netchart__canvas { border: 1px solid #999; }
  .layout { display: block; max-width: none; padding: 0; }
  .content { padding: 0; }
  .prose, .figure, .table-wrap, .hyp-list, .footnotes { max-width: none; }
  .masthead__inner { padding: 0 0 12pt; }
  .chapter { break-before: page; }
  .chapter:first-of-type { break-before: avoid; }
  h1, h2, h3 { break-after: avoid; }
  .figure, .table-wrap, .hyp-list li, .bib-entry, .footnote { break-inside: avoid; }
  .data-table tr { break-inside: avoid; }
  .data-table thead { display: table-header-group; }   /* 跨页时重复表头 */
  .table-wrap { overflow: visible; }                    /* 打印不滚动，让表格自然换行 */
  .figure__panels img { border: 1px solid #999; }
  #figure-3-1 .figure__panels img { border: none; mix-blend-mode: normal; }
  a.xref, .actor-ref { color: #000; border: none; background: none; text-decoration: none; }
  .bib-entry a[href^="http"] { word-break: break-all; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #444; }
  .footnotes[hidden] { display: block !important; }      /* 打印时展开脚注 */
}
