/* ============================================================
   DeCoN-PINN — academic serif web system
   Adapted from the colloquium deck for long-form reading.
   Tokens: light (paper) / dark, plus two layout DIRECTIONS
   toggled via [data-dir="a" | "b"] on <html>.
   ============================================================ */

/* ---------- Fonts ---------- */
:root {
  --font-display: "EB Garamond", "Times New Roman", serif;
  --font-body: "Source Serif 4", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

/* ---------- Color: light (paper) ---------- */
:root,
html[data-theme="light"] {
  --paper:      #f4f0e6;
  --paper-2:    #ece5d4;
  --surface:    #faf7ef;
  --surface-2:  #f0ebdd;
  --ink:        #1a1612;
  --ink-2:      #3d362c;
  --ink-3:      #6b5f4f;
  --ink-4:      #938671;
  --rule:       #cbc0a8;
  --rule-soft:  #ddd3bd;
  --accent:     #8b2b2b;   /* oxblood */
  --accent-2:   #b8574e;
  --accent-wash:#efe2d7;
  --chip:       #e6dfca;
  --shadow:     0 1px 2px rgba(60,46,28,.05), 0 18px 40px -28px rgba(60,46,28,.30);
  --shadow-sm:  0 1px 2px rgba(60,46,28,.06), 0 8px 22px -16px rgba(60,46,28,.28);
  color-scheme: light;
}

/* ---------- Color: dark ---------- */
html[data-theme="dark"] {
  --paper:      #13110e;
  --paper-2:    #1a1713;
  --surface:    #1c1814;
  --surface-2:  #221d18;
  --ink:        #ece5d5;
  --ink-2:      #c8c0ae;
  --ink-3:      #938872;
  --ink-4:      #6f6655;
  --rule:       #3a342a;
  --rule-soft:  #2a251d;
  --accent:     #db8d7c;
  --accent-2:   #e6a597;
  --accent-wash:#2a201b;
  --chip:       #251f18;
  --shadow:     0 1px 2px rgba(0,0,0,.4), 0 24px 50px -30px rgba(0,0,0,.7);
  --shadow-sm:  0 1px 2px rgba(0,0,0,.4), 0 10px 26px -18px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ============================================================
   PALETTES — override the color tokens. Ember (warm/oxblood) is
   the base :root/dark above. The rest cool the neutrals and use
   a more energetic accent. Selected via [data-palette] on <html>.
   ============================================================ */

/* ---- Cobalt ---- */
html[data-palette="cobalt"] {
  --paper:#eef0f4; --paper-2:#e4e7ed; --surface:#f8f9fb; --surface-2:#eceef3;
  --ink:#121620; --ink-2:#2c3340; --ink-3:#586375; --ink-4:#88909f;
  --rule:#ccd2dc; --rule-soft:#dde1e9;
  --accent:#2257d6; --accent-2:#4f7bef; --accent-wash:#e4ebfb; --chip:#e3e7ef;
}
html[data-palette="cobalt"][data-theme="dark"] {
  --paper:#0d1017; --paper-2:#141926; --surface:#161c28; --surface-2:#1d2431;
  --ink:#e8ebf3; --ink-2:#c3cad7; --ink-3:#8b94a4; --ink-4:#6a7384;
  --rule:#2b3343; --rule-soft:#1e2530;
  --accent:#5d92ff; --accent-2:#84adff; --accent-wash:#16213b; --chip:#1a2130;
}

/* ---- Emerald ---- */
html[data-palette="emerald"] {
  --paper:#ecf1ef; --paper-2:#dfe8e3; --surface:#f5f9f7; --surface-2:#e8efeb;
  --ink:#0f1f19; --ink-2:#283f36; --ink-3:#536860; --ink-4:#86978d;
  --rule:#ccd8d1; --rule-soft:#dce5df;
  --accent:#0e9268; --accent-2:#13ac7e; --accent-wash:#ddf0e8; --chip:#e1ebe5;
}
html[data-palette="emerald"][data-theme="dark"] {
  --paper:#0a130f; --paper-2:#111d17; --surface:#13211a; --surface-2:#1a2820;
  --ink:#e2efe9; --ink-2:#bcccc4; --ink-3:#849188; --ink-4:#63726a;
  --rule:#243029; --rule-soft:#19231d;
  --accent:#22d49b; --accent-2:#5ce3b7; --accent-wash:#0f241b; --chip:#15221b;
}

/* ---- Indigo ---- */
html[data-palette="indigo"] {
  --paper:#f0eef6; --paper-2:#e6e3ef; --surface:#f8f7fc; --surface-2:#edebf4;
  --ink:#15131f; --ink-2:#312d41; --ink-3:#5e5874; --ink-4:#8b86a1;
  --rule:#d4cee1; --rule-soft:#e0dced;
  --accent:#5b34e6; --accent-2:#7d5cf0; --accent-wash:#e9e3fc; --chip:#e7e3f2;
}
html[data-palette="indigo"][data-theme="dark"] {
  --paper:#0f0c18; --paper-2:#171324; --surface:#1a1528; --surface-2:#221c32;
  --ink:#ece8f5; --ink-2:#c7c1d7; --ink-3:#8f89a3; --ink-4:#6d6783;
  --rule:#292340; --rule-soft:#1d1830;
  --accent:#9c82ff; --accent-2:#b6a3ff; --accent-wash:#1d1634; --chip:#1c1831;
}

/* ---- Coral ---- */
html[data-palette="coral"] {
  --paper:#f3f1ee; --paper-2:#eae5df; --surface:#faf8f5; --surface-2:#f0ece7;
  --ink:#1c1714; --ink-2:#3b332d; --ink-3:#6b6057; --ink-4:#978c81;
  --rule:#d9cfc7; --rule-soft:#e5ded6;
  --accent:#e2492b; --accent-2:#f06b48; --accent-wash:#fbe5dd; --chip:#ece4dc;
}
html[data-palette="coral"][data-theme="dark"] {
  --paper:#140f0d; --paper-2:#1d1714; --surface:#201916; --surface-2:#28201c;
  --ink:#f0e9e4; --ink-2:#cdc3bb; --ink-3:#94897f; --ink-4:#6f655c;
  --rule:#332a25; --rule-soft:#241d19;
  --accent:#ff7350; --accent-2:#ff9472; --accent-wash:#2a1812; --chip:#221a15;
}

/* Direction B accent behavior handled in the Direction B section below. */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.68;
  font-feature-settings: "onum" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .35s ease, color .35s ease;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--paper); }

