:root {
  color-scheme: light;
  --paper: #f4f0e8;
  --paper-raised: #fbf8f1;
  --ink: #18211f;
  --muted: #67706b;
  --faint: #8b928d;
  --line: rgba(24, 33, 31, 0.14);
  --line-strong: rgba(24, 33, 31, 0.28);
  --accent: #b83a2f;
  --accent-soft: #f0d6cf;
  --accent-ink: #7d251e;
  --trust: #245a52;
  --quote: #e8e1d5;
  --topbar: rgba(244, 240, 232, 0.9);
  --shadow: 0 24px 70px rgba(39, 35, 28, 0.12);
  --article-size: 18px;
  --article-line: 1.82;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121716;
  --paper-raised: #191f1d;
  --ink: rgba(255, 255, 255, 0.88);
  --muted: rgba(255, 255, 255, 0.65);
  --faint: rgba(255, 255, 255, 0.52);
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.25);
  --accent: #e66f5e;
  --accent-soft: #3a2824;
  --accent-ink: #ff9a89;
  --trust: #71b9aa;
  --quote: #232b28;
  --topbar: rgba(18, 23, 22, 0.9);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.toc-open { overflow: hidden; }
button, a { touch-action: manipulation; }
button { font: inherit; }
a { color: inherit; text-underline-offset: 0.2em; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  z-index: 90;
  background: transparent;
}
.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
}

.topbar {
  position: fixed;
  z-index: 80;
  top: 3px;
  left: 0;
  right: 0;
  height: 64px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 0 30px;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.site-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.mark-dot {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 5px var(--accent-soft);
}
.reader-tools { display: flex; align-items: center; gap: 10px; }
.font-controls {
  display: flex;
  align-items: center;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-raised);
}
.font-controls button {
  min-width: 34px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.font-controls button:hover { color: var(--ink); background: var(--quote); }
.font-controls button:disabled { opacity: 0.35; cursor: not-allowed; }
#fontReset { min-width: 32px; color: var(--ink); font-variant-numeric: tabular-nums; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--paper-raised);
  cursor: pointer;
}
.icon-button:hover { border-color: var(--line-strong); }
.toc-toggle { display: none; }
.sun-icon { display: none; }
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }

button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(210px, 270px) minmax(0, 820px) 72px;
  justify-content: center;
  gap: clamp(30px, 4vw, 72px);
  padding: 116px 34px 80px;
}
.toc-sidebar { min-width: 0; }
.toc-inner {
  position: sticky;
  top: 102px;
  max-height: calc(100vh - 126px);
  overflow: auto;
  padding-right: 18px;
  scrollbar-width: thin;
}
.toc-label {
  margin-bottom: 16px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
}
#tocNav { display: grid; gap: 3px; }
#tocNav a {
  position: relative;
  display: block;
  padding: 8px 8px 8px 16px;
  color: var(--muted);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  text-decoration: none;
}
#tocNav a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line-strong);
}
#tocNav a:hover { color: var(--ink); background: var(--quote); }
#tocNav a[aria-current="true"] { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }
#tocNav a[aria-current="true"]::before { background: var(--accent); }
.toc-progress {
  display: flex;
  justify-content: space-between;
  margin-top: 22px;
  padding: 14px 0 0;
  color: var(--faint);
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.toc-progress strong { color: var(--ink); font-variant-numeric: tabular-nums; }

main { min-width: 0; }
.article { width: 100%; }
.article-header {
  padding: 12px 0 52px;
  border-bottom: 1px solid var(--line-strong);
}
.article-kicker {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 22px;
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
}
.article-header h1 {
  max-width: 12em;
  margin: 0;
  color: var(--ink);
  font-size: clamp(42px, 6vw, 76px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0.035em;
  text-wrap: balance;
}
.original-title {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 15px;
}
.author-row {
  display: grid;
  grid-template-columns: 42px auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 34px;
  color: var(--muted);
  font-size: 13px;
}
.author-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--accent-ink);
  background: var(--accent-soft);
  font-weight: 600;
}
.author-row div:nth-child(2) { display: grid; gap: 2px; }
.author-row strong { color: var(--ink); font-weight: 600; }
.author-row time { justify-self: end; font-variant-numeric: tabular-nums; }

