:root {
  color-scheme: light;
  --page: #e7eae6;
  --rail: #dde2dc;
  --ink: #1c201d;
  --muted: #4a524b;
  --line: #c6cdc6;
  --accent: #a33e36;
  --accent-soft: #e9dad6;
  --theme-color: var(--accent);
  --code-bg: #dce1da;
  --reading-size: 19px;
  --sidebar-width: 236px;
  --header-height: 52px;
  --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --book-font: "Noto Serif SC", "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --diagram-bg: var(--page);
  --diagram-ink: var(--ink);
  --diagram-muted: var(--muted);
  --diagram-line: #aebbad;
  --diagram-primary: #0b6f5d;
  --diagram-primary-soft: #d6e5dc;
  --diagram-secondary: #2c6096;
  --diagram-secondary-soft: #dce4ed;
  --diagram-warm: #80531b;
  --diagram-warm-soft: #eae2cf;
  --diagram-danger: #a03946;
  --diagram-danger-soft: #ead9dc;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #191919;
  --rail: #1d1d1d;
  --ink: #e5e5e5;
  --muted: #a6a6a6;
  --line: #363636;
  --accent: #e5a29a;
  --accent-soft: #3b2826;
  --theme-color: var(--accent);
  --code-bg: #242424;
  --diagram-bg: #191919;
  --diagram-ink: #e9f0eb;
  --diagram-muted: #b3c4b8;
  --diagram-line: #7a9283;
  --diagram-primary: #79d4b8;
  --diagram-primary-soft: #243e33;
  --diagram-secondary: #99bff0;
  --diagram-secondary-soft: #29394c;
  --diagram-warm: #e9bf78;
  --diagram-warm-soft: #443822;
  --diagram-danger: #f0a1a8;
  --diagram-danger-soft: #462c33;
}
/* Chinese body face: Noto Serif SC (思源宋体), subset to the characters the book uses (tools/build_fonts.py).
   Songti stays in the stack as the fallback while the file loads and for any glyph outside the subset. */