/* paper grain — barely-there texture so flat fills read as stock */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image: radial-gradient(rgba(120,100,70,.04) 1px, transparent 1px);
  background-size: 3px 3px;
}
html[data-theme="dark"] body::before { opacity: .4; background-image: radial-gradient(rgba(255,240,210,.025) 1px, transparent 1px); }

/* ============================================================
   Reading progress bar
   ============================================================ */
.progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 90;
  background: transparent;
}
.progress__fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width .08s linear;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 80;
  background: color-mix(in oklab, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid var(--rule-soft);
}
.site-header__inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 32px;
  height: 66px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark .pinn { color: var(--accent); font-style: italic; }
.wordmark .mark-dot { color: var(--accent); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-left: 14px;
}
.site-nav a {
  font-family: var(--font-body);
  font-size: 15px;
  letter-spacing: .02em;
  color: var(--ink-3);
  text-decoration: none;
  padding: 6px 0;
  position: relative;
  transition: color .18s ease;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: 0;
  height: 1.5px;
  background: var(--accent);
  transition: right .22s ease;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after { right: 0; }
.site-nav a.current { color: var(--ink); }
.site-nav a.current::after { right: 0; background: var(--rule); }

.header-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* segmented toggle (theme + direction) */
.seg {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  border-radius: 100px;
  padding: 3px;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 100px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .18s ease, background .18s ease;
}
.seg button.on { background: var(--ink); color: var(--paper); }
html[data-theme="dark"] .seg button.on { background: var(--accent); color: #1a1410; }
.seg button:not(.on):hover { color: var(--ink); }
.seg .ico { width: 13px; height: 13px; display: inline-block; }

/* palette swatch dots */
.palette-dots {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 2px;
  margin-right: 2px;
}
.palette-dots button {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.22);
  background: var(--sw);
  cursor: pointer;
  padding: 0;
  transition: transform .15s ease, box-shadow .15s ease;
}
html[data-theme="dark"] .palette-dots button { border-color: rgba(255,255,255,.25); }
.palette-dots button:hover { transform: scale(1.18); }
.palette-dots button.on {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--sw);
}

