:root {
  color-scheme: light;
  --bg: oklch(1 0 0);
  --surface: oklch(0.975 0.005 75);
  --ink: oklch(0.205 0.012 260);
  --ink-soft: oklch(0.41 0.018 260);
  --line: oklch(0.85 0.012 260);
  --amber: oklch(0.64 0.16 62);
  --amber-deep: oklch(0.49 0.14 57);
  --teal: oklch(0.57 0.11 207);
  --lime: oklch(0.73 0.15 135);
  --charcoal: oklch(0.17 0.006 260);
  --code: oklch(0.18 0.018 262);
  --radius: 6px;
  --content: 74ch;
  font-family: "Atkinson Hyperlegible", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--bg); font-size: 16px; line-height: 1.7; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--amber-deep); }
button, summary { font: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }

.skip-link { position: fixed; z-index: 10; top: -6rem; left: 1rem; padding: 0.6rem 0.9rem; color: var(--bg); background: var(--ink); border-radius: var(--radius); }
.skip-link:focus { top: 1rem; }
.reading-progress { position: fixed; z-index: 20; top: 0; right: 0; left: 0; height: 3px; background: transparent; }
.reading-progress span { display: block; width: 0; height: 100%; background: var(--amber); transition: width 120ms linear; }

.site-header { position: sticky; z-index: 5; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 2rem; min-height: 4.6rem; padding: 0.8rem max(1.25rem, calc((100vw - 1360px) / 2)); border-bottom: 1px solid color-mix(in oklch, var(--line), transparent 15%); background: color-mix(in oklch, var(--bg), transparent 6%); backdrop-filter: blur(12px); }
.wordmark { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 750; letter-spacing: 0; text-decoration: none; white-space: nowrap; }
.mark { display: grid; width: 1.65rem; height: 1.65rem; place-items: center; color: var(--bg); background: var(--ink); border-radius: 3px; font-family: ui-monospace, monospace; font-size: 0.85rem; }
.top-nav { display: flex; gap: 1.3rem; font-size: 0.88rem; color: var(--ink-soft); }
.top-nav a { text-decoration: none; }
.mobile-nav { display: none; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 0.75fr); align-items: center; gap: clamp(3rem, 7vw, 8rem); min-height: 76vh; padding: clamp(4.5rem, 10vw, 9rem) max(1.25rem, calc((100vw - 1180px) / 2)) clamp(3rem, 7vw, 6rem); border-bottom: 1px solid var(--line); }
.hero-copy { max-width: 52rem; }
.hero-label, .section-label { margin: 0 0 1rem; color: var(--amber-deep); font-size: 0.76rem; font-weight: 760; letter-spacing: 0.08em; }
.hero h1 { margin: 0; font-size: clamp(3rem, 7vw, 6rem); line-height: 0.97; letter-spacing: 0; text-wrap: balance; }
.hero h1 span { color: var(--amber-deep); }
.hero-lede { max-width: 56ch; margin: 2rem 0 0; color: var(--ink-soft); font-size: 1.16rem; text-wrap: pretty; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem; margin-top: 2rem; }
.button { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0.65rem 1rem; border-radius: var(--radius); font-weight: 700; text-decoration: none; }
.button-primary { color: var(--bg); background: var(--amber-deep); }
.button-primary:hover { color: var(--bg); background: var(--ink); }
.text-action { font-weight: 700; }

.hero-diagram { position: relative; min-height: 29rem; border: 1px solid var(--ink); background: var(--charcoal); color: var(--bg); overflow: hidden; }
.hero-diagram::before, .hero-diagram::after { position: absolute; content: ""; background: color-mix(in oklch, var(--bg), transparent 85%); }
.hero-diagram::before { top: 50%; right: 0; left: 0; height: 1px; }
.hero-diagram::after { top: 0; bottom: 0; left: 50%; width: 1px; }
.diagram-context { position: absolute; z-index: 1; top: 50%; left: 50%; display: grid; width: 8.3rem; aspect-ratio: 1; place-items: center; transform: translate(-50%, -50%); border: 1px solid var(--bg); background: var(--charcoal); border-radius: 50%; font-weight: 800; }
.diagram-arm { position: absolute; z-index: 1; display: grid; max-width: 10rem; gap: 0.2rem; }
.diagram-arm strong { font-size: 1.15rem; line-height: 1.2; }
.diagram-arm small { color: color-mix(in oklch, var(--bg), transparent 35%); line-height: 1.45; }
.effect-arm { top: 4rem; left: 3rem; }
.coeffect-arm { right: 3rem; bottom: 4rem; text-align: right; }
.diagram-kicker { color: var(--amber); font-size: 0.72rem; font-weight: 760; letter-spacing: 0.08em; }
.coeffect-arm .diagram-kicker { color: var(--lime); }
.diagram-note { position: absolute; bottom: 1.5rem; left: 1.5rem; max-width: 10rem; padding: 0.75rem 0.9rem; border-left: 1px solid var(--teal); color: color-mix(in oklch, var(--bg), transparent 18%); font-size: 0.82rem; line-height: 1.5; }

