:root {
  --paper: #fbfaf7;
  --ink: #111110;
  --ink-2: #55534e;
  --ink-3: #8e8b84;
  --rule: #d9d6cf;
  --stage: #0d0d0c;
  --pick: #4a90e2;     /* reCAPTCHA-like selection blue */
  --ok: #4fbf75;
  --miss: #e8a33a;
  --bad: #e2564a;
  --you: #ffffff;
  --model: #ffc36b;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --k-trade: #e9b949; --k-talk: #f08a5d; --k-signal: #5ec8e5; --k-digital: #9b8cf8;
  --k-coordination: #7bd389; --k-record: #c9a27e; --k-living: #e07fbf; --k-physical: #a7b0c2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f0f0e; --ink: #ecebe7; --ink-2: #a9a69f; --ink-3: #75726c; --rule: #2a2927; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f0f0e; --ink: #ecebe7; --ink-2: #a9a69f; --ink-3: #75726c; --rule: #2a2927; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font-family: var(--serif); font-size: 17px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
.wrap { max-width: 1480px; margin: 0 auto; padding: 0 16px 24px; }

header.mast { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 22px 0 14px; border-bottom: 1px solid var(--ink); }
.mast h1 { font-weight: 400; font-size: 30px; letter-spacing: -0.01em; margin: 0; }
.mast h1 em { font-style: italic; }
.mast .kicker { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.mast a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--rule); }
.lede { color: var(--ink-2); font-size: 18px; max-width: 780px; margin: 14px 0 6px; }

.place { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 12px 0 8px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.place[hidden] { display: none; }
.place-k { letter-spacing: .08em; text-transform: uppercase; font-size: 11px; }
.place select { font: inherit; font-size: 13px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 999px; padding: 6px 12px; min-height: 36px; max-width: 100%; }
.place-note { color: var(--ink-3); }
.place-back { font: inherit; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; border-bottom: 1px solid var(--rule); }

.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--rule); margin-bottom: 12px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 0 9px; margin-right: 20px;
  cursor: pointer; color: var(--ink-2); font-size: 15px; min-height: 40px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.layout { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: 20px; align-items: start; }