.menu-btn { display: none; }

/* ============================================================
   Layout — three rails
   ============================================================ */
.layout {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 32px;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 240px;
  gap: 56px;
  align-items: start;
  position: relative;
  z-index: 1;
}

.rail {
  position: sticky;
  top: 90px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
.rail::-webkit-scrollbar { width: 8px; }
.rail::-webkit-scrollbar-thumb { background: var(--rule-soft); border-radius: 8px; }

/* ---------- Curriculum TOC (left) ---------- */
.curriculum { padding-top: 54px; }
.curriculum__label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin: 0 0 18px 2px;
}
.toc-group { margin-bottom: 6px; border-top: 1px solid var(--rule-soft); }
.toc-group:first-of-type { border-top: 0; }
.toc-group__head {
  width: 100%;
  text-align: left;
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 2px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}
.toc-group__num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: .04em;
}
.toc-group__chev {
  margin-left: auto;
  color: var(--ink-4);
  transition: transform .22s ease;
  flex: none;
}
.toc-group[open] .toc-group__chev { transform: rotate(90deg); }
.toc-group__head:hover { color: var(--accent); }
.toc-list { list-style: none; margin: 0 0 12px 0; padding: 0 0 0 2px; }
.toc-list li { position: relative; }
.toc-list a {
  display: block;
  text-decoration: none;
  color: var(--ink-3);
  font-size: 14.5px;
  line-height: 1.4;
  padding: 7px 10px 7px 18px;
  border-left: 2px solid var(--rule-soft);
  transition: color .16s ease, border-color .16s ease;
}
.toc-list a:hover { color: var(--ink); border-color: var(--ink-3); }
.toc-list a.active {
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.toc-list .lnum {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  margin-right: 8px;
}
.toc-list a.active .lnum { color: var(--accent); }

/* ---------- Right rail: on-this-page + meta ---------- */
.aside-rail { padding-top: 54px; }
.onthispage__label,
.meta-block__label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin: 0 0 14px 0;
}
.onthispage ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule-soft); }
.onthispage a {
  display: block;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink-3);
  padding: 6px 0 6px 16px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  transition: color .16s ease, border-color .16s ease;
}
.onthispage a:hover { color: var(--ink); }
.onthispage a.active { color: var(--accent); border-color: var(--accent); }

.meta-block { margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--rule-soft); }
.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-3);
  margin-bottom: 12px;
}
.meta-row .ico { width: 15px; height: 15px; color: var(--ink-4); flex: none; }
.action-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 14px;
  border-radius: 100px;
  padding: 8px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all .18s ease;
}
.action-btn .ico { width: 15px; height: 15px; }
.action-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.action-btn.on { background: var(--accent-wash); border-color: var(--accent); color: var(--accent); }
.action-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* ============================================================
   Article
   ============================================================ */
.article { padding: 54px 0 0; min-width: 0; }
.article__inner { max-width: 680px; }

.lesson-badge {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.lesson-badge .sec {
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 100px;
  padding: 5px 13px;
}
.lesson-badge .part { color: var(--ink-4); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 18px;
}

.lesson-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(40px, 5.4vw, 64px);
  line-height: 1.04;
  letter-spacing: -.018em;
  color: var(--ink);
  margin: 0 0 26px;
  text-wrap: balance;
}
.lesson-title em { font-style: italic; color: var(--accent); }

