:root, [data-theme="light"] {
  --bg: #f6f5f0;
  --surface: #fbfaf6;
  --surface-2: #efede5;
  --ink: #1d2422;
  --ink-2: #4a5350;
  --ink-3: #6e7673;
  --line: #dcd9ce;
  --accent: #2f5d3a;
  --accent-ink: #ffffff;
  --accent-soft: #e3ebdf;
  --hyp: #8a4b12;
  --hyp-soft: #f6e9d9;
  --safe: #8f2a2a;
  --safe-soft: #f5e1de;
  --found: #2c4f6b;
  --found-soft: #e1e9ef;
  --persp: #5b4b72;
  --persp-soft: #ebe6f1;
  --serif: 'Source Serif 4', Georgia, serif;
  --sans: 'General Sans', 'Helvetica Neue', Arial, sans-serif;
  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.85rem + 0.15vw, 0.9375rem);
  --text-base: clamp(1.0625rem, 1.02rem + 0.2vw, 1.125rem);
  --text-lg: clamp(1.2rem, 1.1rem + 0.4vw, 1.375rem);
  --text-xl: clamp(1.6rem, 1.3rem + 1.2vw, 2.25rem);
  --text-2xl: clamp(2.1rem, 1.5rem + 2.6vw, 3.5rem);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 6px 24px rgba(20, 30, 25, .05);
}
[data-theme="dark"] {
  --bg: #141816;
  --surface: #1a1f1d;
  --surface-2: #212724;
  --ink: #e6e8e3;
  --ink-2: #b6bdb8;
  --ink-3: #8c948f;
  --line: #2f3632;
  --accent: #8fc29a;
  --accent-ink: #10201a;
  --accent-soft: #22302a;
  --hyp: #e6ad74;
  --hyp-soft: #33281d;
  --safe: #ef9a8f;
  --safe-soft: #3a2422;
  --found: #9cc0de;
  --found-soft: #1f2a33;
  --persp: #c3b3dc;
  --persp-soft: #2a2533;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--serif); font-size: var(--text-base); line-height: 1.68; text-rendering: optimizeLegibility; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 50; font-family: var(--sans); }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.small { font-size: var(--text-sm); color: var(--ink-2); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px clamp(16px, 4vw, 40px); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); font-family: var(--sans); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; line-height: 1.15; }
.brand .logo { width: 34px; height: 34px; color: var(--accent); flex: none; }
.brand b { display: block; font-weight: 600; font-size: var(--text-sm); letter-spacing: .01em; }
.brand-sub { font-size: var(--text-xs); color: var(--ink-3); }
.topnav { display: flex; align-items: center; gap: clamp(10px, 2vw, 24px); font-size: var(--text-sm); }
.topnav a { color: var(--ink-2); text-decoration: none; }
.topnav a:hover { color: var(--ink); }
.theme-toggle { background: none; border: 1px solid var(--line); color: var(--ink-2); border-radius: 999px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; }
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
@media (max-width: 720px) {
  .topnav a:not([href$="search.html"]) { display: none; }
  .brand-sub { display: none; }
}

.eyebrow { font-family: var(--sans); font-size: var(--text-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 10px; font-weight: 500; }

/* hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 72px); align-items: center; max-width: 1200px; margin: 0 auto; padding: clamp(48px, 9vw, 112px) clamp(20px, 4vw, 40px) clamp(40px, 7vw, 88px); }
.hero h1 { font-size: var(--text-2xl); line-height: 1.06; letter-spacing: -0.02em; margin: 0 0 18px; font-weight: 600; max-width: 16ch; }
.lede { font-size: var(--text-lg); color: var(--ink-2); line-height: 1.45; margin: 0 0 20px; max-width: 40ch; }
.byline { font-family: var(--sans); font-size: var(--text-sm); font-weight: 500; margin: 0 0 28px; }
.byline span { color: var(--ink-3); font-weight: 400; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 36px; }
.btn { font-family: var(--sans); font-size: var(--text-sm); font-weight: 500; text-decoration: none; padding: 11px 18px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); background: var(--surface); transition: border-color .18s, background .18s; }
.btn:hover { border-color: var(--ink-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); border-color: transparent; }
.facts { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 28px; margin: 0; font-family: var(--sans); }
.facts dt { font-size: var(--text-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.facts dd { margin: 2px 0 0; font-size: var(--text-lg); font-weight: 600; font-variant-numeric: tabular-nums; }
.hero-fig { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.hero-fig figcaption { font-family: var(--sans); font-size: var(--text-xs); color: #4a5350; margin-top: 12px; line-height: 1.5; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } .facts { grid-template-columns: repeat(2, auto); } }

/* bands */
.band { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); }
.band-quiet { background: var(--surface-2); border-bottom: 0; }
.band-inner { max-width: 1200px; margin: 0 auto; padding: clamp(48px, 7vw, 88px) clamp(20px, 4vw, 40px); }
.section-title { font-size: var(--text-xl); line-height: 1.15; margin: 0 0 12px; font-weight: 600; letter-spacing: -0.01em; }
.section-lede { color: var(--ink-2); max-width: 62ch; margin: 0 0 36px; }
.tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.tier { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; border-top: 3px solid var(--ink-3); }
.tier-foundation { border-top-color: var(--found); }
.tier-practice { border-top-color: var(--accent); }
.tier-hypothesis { border-top-color: var(--hyp); }
.tier h3 { font-size: var(--text-lg); margin: 14px 0 8px; }
.tier p { margin: 0; color: var(--ink-2); font-size: var(--text-sm); line-height: 1.6; font-family: var(--sans); }
@media (max-width: 860px) { .tiers { grid-template-columns: 1fr; } }
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: clamp(24px, 5vw, 64px); align-items: start; }
.two-col p { max-width: 62ch; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.cite-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.cite { font-size: var(--text-sm); line-height: 1.6; }

/* badges */
.badge { display: inline-block; font-family: var(--sans); font-size: var(--text-xs); font-weight: 500; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); letter-spacing: .01em; }
.badge-foundation { background: var(--found-soft); color: var(--found); }
.badge-practice { background: var(--accent-soft); color: var(--accent); }
.badge-hypothesis { background: var(--hyp-soft); color: var(--hyp); }
.badge-safety { background: var(--safe-soft); color: var(--safe); }
.badge-perspective { background: var(--persp-soft); color: var(--persp); }