/* ── Stage ─────────────────────────────────────────────── */
.stage { position: relative; background: var(--stage); line-height: 0; overflow: hidden; user-select: none; }
.stage img { display: block; width: 100%; height: auto; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage.drawing { cursor: crosshair; touch-action: none; }
.status { position: absolute; inset: 0; display: grid; place-items: center; line-height: 1.4; color: #e9e7e1;
  font-style: italic; font-size: 19px; text-align: center; padding: 24px; background: rgba(13,13,12,.6);
  transition: opacity 400ms; min-height: 200px; }
.status.off { opacity: 0; pointer-events: none; }

/* CAPTCHA grid */
.grid { position: absolute; inset: 0; display: grid; gap: 3px; background: rgba(255,255,255,.85); padding: 3px; line-height: 1; }
.grid[hidden] { display: none; }
.tile { position: relative; background-repeat: no-repeat; cursor: pointer; border: 0; padding: 0; transition: transform 120ms; }
.tile[aria-pressed="true"] { transform: scale(.88); }
.tile[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--pick); color: #fff; font: 600 13px/22px var(--mono); text-align: center; }
.tile.r-ok::before, .tile.r-miss::before, .tile.r-extra::before { content: ""; position: absolute; inset: 0; border: 4px solid; }
.tile.r-ok::before { border-color: var(--ok); }
.tile.r-miss::before { border-color: var(--miss); border-style: dashed; }
.tile.r-extra::before { border-color: var(--bad); }

/* Screen-pixel strokes whatever the image's resolution. */
.box-you, .box-model, .box-guess, .box-about, .box-dim, .mask { vector-effect: non-scaling-stroke; }
.box-you { fill: rgba(255,255,255,.08); stroke: var(--you); stroke-width: 2; }
.box-model { fill: none; stroke: var(--model); stroke-width: 2; stroke-dasharray: 8 5; }
.box-guess { fill: rgba(122,183,255,.12); stroke: #7ab7ff; stroke-width: 2; }
.box-about { fill: none; stroke: #fff; stroke-width: 2; }
.box-dim { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 1; }
.mask { fill: #1b1b1b; stroke: #fff; stroke-width: 1.5; stroke-dasharray: 4 4; }
.mask-q { font-family: var(--mono); fill: #fff; text-anchor: middle; dominant-baseline: middle; }
.over-label { font-family: var(--mono); fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.8); stroke-width: 3px; }

/* ── Panel ─────────────────────────────────────────────── */
.panel { font-size: 16px; line-height: 1.5; }
.panel h2 { font-weight: 400; font-size: 23px; line-height: 1.25; margin: 0 0 6px; }
.panel .k { font-family: var(--mono); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 4px; }
.panel p { margin: 0 0 10px; }
.panel .muted { color: var(--ink-2); }
.panel .why { border-left: 2px solid var(--rule); padding-left: 12px; color: var(--ink-2); }
.btn { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; min-height: 40px;
  padding: 8px 16px; border-radius: 4px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn:disabled { opacity: .4; cursor: default; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.chip { font-size: 14px; min-height: 36px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--rule);
  background: transparent; color: var(--ink-2); cursor: pointer; text-align: left; }
.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); }
.score { font-family: var(--mono); font-size: 13px; margin: 8px 0; }
.score b { font-size: 22px; font-weight: 500; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-family: var(--mono); font-size: 11px; color: var(--ink-2); margin: 6px 0 10px; }
.legend i { display: inline-block; width: 14px; height: 10px; margin-right: 5px; vertical-align: -1px; border: 2px solid; }
.spark { width: 100%; height: 70px; display: block; margin: 6px 0; }
.spark path { fill: none; stroke: #7ab7ff; stroke-width: 2; }
.spark line { stroke: var(--rule); }

.answers { display: grid; gap: 8px; margin: 8px 0; }
.answer { text-align: left; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 6px; background: transparent;
  cursor: pointer; font-size: 15.5px; line-height: 1.45; }
.answer b { font-family: var(--mono); font-size: 11px; margin-right: 6px; color: var(--ink-2); }
.answer:hover { border-color: var(--ink-2); }
.answer.good { border-color: var(--ok); }
.answer.flawed { border-color: var(--bad); }
.answer:disabled { cursor: default; }
pre.record { font-family: var(--mono); font-size: 11.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
  background: color-mix(in srgb, var(--paper) 90%, var(--ink)); padding: 10px 12px; margin: 8px 0; border-radius: 4px; }

.flows { list-style: none; margin: 6px 0; padding: 0; max-height: 470px; overflow-y: auto; border-top: 1px solid var(--rule); }
.flows li { padding: 8px 2px; border-bottom: 1px solid var(--rule); cursor: pointer; font-size: 15px; line-height: 1.35; }
.flows li:hover, .flows li.sel { background: color-mix(in srgb, var(--paper) 90%, var(--ink)); }
.flows .t { border-left: 3px solid var(--c); padding-left: 8px; display: block; }
.flows .m { display: block; padding-left: 11px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }
.flows .m b { color: var(--ink); font-weight: 500; }
.flows li.untrainable .m b { color: var(--ink-3); font-weight: 400; font-style: italic; }

.cases { list-style: none; margin: 0; padding: 0; counter-reset: c; }
.cases li { border-top: 1px solid var(--rule); padding: 10px 0; cursor: pointer; }
.cases li .h { font-size: 17px; }
.cases li .h::before { counter-increment: c; content: counter(c) " · "; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.cases li .b { display: none; font-size: 15px; color: var(--ink-2); margin-top: 6px; }
.cases li .b span { display: block; margin-bottom: 4px; }
.cases li .b em { font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-right: 6px; }
.cases li.open .b { display: block; }

.note { color: var(--ink-2); font-size: 14.5px; max-width: 780px; margin: 18px 0 0; }
.embed-credit { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; margin: 14px 0 4px; }
.embed-credit a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--rule); }

.embed body { background: transparent; }
:root.embed[data-theme="dark"] { --paper: #1b1b1b; --ink: #e2e2e2; --ink-2: #a8a8a8; --ink-3: #7c7c7c; --rule: #343434; }
.embed .wrap { padding: 0; max-width: none; }
.embed header.mast, .embed .intro { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .tabs button { margin-right: 14px; font-size: 14px; }
  .flows { max-height: none; }
}

/* ── The ladder of learning (ladder.js, ?part=ladder) ───────────────────── */
.tabs.rungs { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 3px; border-bottom: 0; margin-bottom: 6px; }
.tabs.rungs button { margin: 0; padding: 8px 0; min-height: 40px; font-family: var(--mono); font-size: 12px; text-align: center;
  border: 1px solid var(--rule); border-radius: 3px; }
.tabs.rungs button[aria-selected="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.rung-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 12px; }
.rung-name { font-family: var(--mono); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-2); margin-right: 4px; }
.inset { position: absolute; inset: 0; display: grid; place-items: center; line-height: 1.3; }
.inset[hidden] { display: none; }
.inset canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
.inset-label { position: absolute; left: 10px; bottom: 8px; font-family: var(--mono); font-size: 11px; color: #e9e7e1;
  background: rgba(0,0,0,.55); padding: 3px 8px; border-radius: 3px; max-width: calc(100% - 20px); }
.slider { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin: 8px 0;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.slider input { width: 100%; accent-color: var(--ink); min-height: 32px; }
.slider b { color: var(--ink); font-weight: 500; min-width: 3em; text-align: right; }
.rule-case { border-left: 3px solid var(--rule); padding: 6px 10px; margin: 8px 0; font-size: 14.5px; }
.rule-case.caught { border-color: var(--ok); }
.rule-case.missed { border-color: var(--bad); }
.rule-case .was { color: var(--ink-2); font-style: italic; margin: 2px 0 4px; }
.feed-list { list-style: none; margin: 8px 0; padding: 0; border-top: 1px solid var(--rule); }
.feed-list li { padding: 9px 4px; border-bottom: 1px solid var(--rule); cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.feed-list li:hover { background: color-mix(in srgb, var(--paper) 90%, var(--ink)); }
.feed-list .c { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); min-width: 92px; text-transform: uppercase; letter-spacing: .05em; }
.law-notes { margin: 6px 0 10px; padding-left: 18px; font-size: 14.5px; color: var(--ink-2); }
.law-notes li { margin-bottom: 4px; }
.copy-text { font-size: 16px; line-height: 1.55; padding: 10px 12px; background: color-mix(in srgb, var(--paper) 92%, var(--ink)); border-radius: 4px; }
.copy-text mark { background: color-mix(in srgb, var(--model) 40%, transparent); color: inherit; border-radius: 2px; }
@media (max-width: 900px) {
  .tabs.rungs { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .tabs.rungs button { font-size: 11px; }
}

/* ── Asking the model (ask.js, ?part=ask) ───────────────────────────────── */
.mini-ladder { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 2px; margin: 4px 0 10px; }
.mini-ladder span { font-family: var(--mono); font-size: 9.5px; text-align: center; padding: 3px 0; border-radius: 2px;
  color: var(--ink-3); border: 1px solid var(--rule); }
.mini-ladder span.on { color: #111; border-color: transparent; font-weight: 500; }
.ask-steps { list-style: none; margin: 0 0 10px; padding: 0; }
.ask-steps li { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.ask-steps li.new { animation: ask-in 400ms ease; }
.ask-steps .src { justify-self: start; font-family: var(--mono); font-size: 11px; padding: 2px 8px; border: 1.5px solid; border-radius: 999px; }
.ask-steps .t { font-size: 16px; }
.ask-steps .m { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.ask-answer { border-left: 3px solid var(--ink); padding: 8px 12px; margin: 6px 0 10px;
  background: color-mix(in srgb, var(--paper) 92%, var(--ink)); animation: ask-in 500ms ease; }
.ask-answer p { font-size: 17px; margin: 4px 0; }
.ask-answer .cannot { font-size: 14.5px; color: var(--ink-2); font-style: italic; }
@keyframes ask-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ask-steps li.new, .ask-answer { animation: none; } }

/* ── What it understood (mind.js, ?part=mind): black and white only ──────── */
.mind-canvas { cursor: grab; touch-action: none; }
.mind-canvas:active { cursor: grabbing; }
.mind-ex { list-style: none; margin: 4px 0 12px; padding: 0; font-size: 15px; }
.mind-ex li { padding: 5px 0; border-bottom: 1px solid var(--rule); }
.mind-ex b { font-family: var(--mono); font-size: 12.5px; font-weight: 500; }
.mind-sel { border-left: 2px solid var(--ink); padding: 6px 12px; margin: 8px 0; }
.mind-sel .n { font-size: 17px; margin: 2px 0 6px; }

/* The nav is hidden on the ask and mind embeds; display:flex above would override [hidden]. */
.tabs[hidden] { display: none; }

/* ── When it emerged (emerge.js, ?part=emerge) ───────────────────────────── */
.emerge-snaps { list-style: none; margin: 4px 0 12px; padding: 0; }
.emerge-snaps li { display: grid; gap: 2px; padding: 7px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.emerge-snaps b { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--ink-2); }
.emerge-snaps code { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); word-break: break-all; }

/* Try the toy Llama, and take it home to Ollama (emerge.js). */
.emerge-try, .emerge-home { border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 12px; }
.emerge-try-row { display: flex; gap: 8px; margin: 6px 0; }
.emerge-try-row input { flex: 1; min-width: 0; font: inherit; font-family: var(--mono); font-size: 14px; padding: 8px 10px;
  background: transparent; color: var(--ink); border: 1px solid var(--rule); border-radius: 4px; }
.emerge-out { font-family: var(--mono); font-size: 14px; line-height: 1.55; min-height: 1.5em; margin: 6px 0; }
.emerge-out b { font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.emerge-cmd { font-family: var(--mono); font-size: 12.5px; background: color-mix(in srgb, var(--paper) 90%, var(--ink));
  padding: 10px 12px; border-radius: 4px; white-space: pre-wrap; margin: 6px 0; }

/* Make it yours: fine-tune on the reader's own inputs (emerge.js, mine.js). */
.emerge-mine { border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 12px; }
.emerge-mine-list { margin: 4px 0 8px; padding-left: 18px; font-size: 15px; }
.emerge-compare { margin: 8px 0; padding: 8px 12px; background: color-mix(in srgb, var(--paper) 92%, var(--ink)); border-radius: 4px; }
.emerge-compare .emerge-out { margin: 4px 0; }

.emerge-inspector { margin-top: 12px; }
a.btn { display: inline-block; text-decoration: none; }

/* Mobile: a real tap area for 'back to your country'. */
.place-back { padding: 8px 2px; }

/* What the reader accomplished: four tiles, then theirs next to a frontier model. */
.emerge-stats { border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 12px; }
.stat-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 8px 0 10px; }
.stat-tile { border: 1px solid var(--rule); padding: 10px; display: grid; gap: 4px; align-content: start; }
.stat-tile b { font-family: var(--mono); font-size: 17px; font-weight: 500; overflow-wrap: anywhere; }
.stat-tile span { font-size: 13px; color: var(--ink-2); }
.stat-vs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.6fr); margin: 6px 0 10px; font-size: 14px; }
.stat-vs > div { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--rule); }
.stat-vs .h { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.stat-vs .l { color: var(--ink-2); }
.stat-vs .a { font-family: var(--mono); font-size: 13px; }
@media (max-width: 600px) {
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-vs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stat-vs .h:first-child { display: none; }
  .stat-vs .l { grid-column: 1 / -1; border-bottom: 0; padding-bottom: 0; font-weight: 500; color: var(--ink); }
}
