/* =========================================================
   Uncertainty Laboratory — styles
   Art direction: a storm-ink observatory (instruments) bound
   to barometer paper (editorial). Iridescent liquid = outcomes,
   acid line = claims. System fonts only; zero dependencies.
   ========================================================= */

:root {
  --ink: #0e0b1f;
  --ink-2: #151030;
  --ink-3: #1f1843;
  --ink-4: #2a2157;
  --paper: #f4eddd;
  --paper-2: #ebe1c9;
  --paper-3: #e1d4b4;
  --type: #1b1630;
  --type-soft: #4a4166;
  --on-ink: #f4eddd;
  --on-ink-soft: #c9c2e6;
  --acid: #d6ff3d;
  --acid-dk: #4d5f00;
  --magenta: #ff4fa3;
  --magenta-dk: #a3115c;
  --violet: #9b7bff;
  --violet-dk: #4b2fb3;
  --cyan: #3fe3f5;
  --cyan-dk: #00687d;
  --amber: #ffb84a;
  --glass: #cfc8ff;
  --focus: var(--acid);
  --link: var(--acid);

  --f-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", "DejaVu Serif", Georgia, serif;
  --f-body: Charter, "Bitstream Charter", "Sitka Text", Cambria, "DejaVu Serif", Georgia, serif;
  --f-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --f-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Motion calibration (guidelines, never blocking) */
  --t-major: 820ms;
  --t-comp: 420ms;
  --t-micro: 200ms;
  --stagger: 90ms;
  --t-bw: 1000ms;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);

  --gutter: clamp(16px, 4vw, 48px);
  --measure: 68ch;
  --radius: 14px;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.1; font-weight: 600; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.3em; }

body {
  background: var(--ink);
  color: var(--on-ink);
  font-family: var(--f-body);
  font-size: clamp(1.02rem, .96rem + .3vw, 1.14rem);
  line-height: 1.62;
  overflow-x: hidden;
}

a { color: var(--link); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--acid); color: var(--ink); padding: 10px 16px; border-radius: 8px;
  font-family: var(--f-ui); font-weight: 700; text-decoration: none;
  transition: top var(--t-micro) var(--ease);
}
.skip-link:focus { top: 12px; }

[hidden] { display: none !important; }
html.no-js .needs-js { display: none !important; }
[id] { scroll-margin-top: 104px; }
@media (min-width: 1100px) { [id] { scroll-margin-top: 72px; } }
#main:focus { outline: none; }

/* ---------- entry / exit black-and-white veil ---------- */
@keyframes bw-in {
  from { filter: grayscale(1) contrast(1.08) brightness(.72); }
  to { filter: grayscale(0) contrast(1) brightness(1); }
}
html.js[data-motion="on"] body { animation: bw-in var(--t-bw) var(--ease) backwards; }
html.js[data-motion="on"].exiting body {
  filter: grayscale(1) brightness(.7);
  transition: filter var(--t-bw) var(--ease-io);
}