.dek {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.6vw, 28px);
  font-style: italic;
  line-height: 1.4;
  color: var(--ink-3);
  margin: 0 0 34px;
  max-width: 38ch;
  text-wrap: pretty;
}

.byline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 14.5px;
  color: var(--ink-3);
  margin-bottom: 46px;
}
.byline .who { color: var(--ink); font-weight: 600; }
.byline .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--rule); }
.byline .ico { width: 15px; height: 15px; vertical-align: -2px; margin-right: 6px; color: var(--ink-4); }

/* ---------- Prose ---------- */
.prose { font-size: 19px; line-height: 1.72; color: var(--ink-2); }
.prose > p { margin: 0 0 26px; }
.prose > p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-weight: 600;
  float: left;
  font-size: 4.4em;
  line-height: .82;
  padding: 6px 14px 0 0;
  color: var(--accent);
}
.prose strong { color: var(--ink); font-weight: 600; }
.prose em { font-style: italic; }
.prose a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
  transition: border-color .16s ease;
}
.prose a:hover { border-color: var(--accent); }

.prose h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 3.4vw, 38px);
  line-height: 1.12;
  letter-spacing: -.012em;
  color: var(--ink);
  margin: 60px 0 22px;
  text-wrap: balance;
  scroll-margin-top: 96px;
}
.prose h2 .h2-num {
  font-family: var(--font-mono);
  font-size: .42em;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: .04em;
  vertical-align: middle;
  margin-right: 16px;
}
.prose h3 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(22px, 2.6vw, 27px);
  line-height: 1.2;
  color: var(--ink);
  margin: 42px 0 16px;
  scroll-margin-top: 96px;
}
.prose ul, .prose ol { margin: 0 0 26px; padding: 0; list-style: none; }
.prose li { margin: 0 0 14px; padding-left: 34px; position: relative; }
.prose ul > li::before {
  content: "";
  position: absolute;
  left: 6px; top: .72em;
  width: 7px; height: 7px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
}
.prose ol { counter-reset: li; }
.prose ol > li { counter-increment: li; }
.prose ol > li::before {
  content: counter(li);
  position: absolute;
  left: 0; top: .04em;
  font-family: var(--font-mono);
  font-size: .8em;
  color: var(--accent);
  font-weight: 500;
}

hr.rule {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 48px 0;
}
.dingbat {
  text-align: center;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: .5em;
  margin: 44px 0;
  user-select: none;
}

/* ============================================================
   Callouts
   ============================================================ */
.callout {
  margin: 38px 0;
  padding: 26px 30px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  box-shadow: var(--shadow-sm);
}
.callout__label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.callout__label .ico { width: 15px; height: 15px; }
.callout p { margin: 0 0 12px; font-size: 18px; }
.callout p:last-child { margin-bottom: 0; }

/* analogy / aside — warmer, quote-like */
.callout.aside {
  background: transparent;
  border: 0;
  border-left: 2px solid var(--accent);
  border-radius: 0;
  box-shadow: none;
  padding: 6px 0 6px 28px;
  font-family: var(--font-display);
}
.callout.aside p { font-size: 21px; font-style: italic; color: var(--ink); line-height: 1.45; }
.callout.aside .callout__label { font-family: var(--font-mono); font-style: normal; }

/* key takeaways */
.takeaways {
  margin: 50px 0 40px;
  padding: 34px 38px;
  border-radius: 6px;
  background: var(--accent-wash);
  border: 1px solid color-mix(in oklab, var(--accent) 24%, transparent);
}
.takeaways__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: nowrap;
}
.takeaways__head .ico { flex: none; }
.takeaways__head .ico { width: 22px; height: 22px; color: var(--accent); }
.takeaways__head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-style: normal;
  font-weight: 600;
  font-size: 26px;
  color: var(--ink);
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.1;
}
.takeaways ul { list-style: none; margin: 0; padding: 0; }
.takeaways li {
  position: relative;
  padding: 0 0 16px 32px;
  margin: 0 0 16px;
  border-bottom: 1px dashed color-mix(in oklab, var(--accent) 26%, transparent);
  font-size: 18px;
  color: var(--ink-2);
}
.takeaways li:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.takeaways li::before {
  content: "";
  position: absolute;
  left: 4px; top: .42em;
  width: 9px; height: 9px;
  background: var(--accent);
  border-radius: 50%;
}
.takeaways li strong { color: var(--ink); }