@font-face {
  font-family: "Noto Serif SC";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("fonts/NotoSerifSC-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Serif SC";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("fonts/NotoSerifSC-SemiBold.woff2") format("woff2");
}
/* The Docsify theme sets antialiased smoothing on every element, which thins text on macOS; restore the default. */
* { box-sizing: border-box; -webkit-font-smoothing: auto; }
html { background: var(--page); scroll-padding-top: calc(var(--header-height) + 24px); }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--ui-font);
  letter-spacing: 0;
  -moz-osx-font-smoothing: auto;
}
body > main { z-index: auto; }
button, input, output, select { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.reader-icon { display: block; width: 19px; height: 19px; flex: 0 0 19px; }
.icon-button {
  width: 36px; height: 36px; display: inline-flex; justify-content: center; align-items: center;
  padding: 0; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted);
  text-decoration: none;
}
.icon-button:hover { background: var(--accent-soft); color: var(--accent); }
.icon-button:disabled { opacity: .35; cursor: default; }
.skip-link {
  position: fixed; z-index: 150; left: 12px; top: -70px; padding: 10px 16px;
  background: var(--page); border: 1px solid var(--accent); border-radius: 4px;
}
.skip-link:focus { top: 10px; }
.reader-topbar {
  position: fixed; z-index: 40; top: 0; left: var(--sidebar-width); right: 0; height: var(--header-height);
  background: var(--page); border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 14px; padding: 0 30px;
}
.reader-brand { font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.reader-topbar-main { display: flex; gap: 12px; align-items: center; min-width: 0; flex: 1; }
.reader-preferences { display: flex; gap: 16px; align-items: center; }
.mode-switch { display: flex; gap: 2px; padding: 0; border: 0; }
.mode-switch button {
  font-size: 12px; line-height: 20px; padding: 5px 12px; white-space: nowrap;
  color: var(--muted); background: none; border: 0; border-radius: 3px;
}
.mode-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.font-control { display: flex; gap: 1px; align-items: center; }
.font-control output { min-width: 25px; font-size: 14px; text-align: center; color: var(--ink); font-variant-numeric: tabular-nums; }
.reader-topbar-actions { display: flex; align-items: center; gap: 3px; }
.reader-progress { position: absolute; height: 1px; bottom: -1px; left: 0; right: 0; overflow: hidden; }
.reader-progress span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }
body .sidebar {
  left: 0; width: var(--sidebar-width); background: var(--rail); border-right: 1px solid var(--line);
  padding: 32px 14px 36px; color: var(--ink); z-index: 60;
}
.sidebar .app-name { margin: 0 12px 28px; text-align: left; font-size: 20px; font-weight: 500; line-height: 1.5; }
.sidebar .app-name-link { color: var(--ink); }
.sidebar .app-name small { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.6; font-weight: 400; }
.sidebar .search { border: 0; padding: 0 6px 18px; margin: 0; }
.sidebar .search .input-wrap { position: relative; }
.sidebar .search input {
  background: var(--page); border: 1px solid var(--line); border-radius: 4px; padding: 8px 34px 8px 10px;
  color: var(--ink); font-size: 12px; width: 100%; box-sizing: border-box; appearance: none; -webkit-appearance: none;
}
.sidebar .search input::-webkit-search-cancel-button { display: none; }
.sidebar .search .clear-button { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); display: none; }
.sidebar.searching .search .clear-button { display: inline-flex; }
.sidebar.searching .sidebar-nav { display: none; }
.sidebar .search .results-panel { display: none; }
.sidebar.searching .search .results-panel { display: block; margin-top: 12px; }
.sidebar .search .matching-post {
  display: block; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.sidebar .search .matching-post h2 { margin: 0 0 4px; font-size: 14px; font-weight: 600; line-height: 1.5; }
.sidebar .search .matching-post small { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.sidebar .search .matching-post p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; word-break: break-word; }
.sidebar .search mark { background: none; color: var(--accent); font-weight: 600; }
.sidebar .search .search-message { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.sidebar-nav { padding: 0; }
.sidebar-nav ul { padding: 0; margin: 0; }
.sidebar-nav li { margin: 2px 0; }
.sidebar-nav > ul > li > a {
  padding: 8px 12px; display: block; white-space: normal; font-size: 13px; line-height: 1.6;
  border-radius: 3px; color: var(--muted); border-right: 0;
}
.sidebar-nav > ul > li > a:hover { background: var(--page); color: var(--ink); text-decoration: none; }
body .sidebar .sidebar-nav li.active > a { background: var(--accent-soft); color: var(--accent); font-weight: 500; border-right: 0; }
.sidebar-toggle { display: none !important; }
.github-corner { display: none; }
.sidebar-scrim { display: none; }
.content { position: relative; left: 0 !important; transform: none !important; margin-left: var(--sidebar-width); padding: 102px 48px 80px; }
body.close .reader-topbar { left: 0; }
body.close .content { margin-left: 0; }
/* text-autospace adds the conventional gap between Chinese and Latin letters or digits where the text has none. */
.markdown-section { max-width: 680px; margin: 0 auto; padding: 0; color: var(--ink); font-family: var(--book-font); font-size: var(--reading-size); line-height: 1.95; overflow-wrap: break-word; text-autospace: normal; }
.markdown-section p, .markdown-section ul, .markdown-section ol { line-height: inherit; word-spacing: normal; }
.markdown-section p, .markdown-section ul, .markdown-section ol, .markdown-section table { margin: 0 0 1.25em; }
.markdown-section ul, .markdown-section ol { padding-left: 1.5em; }
.markdown-section li { margin: .3em 0; }
.markdown-section strong { color: var(--ink); font-weight: 600; }
/* Emphasis: Chinese never slants; it keeps the body face and weight and takes the accent color.
   English keeps the conventional italic in the surrounding color. */
.markdown-section em { color: var(--accent); font-style: normal; }
.markdown-section em:lang(en) { color: inherit; font-style: italic; }
/* Links keep the text color and show a thin accent underline; the term itself stays readable. */
.markdown-section a { color: inherit; font-weight: inherit; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.markdown-section a:hover { color: var(--accent); }
.markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4 {
  color: var(--ink); font-weight: 600; line-height: 1.55; letter-spacing: 0; text-wrap: balance;
  scroll-margin-top: 0;
}
.markdown-section h1 { font-size: 32px; margin: 0 0 14px; }
.markdown-section h2 { font-size: 24px; margin: 54px 0 22px; padding-top: 0; border: 0; }
.markdown-section h3 { font-size: 21px; margin: 38px 0 18px; }
.markdown-section h4 { font-size: 18px; margin: 26px 0 12px; }
.markdown-section .anchor, .markdown-section .anchor span { color: inherit; text-decoration: none; }
.markdown-section .anchor { transition: color .15s; }
.markdown-section .anchor:hover { color: var(--accent); }
.markdown-section .reader-original-title { margin: 0 0 6px; color: var(--muted); font-family: var(--ui-font); font-size: 13px; line-height: 1.6; }
.markdown-section .chapter-kicker { display: none; }
.markdown-section .chapter-credit { display: inline-block; margin: 0 16px 12px 0; color: var(--muted); font-family: var(--ui-font); font-size: 11px; }
.markdown-section .chapter-credit strong { font-weight: 400; color: inherit; }
/* Credits and attributions exist in both languages; each reading mode shows one of them. */
body[data-reading-mode="bilingual"] .markdown-section .chapter-credit[lang="zh-CN"],
body[data-reading-mode="bilingual"] .markdown-section .reader-attribution.translated-source { display: none; }
.markdown-section .reader-code-label { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.markdown-section .reader-error { color: var(--accent); font-family: var(--ui-font); }
.markdown-section .english-prose { color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-size: calc(var(--reading-size) - 1px); line-height: 1.8; }
/* Pull each translation up to its source paragraph so the pair reads as one unit. */
.markdown-section p.english-prose:has(+ p:not(.english-prose)) { margin-bottom: .45em; }
.markdown-section .reader-caption { font-family: var(--ui-font); color: var(--muted); font-size: 13px; line-height: 1.7; margin: 12px 0 24px; }
.markdown-section .reader-attribution { font-family: var(--ui-font); color: var(--muted); font-size: 12px; text-align: right; }
.markdown-section .reader-subheading { margin-top: 30px; font-weight: 600; }
/* Under a chapter title: a subtitle keeps the emphasis color; a lead and other plain italic paragraphs do not. */
.markdown-section .reader-chapter-subtitle { margin-top: -0.2em; font-weight: 600; }
.markdown-section .reader-chapter-lead { color: var(--muted); }
.markdown-section .reader-chapter-lead em, .markdown-section .reader-plain em { color: inherit; }
body[data-reading-mode="chinese"] .translated-source { display: none !important; }
body[data-reading-mode="chinese"] .reader-original-title,
body[data-reading-mode="chinese"] .heading-original { display: none; }
.markdown-section blockquote { color: var(--muted); border-left: 2px solid var(--line); margin: 1.5em 0; padding: 0 0 0 20px; }
.markdown-section blockquote p { margin: .6em 0; font-weight: 400; }
.markdown-section .chapter-epigraph { margin: 26px 0 32px; padding: 0; border: 0; font-size: 17px; line-height: 1.9; }
.chapter-epigraph cite { display: block; margin-top: 8px; text-align: right; font-family: var(--ui-font); font-size: 11px; font-style: normal; }
.markdown-section .reader-quotation { border-left-color: var(--accent); color: var(--ink); }
.markdown-section .reader-translator-note {
  margin: 28px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 12px 0; color: var(--muted); font-family: var(--ui-font); font-size: 13px; line-height: 1.8;
}
.reader-translator-note summary { cursor: pointer; }
.markdown-section .reader-translator-note p { margin: 12px 0; }
.note-reference { white-space: nowrap; }
/* Keep the superscript attached to the preceding text when a line wraps. */
.note-reference::before { content: "\2060"; }
.note-trigger {
  display: inline-flex; position: relative; align-items: center; justify-content: center;
  min-width: 14px; height: 14px; vertical-align: super; padding: 0 2px; margin: 0 1px;
  border: 0; border-radius: 3px; background: transparent;
  font-family: var(--ui-font); font-size: 11px; line-height: 1; font-weight: 600; color: var(--accent);
}
/* Enlarge the hit area without adding space between sentences. */
.note-trigger::before { content: ""; position: absolute; inset: -6px -5px; }
.note-mark { display: block; }
.note-trigger:hover, .note-trigger:focus-visible, .note-trigger[aria-expanded="true"] { background: var(--accent-soft); }
.note-popover {
  position: fixed; z-index: 120; display: flex; flex-direction: column; overflow: hidden;
  color: var(--ink); background: var(--page); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 12px 38px rgb(0 0 0 / .14); font-family: var(--ui-font);
}
.note-popover[hidden], .reader-settings[hidden] { display: none; }
.note-popover-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 9px 12px 4px 20px; }
.note-popover-head h2 { margin: 0; color: var(--muted); font-size: 12px; font-weight: 500; }
.note-popover-head .icon-button { width: 32px; height: 32px; }
.note-popover-body { padding: 4px 20px 20px; overflow: auto; overscroll-behavior: contain; overflow-wrap: anywhere; font-size: 15px; line-height: 1.85; }
.note-popover-body code { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-popover-body p { margin: 0; }
.note-popover-body a { text-underline-offset: 3px; }
.reader-settings {
  position: fixed; z-index: 90; top: calc(var(--header-height) + 10px); width: 244px; padding: 18px 20px;
  background: var(--page); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 30px rgb(0 0 0 / .1);
}
.reader-settings h2 { margin: 0 0 14px; color: var(--muted); font-size: 12px; font-weight: 500; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.settings-row + .settings-row { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.markdown-section pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 5px; color: var(--ink);
  padding: 20px; margin: 24px 0; line-height: 1.7; overflow: auto; max-width: 100%;
}
.markdown-section pre, .markdown-section code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.markdown-section code { color: var(--accent); background: var(--code-bg); font-size: .86em; padding: 2px 5px; border-radius: 3px; }
.markdown-section pre > code {
  padding: 0; border-radius: 0; color: var(--ink); font-size: 14px; line-height: 1.7; background: none;
  white-space: pre-wrap; overflow-wrap: normal;
}
/* Language tabs in the corner of translated examples replace the theme's plain language label. */
.markdown-section pre.has-lang-tabs::after { display: none; }
.code-lang-tabs {
  position: absolute; top: 7px; right: 7px; display: flex; gap: 1px; padding: 1px; font-family: var(--ui-font);
  border: 1px solid var(--line); border-radius: 5px; user-select: none; opacity: .85;
}
.code-lang-tabs:hover { opacity: 1; }
.code-lang-tabs button {
  border: 0; border-radius: 4px; padding: 1px 8px; font-size: 10.5px; line-height: 15px; font-weight: 500;
  background: transparent; color: var(--muted); cursor: pointer;
}
.code-lang-tabs button:hover { color: var(--ink); }
.code-lang-tabs button[aria-pressed="true"] { background: var(--line); color: var(--ink); font-weight: 600; }
.code-lang-tabs button[aria-disabled="true"] { opacity: .45; cursor: help; }
.code-lang-tabs button[aria-disabled="true"]:hover { color: var(--muted); }
.markdown-section pre.has-lang-tabs { padding-top: 32px; }
.reader-settings .mode-switch button { min-height: 30px; padding: 4px 12px; font-size: 13px; }
/* Syntax highlighting: one palette for light, one for dark, applied to every language. */
.markdown-section .token.comment, .markdown-section .token.prolog, .markdown-section .token.doctype,
.markdown-section .token.cdata { color: #586359; font-style: italic; }
.markdown-section .token.punctuation { color: #4f5a52; }
.markdown-section .token.operator { color: #086a8a; }
.markdown-section .token.keyword { color: #8f2190; }
.markdown-section .token.boolean, .markdown-section .token.number { color: #7f5600; }
.markdown-section .token.string, .markdown-section .token.char, .markdown-section .token.attr-value,
.markdown-section .token.triple-quoted-string { color: #2a6f29; }
.markdown-section .token.function { color: #2f5db8; }
.markdown-section .token.class-name { color: #875600; }
.markdown-section .token.builtin { color: #086a8a; }
.markdown-section .token.decorator, .markdown-section .token.annotation { color: #7f5600; }
.markdown-section .token.string-interpolation .token.interpolation { color: var(--ink); }
.markdown-section .token.namespace { opacity: .8; }
:root[data-theme="dark"] .markdown-section .token.comment, :root[data-theme="dark"] .markdown-section .token.prolog,
:root[data-theme="dark"] .markdown-section .token.doctype, :root[data-theme="dark"] .markdown-section .token.cdata { color: #8b968e; }
:root[data-theme="dark"] .markdown-section .token.punctuation { color: #b8c0ba; }
:root[data-theme="dark"] .markdown-section .token.operator { color: #56b6c2; }
:root[data-theme="dark"] .markdown-section .token.keyword { color: #c678dd; }
:root[data-theme="dark"] .markdown-section .token.boolean, :root[data-theme="dark"] .markdown-section .token.number { color: #d19a66; }
:root[data-theme="dark"] .markdown-section .token.string, :root[data-theme="dark"] .markdown-section .token.char,
:root[data-theme="dark"] .markdown-section .token.attr-value, :root[data-theme="dark"] .markdown-section .token.triple-quoted-string { color: #98c379; }
:root[data-theme="dark"] .markdown-section .token.function { color: #61afef; }
:root[data-theme="dark"] .markdown-section .token.class-name { color: #e5c07b; }
:root[data-theme="dark"] .markdown-section .token.builtin { color: #56b6c2; }
:root[data-theme="dark"] .markdown-section .token.decorator, :root[data-theme="dark"] .markdown-section .token.annotation { color: #d19a66; }
.markdown-section table { width: 100%; display: block; overflow-x: auto; font-family: var(--ui-font); font-size: 14px; border-collapse: collapse; }
.markdown-section th { background: var(--rail); font-weight: 600; }
.markdown-section td, .markdown-section th { border-color: var(--line); padding: 10px 14px; }
.markdown-section tr { background: var(--page); border-color: var(--line); }
.markdown-section tr:nth-child(2n) { background: var(--rail); }
.markdown-section img { max-width: 100%; height: auto; }
.medium-zoom-overlay { z-index: 100; background: var(--page) !important; }
.medium-zoom-image--opened { z-index: 101; }
.markdown-section hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
.chapter-visual { margin: 20px 0 28px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-family: var(--ui-font); }
.chapter-story { margin-top: 48px; }
.chapter-visual > summary { display: flex; align-items: center; gap: 14px; padding: 15px 0; list-style: none; cursor: pointer; }
.chapter-visual > summary::-webkit-details-marker { display: none; }
.chapter-visual > summary:hover { color: var(--accent); }
.guide-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; flex: none; }
.guide-label .reader-icon { width: 16px; height: 16px; flex-basis: 16px; }
.chapter-visual .guide-title { margin: 0; padding: 0; border: 0; font-family: var(--ui-font); font-size: 13px; font-weight: 400; line-height: 1.5; flex: 1; text-wrap: initial; }
.guide-chevron { margin-left: auto; color: var(--muted); }
.chapter-visual[open] .guide-chevron { transform: rotate(180deg); }
.diagram-toolbar { display: flex; justify-content: flex-end; margin: 0 0 4px; }
.diagram-stage { background: var(--diagram-bg); border: 0; border-radius: 2px; overflow: hidden; }
.diagram-stage .chapter-svg { display: block; width: 100%; height: auto; }
.chapter-visual[data-layout="mobile"] .chapter-svg,
.section-visual[data-layout="mobile"] .chapter-svg { max-width: 420px; margin: 0 auto; }
.markdown-section .guide-summary { color: var(--muted); font-family: var(--ui-font); font-size: 12px; line-height: 1.7; margin: 10px 0 18px; }
.section-visual { margin: 34px 0 40px; font-family: var(--ui-font); }
.section-visual figcaption { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 0; }
.section-visual .guide-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.section-visual .guide-summary { margin-bottom: 0; }
.diagram-loading { min-height: 240px; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.reader-toc { display: none; }
.reader-toc h2 { font-size: 11px; font-weight: 500; color: var(--muted); margin: 0 0 15px; }
.reader-toc a { display: block; font-size: 12px; line-height: 1.65; color: var(--muted); text-decoration: none; padding: 5px 0 5px 12px; border-left: 1px solid var(--line); }
.reader-toc a[data-depth="3"] { padding-left: 23px; }
.reader-toc a[aria-current="location"] { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }
.reader-toc a:hover { color: var(--accent); }
.reader-toc-close { display: none; }
body.toc-open .reader-toc {
  display: block; position: fixed; z-index: 70; top: calc(var(--header-height) + 12px); right: 18px;
  width: min(310px, calc(100vw - 36px)); max-height: calc(100dvh - var(--header-height) - 35px); overflow: auto;
  background: var(--page); padding: 20px; border: 1px solid var(--line); border-radius: 6px;
}
body.toc-open .reader-toc-close { display: flex; position: absolute; right: 8px; top: 8px; }
.chapter-pagination { display: flex; gap: 24px; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 48px; padding-top: 24px; font-family: var(--ui-font); }
.chapter-pagination a { display: flex; align-items: center; gap: 10px; max-width: 48%; text-decoration: none; font-size: 15px; line-height: 1.6; }
.chapter-pagination a[data-direction="next"] { margin-left: auto; text-align: right; }
.chapter-pagination small { display: block; color: var(--muted); font-size: 12px; }
.diagram-modal {
  width: min(1200px, calc(100vw - 32px)); max-width: none; height: min(900px, calc(100dvh - 32px));
  max-height: none; padding: 0; border: 1px solid var(--line); border-radius: 8px;
  background: var(--page); color: var(--ink); overflow: hidden;
}
.diagram-modal::backdrop { background: rgb(15 23 19 / .7); }
.diagram-modal[open] { display: flex; flex-direction: column; }
.diagram-modal-head { flex: 0 0 62px; display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.diagram-modal h2 { flex: 1; min-width: 0; font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diagram-modal-controls { display: flex; align-items: center; gap: 2px; }
.diagram-modal output { width: 45px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.diagram-viewport { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 20px; background: var(--rail); }
.diagram-canvas { min-width: 100%; min-height: 100%; display: grid; place-items: center; width: max-content; }
.diagram-canvas > svg { display: block; background: var(--diagram-bg); flex: none; }
body.diagram-open { overflow: hidden; }
@media (min-width: 1320px) {
  .content { padding-right: 244px; }
  .reader-toc, body.toc-open .reader-toc {
    display: block; position: fixed; right: 28px; top: 104px; width: 168px; max-height: calc(100dvh - 140px);
    overflow: auto; padding: 0; border: 0; border-radius: 0; background: transparent; z-index: 20;
  }
  .toc-toggle, .reader-toc-close, body.toc-open .reader-toc-close { display: none; }
}
@media (max-width: 1100px) {
  .reader-topbar { padding: 0 18px; gap: 8px; }
  .reader-topbar-main { gap: 8px; }
  .reader-preferences { gap: 8px; }
  .reader-brand { font-size: 13px; }
  .source-toggle { display: none; }
}
@media (max-width: 900px) {
  :root { --header-height: 56px; }
  .reader-topbar, body.close .reader-topbar { left: 0; height: 56px; padding: 0 12px; flex-wrap: nowrap; gap: 6px; }
  .reader-topbar-main { height: 56px; min-width: 0; }
  .reader-brand { font-size: 13px; }
  .reader-topbar-actions { height: 56px; }
  .reader-preferences { width: auto; height: auto; padding: 0; }
  .mode-switch { padding: 0; }
  .mode-switch button { font-size: 12px; min-height: 44px; padding: 5px 10px; }
  .icon-button { width: 44px; height: 44px; }
  .sidebar-nav > ul > li > a { min-height: 44px; }
  .sidebar .search input { font-size: 16px; }
  body .sidebar { top: 56px; padding-top: 24px; width: 280px; transform: translateX(-100%); height: calc(100dvh - 56px); overscroll-behavior: contain; }
  body.close .sidebar { transform: translateX(0); }
  body.close .sidebar-scrim { display: block; position: fixed; inset: 56px 0 0; background: rgb(0 0 0 / .3); border: 0; z-index: 50; }
  .content, body.close .content { margin-left: 0 !important; padding: 90px 22px 56px; }
  .markdown-section { max-width: 680px; line-height: 1.8; }
  .markdown-section .english-prose { line-height: 1.7; }
  .markdown-section h1 { font-size: 26px; }
  .markdown-section h2 { font-size: 22px; margin-top: 40px; }
  .markdown-section h3 { font-size: 20px; }
  .markdown-section .reader-original-title { font-size: 13px; }
  .chapter-visual { margin-top: 20px; }
  .chapter-visual .guide-title { font-size: 12px; }
  .markdown-section .guide-summary { font-size: 12px; }
  .chapter-pagination { gap: 16px; }
  .chapter-pagination a { font-size: 14px; }
  .diagram-modal { width: calc(100vw - 16px); height: calc(100dvh - 16px); }
  .diagram-modal-head { padding: 10px 12px; gap: 6px; flex-wrap: wrap; flex-basis: auto; }
  .diagram-modal h2 { font-size: 16px; flex-basis: 100%; max-width: none; }
  .diagram-modal-controls { gap: 0; width: 100%; justify-content: flex-end; }
  .diagram-modal-controls .icon-button { width: 44px; height: 44px; }
  .diagram-modal output { width: 45px; font-size: 12px; }
  .diagram-viewport { padding: 12px; }
}
@media (max-width: 600px) {
  .reader-brand { display: none; }
  .chapter-visual > summary { gap: 10px; }
}
@media (max-width: 420px) {
  .content, body.close .content { padding-left: 18px; padding-right: 18px; }
  .markdown-section pre { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
/* Draft chapters only: blocks that are not translated yet. */
.markdown-section .pending-translation { background: var(--accent-soft); border-radius: 4px; padding: 2px 8px; }
.markdown-section .pending-translation::before { content: "待译"; display: block; color: var(--accent); font-family: var(--ui-font); font-size: 12px; font-weight: 600; }

/* Translator-written chapter summary and takeaways, after the chapter text. */
.markdown-section .chapter-recap { margin: 2.6em 0 1.4em; padding: 18px 24px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--rail); }
.markdown-section .chapter-recap h2 { margin: 0 0 4px; padding: 0; border: 0; color: var(--accent); font-size: 1.15em; }
.markdown-section .chapter-recap .chapter-recap-note { margin: 0 0 10px; color: var(--muted); font-family: var(--ui-font); font-size: 12.5px; }
.markdown-section .chapter-recap ul { margin-top: .6em; }