.article-body {
  font-size: var(--article-size);
  line-height: var(--article-line);
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.article-intro {
  margin: 48px 0 70px;
  padding: 30px 34px;
  border-left: 4px solid var(--accent);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
}
.article-intro p { margin: 0 0 1em; }
.article-intro p:first-child {
  color: var(--accent-ink);
  font-size: 1.24em;
  font-weight: 600;
}
.article-intro p:last-child { margin-bottom: 0; }

.article-section { position: relative; padding: 72px 0 4px; }
.article-section[data-chapter]::before {
  content: attr(data-chapter);
  position: absolute;
  top: 43px;
  right: 0;
  color: var(--line);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: clamp(64px, 10vw, 112px);
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}
.article-section h2 {
  position: relative;
  max-width: 17em;
  margin: 0 0 38px;
  padding-top: 14px;
  color: var(--ink);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: 0.025em;
  text-wrap: balance;
}
.article-section h2::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 44px;
  height: 3px;
  background: var(--accent);
}
.article-section h3 {
  margin: 42px 0 18px;
  color: var(--trust);
  font-size: 1.08em;
  font-weight: 600;
  line-height: 1.55;
  text-wrap: balance;
}
.article-section p { max-width: 38em; margin: 0 0 1.15em; text-wrap: pretty; }
.article-section .type-line {
  margin-top: 1.7em;
  color: var(--ink);
  font-weight: 600;
}
.article-section .type-line + p {
  margin-top: -0.8em;
  padding-left: 1.75em;
  color: var(--muted);
}
.article-list {
  max-width: 38em;
  margin: 0 0 1.4em;
  padding: 0;
  list-style: none;
}
.article-list li {
  position: relative;
  margin: 0.55em 0;
  padding-left: 1.4em;
}
.article-list li::before {
  content: "";
  position: absolute;
  top: 0.78em;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.quoted-line {
  margin: 1.5em 0 !important;
  padding: 18px 22px;
  border-left: 3px solid var(--trust);
  background: var(--quote);
  color: var(--ink);
}
.evidence-line { font-variant-numeric: tabular-nums; }
.sequence-line {
  max-width: none !important;
  margin: 26px 0 38px !important;
  padding: 22px 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--paper-raised);
  font-weight: 600;
}
.step-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 34px !important;
  color: var(--ink) !important;
}
.closing-line {
  margin-bottom: 0.55em !important;
  color: var(--ink);
  font-size: 1.08em;
  font-weight: 500;
}
.closing-line:last-of-type { color: var(--accent-ink); }
.promo-link a, .article-body p a {
  color: var(--accent-ink);
  text-decoration-thickness: 1px;
}
.reference-line, .references-section p {
  color: var(--muted);
  font-size: 0.79em;
  line-height: 1.7;
}
.references-section cite { color: var(--ink); font-style: normal; font-weight: 500; }
.research-note {
  max-width: none !important;
  margin-top: 34px !important;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--paper-raised);
  font-size: 0.82em;
  line-height: 1.75;
}
.recap-section {
  margin-top: 68px;
  padding: 52px 42px 38px;
  border: 1px solid var(--line-strong);
  border-radius: calc(var(--radius) + 4px);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
}
.recap-section h2 { font-size: clamp(27px, 4vw, 38px); }
.closing-section { padding-bottom: 26px; }