/* ============================================================
   Equation block
   ============================================================ */
.equation {
  margin: 34px 0;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 26px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.equation .eq-body {
  font-family: var(--font-mono);
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.5;
  color: var(--ink);
  overflow-x: auto;
  letter-spacing: -.01em;
  padding: 2px 4px;
  max-width: 100%;
}
.equation .eq-note {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-3);
}
.equation .eq-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}
.m { font-family: var(--font-mono); font-feature-settings: "ss01" 1; }
.var { font-family: var(--font-display); font-style: italic; color: var(--ink); }

/* ============================================================
   Figure placeholder
   ============================================================ */
.figure { margin: 40px 0; }
.figure__frame {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background:
    repeating-linear-gradient(
      135deg,
      transparent 0, transparent 11px,
      color-mix(in oklab, var(--ink-4) 14%, transparent) 11px,
      color-mix(in oklab, var(--ink-4) 14%, transparent) 12px
    ),
    var(--surface-2);
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.figure__tag {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 100px;
  padding: 8px 18px;
}
.figure figcaption {
  margin-top: 14px;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-3);
  padding-left: 2px;
}
.figure figcaption .fnum { font-family: var(--font-mono); font-style: normal; color: var(--accent); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; margin-right: 10px; }

/* ============================================================
   Pager (prev / next)
   ============================================================ */
.pager {
  margin: 64px 0 0;
  padding-top: 40px;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.pager a {
  text-decoration: none;
  display: block;
  padding: 22px 24px;
  border: 1px solid var(--rule-soft);
  border-radius: 6px;
  background: var(--surface);
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.pager a:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.pager .dir {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 8px;
}
.pager .ptitle {
  font-family: var(--font-display);
  font-size: 21px;
  color: var(--ink);
  line-height: 1.2;
}
.pager a.next { text-align: right; }
.pager a.prev:only-child { grid-column: 1; }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  margin-top: 90px;
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
  position: relative;
  z-index: 1;
}
.site-footer__inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 56px 32px 44px;
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  gap: 48px;
}
.site-footer h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin: 0 0 16px;
}
.site-footer p { font-size: 16px; color: var(--ink-3); margin: 0 0 14px; max-width: 42ch; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 10px; }
.site-footer a { color: var(--ink-2); text-decoration: none; font-size: 16px; transition: color .16s ease; }
.site-footer a:hover { color: var(--accent); }
.footer-word {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 12px;
}
.footer-word .pinn { color: var(--accent); font-style: italic; }
.footer-base {
  border-top: 1px solid var(--rule-soft);
  margin-top: 8px;
}
.footer-base__inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  font-size: 14px;
  color: var(--ink-4);
  font-family: var(--font-mono);
  letter-spacing: .03em;
}

/* ============================================================
   DIRECTION B — "Field Notes" overrides
   Asymmetric, numbered, margin-note flavored, cooler structure.
   ============================================================ */
/* Ember-only warm shift in Field Notes; neutral palettes keep their accent */
html[data-dir="b"][data-palette="ember"] {
  --accent:     #9a4221;   /* burnt sienna shift in light */
  --accent-2:   #c06a3e;
  --accent-wash:#efe1d4;
}
html[data-dir="b"][data-palette="ember"][data-theme="dark"] {
  --accent:     #e0a06f;
  --accent-2:   #ecbd92;
  --accent-wash:#2a201a;
}

html[data-dir="b"] .article__inner { max-width: 760px; }

/* Direction B drops the drop-cap for a flush, reportorial open */
html[data-dir="b"] .prose > p:first-of-type::first-letter {
  font-family: inherit; float: none; font-size: inherit;
  line-height: inherit; padding: 0; color: inherit; font-weight: inherit;
}
html[data-dir="b"] .prose > p:first-of-type {
  font-size: 22px;
  line-height: 1.6;
  color: var(--ink);
}

