/* === Font Faces === */
@font-face {
  font-family: "InstrumentSerif";
  src: url("./_shared/fonts/InstrumentSerif-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "InstrumentSerif";
  src: url("./_shared/fonts/InstrumentSerif-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "WorkSans";
  src: url("./_shared/fonts/WorkSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "WorkSans";
  src: url("./_shared/fonts/WorkSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "WorkSans";
  src: url("./_shared/fonts/WorkSans-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "JetBrainsMono";
  src: url("./_shared/fonts/JetBrainsMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* === Design Tokens === */
:root {
  --bg: #f6f3ee;          /* 牛皮纸感米白 */
  --bg2: #ffffff;         /* 卡片白 */
  --bg3: #ece6d8;         /* 浅米色 */
  --ink: #1a1a1a;         /* 主文字 */
  --ink2: #3a3a3a;        /* 次要文字 */
  --muted: #6b6660;       /* 弱化文字 */
  --rule: #d6cfc1;        /* 分隔线 */
  --accent: #8b1a1a;      /* 法律红(主色) */
  --accent-soft: #b85959; /* 柔化红 */
  --accent2: #1f3a5f;     /* 蓝调,辅助 */
  --gold: #b08a3e;        /* 强调金 */
  --shadow: 0 1px 2px rgba(26,26,26,0.04), 0 4px 12px rgba(26,26,26,0.06);
}

/* === Base === */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "WorkSans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 {
  font-family: "InstrumentSerif", "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  color: var(--ink);
  font-weight: 400;
  line-height: 1.25;
}
.serif { font-family: "InstrumentSerif", "Songti SC", "STSong", serif; }
.mono { font-family: "JetBrainsMono", "Menlo", monospace; }
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.2s; }
a:hover { border-bottom-color: var(--accent); }

/* === Layout === */
.container { max-width: 880px; margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 720px; margin: 0 auto; padding: 0 24px; }

/* === Cover === */
.cover {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px 24px;
  border-bottom: 1px solid var(--rule);
  position: relative;
  overflow: hidden;
}
.cover::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(139,26,26,0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(31,58,95,0.04) 0%, transparent 50%);
  pointer-events: none;
}
.cover-inner { position: relative; max-width: 880px; margin: 0 auto; width: 100%; }
.cover-eyebrow {
  font-family: "WorkSans", sans-serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cover-eyebrow::before {
  content: "";
  display: inline-block;
  width: 32px;
  height: 1px;
  background: var(--accent);
}
.cover h1 {
  font-size: clamp(48px, 7vw, 88px);
  letter-spacing: -0.02em;
  margin-bottom: 32px;
}
.cover h1 em {
  font-style: italic;
  color: var(--accent);
}
.cover-sub {
  max-width: 640px;
  margin-bottom: 40px;
}
.cover-sub-lead {
  font-family: "InstrumentSerif", "Songti SC", serif;
  font-size: clamp(20px, 2.4vw, 24px);
  line-height: 1.55;
  color: var(--ink2);
  margin-bottom: 18px;
}
.cover-sub-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.cover-sub-points li {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  background: rgba(139, 26, 26, 0.06);
  border: 1px solid rgba(139, 26, 26, 0.12);
  padding: 8px 12px;
  border-radius: 2px;
}
.cover-sub-note {
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.cover-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 0;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  padding-top: 28px;
  margin-top: 8px;
}
.cover-meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 16px;
  border-right: 1px solid var(--rule);
  line-height: 1.4;
}
.cover-meta-item:first-child { padding-left: 0; }
.cover-meta-item:last-child {
  border-right: none;
  padding-right: 0;
}
.cover-meta-item strong {
  color: var(--ink);
  font-weight: 700;
}
.cover-edition {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  margin-top: 20px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.cover-edition span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cover-edition strong {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 11px;
}
.cover-tagline {
  margin-top: 28px;
  max-width: 520px;
  font-family: "InstrumentSerif", "Songti SC", serif;
  font-size: 18px;
  font-style: italic;
  line-height: 1.55;
  color: var(--ink2);
}

/* === Disclaimer === */
.disclaimer-page {
  background: linear-gradient(180deg, #faf6ef 0%, #f4ecdd 100%);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 80px 0;
}
.disclaimer-eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: #b5651d;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 12px;
}
.disclaimer-page h2 {
  font-size: 34px;
  margin-bottom: 24px;
  color: #1a1a1a;
}
.disclaimer-lede {
  font-size: 16px;
  line-height: 1.8;
  color: #444;
  margin-bottom: 40px;
  max-width: 760px;
}
.disclaimer-block {
  background: #fff;
  border: 1px solid #e6dcc4;
  border-left: 4px solid #b5651d;
  border-radius: 6px;
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.disclaimer-block h3 {
  font-size: 18px;
  color: #1a1a1a;
  margin-bottom: 12px;
  font-weight: 700;
}
.disclaimer-block p,
.disclaimer-block li {
  font-size: 14.5px;
  line-height: 1.85;
  color: #333;
  margin-bottom: 10px;
}
.disclaimer-block ul {
  padding-left: 22px;
  margin: 8px 0;
}
.disclaimer-block li {
  margin-bottom: 6px;
}
.disclaimer-final {
  background: #fffaf0;
  border-left-color: #8b3a1a;
}
.disclaimer-signoff {
  text-align: right;
  margin-top: 32px;
  color: #555;
  font-size: 14px;
}
.disclaimer-signoff p {
  margin: 4px 0;
}
.disclaimer-date {
  color: #888;
  font-size: 13px;
}

/* === Chapter Disclaimer Note (per-chapter) === */
.chapter-disclaimer {
  background: #fdf6e3;
  border: 1px dashed #d6c690;
  border-radius: 4px;
  padding: 10px 16px;
  margin: 16px 0 28px 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: #6b5a2e;
}
.chapter-disclaimer strong {
  color: #8b6914;
}

/* === Copyright Page === */
.copyright-page {
  background:
    radial-gradient(ellipse at 15% 0%, rgba(176, 138, 62, 0.12) 0%, transparent 45%),
    radial-gradient(ellipse at 90% 80%, rgba(139, 26, 26, 0.18) 0%, transparent 50%),
    linear-gradient(165deg, #1a1816 0%, #121110 55%, #0e0d0c 100%);
  color: #c8c2b8;
  padding: 80px 0;
  border-top: none;
}
.copyright-page h2 {
  font-size: 28px;
  color: #f2ece3;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.copyright-tagline {
  font-size: 14px;
  color: #8a847a;
  margin-bottom: 40px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.copyright-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px 36px;
  margin-bottom: 40px;
}
.copyright-col h3 {
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 14px;
  font-weight: 700;
}
.copyright-col p,
.copyright-col li {
  font-size: 14px;
  line-height: 1.85;
  color: #c8c2b8;
  margin-bottom: 8px;
}
.copyright-col p strong {
  color: #f2ece3;
  margin-right: 0.35em;
}
.copyright-col ul,
.copyright-col ol {
  padding-left: 0;
  list-style: none;
  margin: 0;
}
.copyright-facts li,
.copyright-rules li,
.copyright-hotlines li {
  padding-left: 0;
  position: relative;
  margin-bottom: 10px;
}
.copyright-facts li::before,
.copyright-rules li::before,
.copyright-hotlines li::before {
  content: none;
}
.copyright-facts li span {
  display: inline-block;
  min-width: 2.5em;
  margin-right: 10px;
  color: #8a847a;
  font-size: 12.5px;
  letter-spacing: 0.06em;
}
.copyright-rules {
  counter-reset: crule;
}
.copyright-rules li {
  padding-left: 1.6em;
  counter-increment: crule;
}
.copyright-rules li::before {
  content: counter(crule) ".";
  position: absolute;
  left: 0;
  color: var(--gold);
  font-family: "JetBrainsMono", monospace;
  font-size: 12.5px;
}
.copyright-hotlines li {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.copyright-hotlines strong {
  color: #f2ece3;
  font-family: "JetBrainsMono", monospace;
  font-size: 15px;
  min-width: 4.2em;
}
.copyright-hotlines span {
  color: #c8c2b8;
}
.copyright-meta {
  border-top: 1px solid rgba(214, 207, 193, 0.18);
  padding-top: 24px;
  font-size: 12.5px;
  color: #8a847a;
  line-height: 1.8;
}
.copyright-meta p {
  margin: 4px 0;
}
.copyright-owner {
  color: #e8e0d4 !important;
  margin-bottom: 10px !important;
}
.copyright-online {
  margin: 10px 0 14px;
  color: #8a847a;
  letter-spacing: 0.04em;
}
.copyright-online a {
  color: var(--gold);
  font-family: "JetBrainsMono", "Menlo", monospace;
  font-size: 13px;
  border-bottom: 1px solid rgba(176, 138, 62, 0.45);
  text-decoration: none;
}
.copyright-online a:hover {
  color: #f2ece3;
  border-bottom-color: var(--gold);
}
.copyright-meta strong {
  color: #e8e0d4;
}

/* === TOC === */
.toc {
  background: var(--bg2);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 64px 0;
}
.toc h2 { font-size: 32px; margin-bottom: 32px; }
.toc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  border-top: 1px solid var(--rule);
}
.toc-item {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--rule);
  font-size: 15px;
  color: var(--ink2);
  border-right: 1px solid var(--rule);
  transition: background 0.2s;
}
.toc-item:nth-child(2n) { border-right: none; }
.toc-item:hover { background: var(--bg3); }
.toc-num {
  font-family: "InstrumentSerif", serif;
  font-size: 20px;
  color: var(--accent);
  font-style: italic;
  min-width: 32px;
}
.toc-title { flex: 1; }

/* === Content sections === */
section.chapter {
  padding: 96px 0;
  border-bottom: 1px solid var(--rule);
}
section.chapter:last-of-type { border-bottom: none; }
.chapter-num {
  font-family: "InstrumentSerif", serif;
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.chapter-num::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
  max-width: 80px;
}
.chapter h2 {
  font-size: 44px;
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}
.chapter h2 em { font-style: italic; color: var(--accent); }
.chapter-lede {
  font-size: 19px;
  color: var(--ink2);
  line-height: 1.6;
  margin-bottom: 48px;
  max-width: 720px;
  font-family: "InstrumentSerif", "Songti SC", serif;
  font-style: italic;
}
.chapter h3 {
  font-size: 26px;
  margin: 56px 0 16px;
  color: var(--ink);
}
.chapter h3::before {
  content: "§ ";
  color: var(--accent);
  font-style: italic;
}
.chapter h4 {
  font-size: 18px;
  margin: 32px 0 12px;
  font-family: "WorkSans", sans-serif;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0;
}
.chapter p { margin-bottom: 18px; }
.chapter ul, .chapter ol { margin: 12px 0 24px 24px; }
.chapter li { margin-bottom: 8px; }

/* === Inline mark === */
mark.key {
  background: rgba(139,26,26,0.08);
  color: var(--accent);
  padding: 0 4px;
  border-radius: 2px;
  font-weight: 600;
}

/* === Callout box === */
.callout {
  background: var(--bg2);
  border-left: 3px solid var(--accent);
  padding: 24px 28px;
  margin: 32px 0;
  box-shadow: var(--shadow);
}
.callout.warn { border-left-color: var(--accent); background: #faf0f0; }
.callout.note { border-left-color: var(--accent2); background: #f0f4f8; }
.callout.tip { border-left-color: var(--gold); background: #faf6e9; }
.callout.script { border-left-color: #2f6f5e; background: #f0f6f3; color: var(--ink); }
.callout-title {
  font-family: "WorkSans", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.callout.warn .callout-title { color: var(--accent); }
.callout.note .callout-title { color: var(--accent2); }
.callout.tip .callout-title { color: var(--gold); }
.callout.script .callout-title { color: #2f6f5e; }
.callout p:last-child { margin-bottom: 0; }
.callout.script ol, .callout.script ul { margin: 8px 0 0 1.2rem; color: var(--ink); }
.callout.script li { margin-bottom: 8px; color: var(--ink); }
.callout.warn ol, .callout.warn ul { margin: 8px 0 0 1.2rem; }
.callout.warn li { margin-bottom: 8px; }

/* === Quote / 话术框 === */
.script {
  background: #f0f6f3;
  color: var(--ink);
  border: 1px solid #c5d9d0;
  border-left: 3px solid #2f6f5e;
  padding: 24px 28px;
  margin: 24px 0;
  border-radius: 4px;
  position: relative;
  box-shadow: var(--shadow);
}
.script-label {
  font-family: "WorkSans", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #2f6f5e;
  margin-bottom: 12px;
}
.script p { margin-bottom: 12px; line-height: 1.7; }
.script p:last-child { margin-bottom: 0; }
.script em { color: #8b6914; font-style: normal; font-weight: 600; }

/* === Tables === */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 600px;
  margin: 32px 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg2);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  min-width: 600px;
}
th {
  background: var(--bg3);
  color: var(--ink);
  font-family: "WorkSans", sans-serif;
  font-weight: 700;
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1.5px solid var(--rule);
  white-space: nowrap;
  font-size: 13px;
  letter-spacing: 0.02em;
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink2);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* === Diagram === */
.diagram {
  margin: 40px 0;
  background: var(--bg2);
  border: 1px solid var(--rule);
  padding: 32px 24px;
  border-radius: 4px;
  text-align: center;
}
.diagram figcaption {
  font-size: 13px;
  color: var(--muted);
  margin-top: 16px;
  font-style: italic;
  font-family: "InstrumentSerif", serif;
}
.flow-v {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  max-width: 520px;
  margin: 0 auto;
  text-align: left;
}
.flow-v-item {
  width: 100%;
  background: #faf0f0;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 14px 18px;
  color: var(--ink);
}
.flow-v-item strong {
  display: block;
  color: var(--accent);
  font-size: 14px;
  margin-bottom: 4px;
}
.flow-v-item span {
  font-size: 13.5px;
  color: var(--ink2);
  line-height: 1.5;
}
.flow-v-item.final {
  background: #f0f6f3;
  border-color: #2f6f5e;
  color: var(--ink);
}
.flow-v-item.final strong { color: #2f6f5e; }
.flow-v-item.final span { color: var(--ink2); }
.flow-v-arrow {
  color: var(--accent);
  font-size: 18px;
  line-height: 1.4;
  padding: 2px 0;
}
.flow-h {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 8px;
  max-width: 760px;
  margin: 0 auto;
}
.flow-h-item {
  flex: 1 1 140px;
  min-width: 120px;
  max-width: 180px;
  background: #faf0f0;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 12px 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  text-align: center;
}
.flow-h-item.dark {
  background: #8b1a1a;
  border-color: #8b1a1a;
  color: #fff;
}
.flow-h-item.blue {
  background: #1f3a5f;
  border-color: #1f3a5f;
  color: #fff;
}
.flow-h-item.mid {
  background: #b85959;
  border-color: #b85959;
  color: #fff;
}
.flow-h-arrow {
  display: flex;
  align-items: center;
  color: var(--accent);
  font-size: 16px;
  flex: 0 0 auto;
  align-self: center;
}
@media (max-width: 768px) {
  .flow-h-arrow { display: none; }
  .flow-h-item { max-width: none; flex: 1 1 100%; }
}

/* === Chart === */
.chart-figure {
  margin: 40px 0;
  background: var(--bg2);
  border: 1px solid var(--rule);
  padding: 24px;
  border-radius: 4px;
}
.chart-figure figcaption {
  font-family: "WorkSans", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 16px;
  letter-spacing: 0.01em;
}
.chart-subcaption {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 6px;
}
#chart-compensation, #chart-cases { width: 100%; min-height: 380px; }

/* === Case card === */
.case-card {
  background: var(--bg2);
  border: 1px solid var(--rule);
  padding: 28px;
  margin: 24px 0;
  border-radius: 4px;
  position: relative;
  box-shadow: var(--shadow);
}
.case-tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: var(--accent);
  color: white;
  padding: 4px 10px;
  border-radius: 2px;
  font-weight: 700;
  margin-bottom: 12px;
}
.case-card h4 {
  font-family: "InstrumentSerif", serif;
  font-size: 22px;
  font-weight: 400;
  margin: 0 0 12px 0;
  color: var(--ink);
  font-style: italic;
}
.case-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  font-family: "JetBrainsMono", monospace;
}
.case-card p { font-size: 15px; margin-bottom: 12px; }
.case-outcome {
  background: #faf0f0;
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 14.5px;
  color: var(--ink2);
}
.case-outcome strong { color: var(--accent); font-weight: 700; }
.case-link {
  cursor: pointer;
  border-bottom: 1px solid var(--accent);
  font-weight: 600;
}
.case-link:hover {
  border-bottom-width: 2px;
}

/* === Checklist === */
.checklist {
  background: var(--bg2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 24px;
  margin: 24px 0;
}
.checklist h4 {
  margin: 0 0 16px 0;
  font-family: "WorkSans", sans-serif;
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.checklist ul { list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 15px;
}
.checklist li:last-child { border-bottom: none; }
.checklist li::before {
  content: "□";
  color: var(--accent);
  font-size: 18px;
  line-height: 1.3;
  flex-shrink: 0;
  font-family: "JetBrainsMono", monospace;
}

/* === Flow === */
.flow-steps {
  display: grid;
  grid-template-columns: 1fr;
  margin: 32px 0;
}
.flow-step {
  display: flex;
  gap: 24px;
  padding: 24px 0;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.flow-step:last-child { border-bottom: none; }
.flow-step-num {
  font-family: "InstrumentSerif", serif;
  font-size: 48px;
  color: var(--accent);
  font-style: italic;
  line-height: 1;
  min-width: 56px;
  text-align: center;
}
.flow-step-content h5 {
  font-family: "WorkSans", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}
.flow-step-content p { font-size: 15px; color: var(--ink2); margin-bottom: 6px; }
.flow-step-content .when {
  font-size: 13px;
  color: var(--muted);
  font-family: "JetBrainsMono", monospace;
}

/* === Pull quote === */
.pull-quote {
  font-family: "InstrumentSerif", serif;
  font-size: 28px;
  line-height: 1.35;
  color: var(--ink);
  text-align: center;
  margin: 56px auto;
  padding: 0 32px;
  max-width: 720px;
  font-style: italic;
  position: relative;
}
.pull-quote::before, .pull-quote::after {
  content: "";
  display: block;
  width: 40px;
  height: 1px;
  background: var(--accent);
  margin: 24px auto;
}

/* === Timeline === */
.timeline {
  --dot-size: 14px;
  --dot-top: 6px;
  --line-w: 2px;
  position: relative;
  margin: 32px 0;
  padding-left: 0;
  border-left: none;
}
.timeline::before {
  content: "";
  position: absolute;
  left: calc(var(--dot-size) / 2 - var(--line-w) / 2);
  top: calc(var(--dot-top) + var(--dot-size) / 2);
  bottom: calc(var(--dot-top) + var(--dot-size) / 2);
  width: var(--line-w);
  background: var(--rule);
  border-radius: 1px;
}
.timeline-item {
  position: relative;
  padding: 0 0 28px calc(var(--dot-size) + 20px);
}
.timeline-item:last-child {
  padding-bottom: 0;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--dot-top);
  width: var(--dot-size);
  height: var(--dot-size);
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  box-sizing: border-box;
  z-index: 1;
}
.timeline-item.active::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 26, 26, 0.12);
}
.timeline-item h5 {
  font-family: "WorkSans", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin: 2px 0 6px;
}
.timeline-item p {
  font-size: 14.5px;
  color: var(--ink2);
  margin-bottom: 0;
}
.timeline-item .time {
  font-size: 12px;
  color: var(--accent);
  font-family: "JetBrainsMono", monospace;
  letter-spacing: 0.05em;
  line-height: 1.4;
}

/* === Two col === */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 32px 0;
}
.col-card {
  background: var(--bg2);
  border: 1px solid var(--rule);
  padding: 24px;
  border-radius: 4px;
}
.col-card h4 {
  font-family: "WorkSans", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 16px;
}
.col-card.good h4 { color: var(--accent2); }
.col-card.bad h4 { color: var(--accent); }

/* === Footer === */
footer {
  background: var(--bg2);
  color: var(--ink2);
  padding: 80px 0 40px;
  margin-top: 0;
  border-top: 1px solid var(--rule);
}
footer .container { color: var(--ink2); }
footer h2 {
  color: var(--ink);
  font-size: 32px;
  margin-bottom: 16px;
}
footer .epilogue {
  font-family: "InstrumentSerif", serif;
  font-size: 22px;
  line-height: 1.6;
  font-style: italic;
  color: var(--ink2);
  max-width: 640px;
  margin-bottom: 48px;
}
.sources {
  border-top: 1px solid var(--rule);
  padding-top: 32px;
}
.sources h3 {
  color: var(--ink);
  font-family: "WorkSans", sans-serif;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 12px;
}
.sources-note {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 24px 0;
  max-width: 720px;
}
.sources ol {
  padding-left: 1.2rem;
  font-size: 13.5px;
  color: var(--ink2);
  list-style: none;
}
.sources li {
  margin-bottom: 14px;
  line-height: 1.55;
  padding-left: 2.2rem;
  position: relative;
}
.sources li:not(.sources-cat)::before {
  content: attr(value) ".";
  position: absolute;
  left: 0;
  color: var(--muted);
  font-family: "JetBrainsMono", monospace;
  font-size: 12.5px;
}
.sources-cat {
  list-style: none;
  padding-left: 0 !important;
  margin: 28px 0 12px 0;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 6px;
}
.sources-cat::before { content: none !important; }
.sources-cat span {
  font-family: "WorkSans", sans-serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: none;
  font-weight: 700;
  color: var(--accent);
}
.sources .src-title {
  color: var(--ink);
  display: block;
  margin-bottom: 2px;
}
.sources .src-url {
  display: block;
  color: var(--accent2);
  font-size: 12.5px;
  word-break: break-all;
  font-family: "JetBrainsMono", monospace;
}
.sources a { color: var(--accent2); border-bottom: 1px dotted var(--accent2); }
.sources a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.colophon {
  border-top: 1px solid var(--rule);
  margin-top: 48px;
  padding-top: 24px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  font-family: "JetBrainsMono", monospace;
  letter-spacing: 0.05em;
}

/* === Citation === */
sup a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.7em;
  font-weight: 700;
  margin-left: 2px;
  border-bottom: none;
}
sup a:hover { border-bottom: 1px solid var(--accent); }

/* === Responsive === */
@media (max-width: 768px) {
  .cover { padding: 60px 24px; }
  .toc-grid { grid-template-columns: 1fr; }
  .toc-item { border-right: none; }
  section.chapter { padding: 64px 0; }
  .chapter h2 { font-size: 34px; }
  .chapter h3 { font-size: 22px; }
  .two-col { grid-template-columns: 1fr; }
  .cover-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .cover-meta-item {
    border-right: none;
    padding: 0;
  }
  .cover-tagline { font-size: 16px; }
  .pull-quote { font-size: 22px; }
  .container, .container-narrow { padding: 0 20px; }
  .copyright-grid { grid-template-columns: 1fr; gap: 32px; }
}
@media print {
  @page {
    size: A4;
    margin: 12mm 11mm 14mm;
  }

  html, body {
    background: #f6f3ee !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* 取消网页全屏高度，避免封面/章节留下半页空白 */
  .cover,
  .disclaimer-page,
  section.chapter,
  .copyright-page {
    min-height: 0 !important;
  }

  .cover {
    display: block;
    padding: 36px 12px 28px;
    break-after: page;
    page-break-after: always;
  }

  .cover h1 {
    font-size: 42px;
    margin-bottom: 18px;
  }

  .disclaimer-page {
    padding: 28px 0 20px;
    /* 免责与目录连续排，不再单独占一整页 */
    break-after: auto;
    page-break-after: auto;
  }

  nav.toc,
  .toc {
    padding: 14px 0 10px;
    /* 目录整块同一页，禁止拦腰拆到上下两页；目录后仍换页进入正文（与改错前一致） */
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: page;
    page-break-after: always;
  }

  .toc h2 {
    font-size: 26px;
    margin-bottom: 12px;
  }

  .toc-grid,
  .toc-item {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .toc-item {
    padding: 10px 12px;
    font-size: 13px;
  }

  section.chapter {
    padding: 22px 0 18px;
    /* 关键：章节之间连续排版，不再每章强制换页 */
    break-before: auto;
    page-break-before: auto;
  }

  .chapter-lede {
    margin-bottom: 20px;
  }

  /* 只避免「标题孤行」，大块卡片/表格允许跨页，否则页尾会空一大截 */
  h2, h3, h4, .chapter-num {
    break-after: avoid;
    page-break-after: avoid;
  }

  .callout,
  .case-card,
  .table-wrap,
  .script,
  .checklist,
  .flow-steps,
  figure.diagram {
    break-inside: auto;
    page-break-inside: auto;
  }

  orphans: 3;
  widows: 3;

  /* 链接在 PDF 里保持可辨识；微信内置阅读器常点不开外链 */
  a {
    color: var(--accent) !important;
    text-decoration: underline;
  }

  .toc a,
  .toc a:visited,
  .copyright-online a,
  .copyright-online a:visited,
  sup a {
    text-decoration: none;
  }

  .toc a,
  .toc a:visited,
  sup a {
    color: inherit !important;
  }

  .copyright-online a,
  .copyright-online a:visited {
    color: var(--gold) !important;
    border-bottom: 1px solid rgba(176, 138, 62, 0.55);
  }

  .toc a::after,
  .copyright-online a::after,
  sup a::after {
    content: none !important;
  }

  /* 把完整网址印在链接下方，方便手机长按复制到浏览器打开 */
  a.case-link::after,
  a.src-url::after {
    content: attr(href);
    display: block;
    margin-top: 3px;
    font-size: 10px;
    font-weight: 400;
    line-height: 1.4;
    color: #6b6660 !important;
    text-decoration: none;
    border: none;
    word-break: break-all;
  }

  .copyright-page {
    padding: 36px 0 28px;
    break-before: page;
    page-break-before: always;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
