/* 《最终考察》中文译本：仿原书版式（连续正文、■小标题、页边页码、侧边章节索引）。
   主文件：F:\vn\VN\tools\umineko_fa_qa\book_layout\book.css，复制到两卷 build/ 后由构建脚本输出。 */
:root {
  color-scheme: light;
  --paper: #fbf9f4;
  --paper-2: #f3efe6;
  --ink: #1d1b19;
  --ink-2: #3b3732;
  --muted: #8a8279;
  --rule: #d9d2c5;
  --rule-strong: #1d1b19;
  --tab: #c9c4bb;
  --tab-ink: #2a2724;
  --tab-active: #1d1b19;
  --tab-active-ink: #f6f2ea;
  --note-bg: #f1ede4;
  --link: #6b4a2b;
  --red: #b3262b;
  --head-h: 2.75rem;
  --tabs-w: 3.1rem;
  --measure: 41rem;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --latin: "Cormorant Garamond", "EB Garamond", "Garamond", "Times New Roman", serif;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #15140f;
  --paper-2: #1e1c17;
  --ink: #e8e2d6;
  --ink-2: #cfc7b9;
  --muted: #958c7f;
  --rule: #3a362f;
  --rule-strong: #e8e2d6;
  --tab: #3a3731;
  --tab-ink: #d9d2c4;
  --tab-active: #e8e2d6;
  --tab-active-ink: #15140f;
  --note-bg: #211f19;
  --link: #e0b884;
  --red: #ec6a5e;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--head-h) + 1rem); }
html.anchor-jump { scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.95 var(--serif);
  font-feature-settings: "palt" 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
[hidden] { display: none !important; }
.cont-heading { display: none; }

/* ---------- running head（原书页眉） ---------- */
.running-head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  height: var(--head-h);
  padding: 0 1rem 0 calc(var(--tabs-w) + 1rem);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
  font: 13px/1 var(--sans);
  color: var(--ink-2);
}
.rh-title { display: flex; align-items: baseline; gap: .7rem; min-width: 0; text-decoration: none; font: 600 14px/1 var(--serif); letter-spacing: .08em; white-space: nowrap; }
.rh-title em { font: italic 400 14px/1 var(--latin); letter-spacing: .02em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.rh-chapter { margin-left: auto; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rh-page { min-width: 3.2em; font: italic 15px/1 var(--latin); color: var(--ink); text-align: right; }
.toc-toggle, .theme-toggle {
  appearance: none; flex: none; cursor: pointer;
  padding: .3rem .75rem; border: 1px solid var(--rule); border-radius: 2px;
  background: transparent; color: var(--ink-2); font: 13px/1.2 var(--sans);
}
.toc-toggle:hover, .theme-toggle:hover, .toc-toggle[aria-expanded="true"] { border-color: var(--ink); color: var(--ink); }

/* ---------- edge tabs（原书侧边章节索引） ---------- */
.edge-tabs {
  position: fixed; z-index: 25; inset: 0 auto 0 0;
  display: flex; flex-direction: column; gap: 2px;
  width: var(--tabs-w); padding: .5rem 0;
  background: var(--paper-2);
  border-right: 1px solid var(--rule);
}
.edge-tab {
  flex: 1 1 0; min-height: 0;
  display: flex; flex-direction: row-reverse; align-items: center; justify-content: center; gap: .15rem;
  writing-mode: vertical-rl; text-orientation: mixed;
  margin-right: .35rem; padding: .3rem 0;
  background: var(--tab); color: var(--tab-ink);
  border-radius: 0 3px 3px 0;
  text-decoration: none; overflow: hidden;
  transition: background .15s, color .15s;
}
.edge-tab:hover { filter: brightness(.95); }
.edge-tab.is-active { background: var(--tab-active); color: var(--tab-active-ink); margin-right: 0; }
.tab-en { font: italic 600 17px/1 var(--latin); letter-spacing: .03em; white-space: nowrap; }
.tab-zh { font: 600 13px/1 var(--serif); letter-spacing: .35em; white-space: nowrap; }

/* ---------- cover ---------- */
.book-cover {
  margin-left: var(--tabs-w);
  padding: 7rem 1.5rem 6rem;
  text-align: center;
  color: #efe7d8;
  background:
    radial-gradient(ellipse at 50% 30%, rgb(160 120 60 / 18%), transparent 60%),
    linear-gradient(160deg, #18150f, #2b2419 55%, #120f0b);
}
.cover-jp { margin: 0; font: 15px/1.6 var(--serif); letter-spacing: .5em; color: #c9b896; }
.book-cover h1 { margin: 1.4rem auto .6rem; font: 600 clamp(2rem, 5vw, 3.4rem)/1.25 var(--serif); letter-spacing: .06em; }
.cover-en { margin: 0; font: italic 400 clamp(1.1rem, 2.4vw, 1.6rem)/1.4 var(--latin); color: #d8c7a3; }
.cover-author { margin: 2.2rem 0 0; font: 14px/1.6 var(--sans); letter-spacing: .3em; color: #b8a888; }
.cover-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem 1.6rem; margin-top: 2.4rem; font: 14px/1.6 var(--sans); }
.cover-nav a { color: #efe7d8; text-decoration: none; border-bottom: 1px solid rgb(239 231 216 / 45%); padding-bottom: .1rem; }
.cover-nav a:hover { border-bottom-color: #efe7d8; }
/* colour dust jacket beside the title (the scan only has the plain board cover) */
.book-cover.has-jacket { display: flex; align-items: center; justify-content: center; gap: clamp(2rem, 6vw, 5rem); padding: 5rem 1.5rem; text-align: left; }
.cover-jacket { flex: none; width: clamp(10rem, 22vw, 15.5rem); height: auto; border-radius: 2px; box-shadow: 0 1.4rem 2.6rem rgb(0 0 0 / 50%), 0 0 0 1px rgb(255 255 255 / 7%); }
.has-jacket .cover-text { max-width: 38rem; }
.has-jacket h1 { font-size: clamp(1.8rem, 3.4vw, 2.7rem); }
.has-jacket .cover-nav { justify-content: flex-start; }
/* arriving from the landing page (which fades to this cover colour): let the cover settle in */
.cover-jacket, .cover-text { animation: cover-in .9s cubic-bezier(.22, .61, .36, 1) both; }
.cover-text { animation-delay: .12s; }
@keyframes cover-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .cover-jacket, .cover-text { animation: none; } }
@media (max-width: 720px) {
  .book-cover.has-jacket { flex-direction: column; gap: 2.2rem; padding: 3.5rem 1rem 3rem; text-align: center; }
  .has-jacket .cover-nav { justify-content: center; }
}

/* ---------- reading column ---------- */
main { margin-left: var(--tabs-w); padding: 1rem 1.25rem 6rem; }
.chapter, .unscoped { max-width: var(--measure); margin: 0 auto; }
.chapter { position: relative; scroll-margin-top: var(--head-h); }
.document { position: relative; }

.chapter-opener {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  margin: 5.5rem 0 3.5rem; padding: 2.6rem 0 2.4rem;
  border-top: 2px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong);
  text-align: center;
}
.opener-en { font: italic 600 clamp(2rem, 5vw, 3rem)/1.1 var(--latin); letter-spacing: .02em; }
.opener-sub { font: italic 400 1.2rem/1.3 var(--latin); color: var(--muted); }
.opener-zh { margin-top: .8rem; font: 600 1.15rem/1.4 var(--serif); letter-spacing: .25em; }
.chapter:first-of-type .chapter-opener { margin-top: 3rem; }

/* 正文：连续排版，不再一段一个框 */
.component { margin: 0; padding: 0; border: 0; background: none; box-shadow: none; overflow-wrap: anywhere; }
.chapter p { margin: 0 0 .55em; text-align: justify; text-indent: 2em; }
.chapter li p, .chapter td p, .chapter th p, .chapter blockquote p,
.image-translation-box p, .component-character-card p, .component-table p,
.component-tip-card[class*="role-source"] p { text-indent: 0; }
.component-body-first-play + .component-body-analysis,
.component-body-analysis + .component-body-first-play { margin-top: 1.2em; }

.chapter h1, .chapter h2, .chapter h3, .chapter h4, .chapter h5 {
  color: var(--ink); line-height: 1.5; font-weight: 700; text-indent: 0;
  scroll-margin-top: calc(var(--head-h) + 1rem);
  break-after: avoid;
}
.chapter h2 { margin: 2.6em 0 1em; font-size: 1.45rem; letter-spacing: .06em; }
.chapter h3 { margin: 2.3em 0 .8em; font-size: 1.2rem; letter-spacing: .03em; }
.chapter h4 { margin: 1.9em 0 .6em; font-size: 1.05rem; }
.chapter h5 { margin: 1.4em 0 .4em; font-size: 1rem; }
.component.heading-only + .component.heading-only > :first-child { margin-top: .6em; }

.chapter blockquote {
  margin: .9em 0 .9em 2em; padding: 0 0 0 1em;
  border-left: 1px solid var(--rule); color: var(--ink-2);
}
.chapter ul, .chapter ol { margin: .5em 0 .9em; padding-left: 2.2em; }
.chapter li { margin: .15em 0; }
.chapter hr { border: 0; border-top: 1px solid var(--rule); margin: 2em auto; width: 40%; }
.chapter strong { font-weight: 700; }
.chapter code { font: .88em/1.5 ui-monospace, Consolas, monospace; }

/* 表格：原书式的上下粗线 */
.chapter table { width: 100%; margin: 1.2em 0 1.6em; border-collapse: collapse; font-size: .9rem; line-height: 1.7; border-top: 2px solid var(--rule-strong); border-bottom: 2px solid var(--rule-strong); }
.chapter th, .chapter td { padding: .4em .6em; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.chapter th { font-weight: 700; background: var(--paper-2); }
.chapter td[style*="right"], .chapter th[style*="right"] { white-space: nowrap; }

/* 提示卡 / 人物卡：只有原书里确实是框的才画框（作者旁注、引用来源、阅读提示等）；
   小标题卡与场景卡（V1 蝴蝶标记、V2 ♣）按原书不加框 */
.component-tip-card:is(.role-source-note, .role-warning-guide, .role-section-guide, .role-evidence-table, .role-scene-note,
  .role-interpretation, .role-meta, .role-version-note, .role-tips,
  [data-category="AUTHOR_COMMENT"], [data-category="OTHER_MEDIA"], [data-category="READING_GUIDE"],
  [data-category="WORK_SUPPLEMENT"], [data-category="TERM_GLOSSARY"]):not(.heading-only) {
  margin: 1.3em 0; padding: .9em 1.2em;
  background: var(--note-bg); border: 1px solid var(--rule);
}
.component-tip-card > :first-child { margin-top: 0; }
.role-butterfly-prompt > h3:first-child, .role-butterfly-prompt > h4:first-child { margin: 1.4em 0 .3em; font-size: 1rem; }
.role-butterfly-prompt > h3:first-child::before, .role-butterfly-prompt > h4:first-child::before {
  content: ""; display: inline-block; width: 1.1em; height: .92em; margin-right: .35em; vertical-align: -.08em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 20'%3E%3Cpath d='M12 9C10 3 4 0 1 2c-1 4 2 7 6 8-4 1-5 6-2 8 3 1 6-3 7-7 1 4 4 8 7 7 3-2 2-7-2-8 4-1 7-4 6-8-3-2-9 1-11 7z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 20'%3E%3Cpath d='M12 9C10 3 4 0 1 2c-1 4 2 7 6 8-4 1-5 6-2 8 3 1 6-3 7-7 1 4 4 8 7 7 3-2 2-7-2-8 4-1 7-4 6-8-3-2-9 1-11 7z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.component-character-card {
  margin: 1.4em 0; padding: 1em 1.3em;
  border: 1px solid var(--rule-strong);
}
.component-character-card > :first-child { margin-top: 0; }
.component-character-card > :last-child { margin-bottom: 0; }

/* 图与图中文字 */
.illustration-page { margin: 1.8em auto 1em; text-align: center; }
.illustration-page img { display: block; width: min(100%, 36rem); height: auto; margin: 0 auto; border: 1px solid var(--rule); background: var(--paper-2); }
.illustration-page figcaption { margin-top: .5em; color: var(--muted); font: .8rem/1.5 var(--sans); }
.image-translation-box {
  max-width: 36rem; margin: .4em auto 1.8em; padding: .7em 1em;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-size: .9rem; line-height: 1.8; color: var(--ink-2);
}
.image-translation-box::before { content: "图中文字"; display: block; margin-bottom: .3em; font: 11px/1 var(--sans); letter-spacing: .2em; color: var(--muted); }
.image-translation-box p { margin: .3em 0; }

/* 页边页码（原书页码） */
.page-mark { position: relative; height: 0; margin: 0; }
.page-anchor { position: absolute; }
.folio {
  position: absolute; top: .35rem; right: calc(-1 * clamp(3rem, 6vw, 5.5rem));
  font: italic 14px/1 var(--latin); color: var(--muted); letter-spacing: .04em;
  user-select: none;
}
.folio::before { content: "p."; margin-right: .1em; font-size: 11px; opacity: .7; }

/* 原书目录：去掉表格线，用点线引导到页码（仿原书目录页） */
.chapter table.printed-toc { border: 0; font-size: .95rem; margin: .6em 0 2em; }
.printed-toc thead { display: none; }
.printed-toc tr { display: flex; align-items: baseline; }
.printed-toc td { border: 0; padding: .18em 0; }
.printed-toc td:first-child { flex: 1; display: flex; align-items: baseline; min-width: 0; }
.printed-toc td:first-child::after { content: ""; flex: 1; min-width: 1.5em; margin: 0 .5em; border-bottom: 1px dotted var(--muted); transform: translateY(-.32em); }
.printed-toc td:last-child { font: italic 15px/1.6 var(--latin); padding-left: .2em; }

/* 原书目录与文中页码引用 */
.toc-link, .toc-page { text-decoration: none; }
.toc-link:hover, .toc-page:hover { color: var(--link); text-decoration: underline; text-underline-offset: .2em; }
.page-ref { color: var(--link); text-decoration: none; border-bottom: 1px dotted currentColor; }
.page-ref:hover { border-bottom-style: solid; }

/* 第 6 章 对谈：发言人标签 */
.component-qa-dialogue p { text-indent: 0; }
.component-qa-dialogue p:not(.turn) { padding-left: 4.6em; }
.turn { position: relative; padding-left: 4.6em; margin-top: .9em !important; }
.turn .speaker {
  position: absolute; left: 0; top: .32em;
  display: inline-block; min-width: 3.8em; padding: .05em .45em;
  font: 600 12px/1.6 var(--sans); letter-spacing: .04em; text-align: center;
  background: var(--ink); color: var(--paper);
}
.turn-r .speaker { background: var(--ink-2); }
.turn-m { color: var(--ink-2); }
.turn-m .speaker { background: none; color: var(--muted); }

/* ---------- contents drawer ---------- */
.toc-drawer {
  position: fixed; z-index: 40; top: 0; bottom: 0; left: 0;
  width: min(26rem, 92vw);
  display: flex; flex-direction: column;
  background: var(--paper); border-right: 1px solid var(--rule);
  box-shadow: 8px 0 30px rgb(0 0 0 / 18%);
  transform: translateX(-102%); transition: transform .22s ease;
  font: 14px/1.6 var(--sans);
}
.toc-drawer.is-open { transform: none; }
.toc-scrim { position: fixed; inset: 0; z-index: 35; background: rgb(0 0 0 / 28%); }
.toc-head { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border-bottom: 1px solid var(--rule); }
.toc-head strong { font: 600 15px/1 var(--serif); letter-spacing: .2em; }
.toc-filter { flex: 1; min-width: 0; padding: .35rem .6rem; border: 1px solid var(--rule); border-radius: 2px; background: var(--paper-2); color: var(--ink); font: inherit; }
.toc-close { appearance: none; border: 0; background: none; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.toc-body { flex: 1; overflow: auto; padding: .6rem .9rem 2rem; }
.toc-printed { display: block; margin: .2rem 0 .8rem; color: var(--link); text-decoration: none; }
.toc-chapter { border-bottom: 1px solid var(--rule); }
.toc-chapter summary { padding: .5rem 0 .5rem 1.1rem; cursor: pointer; font-weight: 600; list-style: none; position: relative; }
.toc-chapter summary::-webkit-details-marker { display: none; }
.toc-chapter summary::before { content: "▸"; position: absolute; left: 0; top: .55rem; color: var(--muted); }
.toc-chapter[open] summary::before { content: "▾"; }
.toc-chapter summary a { text-decoration: none; }
.toc-en { display: block; font: italic 600 14px/1.2 var(--latin); color: var(--muted); }
.toc-chapter ol { list-style: none; margin: 0 0 .7rem; padding: 0; }
.toc-chapter li a { display: block; padding: .12rem 0; text-decoration: none; color: var(--ink-2); }
.toc-chapter li a:hover { color: var(--link); }
.toc-chapter .lvl-2 a { font-weight: 600; }
.toc-chapter .lvl-4 a { padding-left: 1em; font-size: 13px; }
.toc-chapter .minor { display: none; }
.toc-drawer.is-filtering .minor { display: list-item; }
.toc-drawer.is-filtering li.no-match { display: none; }
.toc-drawer.is-filtering .toc-chapter.no-match { display: none; }

.book-footer { margin-left: var(--tabs-w); padding: 2rem 1rem 4rem; text-align: center; color: var(--muted); font: 12px/1.6 var(--sans); border-top: 1px solid var(--rule); }

/* ---------- narrow screens ---------- */
@media (max-width: 1100px) {
  .folio { position: static; display: block; margin: 1rem 0 .4rem; text-align: right; border-top: 1px dashed var(--rule); padding-top: .25rem; font-size: 12px; }
  .page-mark { height: auto; }
}
@media (max-width: 760px) {
  :root { --tabs-w: 0rem; --head-h: 2.6rem; }
  body { font-size: 16px; }
  .edge-tabs {
    inset: auto 0 0 0; width: auto; height: 2.6rem; flex-direction: row; padding: 0;
    overflow-x: auto; border-right: 0; border-top: 1px solid var(--rule);
  }
  .edge-tab { writing-mode: horizontal-tb; flex: 0 0 auto; margin: 0; padding: 0 .7rem; border-radius: 0; flex-direction: column; justify-content: center; }
  .tab-en { font-size: 12px; }
  .tab-zh { font-size: 10px; }
  .rh-title em, .rh-chapter { display: none; }
  .running-head { padding-left: .6rem; gap: .5rem; }
  main { padding: .5rem 1rem 5rem; }
  .book-cover { padding: 4rem 1rem 3.5rem; }
  .turn, .component-qa-dialogue p:not(.turn) { padding-left: 0; }
  .turn .speaker { position: static; margin-right: .5em; }
  .book-footer { padding-bottom: 4rem; }
}
@media print {
  .running-head, .edge-tabs, .toc-drawer, .toc-scrim, .book-cover nav { display: none !important; }
  .book-cover, main, .book-footer { margin-left: 0; }
  .book-cover { color: #000; background: none; }
  .chapter-opener { break-before: page; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}

/* ---------- 原文对照：每页译文上方的原书扫描页（默认不显示、不下载） ---------- */
.scan-toggle {
  appearance: none; flex: none; cursor: pointer;
  padding: .3rem .75rem; border: 1px solid var(--rule); border-radius: 2px;
  background: transparent; color: var(--ink-2); font: 13px/1.2 var(--sans);
}
.scan-toggle:hover { border-color: var(--ink); color: var(--ink); }
.scan-toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.page-scan { display: none; }
body.show-scans .page-scan, .page-scan.is-open {
  display: block; margin: 2.2em 0 1.4em; padding: .6em; background: var(--paper-2); border: 1px solid var(--rule);
}
.page-scan figcaption { display: flex; justify-content: space-between; gap: 1em; margin: 0 0 .5em; font: 12px/1.4 var(--sans); color: var(--muted); }
.page-scan figcaption a { color: var(--link); text-decoration: none; }
.page-scan img { display: block; width: 100%; height: auto; background: #fff; }
html[data-theme="dark"] .page-scan img { filter: brightness(.78) contrast(1.06); }
.folio { cursor: pointer; }
.folio:hover { color: var(--link); }
@media (max-width: 760px) { .scan-toggle { padding: .3rem .5rem; } }
@media print { .scan-toggle { display: none !important; } }