/* Big numbered section heads */
html[data-dir="b"] .prose h2 {
  border-top: 1px solid var(--rule);
  padding-top: 26px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 22px;
  align-items: start;
}
html[data-dir="b"] .prose h2 .h2-num {
  font-size: .9em;
  display: inline-block;
  margin: 0;
  padding-top: .12em;
}

/* Title treatment: left ruled, smaller dek measure */
html[data-dir="b"] .lesson-title { font-weight: 500; letter-spacing: -.022em; }
html[data-dir="b"] .lesson-badge .sec {
  border-radius: 3px;
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}
html[data-theme="dark"][data-dir="b"] .lesson-badge .sec { color: #1a1410; }

/* Asides become right-margin notes on wide screens */
@media (min-width: 1180px) {
  html[data-dir="b"] .callout.aside {
    float: right;
    clear: right;
    width: 230px;
    margin: 6px -290px 22px 0;
    padding: 0 0 0 16px;
    border-left: 2px solid var(--accent);
  }
  html[data-dir="b"] .callout.aside p { font-size: 15px; font-style: normal; line-height: 1.4; color: var(--ink-2); }
  html[data-dir="b"] .callout.aside .callout__label { font-size: 10px; }
}

/* Direction B: equation blocks centered, no left bar — more formal */
html[data-dir="b"] .equation {
  border-left: 1px solid var(--rule-soft);
  border-top: 2px solid var(--accent);
  align-items: center;
  text-align: center;
}

/* Direction B hides the drop-cap accent on takeaways head icon emphasis—keep */

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 248px minmax(0,1fr); gap: 44px; }
  .aside-rail { display: none; }
}
@media (max-width: 880px) {
  .site-header__inner { padding: 0 14px; gap: 10px; }
  .site-nav { display: none; }
  .menu-btn {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border: 1px solid var(--rule); border-radius: 9px;
    background: var(--surface-2); color: var(--ink);
    cursor: pointer; margin-left: auto;
  }
  .header-tools { margin-left: 0; }
  /* On phones the header row can't fit the palette dots + direction toggle
     alongside the theme switch and curriculum button — hide the extras so the
     row never overflows (color-select stays available on tablet/desktop). */
  .header-tools .seg.dir-seg { display: none; }
  .header-tools .palette-dots { display: none; }
  .layout { grid-template-columns: minmax(0,1fr); gap: 0; padding: 0 22px; }
  .rail.curriculum {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 340px);
    max-height: none;
    background: var(--paper);
    border-right: 1px solid var(--rule);
    z-index: 95;
    padding: 24px 22px 40px;
    transform: translateX(-102%);
    transition: transform .3s ease;
    box-shadow: var(--shadow);
  }
  body.nav-open .rail.curriculum { transform: translateX(0); }
  .nav-scrim {
    position: fixed; inset: 0; background: rgba(20,16,10,.5);
    z-index: 94; opacity: 0; pointer-events: none; transition: opacity .3s ease;
  }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .article { padding-top: 36px; }
  html[data-dir="b"] .callout.aside { float: none; width: auto; margin: 24px 0; }
  .site-footer__inner { grid-template-columns: 1fr; gap: 32px; }
  .footer-base__inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .pager { grid-template-columns: 1fr; }
}
@media (max-width: 880px) {
  .nav-scrim { display: block; }
}
@media (min-width: 881px) {
  .nav-scrim { display: none; }
}

/* ============================================================
   Shared page hero (index + home) + wrappers
   ============================================================ */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 32px; position: relative; z-index: 1; }
.wrap-wide { max-width: 1480px; margin: 0 auto; padding: 0 32px; position: relative; z-index: 1; }