.content-shell { display: grid; grid-template-columns: minmax(11rem, 13rem) minmax(0, var(--content)); justify-content: center; gap: clamp(2rem, 6vw, 7rem); padding: clamp(4rem, 8vw, 8rem) 1.25rem; }
.chapter-rail { position: sticky; top: 7rem; align-self: start; padding-top: 0.4rem; font-size: 0.82rem; line-height: 1.4; }
.chapter-rail > p { margin: 0 0 0.85rem; color: var(--ink-soft); }
.chapter-rail nav { display: grid; gap: 0.7rem; border-left: 1px solid var(--line); }
.chapter-rail a { padding-left: 0.8rem; color: var(--ink-soft); text-decoration: none; }
.chapter-rail a[aria-current="true"] { color: var(--ink); font-weight: 720; }
.lesson-content { min-width: 0; }
.chapter { padding: 0 0 clamp(4rem, 9vw, 8rem); scroll-margin-top: 7rem; }
.chapter-heading { max-width: 66ch; margin-bottom: 1.75rem; }
.chapter-heading h2 { margin: 0; font-size: clamp(1.9rem, 3.8vw, 3.35rem); line-height: 1.12; letter-spacing: 0; text-wrap: balance; }
.lesson-content p { max-width: var(--content); text-wrap: pretty; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1.5rem, 4vw, 3.5rem); }
.lead-grid { margin-top: 1.5rem; color: var(--ink-soft); }
.lead-grid p { margin: 0; }