.article-media {
  margin: 72px 0 8px;
}
.media-zoom {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-raised);
  cursor: zoom-in;
  box-shadow: var(--shadow);
}
.media-zoom img {
  display: block;
  width: 100%;
  height: auto;
}
.zoom-hint {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 7px 10px;
  border-radius: 8px;
  color: #fff;
  background: rgba(10, 14, 13, 0.72);
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.media-zoom:hover .zoom-hint,
.media-zoom:focus-visible .zoom-hint { opacity: 1; transform: translateY(0); }
.article-media figcaption {
  margin-top: 10px;
  color: var(--faint);
  font-size: 12px;
  text-align: right;
}

.article-footer {
  margin-top: 86px;
  padding: 38px 0 18px;
  border-top: 2px solid var(--ink);
}
.translation-notice {
  margin: 0 0 26px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 600;
}
.article-footer dl { display: grid; gap: 10px; margin: 0 0 28px; }
.article-footer dl div { display: grid; grid-template-columns: 92px 1fr; gap: 14px; }
.article-footer dt { color: var(--faint); font-size: 13px; }
.article-footer dd { margin: 0; color: var(--muted); font-size: 14px; }
.source-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  color: var(--paper-raised);
  background: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.source-button:hover { background: var(--accent); color: #fff; }
.source-button svg { width: 17px; height: 17px; }

.chapter-rail {
  position: sticky;
  top: 108px;
  display: grid;
  justify-items: center;
  align-self: start;
  gap: 12px;
  height: calc(100vh - 160px);
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.18em;
}
.chapter-rail span { writing-mode: vertical-rl; }
.chapter-rail i { width: 1px; height: 100%; background: var(--line); }
.chapter-rail b { font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0; }

.media-dialog {
  width: min(94vw, 1320px);
  max-width: none;
  max-height: 92vh;
  padding: 42px 18px 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--paper-raised);
  box-shadow: 0 30px 90px rgba(0,0,0,.38);
  overscroll-behavior: contain;
}
.media-dialog::backdrop { background: rgba(5, 8, 7, 0.76); backdrop-filter: blur(5px); }
.media-dialog img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 8px; }
.media-dialog p { margin: 12px 4px 0; color: var(--muted); font-size: 13px; text-align: center; }
.dialog-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  color: var(--ink);
  background: var(--quote);
  cursor: pointer;
}
.toc-scrim { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1050px) {
  .layout { grid-template-columns: 220px minmax(0, 760px); gap: 42px; }
  .chapter-rail { display: none; }
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    padding: 0 16px;
    gap: 12px;
  }
  .toc-toggle { display: inline-grid; }
  .site-mark { justify-self: start; }
  .layout { display: block; padding: 104px 22px 64px; }
  .toc-sidebar {
    position: fixed;
    z-index: 92;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(84vw, 330px);
    padding: 78px 18px 24px;
    background: var(--paper-raised);
    border-right: 1px solid var(--line);
    box-shadow: 24px 0 60px rgba(0,0,0,.2);
    transform: translateX(-105%);
    transition: transform 220ms cubic-bezier(.2,.8,.2,1);
  }
  .toc-open .toc-sidebar { transform: translateX(0); }
  .toc-inner { position: static; max-height: 100%; padding-right: 4px; }
  .toc-scrim {
    position: fixed;
    z-index: 91;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(5,8,7,.46);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }
  .toc-open .toc-scrim { display: block; opacity: 1; pointer-events: auto; }
  .article-header h1 { font-size: clamp(39px, 10vw, 64px); }
}

@media (max-width: 560px) {
  .topbar { padding: 0 12px; }
  .site-mark span:last-child { display: none; }
  .reader-tools { gap: 6px; }
  .font-controls button { min-width: 30px; padding: 0 5px; }
  .layout { padding: 94px 18px 50px; }
  .article-header { padding-bottom: 38px; }
  .article-header h1 { max-width: 8em; font-size: 42px; line-height: 1.12; }
  .article-kicker { margin-bottom: 18px; }
  .author-row { grid-template-columns: 38px 1fr; }
  .author-avatar { width: 38px; height: 38px; }
  .author-row time { grid-column: 2; justify-self: start; margin-top: -5px; }
  .article-intro { margin: 34px -2px 48px; padding: 24px 22px; }
  .article-section { padding-top: 58px; }
  .article-section[data-chapter]::before { top: 40px; font-size: 62px; }
  .article-section h2 { margin-bottom: 30px; font-size: 29px; }
  .article-section p { max-width: none; }
  .recap-section { margin: 56px -6px 0; padding: 40px 22px 26px; }
  .article-media { margin: 54px -6px 0; }
  .zoom-hint { display: none; }
  .translation-notice { font-size: 19px; }
  .article-footer dl div { grid-template-columns: 76px 1fr; }
  .media-dialog { width: calc(100vw - 18px); padding: 42px 9px 12px; }
}

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

@media print {
  :root { --paper: #fff; --paper-raised: #fff; --ink: #111; --muted: #444; }
  .topbar, .reading-progress, .toc-sidebar, .chapter-rail, .zoom-hint { display: none !important; }
  .layout { display: block; padding: 0; }
  .article { max-width: 720px; margin: 0 auto; }
  .article-section, .article-media { break-inside: avoid; }
  .source-button { border: 1px solid #111; color: #111; background: #fff; }
}