.page-hero { padding: 88px 0 56px; border-bottom: 1px solid var(--rule); }
.page-hero .eyebrow { margin-bottom: 22px; }
.page-hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(48px, 7vw, 92px);
  line-height: 1.0;
  letter-spacing: -.022em;
  color: var(--ink);
  margin: 0 0 28px;
  max-width: 16ch;
  text-wrap: balance;
}
.page-hero h1 em { font-style: italic; color: var(--accent); }
.page-hero .dek {
  max-width: 60ch;
  font-size: clamp(20px, 2.4vw, 26px);
}

/* hub stats strip */
.hub-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 40px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.hub-stats .stat-cell {
  flex: 1 1 0;
  min-width: 150px;
  padding: 24px 28px;
  border-right: 1px solid var(--rule-soft);
}
.hub-stats .stat-cell:last-child { border-right: 0; }
.hub-stats .num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 46px;
  line-height: 1;
  color: var(--ink);
}
.hub-stats .num .accent { color: var(--accent); }
.hub-stats .lbl {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 10px;
}

/* ---------- Syllabus modules ---------- */
.modules { padding: 30px 0 20px; }
.module {
  display: grid;
  grid-template-columns: 340px minmax(0,1fr);
  gap: 56px;
  padding: 52px 0;
  border-bottom: 1px solid var(--rule);
}
.module:last-child { border-bottom: 0; }
.module__aside { position: sticky; top: 92px; align-self: start; }
.module__num {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: .18em;
  color: var(--accent);
  margin-bottom: 14px;
}
.module__num .roman {
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0;
  color: var(--accent);
  display: block;
  line-height: .9;
  margin-bottom: 12px;
}
.module__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  line-height: 1.1;
  color: var(--ink);
  margin: 0 0 14px;
  text-wrap: balance;
}
.module__blurb { font-size: 16px; color: var(--ink-3); margin: 0 0 16px; max-width: 34ch; }
.module__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.lesson-list { display: flex; flex-direction: column; }
.lesson-row {
  display: grid;
  grid-template-columns: 54px minmax(0,1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 20px 18px 20px 6px;
  text-decoration: none;
  border-top: 1px solid var(--rule-soft);
  transition: background .16s ease, padding .18s ease;
  position: relative;
}
.lesson-row:first-child { border-top: 0; }
.lesson-row::after {
  content: "";
  position: absolute;
  left: 0; bottom: -1px;
  height: 1px; width: 0;
  background: var(--accent);
  transition: width .25s ease;
}
.lesson-row:hover { background: var(--surface); padding-left: 14px; }
.lesson-row:hover::after { width: 100%; }
.lesson-row .lrnum {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.lesson-row:hover .lrnum { color: var(--accent); }
.lesson-row .lrtitle {
  font-family: var(--font-display);
  font-size: 21px;
  color: var(--ink);
  line-height: 1.2;
}
.lesson-row .lrmeta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-4);
  white-space: nowrap;
}
.lesson-row .lrarrow { color: var(--ink-4); opacity: 0; transform: translateX(-6px); transition: all .2s ease; }
.lesson-row:hover .lrarrow { opacity: 1; transform: translateX(0); color: var(--accent); }

/* Direction B: modules become a tighter index list */
html[data-dir="b"] .module__num .roman { font-style: normal; font-weight: 500; }
html[data-dir="b"] .lesson-row .lrtitle { font-family: var(--font-body); font-size: 19px; }

/* ============================================================
   Homepage
   ============================================================ */