/* contents */
.contents { max-width: 1200px; margin: 0 auto; padding: clamp(48px, 7vw, 88px) clamp(20px, 4vw, 40px); }
.parts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 40px; margin-top: 28px; }
@media (max-width: 860px) { .parts-grid { grid-template-columns: 1fr; } }
.part-block { border-top: 1px solid var(--ink); padding-top: 16px; }
.part-block header { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: baseline; }
.part-block .eyebrow { grid-column: 1 / -1; margin-bottom: 4px; }
.part-block h3 { font-size: var(--text-lg); margin: 0; line-height: 1.25; grid-column: 1 / -1; }
.part-status { grid-column: 1 / -1; margin: 8px 0 0; }
.ch-list { list-style: none; margin: 12px 0 24px; padding: 0; }
.ch-list a { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: var(--text-sm); line-height: 1.4; font-family: var(--sans); }
.ch-list a:hover .t { color: var(--accent); }
.ch-list .n { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ch-list .m { color: var(--ink-3); font-size: var(--text-xs); white-space: nowrap; padding-top: 2px; }

/* reader */
.reader { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: clamp(24px, 4vw, 64px); max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
.toc { position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 64px); overflow-y: auto; padding: 32px 4px 32px 0; font-family: var(--sans); font-size: var(--text-xs); scrollbar-width: thin; }
.toc summary { font-weight: 600; font-size: var(--text-sm); cursor: pointer; margin-bottom: 10px; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li a { display: grid; grid-template-columns: 2em 1fr; padding: 5px 8px; border-radius: 6px; color: var(--ink-2); text-decoration: none; line-height: 1.35; }
.toc li a:hover { background: var(--surface-2); color: var(--ink); }
.toc li a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.toc .n { color: var(--ink-3); }
.toc-part { margin: 16px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 500; }
@media (max-width: 980px) {
  .reader { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; padding: 16px 0 0; }
  .toc-details:not([open]) ol { display: none; }
  .toc summary { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 0; }
  .toc summary::after { content: " ▾"; color: var(--ink-3); }
  .toc ol { padding-top: 10px; }
}

.chapter, .page { min-width: 0; padding: clamp(32px, 5vw, 64px) 0 72px; }
.page { max-width: 760px; margin: 0 auto; padding-left: clamp(16px, 4vw, 40px); padding-right: clamp(16px, 4vw, 40px); }
.ch-head { max-width: 70ch; margin-bottom: 28px; }
.ch-head h1 { font-size: var(--text-xl); line-height: 1.15; letter-spacing: -0.015em; margin: 0 0 16px; font-weight: 600; }
.ch-label { display: block; font-family: var(--sans); font-size: var(--text-sm); font-weight: 500; color: var(--accent); letter-spacing: .02em; margin-bottom: 8px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-family: var(--sans); font-size: var(--text-xs); color: var(--ink-3); margin: 0; }
.callout { max-width: 70ch; border-radius: var(--radius); padding: 16px 20px; margin: 0 0 32px; font-family: var(--sans); font-size: var(--text-sm); line-height: 1.55; border-left: 3px solid; }
.callout-hyp { background: var(--hyp-soft); border-color: var(--hyp); }
.callout-safety { background: var(--safe-soft); border-color: var(--safe); }

.prose { max-width: 70ch; }
.prose p { margin: 0 0 1.05em; }
.prose h2 { font-size: var(--text-lg); line-height: 1.3; margin: 2em 0 .6em; font-weight: 600; letter-spacing: -0.005em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin: 0 0 .5em; }
.prose li::marker { color: var(--ink-3); }
.prose strong { font-weight: 650; }
.fig { margin: 2em 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(10px, 2vw, 20px); }
.fig img { margin: 0 auto; max-height: 720px; width: auto; }
.fig figcaption { margin-top: 12px; font-family: var(--sans); font-size: var(--text-xs); color: #4a5350; }
.fig summary { cursor: pointer; color: #2f5d3a; }
.fig details p { margin: 8px 0 0; line-height: 1.5; }
.table-wrap { overflow-x: auto; margin: 1.6em 0; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: var(--text-xs); line-height: 1.45; min-width: 560px; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

.refs { max-width: 70ch; margin-top: 48px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.refs h2 { font-size: var(--text-lg); margin: 0 0 4px; }
.refs-note { font-family: var(--sans); font-size: var(--text-xs); color: var(--ink-3); margin: 0 0 16px; }
.refs p, .refs li { font-size: var(--text-sm); line-height: 1.55; }
.refs ol { padding-left: 1.6em; }

.pager { max-width: 70ch; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 48px; font-family: var(--sans); }
.pager a { display: block; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); font-size: var(--text-sm); line-height: 1.4; background: var(--surface); }
.pager a:hover { border-color: var(--accent); }
.pager a span { display: block; font-size: var(--text-xs); color: var(--ink-3); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }
.pager .next { text-align: right; grid-column: 2; }
@media (max-width: 600px) { .pager { grid-template-columns: 1fr; } .pager .next { grid-column: 1; } }

/* search */
.search-box input { width: 100%; font: inherit; font-family: var(--sans); padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.results { list-style: none; padding: 0; margin: 20px 0; }
.results li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.results a { font-family: var(--sans); font-weight: 500; font-size: var(--text-sm); }
.results p { margin: 4px 0 0; font-size: var(--text-sm); color: var(--ink-2); }
.results mark { background: var(--accent-soft); color: inherit; padding: 0 2px; border-radius: 3px; }

.foot { border-top: 1px solid var(--line); background: var(--surface-2); font-family: var(--sans); font-size: var(--text-xs); color: var(--ink-2); }
.foot-inner { max-width: 1200px; margin: 0 auto; padding: 32px clamp(20px, 4vw, 40px); }
.foot p { margin: 0 0 8px; max-width: 90ch; }
.machine a { color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