.runtime-map { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; gap: 0.7rem; align-items: center; margin-top: 3rem; padding: 1rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.map-step { display: grid; gap: 0.2rem; min-height: 7rem; align-content: center; padding: 1rem; border: 1px solid currentColor; border-radius: var(--radius); }
.map-step span { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.map-step strong { font-size: 1.05rem; }
.map-step small { color: var(--ink-soft); line-height: 1.35; }
.amber { color: var(--amber-deep); background: color-mix(in oklch, var(--amber), transparent 90%); }
.teal { color: var(--teal); background: color-mix(in oklch, var(--teal), transparent 91%); }
.ink { color: var(--ink); background: var(--surface); }
.lime { color: oklch(0.42 0.1 135); background: color-mix(in oklch, var(--lime), transparent 88%); }
.map-arrow { color: var(--ink-soft); font-size: 1.35rem; }

.code-panel { margin: 2.25rem 0; overflow: hidden; border: 1px solid var(--charcoal); border-radius: var(--radius); background: var(--code); color: oklch(0.94 0.01 90); box-shadow: 0 1.1rem 2.5rem color-mix(in oklch, var(--ink), transparent 90%); }
.code-panel-bar { display: flex; align-items: center; justify-content: space-between; min-height: 2.7rem; padding: 0 0.75rem 0 1rem; border-bottom: 1px solid color-mix(in oklch, var(--bg), transparent 84%); color: color-mix(in oklch, var(--bg), transparent 35%); font-size: 0.8rem; }
.copy-button { min-height: 2rem; padding: 0.25rem 0.55rem; border: 1px solid color-mix(in oklch, var(--bg), transparent 62%); border-radius: 3px; color: var(--bg); background: transparent; cursor: pointer; }
.copy-button:hover { background: color-mix(in oklch, var(--bg), transparent 88%); }
pre { margin: 0; padding: 1.35rem; overflow: auto; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.83rem; line-height: 1.65; tab-size: 2; }
.compact pre { font-size: 0.8rem; }
.callout { margin: 2.1rem 0; padding: 1.25rem 1.35rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.callout strong { display: block; margin-bottom: 0.3rem; }
.callout p { margin: 0; color: var(--ink-soft); }
.amber-callout { border-color: color-mix(in oklch, var(--amber), var(--line) 55%); }
.formula-row { display: grid; grid-template-columns: 1fr auto 1fr 1.4fr; gap: 1rem; align-items: center; margin-top: 2.5rem; padding: 1.25rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.formula-row > div { display: grid; gap: 0.15rem; }
.formula-row span, .formula-row small { color: var(--ink-soft); font-size: 0.78rem; }
.formula-row strong { font-family: ui-monospace, monospace; font-size: 0.95rem; }
.formula-arrow { color: var(--amber-deep); font-size: 0.85rem; }
.formula-result { color: var(--teal); }

.service-example { display: grid; grid-template-columns: minmax(0, 1fr) 8rem minmax(0, 1fr); gap: 1rem; align-items: center; margin: 2.5rem 0; }
.service-role { padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); }
.service-role p { margin: 0; color: var(--ink-soft); font-size: 0.75rem; font-weight: 750; letter-spacing: 0.06em; }
.service-role h3 { margin: 0.35rem 0; font-size: 1.2rem; }
.service-role code { color: var(--amber-deep); font-family: ui-monospace, monospace; font-size: 0.78rem; }
.service-role span { display: block; margin-top: 0.8rem; color: var(--ink-soft); font-size: 0.85rem; line-height: 1.45; }
.provider { border-top: 4px solid var(--amber); }
.consumer { border-top: 4px solid var(--teal); }
.service-link { display: grid; gap: 0.4rem; text-align: center; }
.service-link span { color: var(--teal); font-family: ui-monospace, monospace; font-size: 0.75rem; }
.service-link i { display: block; height: 1px; background: var(--teal); position: relative; }
.service-link i::after { position: absolute; top: -0.25rem; right: 0; content: ""; border-top: 0.3rem solid transparent; border-bottom: 0.3rem solid transparent; border-left: 0.45rem solid var(--teal); }

.timeline-demo { margin: 2.5rem 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.timeline-tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--surface); }
.timeline-tabs button { flex: 1 0 auto; min-height: 3rem; padding: 0.6rem 0.85rem; border: 0; border-bottom: 3px solid transparent; color: var(--ink-soft); background: transparent; cursor: pointer; }
.timeline-tabs button[aria-selected="true"] { border-bottom-color: var(--amber-deep); color: var(--ink); font-weight: 750; }
.timeline-panel { display: grid; grid-template-columns: minmax(8rem, 1fr) 4rem minmax(8rem, 1fr); gap: 1rem; align-items: center; min-height: 12.5rem; padding: 2rem; }
.timeline-state { display: grid; gap: 0.35rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); }
.timeline-state span { color: var(--ink-soft); font-size: 0.8rem; }
.timeline-state strong { color: var(--amber-deep); font-size: 0.95rem; }
.timeline-track { height: 1px; background: var(--line); }
.timeline-explanation { grid-column: 1 / -1; margin: 0; color: var(--ink-soft); }
.lifecycle-list { display: grid; gap: 1rem; margin: 0; padding: 0; list-style: none; counter-reset: lifecycle; }
.lifecycle-list li { position: relative; padding-left: 2.8rem; color: var(--ink-soft); }
.lifecycle-list li::before { position: absolute; top: 0.1rem; left: 0; display: grid; width: 1.8rem; aspect-ratio: 1; place-items: center; content: counter(lifecycle); counter-increment: lifecycle; border: 1px solid var(--ink); border-radius: 50%; color: var(--ink); font-size: 0.78rem; font-weight: 750; }

.guarantee-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 2.5rem 0; border: 1px solid var(--line); background: var(--line); }
.guarantee { min-height: 15rem; padding: 1.35rem; background: var(--bg); }
.guarantee span { color: var(--amber-deep); font-family: ui-monospace, monospace; font-size: 0.73rem; }
.guarantee h3 { margin: 0.55rem 0; font-size: 1.25rem; line-height: 1.2; }
.guarantee p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }
.boundary-table { margin-top: 2.5rem; overflow-x: auto; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.boundary-row { display: grid; grid-template-columns: 1.1fr 0.65fr 1.2fr; gap: 1.2rem; min-width: 42rem; padding: 0.9rem 0.3rem; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.boundary-row:last-child { border-bottom: 0; }
.boundary-head { color: var(--ink-soft); font-size: 0.75rem; font-weight: 750; }
.yes { color: oklch(0.39 0.11 145); font-weight: 750; }
.no { color: oklch(0.53 0.16 30); font-weight: 750; }

.dsh-tree { margin: 2.5rem 0; padding: 1.4rem; border: 1px solid var(--ink); background: var(--charcoal); color: var(--bg); }
.tree-root { display: inline-block; padding: 0.5rem 0.7rem; background: var(--amber-deep); font-family: ui-monospace, monospace; font-size: 0.85rem; font-weight: 700; }
.tree-branches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 1.4rem; background: color-mix(in oklch, var(--bg), transparent 82%); }
.tree-branch { min-height: 12rem; padding: 1rem; background: var(--charcoal); }
.tree-branch > span { color: var(--lime); font-size: 0.78rem; font-weight: 700; }
.tree-branch ul { display: grid; gap: 0.35rem; margin: 0.85rem 0 0; padding: 0; list-style: none; color: color-mix(in oklch, var(--bg), transparent 18%); font-size: 0.87rem; }
.tree-branch li::before { margin-right: 0.45rem; content: "↳"; color: var(--amber); }
.note-grid { gap: 1px; margin-top: 2rem; background: var(--line); }
.note-grid > div { padding: 1.3rem; background: var(--surface); }
.note-grid h3 { margin: 0 0 0.6rem; font-size: 1rem; }
.note-grid p { margin: 0; color: var(--ink-soft); font-size: 0.93rem; }

.reading-list { display: grid; gap: 0; margin: 2rem 0 0; padding: 0; list-style: none; counter-reset: reading; border-top: 1px solid var(--line); }
.reading-list li { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); column-gap: 0.5rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.reading-list li::before { grid-row: span 2; content: counter(reading, decimal-leading-zero); counter-increment: reading; color: var(--amber-deep); font-family: ui-monospace, monospace; font-size: 0.75rem; }
.reading-list a { font-weight: 750; }
.reading-list span { grid-column: 2; color: var(--ink-soft); font-size: 0.88rem; }

.site-footer { display: flex; align-items: center; justify-content: space-between; padding: 1.5rem max(1.25rem, calc((100vw - 1180px) / 2)); border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 0.78rem; letter-spacing: 0.06em; }
.site-footer p { margin: 0; }
.site-footer a { display: grid; width: 2.2rem; height: 2.2rem; place-items: center; border: 1px solid var(--line); border-radius: 50%; text-decoration: none; }
.copy-status { position: fixed; z-index: 10; right: 1rem; bottom: 1rem; min-height: 1px; color: var(--bg); }
.copy-status:not(:empty) { padding: 0.45rem 0.7rem; background: var(--ink); border-radius: 3px; font-size: 0.85rem; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .hero-diagram { min-height: 22rem; }
  .content-shell { grid-template-columns: 1fr; max-width: 50rem; margin: auto; }
  .chapter-rail { display: none; }
  .top-nav { display: none; }
  .mobile-nav { display: block; }
  .mobile-nav summary { cursor: pointer; font-size: 0.86rem; font-weight: 720; }
  .mobile-nav nav { position: absolute; top: 3.8rem; right: 1rem; display: grid; min-width: 13rem; padding: 0.7rem; border: 1px solid var(--line); background: var(--bg); box-shadow: 0 0.8rem 2rem color-mix(in oklch, var(--ink), transparent 88%); }
  .mobile-nav a { padding: 0.45rem; text-decoration: none; font-size: 0.88rem; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .site-header { min-height: 4rem; }
  .hero { gap: 1.3rem; padding-top: 2.5rem; padding-bottom: 1rem; }
  .hero h1 { font-size: clamp(2.6rem, 14vw, 4rem); }
  .hero-lede { margin-top: 1.35rem; font-size: 1.05rem; }
  .hero-diagram { min-height: 14rem; }
  .effect-arm { top: 1rem; left: 1.5rem; }
  .coeffect-arm { right: 1.5rem; bottom: 1rem; }
  .diagram-context { width: 5rem; }
  .diagram-arm strong { font-size: 1rem; }
  .diagram-arm small { font-size: 0.75rem; }
  .diagram-note { display: none; }
  .content-shell { padding-top: 2rem; }
  .two-column, .guarantee-grid, .tree-branches { grid-template-columns: 1fr; }
  .runtime-map { grid-template-columns: 1fr; gap: 0; }
  .map-step { min-height: auto; }
  .map-arrow { justify-self: center; transform: rotate(90deg); }
  .service-example { grid-template-columns: 1fr; }
  .service-link { grid-template-columns: auto 1fr; align-items: center; }
  .service-link i { width: 100%; }
  .timeline-panel { grid-template-columns: 1fr; padding: 1.25rem; }
  .timeline-track { width: 1px; height: 1.5rem; justify-self: center; }
  .formula-row { grid-template-columns: 1fr; }
  .formula-arrow { transform: rotate(90deg); }
  .chapter-heading h2 { font-size: clamp(1.8rem, 9vw, 2.5rem); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reading-progress span { transition: none; }
}