.home-hero {
  padding: 96px 0 30px;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 70px;
  align-items: center;
}
.home-hero .lede h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(46px, 6vw, 86px);
  line-height: .98;
  letter-spacing: -.024em;
  color: var(--ink);
  margin: 20px 0 26px;
  text-wrap: balance;
}
.home-hero .lede h1 em { font-style: italic; color: var(--accent); }
.home-hero .lede p {
  font-size: clamp(19px, 2.1vw, 23px);
  color: var(--ink-2);
  max-width: 46ch;
  margin: 0 0 34px;
  line-height: 1.55;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 14px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 17px;
  text-decoration: none;
  padding: 14px 26px;
  border-radius: 100px;
  border: 1px solid transparent;
  transition: all .18s ease;
}
.btn .ico { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); color: #faf7ef; }
html[data-theme="dark"] .btn-primary { color: #1a1410; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn-ghost { border-color: var(--rule); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-3); }

/* hero result card */
.hero-card {
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 36px 38px;
}
.hero-card .hc-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 22px;
}
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.compare .cc { }
.compare .cc .vs {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.compare .cc .big {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 84px;
  line-height: .9;
  letter-spacing: -.02em;
  color: var(--ink-3);
}
.compare .cc.win .big { color: var(--accent); }
.compare .cc .big .pct { font-size: 36px; vertical-align: 16px; }
.compare .cc .cl { font-size: 14px; color: var(--ink-3); margin-top: 10px; line-height: 1.35; }
.hero-card .hc-foot {
  margin-top: 26px; padding-top: 20px;
  border-top: 1px solid var(--rule-soft);
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-4); line-height: 1.5;
}

/* generic section */
.section { padding: 80px 0; border-top: 1px solid var(--rule); }
.section__label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}
.section h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(34px, 4.4vw, 54px);
  line-height: 1.05;
  letter-spacing: -.018em;
  color: var(--ink);
  margin: 0 0 26px;
  max-width: 20ch;
  text-wrap: balance;
}
.section h2 em { font-style: italic; color: var(--accent); }
.section .body-lg { font-size: 20px; color: var(--ink-2); max-width: 62ch; line-height: 1.6; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 70px; align-items: start; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; margin-top: 50px; }
.feature {
  border: 1px solid var(--rule-soft);
  border-radius: 8px;
  padding: 30px 28px;
  background: var(--surface);
  transition: border-color .18s ease, transform .18s ease;
}
.feature:hover { border-color: var(--accent); transform: translateY(-3px); }
.feature .fnum {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .12em;
  color: var(--accent);
  margin-bottom: 18px;
}
.feature h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 24px;
  color: var(--ink);
  margin: 0 0 12px;
  line-height: 1.15;
}
.feature p { font-size: 16px; color: var(--ink-3); margin: 0; line-height: 1.55; }

/* results metrics row */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-top: 46px; border-top: 1px solid var(--rule); }
.metric { padding: 32px 30px 32px 0; border-right: 1px solid var(--rule-soft); }
.metric:last-child { border-right: 0; padding-right: 0; }
.metric .mv {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(52px, 6vw, 76px);
  line-height: .92;
  letter-spacing: -.02em;
  color: var(--ink);
}
.metric .mv .accent { color: var(--accent); }
.metric .ml { font-size: 16px; color: var(--ink-3); margin-top: 14px; max-width: 28ch; line-height: 1.4; }

/* big CTA band */
.cta-band { padding: 84px 0; border-top: 1px solid var(--rule); background: var(--paper-2); }
.cta-band .inner { text-align: center; max-width: 760px; margin: 0 auto; }
.cta-band h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(36px, 5vw, 60px);
  line-height: 1.04;
  letter-spacing: -.02em;
  color: var(--ink);
  margin: 0 0 22px;
  text-wrap: balance;
}
.cta-band h2 em { font-style: italic; color: var(--accent); }
.cta-band p { font-size: 20px; color: var(--ink-3); margin: 0 0 34px; }
.cta-band .btn-row { justify-content: center; }

@media (max-width: 980px) {
  .home-hero { grid-template-columns: 1fr; gap: 40px; }
  .module { grid-template-columns: 1fr; gap: 24px; }
  .module__aside { position: static; }
  .two-col { grid-template-columns: 1fr; gap: 36px; }
  .feature-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--rule-soft); padding: 26px 0; }
}

/* mobile floating curriculum toggle */
.curriculum-fab {
  display: none;
  position: fixed;
  left: 18px; bottom: 18px;
  z-index: 70;
  align-items: center; gap: 8px;
  background: var(--ink); color: var(--paper);
  border: 0; border-radius: 100px;
  padding: 12px 18px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  cursor: pointer; box-shadow: var(--shadow);
}
@media (max-width: 880px) { .curriculum-fab { display: inline-flex; } }