/* ---------- masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 50;
  background: rgba(14, 11, 31, .96);
  border-bottom: 1px solid rgba(214, 255, 61, .28);
  font-family: var(--f-ui);
  font-size: .86rem;
}
.masthead-inner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  padding: 8px var(--gutter);
  max-width: 1440px; margin: 0 auto;
}
.wordmark {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--on-ink); text-decoration: none; font-weight: 700; letter-spacing: .02em;
}
.wordmark-glyph { width: 22px; height: 22px; color: var(--glass); }
.site-nav { order: 3; flex: 1 1 100%; overflow-x: auto; scrollbar-width: thin; }
.site-nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 2px 0 4px; white-space: nowrap; }
.site-nav a {
  display: inline-block; padding: 6px 10px; border-radius: 999px;
  color: var(--on-ink-soft); text-decoration: none;
  transition: background-color var(--t-micro) var(--ease), color var(--t-micro) var(--ease);
}
.site-nav a:hover { background: var(--ink-3); color: var(--on-ink); }
.masthead-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.front {
  margin: 0; font-family: var(--f-mono); font-size: .76rem; color: var(--on-ink-soft);
  border: 1px dashed rgba(207, 200, 255, .35); padding: 4px 10px; border-radius: 999px;
  max-width: 34ch; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.front-label { color: var(--acid); text-transform: uppercase; letter-spacing: .12em; margin-right: 4px; }
.tool-btn {
  background: transparent; border: 1px solid rgba(207, 200, 255, .35); color: var(--on-ink-soft);
  border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: .78rem;
  transition: border-color var(--t-micro) var(--ease), color var(--t-micro) var(--ease);
  min-height: 32px;
}
.tool-btn:hover, .tool-btn[aria-pressed="true"] { border-color: var(--acid); color: var(--on-ink); }
.sahilverse-link {
  color: var(--ink); background: var(--acid); text-decoration: none; font-weight: 700;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}
.sahilverse-link:hover { background: #e9ff8f; }

@media (min-width: 1100px) {
  .site-nav { order: 0; flex: 1 1 auto; }
  .front { display: block; }
}
@media (max-width: 560px) {
  .front { display: none; }
  .masthead-tools { margin-left: 0; width: 100%; }
  .sahilverse-link { margin-left: auto; }
}

/* ---------- shared buttons & tags ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px;
  font-family: var(--f-ui); font-weight: 650; font-size: .95rem; text-decoration: none;
  cursor: pointer; border: 1.5px solid transparent;
  transition: transform var(--t-micro) var(--ease), background-color var(--t-micro) var(--ease), border-color var(--t-micro) var(--ease), color var(--t-micro) var(--ease);
}
.btn:active { transform: translateY(1px) scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-acid { background: var(--acid); color: var(--ink); }
.btn-acid:hover { background: #e9ff8f; }
.btn-ghost { background: transparent; color: inherit; border-color: currentColor; }
.btn-ghost:hover { background: rgba(207, 200, 255, .12); }

.tag {
  display: inline-block; font-family: var(--f-ui); font-size: .68rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; line-height: 1.3;
  padding: 2px 8px; border-radius: 999px; vertical-align: .12em; white-space: nowrap;
}
.tag-est { background: #0b5466; color: #e9fbff; }
.tag-con { background: #7a1a52; color: #ffe9f4; }
.tag-hyp { background: #6a4800; color: #fff3d6; }
.tag-sim { background: #3a2d7a; color: #ece6ff; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  display: grid; gap: clamp(24px, 4vw, 56px);
  padding: clamp(32px, 6vw, 88px) var(--gutter) clamp(32px, 5vw, 64px);
  max-width: 1440px; margin: 0 auto;
  background:
    radial-gradient(60% 50% at 80% 30%, rgba(155, 123, 255, .22), transparent 70%),
    radial-gradient(40% 40% at 10% 90%, rgba(255, 79, 163, .14), transparent 70%);
}
@media (min-width: 960px) { .hero { grid-template-columns: 1.05fr .95fr; align-items: center; } }
.kicker {
  font-family: var(--f-mono); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--acid); margin-bottom: 18px;
}
.hero h1 {
  font-family: var(--f-display); font-weight: 400;
  font-size: clamp(3rem, 10.5vw, 8.2rem); line-height: .9; letter-spacing: -.02em;
}
.h1-a { display: block; font-style: italic; color: var(--on-ink); }
.h1-b {
  display: block; color: transparent;
  background: linear-gradient(100deg, var(--cyan), var(--violet) 40%, var(--magenta) 75%, var(--amber));
  -webkit-background-clip: text; background-clip: text;
  padding-bottom: .06em;
}
@supports not ((-webkit-background-clip: text) or (background-clip: text)) { .h1-b { color: var(--violet); } }
.hero-sub { font-family: var(--f-display); font-style: italic; font-size: clamp(1.25rem, 2.2vw, 1.7rem); margin: 18px 0 14px; color: var(--on-ink); }
.hero-lede { max-width: 58ch; color: var(--on-ink-soft); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0; }
.hero-actions .btn-ghost { color: var(--on-ink); }
.legend-key { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0; font-family: var(--f-ui); font-size: .85rem; color: var(--on-ink-soft); }
.legend-key div { display: flex; gap: 6px; align-items: baseline; }
.legend-key dt { font-weight: 700; color: var(--on-ink); display: inline-flex; align-items: center; gap: 6px; }
.legend-key dd { margin: 0; }
.swatch { display: inline-block; width: 22px; height: 10px; border-radius: 3px; }
.swatch-acid { background: var(--acid); height: 3px; }
.swatch-liquid { background: linear-gradient(90deg, var(--cyan), var(--violet), var(--magenta)); }
.swatch-band { background: rgba(214, 255, 61, .25); border: 1px dashed rgba(214, 255, 61, .6); }
.hero-figure { margin: 0; }
.hero-figure figcaption { font-family: var(--f-mono); font-size: .78rem; color: var(--on-ink-soft); margin-top: 6px; max-width: 52ch; }
.hero-art { width: 100%; height: auto; }

/* decorative motion (only when motion is on, paused when tab hidden) */
@keyframes iso-drift { to { stroke-dashoffset: -180; } }
@keyframes iso-breathe { 0%, 100% { transform: rotate(0deg) scale(1); } 50% { transform: rotate(3deg) scale(1.02); } }
@keyframes drop-fall { 0% { transform: translateY(-8px); opacity: 0; } 15% { opacity: .9; } 85% { opacity: .9; } 100% { transform: translateY(140px); opacity: 0; } }
@keyframes slosh { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
html[data-motion="on"] .iso-field { transform-origin: 330px 215px; transform-box: view-box; animation: iso-breathe 26s var(--ease-io) infinite; }
html[data-motion="on"] .iso[stroke-dasharray] { animation: iso-drift 30s linear infinite; }
html[data-motion="on"] .drop { animation: drop-fall 6.5s var(--ease-io) infinite; }
html[data-motion="on"] .drop-1 { animation-delay: -2.1s; animation-duration: 7.4s; }
html[data-motion="on"] .drop-2 { animation-delay: -4.3s; animation-duration: 5.8s; }
html[data-motion="on"] .meniscus { animation: slosh 3.6s var(--ease-io) infinite; }
html.is-hidden *, html.is-hidden *::before, html.is-hidden *::after { animation-play-state: paused !important; }

/* ---------- status legend ---------- */
.status-legend { max-width: 1440px; margin: 0 auto; padding: 18px var(--gutter) 40px; font-family: var(--f-ui); font-size: .9rem; color: var(--on-ink-soft); }
.status-intro { margin-bottom: 10px; }
.status-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
@media (min-width: 760px) { .status-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .status-list { grid-template-columns: repeat(4, 1fr); } }
.status-list li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }

/* ---------- plates (instrument sections) ---------- */
.plate { padding: clamp(40px, 7vw, 96px) var(--gutter); position: relative; }
.plate > * { max-width: 1320px; margin-left: auto; margin-right: auto; }
.plate-head { margin-bottom: clamp(20px, 3vw, 36px); }
.plate-no {
  font-family: var(--f-mono); text-transform: uppercase; letter-spacing: .2em; font-size: .8rem;
  color: var(--acid); margin-bottom: 8px;
}
.plate h2 { font-family: var(--f-display); font-weight: 400; font-size: clamp(2rem, 5vw, 3.6rem); letter-spacing: -.01em; }
.plate-dek { max-width: 70ch; margin-top: 12px; color: var(--on-ink-soft); }
.plate-instrument { background: linear-gradient(180deg, var(--ink-2), var(--ink) 80%); border-top: 1px solid var(--ink-4); }
.plate-noise { background: radial-gradient(70% 60% at 85% 10%, rgba(63, 227, 245, .12), transparent 70%), #120d2a; }
.plate-prism { background: linear-gradient(180deg, #0d0a1f, #170f33); }
.plate-prism::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: linear-gradient(90deg, var(--magenta), var(--amber), var(--acid), var(--cyan), var(--violet));
}
.noscript-note { background: var(--ink-3); border-left: 4px solid var(--amber); padding: 14px 18px; border-radius: 8px; }

/* ---------- instrument ---------- */
.console { display: grid; gap: 22px; }
@media (min-width: 1000px) { .console { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: start; } }

.q-card {
  background: var(--ink-3); border: 1px solid var(--ink-4); border-radius: var(--radius);
  padding: clamp(18px, 3vw, 30px);
}
.q-meta { font-family: var(--f-mono); font-size: .8rem; color: var(--on-ink-soft); display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.q-tag { border: 1px solid rgba(207, 200, 255, .4); border-radius: 999px; padding: 0 8px; }
.q-tag:empty { display: none; }
.q-text { font-family: var(--f-display); font-weight: 400; font-size: clamp(1.35rem, 2.6vw, 1.9rem); line-height: 1.25; margin-bottom: 18px; }
.q-text:focus { outline: none; }
.q-text:focus-visible { outline: 3px solid var(--focus); }

.choices, .confidence { border: 0; margin: 0 0 16px; padding: 0; }
.choices { display: grid; gap: 10px; }
.choice {
  position: relative; display: flex; gap: 14px; align-items: center;
  padding: 14px 16px; border-radius: 12px; cursor: pointer;
  background: var(--ink-2); border: 1.5px solid var(--ink-4);
  transition: border-color var(--t-micro) var(--ease), background-color var(--t-micro) var(--ease), transform var(--t-micro) var(--ease);
}
.choice:hover { border-color: var(--glass); }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice-key {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--f-mono); font-weight: 700; border: 1.5px solid var(--glass); color: var(--glass);
}
.choice-text { font-size: 1.05rem; }
.choice:has(input:checked) { border-color: var(--acid); background: #24204a; }
.choice input:checked + .choice-key { background: var(--acid); color: var(--ink); border-color: var(--acid); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.choice input:focus-visible + .choice-key { box-shadow: 0 0 0 3px var(--focus); }
.choice.is-correct { border-color: var(--cyan); }
.choice.is-wrong { border-color: var(--magenta); }
.choices[disabled] .choice { cursor: default; }

.confidence legend { font-family: var(--f-ui); font-weight: 650; font-size: .95rem; margin-bottom: 10px; }
.conf-scale { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (min-width: 520px) { .conf-scale { grid-template-columns: repeat(6, 1fr); } }
.conf-scale label { position: relative; cursor: pointer; }
.conf-scale input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.conf-scale span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px;
  border-radius: 10px; border: 1.5px solid var(--ink-4); background: var(--ink-2);
  font-family: var(--f-mono); font-weight: 700; font-size: 1rem;
  transition: background-color var(--t-micro) var(--ease), border-color var(--t-micro) var(--ease), color var(--t-micro) var(--ease);
}
.conf-scale small { font-weight: 400; font-size: .66rem; color: var(--on-ink-soft); }
.conf-scale label:hover span { border-color: var(--glass); }
.conf-scale input:checked + span { background: var(--acid); color: var(--ink); border-color: var(--acid); }
.conf-scale input:checked + span small { color: var(--ink); }
.conf-scale input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 3px; }
.certainty-warning { font-family: var(--f-ui); font-size: .85rem; color: var(--amber); margin: 10px 0 0; }

.q-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.q-actions .btn-ghost { color: var(--on-ink); }
.feedback { margin-top: 16px; }
.feedback:empty { display: none; }
.feedback .fb {
  border-radius: 12px; padding: 14px 16px; background: var(--ink-2); border-left: 4px solid var(--cyan);
  animation: rise var(--t-comp) var(--ease) both;
}
.feedback .fb.miss { border-left-color: var(--magenta); }
.feedback .fb-head { font-family: var(--f-ui); font-weight: 700; margin-bottom: 4px; }
.feedback .fb p { margin: 0; color: var(--on-ink-soft); }
.feedback .fb p + p { margin-top: 6px; }
.next-btn { margin-top: 12px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.gauge-panel {
  background: var(--ink-2); border: 1px solid var(--ink-4); border-radius: var(--radius);
  padding: clamp(14px, 2.4vw, 24px);
}
.view-switch { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; font-family: var(--f-ui); }
.seg {
  border: 1px solid var(--ink-4); background: var(--ink-3); color: var(--on-ink-soft);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: .85rem; min-height: 36px;
  transition: background-color var(--t-micro) var(--ease), color var(--t-micro) var(--ease);
}
.seg[aria-pressed="true"] { background: var(--on-ink); color: var(--ink); border-color: var(--on-ink); }
.viz svg { width: 100%; height: auto; }
.viz { animation: rise var(--t-comp) var(--ease) both; }

/* gauge svg parts (built in app.js) */
.g-glass { fill: rgba(255, 255, 255, .035); stroke: var(--glass); stroke-opacity: .55; stroke-width: 1.5; }
.g-liquid { transform-box: fill-box; transform-origin: 50% 100%; transition: transform var(--t-major) var(--ease); }
.g-band { fill: var(--acid); fill-opacity: .16; stroke: var(--acid); stroke-opacity: .5; stroke-dasharray: 3 3; transition: y var(--t-major) var(--ease), height var(--t-major) var(--ease); }
.g-claim { stroke: var(--acid); stroke-width: 2.6; }
.g-tick { stroke: var(--glass); stroke-opacity: .3; }
.g-label { fill: var(--on-ink); font-family: var(--f-mono); font-size: 14px; }
.g-sub { fill: var(--on-ink-soft); font-family: var(--f-mono); font-size: 11px; }
.g-empty { fill: var(--on-ink-soft); font-family: var(--f-mono); font-size: 12px; opacity: .7; }
.g-crack { stroke: var(--amber); stroke-width: 1.6; fill: none; }
.axis line, .axis path { stroke: var(--glass); stroke-opacity: .45; }
.axis text { fill: var(--on-ink-soft); font-family: var(--f-mono); font-size: 11px; }
.diag { stroke: var(--acid); stroke-dasharray: 5 5; stroke-width: 1.6; }
.pt { fill: url(#rel-liq); stroke: var(--on-ink); stroke-width: 1; transition: cx var(--t-comp) var(--ease), cy var(--t-comp) var(--ease), r var(--t-comp) var(--ease); }
.whisk { stroke: var(--on-ink-soft); stroke-width: 1.4; }

.bin-table, .kent-table, .myth-table { width: 100%; border-collapse: collapse; font-family: var(--f-ui); font-size: .92rem; }
.bin-table caption, .kent-table caption, .myth-table caption { text-align: left; font-weight: 700; padding-bottom: 8px; }
.bin-table th, .bin-table td { padding: 8px 6px; border-bottom: 1px solid var(--ink-4); text-align: right; font-variant-numeric: tabular-nums; }
.bin-table th:first-child, .bin-table td:first-child { text-align: left; }

.readouts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 14px 0 0; }
@media (min-width: 620px) { .readouts { grid-template-columns: repeat(3, 1fr); } }
.readouts div { background: var(--ink-3); border-radius: 10px; padding: 10px 12px; }
.readouts dt { font-family: var(--f-ui); font-size: .76rem; color: var(--on-ink-soft); }
.readouts dt small { display: block; font-size: .68rem; opacity: .85; }
.readouts dd { margin: 2px 0 0; font-family: var(--f-mono); font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.readouts dd.flash { animation: flash var(--t-comp) var(--ease); }
@keyframes flash { 0% { color: var(--acid); } 100% { color: inherit; } }

.readout-text {
  margin-top: 22px; background: var(--paper); color: var(--type); border-radius: var(--radius);
  padding: clamp(18px, 3vw, 30px); --focus: var(--violet-dk); --link: var(--violet-dk);
}
.readout-text h3 { font-family: var(--f-display); font-weight: 400; font-size: 1.6rem; margin-bottom: 10px; }
.readout-text p { max-width: var(--measure); }
.readout-text .rt-note { font-family: var(--f-ui); font-size: .85rem; color: var(--type-soft); }

.explain { margin-top: 14px; background: var(--ink-3); border-radius: 12px; border: 1px solid var(--ink-4); }
.explain summary, .paper-version > summary {
  cursor: pointer; padding: 14px 18px; font-family: var(--f-ui); font-weight: 650; list-style-position: inside;
}
.explain-body { padding: 0 18px 16px; color: var(--on-ink-soft); max-width: 80ch; }
.explain-body strong { color: var(--on-ink); }
.kbd-list { list-style: none; padding: 0; }
.kbd-list li { margin-bottom: 6px; }
kbd {
  font-family: var(--f-mono); font-size: .85em; background: var(--ink); border: 1px solid var(--glass);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--on-ink);
}

.paper-version { margin-top: 24px; background: var(--paper); color: var(--type); border-radius: var(--radius); --focus: var(--violet-dk); --link: var(--violet-dk); }
.paper-body { padding: 0 20px 20px; }
.paper-list li { margin-bottom: 6px; }
.answer-key { margin-top: 10px; background: var(--paper-2); border-radius: 10px; padding: 10px 14px; }
.answer-key summary { cursor: pointer; font-family: var(--f-ui); font-weight: 650; }

/* ---------- noise machine ---------- */
.noise-grid { display: grid; gap: 22px; }
@media (min-width: 960px) { .noise-grid { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); align-items: start; } }
.noise-controls { background: var(--ink-3); border-radius: var(--radius); padding: clamp(16px, 2.6vw, 26px); border: 1px solid var(--ink-4); font-family: var(--f-ui); font-size: .92rem; }
.ctl { border: 0; padding: 0; margin: 0 0 18px; }
.ctl legend, .ctl > label { font-weight: 650; display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.ctl output { font-family: var(--f-mono); color: var(--acid); }
.ctl-help { font-size: .82rem; color: var(--on-ink-soft); margin: 6px 0 0; }
.ctl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.ctl-row .btn-ghost { color: var(--on-ink); }
.pill { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; cursor: pointer; margin-bottom: 6px; border: 1px solid transparent; }
.pill:has(input:checked) { border-color: var(--acid); background: var(--ink-2); }
.pill input { margin-top: .3em; accent-color: var(--acid); }
.pill small { color: var(--on-ink-soft); }
select { background: var(--ink-2); border: 1px solid var(--glass); border-radius: 8px; padding: 8px 10px; min-height: 40px; }
input[type="range"] { width: 100%; accent-color: var(--acid); min-height: 32px; }
.seed-line { font-family: var(--f-mono); font-size: .76rem; color: var(--on-ink-soft); margin: 0; }
.noise-out { background: var(--ink-2); border-radius: var(--radius); padding: clamp(14px, 2.4vw, 24px); border: 1px solid var(--ink-4); }
.noise-out svg { width: 100%; height: auto; }
.noise-readout { font-size: .98rem; color: var(--on-ink-soft); }
.noise-readout strong { color: var(--on-ink); }
.noise-model { margin-top: 26px; color: var(--on-ink-soft); }
.noise-model > * { max-width: 80ch; }
.noise-model h3 { font-family: var(--f-display); font-weight: 400; font-size: 1.5rem; color: var(--on-ink); margin-bottom: 10px; }

/* ---------- phrase prism ---------- */
.prism { display: grid; gap: 22px; }
@media (min-width: 960px) { .prism { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); align-items: start; } }
.prism-sliders { display: grid; gap: 10px; }
.phrase { background: var(--ink-3); border: 1px solid var(--ink-4); border-radius: 12px; padding: 10px 14px; font-family: var(--f-ui); }
.phrase label { display: flex; justify-content: space-between; gap: 10px; font-weight: 650; }
.phrase output { font-family: var(--f-mono); color: var(--acid); }
.phrase output.unset { color: var(--on-ink-soft); font-weight: 400; }
.phrase .hue { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: .05em; }
.prism-out { background: var(--ink-2); border: 1px solid var(--ink-4); border-radius: var(--radius); padding: clamp(14px, 2.4vw, 24px); }
.prism-out svg { width: 100%; height: auto; }
.prism-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.prism-actions .btn-ghost { color: var(--on-ink); }
.share-field { display: block; font-family: var(--f-ui); font-size: .85rem; margin-bottom: 10px; }
.share-field input { width: 100%; margin-top: 4px; background: var(--ink); border: 1px solid var(--glass); border-radius: 8px; padding: 8px; font-family: var(--f-mono); font-size: .8rem; }
.prism-readout { color: var(--on-ink-soft); }
.prism-readout ul { padding-left: 1.1em; }
.prism-readout li { margin-bottom: 6px; }
.p-label { fill: var(--on-ink); font-family: var(--f-ui); font-size: 12px; }
.p-band { fill: var(--acid); fill-opacity: .18; stroke: var(--acid); stroke-opacity: .7; stroke-dasharray: 3 3; }
.p-mark { stroke-width: 3; }
.p-friend { fill: none; stroke: var(--on-ink); stroke-width: 2; }
.p-track { stroke: var(--glass); stroke-opacity: .25; }

/* ---------- field guide (paper) ---------- */
.guide {
  background: var(--paper); color: var(--type);
  padding: clamp(48px, 8vw, 110px) var(--gutter);
  --focus: var(--violet-dk); --link: var(--violet-dk);
  background-image:
    repeating-linear-gradient(0deg, rgba(27, 22, 48, .035) 0 1px, transparent 1px 32px);
}
.guide > * { max-width: 1120px; margin-left: auto; margin-right: auto; }
.guide-head .plate-no { color: var(--violet-dk); }
.guide h2 { font-family: var(--f-display); font-weight: 400; font-size: clamp(2rem, 5vw, 3.4rem); max-width: 22ch; letter-spacing: -.01em; }
.guide-dek { color: var(--type-soft); margin-top: 12px; max-width: 64ch; }
.toc { margin: 26px 0 10px; border-top: 2px solid var(--type); border-bottom: 1px solid var(--type); padding: 12px 0; font-family: var(--f-ui); }
.toc ol { columns: 1; margin: 0; padding-left: 1.5em; }
@media (min-width: 720px) { .toc ol { columns: 3; column-gap: 32px; } }
.toc li { margin-bottom: 6px; break-inside: avoid; }
.chapter { padding: clamp(28px, 4vw, 48px) 0; border-bottom: 1px solid rgba(27, 22, 48, .2); }
.chapter > p, .chapter > h4, .chapter > ul, .chapter > ol, .chapter > dl, .chapter > .verdict { max-width: var(--measure); }
.chapter h3 { font-family: var(--f-display); font-weight: 400; font-size: clamp(1.6rem, 3.4vw, 2.4rem); margin-bottom: 16px; display: flex; gap: 14px; align-items: baseline; }
.ch-no {
  font-family: var(--f-mono); font-size: .9rem; color: var(--paper); background: var(--type);
  width: 2em; height: 2em; display: inline-grid; place-items: center; border-radius: 50%; flex: none;
}
@media (min-width: 1100px) {
  .chapter { display: grid; grid-template-columns: minmax(200px, 250px) minmax(0, 1fr); column-gap: 56px; }
  .chapter > * { grid-column: 2; }
  .chapter > h3 { grid-column: 1; grid-row: 1 / span 40; align-self: start; position: sticky; top: 88px; flex-direction: column; gap: 10px; font-size: 1.9rem; }
  .does-not > h3 { position: static; }
}
.chapter h4 { font-family: var(--f-display); font-weight: 600; font-size: 1.22rem; margin: 22px 0 6px; }
.glossary dt { font-family: var(--f-display); font-weight: 700; font-size: 1.2rem; margin-top: 18px; }
.glossary dd { margin: 4px 0 0; }
.lenses { display: grid; gap: 16px; margin: 20px 0; }
@media (min-width: 820px) { .lenses { grid-template-columns: 1fr 1fr; } }
.lens { border-radius: var(--radius); padding: 20px 22px; border: 2px solid var(--type); background: var(--paper-2); }
.lens-a { box-shadow: 6px 6px 0 var(--cyan-dk); }
.lens-b { box-shadow: 6px 6px 0 var(--magenta-dk); }
.lens h4 { margin-top: 0; }
.lens-implication { font-family: var(--f-ui); font-size: .92rem; margin: 0; }
.verdict { background: var(--paper-3); padding: 14px 18px; border-radius: 10px; }
.case { margin: 26px 0; padding: clamp(18px, 3vw, 30px); background: #fbf6ea; border: 1px solid rgba(27, 22, 48, .25); border-radius: var(--radius); }
.case > p, .case > h4 { max-width: var(--measure); }
.case-label { font-family: var(--f-mono); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--magenta-dk); margin-bottom: 6px; }
.case h4 { font-family: var(--f-display); font-size: clamp(1.4rem, 2.6vw, 1.9rem); font-weight: 400; margin: 0 0 12px; }
q { quotes: "“" "”"; font-style: italic; }
.kent-table { max-width: 560px; margin: 14px 0 18px; }
.kent-table th, .kent-table td { padding: 7px 10px; border-bottom: 1px solid rgba(27, 22, 48, .25); text-align: left; }
.kent-table thead th { border-bottom: 2px solid var(--type); }
.kent-table td { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.pull {
  font-family: var(--f-display); font-style: italic; font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.25;
  max-width: 30ch; margin: 26px 0; padding-left: 18px; border-left: 4px solid var(--magenta-dk);
}
.table-wrap { overflow-x: auto; }
.myth-table { min-width: 640px; }
.myth-table th, .myth-table td { padding: 10px; border-bottom: 1px solid rgba(27, 22, 48, .25); vertical-align: top; text-align: left; }
.myth-table thead th { border-bottom: 2px solid var(--type); }
.myth-table tbody th { font-family: var(--f-display); font-style: italic; font-weight: 400; font-size: 1rem; width: 30%; }
.counter li, .ethics li, .does-not li { margin-bottom: 12px; }
.does-not { background: var(--type); color: var(--paper); border-radius: var(--radius); padding: clamp(22px, 4vw, 40px); margin-top: 30px; border-bottom: 0; --link: var(--acid); --focus: var(--acid); }
.does-not .ch-no { background: var(--acid); color: var(--type); }
.does-not strong { color: var(--acid); }

/* ---------- diary ---------- */
.plate-diary { background: var(--paper-2); color: var(--type); --focus: var(--violet-dk); --link: var(--violet-dk); }
.plate-diary .plate-no { color: var(--violet-dk); }
.plate-diary .plate-dek { color: var(--type-soft); }
.diary { display: grid; gap: 14px; }
@media (min-width: 900px) { .diary { grid-template-columns: 1fr 1fr; } }
.prompt label { display: block; font-family: var(--f-display); font-size: 1.1rem; margin-bottom: 6px; }
.p-no { font-family: var(--f-mono); font-size: .8rem; color: var(--magenta-dk); margin-right: 6px; }
textarea {
  width: 100%; min-height: 96px; resize: vertical; background: #fffdf6; color: var(--type);
  border: 1.5px solid rgba(27, 22, 48, .35); border-radius: 10px; padding: 10px 12px; line-height: 1.5;
  background-image: repeating-linear-gradient(0deg, transparent 0 23px, rgba(75, 47, 179, .12) 23px 24px);
  background-attachment: local;
}
textarea:focus-visible { border-color: var(--violet-dk); }
.diary-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; grid-column: 1 / -1; }
.diary-actions .btn-ghost { color: var(--type); }
.diary-status { margin: 0; font-family: var(--f-ui); font-size: .88rem; color: var(--type-soft); }

/* ---------- FAQ ---------- */
.faq { padding: clamp(48px, 7vw, 96px) var(--gutter); background: var(--ink); }
.faq > * { max-width: 920px; margin-left: auto; margin-right: auto; }
.faq h2 { font-family: var(--f-display); font-weight: 400; font-size: clamp(2rem, 4.6vw, 3.2rem); margin-bottom: 22px; }
.faq details { border-top: 1px solid var(--ink-4); }
.faq details:last-of-type { border-bottom: 1px solid var(--ink-4); }
.faq summary {
  cursor: pointer; padding: 18px 4px; font-family: var(--f-display); font-size: 1.22rem; list-style: none;
  display: flex; justify-content: space-between; gap: 14px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--f-mono); color: var(--acid); transition: transform var(--t-micro) var(--ease); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { color: var(--on-ink-soft); padding: 0 4px 18px; max-width: var(--measure); }

/* ---------- reading ---------- */
.reading { background: var(--paper); color: var(--type); padding: clamp(48px, 7vw, 96px) var(--gutter); --focus: var(--violet-dk); --link: var(--violet-dk); }
.reading > * { max-width: 1000px; margin-left: auto; margin-right: auto; }
.reading h2 { font-family: var(--f-display); font-weight: 400; font-size: clamp(2rem, 4.6vw, 3.2rem); margin-bottom: 12px; }
.reading-note { font-family: var(--f-ui); font-size: .9rem; color: var(--type-soft); }
.refs { padding-left: 1.6em; }
.refs li { margin-bottom: 14px; padding-left: 4px; overflow-wrap: anywhere; }
.refs a { font-family: var(--f-mono); font-size: .82em; }
.ref-note { display: block; font-family: var(--f-ui); font-size: .82rem; color: var(--type-soft); }

/* ---------- related & CTA ---------- */
.related { padding: clamp(48px, 7vw, 96px) var(--gutter); background: linear-gradient(180deg, #120d2a, var(--ink)); }
.related > * { max-width: 1200px; margin-left: auto; margin-right: auto; }
.related h2 { font-family: var(--f-display); font-weight: 400; font-size: clamp(2rem, 4.6vw, 3.2rem); margin-bottom: 10px; }
.related-note { color: var(--on-ink-soft); font-family: var(--f-ui); font-size: .9rem; }
.related-list { list-style: none; padding: 0; display: grid; gap: 12px; margin-top: 20px; }
@media (min-width: 720px) { .related-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .related-list { grid-template-columns: repeat(5, 1fr); } }
.related-list a {
  display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 18px; border-radius: var(--radius);
  background: var(--ink-3); border: 1px solid var(--ink-4); text-decoration: none; color: var(--on-ink);
  transition: transform var(--t-micro) var(--ease), border-color var(--t-micro) var(--ease);
}
.related-list a:hover { transform: translateY(-3px); border-color: var(--acid); }
.rel-title { font-family: var(--f-display); font-size: 1.25rem; }
.rel-desc { font-family: var(--f-ui); font-size: .86rem; color: var(--on-ink-soft); }

.cta { padding: clamp(48px, 7vw, 96px) var(--gutter); background: var(--acid); color: var(--ink); --focus: var(--ink); --link: var(--ink); }
.cta > * { max-width: 1200px; margin-left: auto; margin-right: auto; }
.cta h2 { font-family: var(--f-display); font-weight: 400; font-size: clamp(2rem, 5vw, 3.4rem); margin-bottom: 22px; text-wrap: balance; }
.cta-grid { display: grid; gap: 12px; }
@media (min-width: 640px) { .cta-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .cta-grid { grid-template-columns: repeat(4, 1fr); } }
.cta-card {
  display: flex; flex-direction: column; gap: 4px; padding: 20px; border-radius: var(--radius);
  background: var(--ink); color: var(--on-ink); text-decoration: none; font-family: var(--f-display); font-size: 1.3rem;
  transition: transform var(--t-micro) var(--ease);
}
.cta-card:hover { transform: translateY(-3px); }
.cta-card:focus-visible { outline-color: var(--ink); }
.cta-k { font-family: var(--f-mono); font-size: .75rem; letter-spacing: .18em; text-transform: uppercase; color: var(--acid); }
.cta-fallback { margin-top: 18px; font-family: var(--f-ui); }

.site-footer { background: var(--ink); color: var(--on-ink-soft); font-family: var(--f-ui); font-size: .86rem; padding: 36px var(--gutter) 48px; border-top: 1px solid var(--ink-4); }
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-mark { color: var(--on-ink); font-weight: 650; }

/* ---------- scroll reveals (JS adds .reveal; motion on only) ---------- */
html.js[data-motion="on"] .reveal { opacity: 0; transform: translateY(18px); transition: opacity var(--t-major) var(--ease), transform var(--t-major) var(--ease); transition-delay: calc(var(--i, 0) * var(--stagger)); }
html.js[data-motion="on"] .reveal.in { opacity: 1; transform: none; }

/* ---------- motion off / reduced ---------- */
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after {
  animation: none !important; transition-duration: 0s !important; transition-delay: 0s !important;
}
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="on"]) *, html:not([data-motion="on"]) *::before, html:not([data-motion="on"]) *::after {
    animation: none !important; transition-duration: 0s !important; transition-delay: 0s !important;
  }
}
@media (prefers-reduced-motion: no-preference) {
  html[data-motion="on"] { scroll-behavior: smooth; }
}

/* ---------- forced colours ---------- */
@media (forced-colors: active) {
  .tag, .btn, .seg, .choice, .conf-scale span { border: 1px solid CanvasText; }
  .h1-b { color: CanvasText; background: none; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .masthead, .hero-figure, .hero-actions, .instrument, .noise-grid, .prism, .diary-actions, .cta, .related, .skip-link, .status-legend { display: none !important; }
  .plate, .guide, .faq, .reading, .plate-diary { background: #fff !important; color: #000 !important; padding: 12pt 0; }
  .plate-dek, .faq details p, .noise-model { color: #000 !important; }
  .paper-version, .paper-version details { display: block; }
  .faq details > p { display: block; }
  a { color: #000; }
  .does-not { background: #fff; color: #000; border: 1px solid #000; }
  .does-not strong { color: #000; }
  .tag { border: 1px solid #000; background: #fff !important; color: #000 !important; }
}
