/* Off-chain Bitcoin — shared styles
   Colour carries meaning in every figure:
     chain   (amber) — something that is, or can be, on the blockchain
     off     (blue)  — signed but unbroadcast transactions held off chain
     secret  (plum)  — private key material
     trust   (red)   — a trust assumption or a loss
     ok      (green) — a check that passed / a safe outcome
*/

:root {
  --bg: #f5f6f3;
  --bg-2: #eceeea;
  --bg-3: #e1e4df;
  --surface: #ffffff;
  --ink: #18202b;
  --ink-2: #46505e;
  --ink-3: #5f6875;
  --rule: #cdd2d8;
  --rule-soft: #e0e3e7;
  --rule-strong: #a9b0ba;

  --chain: #b86a00;
  --chain-ink: #8f5200;
  --chain-bg: #fbecd6;
  --off: #2c5aa0;
  --off-bg: #e3ebf7;
  --secret: #a3326a;
  --secret-bg: #f6e1ec;
  --trust: #b42318;
  --trust-bg: #fbe4e1;
  --ok: #23704a;
  --ok-bg: #dcefe3;

  /* text on solid ink-coloured buttons */
  --on-ink: #ffffff;
  --ink-hover: #2d3a4b;
  --shadow: rgba(24, 32, 43, 0.25);

  /* the four people who appear in the figures */
  --p-alice: #2563a8;
  --p-bob: #0e7c66;
  --p-carol: #a2275f;
  --p-dave: #6d3fc0;

  --serif: "Literata", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 40rem;
  --wide: 66rem;
  --gutter: 20px;
  color-scheme: light;
}

/* Dark theme: follows the system unless the reader picks one (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { 
    --bg: #121519;
    --bg-2: #1a1e24;
    --bg-3: #242a32;
    --surface: #181c22;
    --ink: #e5e8ec;
    --ink-2: #b9c0c9;
    --ink-3: #939ca8;
    --rule: #343b45;
    --rule-soft: #262c34;
    --rule-strong: #4d5662;
    --chain: #e0a347;
    --chain-ink: #f2bf6c;
    --chain-bg: #33270f;
    --off: #84aef0;
    --off-bg: #172338;
    --secret: #e88cba;
    --secret-bg: #351927;
    --trust: #f5867a;
    --trust-bg: #3a1916;
    --ok: #74d09e;
    --ok-bg: #132b1d;
    --on-ink: #121519;
    --ink-hover: #c7ccd3;
    --shadow: rgba(0, 0, 0, 0.5);
    --p-alice: #4f86d4;
    --p-bob: #2c9c7f;
    --p-carol: #c4558f;
    --p-dave: #8c6fe0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] { 
    --bg: #121519;
    --bg-2: #1a1e24;
    --bg-3: #242a32;
    --surface: #181c22;
    --ink: #e5e8ec;
    --ink-2: #b9c0c9;
    --ink-3: #939ca8;
    --rule: #343b45;
    --rule-soft: #262c34;
    --rule-strong: #4d5662;
    --chain: #e0a347;
    --chain-ink: #f2bf6c;
    --chain-bg: #33270f;
    --off: #84aef0;
    --off-bg: #172338;
    --secret: #e88cba;
    --secret-bg: #351927;
    --trust: #f5867a;
    --trust-bg: #3a1916;
    --ok: #74d09e;
    --ok-bg: #132b1d;
    --on-ink: #121519;
    --ink-hover: #c7ccd3;
    --shadow: rgba(0, 0, 0, 0.5);
    --p-alice: #4f86d4;
    --p-bob: #2c9c7f;
    --p-carol: #c4558f;
    --p-dave: #8c6fe0;
    color-scheme: dark;
  }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.62;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; }

a { color: var(--off); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }

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

::selection { background: var(--off-bg); }

h1, h2, h3, h4 { font-family: var(--serif); color: var(--ink); margin: 0; }

h1 {
  font-size: clamp(2.05rem, 1.2rem + 3.6vw, 3.3rem);
  line-height: 1.06;
  font-weight: 650;
  letter-spacing: -0.022em;
  font-variation-settings: "opsz" 72;
  max-width: 18ch;
}

h2 {
  font-size: 1.62rem;
  line-height: 1.2;
  font-weight: 620;
  letter-spacing: -0.012em;
  font-variation-settings: "opsz" 48;
  margin: 3.2rem 0 0.9rem;
}

h3 {
  font-size: 1.18rem;
  line-height: 1.3;
  font-weight: 620;
  margin: 2rem 0 0.5rem;
}

p { margin: 0 0 1.05em; }

code, .mono, kbd {
  font-family: var(--mono);
  font-size: 0.84em;
}

p code, li code, td code {
  background: var(--bg-2);
  border-radius: 3px;
  padding: 0.08em 0.3em;
  white-space: nowrap;
}

sup.cite { font-size: 0.66em; line-height: 0; margin-left: 0.08em; font-family: var(--mono); }
sup.cite a { text-decoration: none; color: var(--off); }
sup.cite a:hover { text-decoration: underline; }

/* ---------- Header ---------- */

.site-head {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.site-head .inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 14px var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 28px;
}
.wordmark {
  font-weight: 680;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark:hover { color: var(--ink); }
.wordmark span { color: var(--chain); }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 0.95rem; }
.site-nav a { color: var(--ink-2); text-decoration: none; padding: 2px 0; }
.site-nav a:hover { color: var(--ink); text-decoration: underline; }
.site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; text-decoration-color: var(--chain); }

/* ---------- Page frame ---------- */

main { display: block; }

.frame {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.prose { max-width: var(--measure); }
.prose > ul, .prose > ol { padding-left: 1.25em; margin: 0 0 1.1em; }
.prose li { margin: 0.3em 0; }

.chapter-head { padding: 3.4rem 0 1.6rem; }
.chapter-head .series { font-size: 0.95rem; color: var(--ink-3); margin: 0 0 1rem; }
.chapter-head .answer {
  font-size: 1.22rem;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 36rem;
  margin: 1.2rem 0 0;
}

/* Facts table under each chapter title */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr));
  gap: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0 0;
}
.facts div { padding: 0.85rem 1.2rem 0.95rem 0; border-bottom: 1px solid var(--rule-soft); }
.facts dt { font-size: 0.86rem; color: var(--ink-3); margin: 0 0 0.2rem; }
.facts dd { margin: 0; font-size: 0.98rem; line-height: 1.45; }

.toc {
  margin: 2.2rem 0 0;
  font-size: 0.98rem;
}
.toc p { margin: 0 0 0.4rem; color: var(--ink-3); font-size: 0.9rem; }
.toc ol { margin: 0; padding-left: 1.3em; }
.toc li { break-inside: avoid; margin: 0.15rem 0; }

/* ---------- Figures ---------- */

figure.fig {
  margin: 2.2rem 0 2.6rem;
  max-width: var(--wide);
}
figure.fig .panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 18px;
}
figure.fig.bare .panel { background: transparent; border: 0; padding: 0; }
figure.fig svg { display: block; width: 100%; height: auto; }
figcaption {
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--ink-2);
  max-width: var(--measure);
  margin-top: 0.75rem;
}
figcaption b { color: var(--ink); font-weight: 620; }
.fig-num { font-weight: 650; color: var(--ink); margin-right: 0.35em; }

/* SVG vocabulary (figures share these classes) */
.s-text { font-family: var(--serif); font-size: 14px; fill: var(--ink); }
.s-small { font-family: var(--serif); font-size: 12.5px; fill: var(--ink-2); }
.s-mono { font-family: var(--mono); font-size: 12px; fill: var(--ink); }
.s-mono-sm { font-family: var(--mono); font-size: 11px; fill: var(--ink-2); }
.s-strong { font-weight: 650; }
.s-chain-line { stroke: var(--chain); stroke-width: 2; }
.s-chain-box { fill: var(--chain-bg); stroke: var(--chain); stroke-width: 1.6; }
.s-chain-text { fill: var(--chain-ink); }
.s-off-box { fill: var(--off-bg); stroke: var(--off); stroke-width: 1.4; stroke-dasharray: 5 3; }
.s-off-solid { fill: var(--off-bg); stroke: var(--off); stroke-width: 1.4; }
.s-off-text { fill: var(--off); }
.s-off-line { stroke: var(--off); stroke-width: 1.4; stroke-dasharray: 5 3; fill: none; }
.s-secret-box { fill: var(--secret-bg); stroke: var(--secret); stroke-width: 1.4; }
.s-secret-text { fill: var(--secret); }
.s-trust-box { fill: var(--trust-bg); stroke: var(--trust); stroke-width: 1.4; }
.s-trust-text { fill: var(--trust); }
.s-ok-box { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 1.4; }
.s-ok-text { fill: var(--ok); }
.s-node { fill: var(--surface); stroke: var(--rule-strong); stroke-width: 1.2; }
.s-line { stroke: var(--ink-2); stroke-width: 1.3; fill: none; }
.s-line-soft { stroke: var(--rule-strong); stroke-width: 1.1; fill: none; }
.s-muted { fill: var(--ink-3); }

/* Legend for colour meanings */
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.86rem; color: var(--ink-2); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 13px; height: 13px; border-radius: 3px; border: 1.5px solid; }
.legend .k-chain { background: var(--chain-bg); border-color: var(--chain); }
.legend .k-off { background: var(--off-bg); border-color: var(--off); border-style: dashed; }
.legend .k-secret { background: var(--secret-bg); border-color: var(--secret); }
.legend .k-trust { background: var(--trust-bg); border-color: var(--trust); }
.legend .k-ok { background: var(--ok-bg); border-color: var(--ok); }

/* ---------- Math ---------- */

.math {
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.7;
  background: var(--surface);
  border: 1px solid var(--rule-soft);
  border-left: 3px solid var(--rule-strong);
  border-radius: 4px;
  padding: 12px 16px;
  margin: 0.4rem 0 1.4rem;
  white-space: pre;
  overflow-x: auto;
  max-width: var(--measure);
}

/* ---------- Asides ---------- */

.note {
  max-width: var(--measure);
  border-left: 3px solid var(--off);
  background: var(--off-bg);
  padding: 0.9rem 1.1rem;
  border-radius: 0 4px 4px 0;
  margin: 1.6rem 0;
  font-size: 0.98rem;
}
.note.trust { border-color: var(--trust); background: var(--trust-bg); }
.note p:last-child { margin-bottom: 0; }
.note h3 { margin: 0 0 0.35rem; font-size: 1.02rem; }

.stops {
  max-width: var(--measure);
  border-top: 1px solid var(--rule);
  margin: 3rem 0 0;
  padding-top: 1.2rem;
  font-size: 0.98rem;
}
.stops h2 { margin-top: 0; font-size: 1.25rem; }
.stops ul { padding-left: 1.2em; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin: 1.6rem 0 2rem; max-width: var(--wide); }
table.data { border-collapse: collapse; width: 100%; font-size: 0.93rem; line-height: 1.45; min-width: 640px; }
table.data th, table.data td { text-align: left; vertical-align: top; padding: 0.6rem 0.9rem 0.6rem 0; border-bottom: 1px solid var(--rule-soft); }
table.data thead th { font-weight: 650; border-bottom: 1.5px solid var(--rule-strong); font-size: 0.9rem; }
table.data tbody th { font-weight: 620; min-width: 9rem; }
table.data td.num { font-family: var(--mono); font-size: 0.84rem; }

/* ---------- Sources ---------- */

.sources {
  max-width: var(--measure);
  border-top: 1px solid var(--rule);
  margin: 3rem 0 0;
  padding-top: 1.2rem;
}
.sources h2 { margin-top: 0; font-size: 1.25rem; }
.sources ol { padding-left: 1.6em; font-size: 0.92rem; line-height: 1.5; }
.sources li { margin: 0.45rem 0; }
.sources li:target { background: var(--chain-bg); }
.sources .checked { font-size: 0.9rem; color: var(--ink-3); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--rule);
  margin: 3rem 0 0;
  padding: 1.2rem 0 0;
  font-size: 0.98rem;
}
.pager a { text-decoration: none; }
.pager a span { display: block; font-size: 0.85rem; color: var(--ink-3); }
.pager a:hover strong { text-decoration: underline; }
.pager .next { text-align: right; margin-left: auto; }

.site-foot {
  margin: 4rem 0 0;
  border-top: 1px solid var(--rule);
  padding: 1.4rem 0 3rem;
  font-size: 0.88rem;
  color: var(--ink-3);
}

/* ---------- Controls ---------- */

.btn {
  font-family: var(--serif);
  font-size: 0.92rem;
  line-height: 1.2;
  padding: 0.5rem 0.85rem;
  border-radius: 4px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--ink-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover:not(:disabled) { background: var(--ink-hover); }
.btn.danger { border-color: var(--trust); color: var(--trust); }
.btn.danger:hover:not(:disabled) { background: var(--trust-bg); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 0.92rem; }
.check input { accent-color: var(--off); }

/* ---------- Home ---------- */

.home-hero { padding: 3.6rem 0 1.4rem; }
.home-hero h1 { max-width: 20ch; }
.home-hero .answer { font-size: 1.2rem; line-height: 1.6; color: var(--ink-2); max-width: 38rem; margin: 1.3rem 0 0; }

.chapters { list-style: none; padding: 0; margin: 1.4rem 0 0; max-width: var(--wide); border-top: 1px solid var(--rule); }
.chapters li { border-bottom: 1px solid var(--rule-soft); }
.chapters a {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 4px 24px;
  padding: 1rem 0;
  text-decoration: none;
  color: var(--ink);
}
.chapters .topic { color: var(--ink-3); font-size: 0.95rem; padding-top: 0.2rem; }
.chapters .q { font-size: 1.3rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.chapters .d { grid-column: 2; font-size: 0.98rem; color: var(--ink-2); }
.chapters a:hover .q { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.16em; }

/* ---------- Ark sandbox ---------- */

.ark-sim { border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); overflow: hidden; font-family: var(--serif); }
.ark-sim .ark-sub { font-size: 0.82rem; font-weight: 600; color: var(--ink-3); margin: 14px 0 7px; }
.ark-sim .ark-sub:first-child { margin-top: 0; }
.ark-tour { background: var(--bg-2); border-bottom: 1px solid var(--rule); padding: 14px 16px; }
.ark-tour-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ark-tour-tag { font-size: 0.86rem; font-weight: 650; color: var(--ink); }
.ark-status { margin-left: auto; font-family: var(--mono); font-size: 0.72rem; color: var(--ink-3); }
.ark-tour-body { font-size: 0.97rem; line-height: 1.55; color: var(--ink); min-height: 46px; }
.ark-tour-body b { font-weight: 650; }
.ark-term { color: var(--off); border-bottom: 1px dotted var(--off); cursor: help; }
.ark-tour-nav { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.ark-tour-count { margin-left: auto; font-family: var(--mono); font-size: 0.72rem; color: var(--ink-3); }
.ark-btn { font-family: var(--serif); font-size: 0.84rem; line-height: 1.2; border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); padding: 6px 11px; border-radius: 4px; cursor: pointer; }
.ark-btn:hover:not(:disabled) { border-color: var(--ink-2); }
.ark-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ark-btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.ark-btn.primary:hover:not(:disabled) { background: var(--ink-hover); }
.ark-btn.ghost { background: transparent; border-style: dashed; color: var(--ink-2); }
.ark-btn.xs { font-size: 0.76rem; padding: 4px 8px; }
.ark-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.ark-controls { padding: 16px; border-right: 1px solid var(--rule); background: var(--bg); }
.ark-op { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.ark-users { display: flex; flex-direction: column; gap: 8px; }
.ark-user { position: relative; border: 1px solid var(--rule-soft); border-radius: 5px; padding: 8px 9px 8px 12px; background: var(--surface); }
.ark-user::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--uc); border-radius: 5px 0 0 5px; }
.ark-uhead { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.ark-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.ark-uname { font-weight: 650; font-size: 0.9rem; }
.ark-bal { margin-left: auto; text-align: right; font-family: var(--mono); font-size: 0.68rem; line-height: 1.4; }
.ark-lbl { color: var(--ink-3); }
.ark-chain { color: var(--chain-ink); }
.ark-inark { color: var(--off); }
.ark-exn { color: var(--trust); }
.ark-uacts { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.ark-sel { font-family: var(--serif); font-size: 0.76rem; background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 4px; padding: 4px 5px; cursor: pointer; color: var(--ink); }
.ark-meter { height: 9px; border-radius: 5px; background: var(--bg-3); overflow: hidden; border: 1px solid var(--rule); margin-bottom: 7px; }
.ark-meter-fill { height: 100%; background: var(--chain); transition: width .35s; }
.ark-arow { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.7rem; color: var(--ink-2); margin: 2px 0; }
.ark-arow b { color: var(--ink); }
.ark-arow b.ark-amber { color: var(--chain-ink); }
.ark-arow b.ark-moss { color: var(--ok); }
.ark-note { font-size: 0.76rem; color: var(--ink-3); margin-top: 7px; line-height: 1.4; }
.ark-toggles { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 0.8rem; color: var(--ink-2); }
.ark-toggles label { display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }
.ark-toggles input { accent-color: var(--off); }
.ark-stage { padding: 16px; min-width: 0; }
.ark-lane { margin-bottom: 16px; }
.ark-lhead { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-bottom: 8px; font-size: 0.84rem; font-weight: 650; color: var(--ink-2); }
.ark-pill { font-family: var(--mono); font-weight: 400; font-size: 0.66rem; color: var(--ink-2); background: var(--bg-2); border: 1px solid var(--rule-soft); border-radius: 20px; padding: 1px 9px; }
.ark-chainstrip { display: flex; gap: 6px; flex-wrap: wrap; align-items: stretch; }
.ark-block { min-width: 80px; border: 1px solid var(--rule-soft); border-radius: 4px; background: var(--surface); padding: 5px 7px; font-family: var(--mono); }
.ark-bh { font-size: 0.66rem; font-weight: 500; color: var(--ink-3); }
.ark-bt { font-size: 0.63rem; color: var(--ink-2); margin-top: 2px; line-height: 1.3; }
.ark-block.round { border-color: var(--chain); background: var(--chain-bg); }
.ark-block.round .ark-bh { color: var(--chain-ink); }
.ark-block.exit { border-color: var(--trust); background: var(--trust-bg); }
.ark-block.exit .ark-bh { color: var(--trust); }
.ark-block.board .ark-bh { color: var(--chain-ink); }
.ark-treebox { border: 1px solid var(--rule-soft); border-radius: 5px; background: var(--bg); padding: 8px; margin-bottom: 8px; }
.ark-treebox svg { display: block; }
.ark-sim svg text { font-family: var(--mono); }
.ark-views { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 14px; align-items: start; margin-bottom: 16px; }
.ark-view { border: 1px solid var(--rule-soft); border-radius: 5px; background: var(--surface); padding: 10px; min-width: 0; }
.ark-vhead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 0.84rem; font-weight: 650; color: var(--ink-2); }
.ark-vhead .ark-pill { margin-left: auto; }
.ark-subhead { font-size: 0.78rem; font-weight: 600; color: var(--ink-3); margin: 10px 0 6px; }
.ark-txwrap { overflow-x: auto; overflow-y: hidden; }
.ark-txwrap svg { display: block; max-width: none; }
.ark-txhint { font-size: 0.74rem; color: var(--ink-3); margin-top: 4px; }
.ark-empty { color: var(--ink-3); font-size: 0.84rem; padding: 16px; text-align: center; border: 1px dashed var(--rule); border-radius: 5px; }
.ark-cxnote { font-size: 0.82rem; line-height: 1.5; color: var(--ink-2); margin-top: 8px; }
.ark-cxnote b { color: var(--ink); font-weight: 650; }
.ark-cheatrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.ark-btn.cheat { background: var(--trust-bg); border-color: var(--trust); color: var(--trust); font-weight: 600; }
.ark-btn.cheat:hover:not(:disabled) { background: var(--trust); color: var(--on-ink); }
.ark-cheathint { font-size: 0.78rem; color: var(--ink-3); }
.ark-cheatdone { font-size: 0.82rem; line-height: 1.45; color: var(--trust); }
.ark-mech { border: 1px solid var(--rule); border-left: 3px solid var(--off); border-radius: 5px; background: var(--off-bg); padding: 11px 13px; margin-top: 4px; }
.ark-mech.warn { border-left-color: var(--trust); background: var(--trust-bg); }
.ark-mtitle { font-weight: 650; font-size: 0.86rem; color: var(--off); margin-bottom: 5px; }
.ark-mech.warn .ark-mtitle { color: var(--trust); }
.ark-mtxt { font-size: 0.88rem; line-height: 1.5; color: var(--ink-2); }
.ark-mtxt b { color: var(--ink); font-weight: 650; }
.ark-legend { display: flex; flex-wrap: wrap; gap: 7px 14px; font-size: 0.76rem; color: var(--ink-2); margin-top: 12px; }
.ark-li { display: flex; align-items: center; gap: 5px; }
.ark-sw { width: 11px; height: 11px; border-radius: 3px; border: 1.4px solid var(--rule); flex: 0 0 auto; }
.ark-li b.ark-moss { color: var(--ok); }
.ark-li b.ark-amber { color: var(--chain-ink); }
.ark-logwrap { border-top: 1px solid var(--rule); padding: 12px 16px; background: var(--bg); }
.ark-log { max-height: 150px; overflow-y: auto; }
.ark-loge { font-family: var(--mono); font-size: 0.72rem; padding: 4px 0; border-bottom: 1px solid var(--rule-soft); color: var(--ink-2); display: flex; gap: 8px; }
.ark-loge:last-child { border-bottom: 0; }
.ark-loge.you { color: var(--ink); }
.ark-logh { color: var(--chain-ink); flex: 0 0 auto; }
.ark-sim-tip { position: fixed; z-index: 60; pointer-events: none; opacity: 0; transition: opacity .1s; max-width: 270px; background: var(--ink); color: var(--on-ink); font-family: var(--serif); font-size: 0.8rem; line-height: 1.4; padding: 8px 10px; border-radius: 5px; box-shadow: 0 6px 22px var(--shadow); }

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .ark-views { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .ark-grid { grid-template-columns: 1fr; }
  .ark-controls { border-right: 0; border-bottom: 1px solid var(--rule); }
}
@media (max-width: 640px) {
  body { font-size: 17px; }
  :root { --gutter: 16px; }
  .chapter-head { padding-top: 2.2rem; }
  .chapters a { grid-template-columns: 1fr; }
  .chapters .d { grid-column: 1; }
  figure.fig .panel { padding: 12px; }
  h2 { font-size: 1.42rem; margin-top: 2.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

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

/* Wide drawings scroll sideways on narrow screens instead of shrinking to illegibility */
.panel.scroll { overflow-x: auto; }
@media (max-width: 640px) {
  .panel.scroll > svg { min-width: 620px; }
}

/* ---------- Step-by-step scenes ---------- */

.scene {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 20px 22px 16px;
}
.scene:focus-within { border-color: var(--rule-strong); }
.scene-cap { max-width: 46rem; }
.scene-count { margin: 0 0 0.2rem; font-size: 0.86rem; color: var(--ink-3); }
.scene-title { font-size: 1.28rem; line-height: 1.3; font-weight: 640; margin: 0 0 0.4rem; }
.scene-text { margin: 0; font-size: 1.02rem; line-height: 1.55; color: var(--ink-2); }
.scene-text b { color: var(--ink); font-weight: 640; }
.scene-body { margin-top: 14px; }
.scene-body.with-side { display: grid; grid-template-columns: minmax(0, 1fr) 15.5rem; gap: 18px; align-items: start; }
.scene-canvas { overflow-x: auto; }
.scene-canvas svg { display: block; width: 100%; height: auto; }
.scene-side { font-size: 0.92rem; }
.scene-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule-soft); }
.scene-dots { display: flex; gap: 6px; align-items: center; }
.scene-dots .dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--rule-strong); background: var(--surface); padding: 0; cursor: pointer; }
.scene-dots .dot.past { background: var(--rule); }
.scene-dots .dot.on { background: var(--ink); border-color: var(--ink); }

/* knowledge table in scene side panels */
.knows { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.knows th, .knows td { padding: 5px 4px; border-bottom: 1px solid var(--rule-soft); text-align: left; vertical-align: top; }
.knows thead th { font-weight: 650; font-size: 0.82rem; color: var(--ink-2); }
.knows td.y, .knows td.n { text-align: center; width: 3.2rem; font-weight: 650; }
.knows td.y { color: var(--ok); }
.knows td.n { color: var(--ink-3); }
.knows tr.new td, .knows tr.new th { background: var(--chain-bg); }
.side-note { margin: 10px 0 0; font-size: 0.86rem; line-height: 1.45; color: var(--ink-2); }
.side-note b { color: var(--ink); }

/* SVG kit */
.tx { font-family: var(--serif); fill: var(--ink); }
.tx-s { font-size: 13.5px; }
.tx-m { font-size: 15.5px; }
.tx-l { font-size: 19px; }
.tx-b { font-weight: 650; }
.tx-i { font-style: italic; }
.tx-mono { font-family: var(--mono); font-size: 12.5px; }
.c-ink { fill: var(--ink); } .c-muted { fill: var(--ink-3); } .c-chain { fill: var(--chain-ink); }
.c-off { fill: var(--off); } .c-secret { fill: var(--secret); } .c-trust { fill: var(--trust); } .c-ok { fill: var(--ok); }
.bx { stroke-width: 1.5; }
.bx-node { fill: var(--surface); stroke: var(--rule-strong); }
.bx-plain { fill: var(--bg); stroke: var(--rule-soft); }
.bx-chain { fill: var(--chain-bg); stroke: var(--chain); stroke-width: 1.8; }
.bx-off { fill: var(--off-bg); stroke: var(--off); stroke-dasharray: 6 4; }
.bx-offsolid { fill: var(--off-bg); stroke: var(--off); }
.bx-secret { fill: var(--secret-bg); stroke: var(--secret); }
.bx-trust { fill: var(--trust-bg); stroke: var(--trust); }
.bx-ok { fill: var(--ok-bg); stroke: var(--ok); }
.bx-ghost { fill: var(--bg); stroke: var(--rule); stroke-dasharray: 4 4; }
.ln { fill: none; stroke-width: 1.6; }
.ln-thick { stroke-width: 2.6; }
.ln-dash { stroke-dasharray: 6 4; }
.ln-ink { stroke: var(--ink-2); } .ln-muted { stroke: var(--rule-strong); } .ln-chain { stroke: var(--chain); }
.ln-off { stroke: var(--off); } .ln-secret { stroke: var(--secret); } .ln-trust { stroke: var(--trust); } .ln-ok { stroke: var(--ok); }
.mk-ink { fill: var(--ink-2); } .mk-muted { fill: var(--rule-strong); } .mk-chain { fill: var(--chain); }
.mk-off { fill: var(--off); } .mk-secret { fill: var(--secret); } .mk-trust { fill: var(--trust); } .mk-ok { fill: var(--ok); }
.key-bow { fill: none; stroke-width: 2.2; }
.key-bit { fill: none; stroke-width: 2.2; stroke-linecap: round; }
.key-secret .key-bow, .key-secret .key-bit { stroke: var(--secret); }
.key-ok .key-bow, .key-ok .key-bit { stroke: var(--ok); }
.key-off .key-bow, .key-off .key-bit { stroke: var(--off); }
.key-muted .key-bow, .key-muted .key-bit { stroke: var(--rule-strong); }
.lock-shackle { fill: none; stroke: var(--chain-ink); stroke-width: 2.2; }
.lock-body { fill: var(--chain); }
.person-ini { fill: #fff; }
.dim { opacity: 0.35; }
.hi .bx, .bx.hi { stroke-width: 2.6; }

.enter { animation: scene-enter 0.5s ease-out both; }
.no-anim .enter { animation: none; }
@keyframes scene-enter { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 1100px) {
  .scene-body.with-side { grid-template-columns: minmax(0, 1fr); }
  .scene-side { max-width: 34rem; }
}
@media (max-width: 640px) {
  .scene { padding: 14px 12px 12px; }
}

/* segmented control, verdicts, sliders */
.segs { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule-strong); border-radius: 6px; overflow: hidden; }
.seg { font-family: var(--serif); font-size: 0.92rem; padding: 0.45rem 0.8rem; background: var(--surface); border: 0; border-right: 1px solid var(--rule-soft); cursor: pointer; color: var(--ink-2); }
.seg:last-child { border-right: 0; }
.seg.on { background: var(--ink); color: var(--on-ink); }
.race-controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 14px; }
.verdict { border-radius: 6px; padding: 0.75rem 1rem; margin: 0 0 12px; font-size: 1rem; line-height: 1.5; border-left: 4px solid; box-sizing: border-box; }
.verdict b { font-weight: 650; }
.v-ok { background: var(--ok-bg); border-color: var(--ok); }
.v-wait { background: var(--bg-2); border-color: var(--rule-strong); }
.v-trust { background: var(--trust-bg); border-color: var(--trust); }
.day-label { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 0.95rem; color: var(--ink-2); }
.day-range { flex: 1; max-width: 640px; accent-color: var(--chain); }
.panel.interactive { padding: 20px 22px; }
@media (max-width: 640px) { .panel.interactive { padding: 14px 12px; } }

/* "The precise version": optional detail, closed by default */
details.precise { margin: 2.6rem 0 0; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); padding: 0 1.1rem; }
details.precise > summary { cursor: pointer; padding: 0.85rem 0; font-weight: 640; font-size: 1.08rem; list-style-position: outside; }
details.precise[open] { padding-bottom: 0.6rem; }
details.precise[open] > summary { border-bottom: 1px solid var(--rule-soft); margin-bottom: 0.9rem; }
details.precise p, details.precise li { font-size: 0.98rem; }

/* Spark payment figure: leaves as banknotes */
.wallet { border: 1px solid var(--rule-soft); border-radius: 6px; padding: 12px 14px; background: var(--bg); }
.wallet-h { margin: 0 0 8px; font-size: 0.95rem; }
.wallet-sum { color: var(--ink-2); }
.bills { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; align-items: center; }
.bill { display: inline-flex; align-items: center; justify-content: center; height: 1.8rem; padding: 0 8px; border-radius: 4px; border: 1.5px solid var(--off); background: var(--off-bg); color: var(--off); font-family: var(--mono); font-size: 0.8rem; font-weight: 500; }
.bill.small { border-color: var(--trust); }
.bill.pick { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.bill.swap-out { background: var(--bg-2); border: 1.5px dashed var(--rule-strong); color: var(--ink-3); }
.bill.swap-in { background: var(--chain-bg); border-color: var(--chain); color: var(--chain-ink); }
.pay-controls { margin-top: 14px; }
.pay-presets { margin-top: 8px; }
.muted-label { color: var(--ink-3); font-size: 0.92rem; }
.pay-steps { margin: 14px 0 0; padding-left: 1.4em; }
.pay-steps li { margin: 0 0 10px; }
.pay-steps p { margin: 0; font-size: 0.98rem; }
.amount-input { font-family: var(--mono); font-size: 0.95rem; padding: 0.45rem 0.6rem; border: 1px solid var(--rule-strong); border-radius: 4px; width: 10rem; background: var(--surface); color: var(--ink); }

/* Ark sandbox, behind a disclosure */
details.sandbox-wrap { margin: 1.2rem 0 2rem; max-width: var(--wide); }
details.sandbox-wrap > summary { cursor: pointer; display: inline-block; font-weight: 640; padding: 0.55rem 0.95rem; border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--surface); margin-bottom: 12px; }
details.sandbox-wrap[open] > summary { background: var(--bg-2); }
.sandbox-note { font-size: 0.9rem; color: var(--ink-2); max-width: var(--measure); margin-top: 10px; }

.scroll-hint { display: none; margin: 6px 0 0; font-size: 0.84rem; color: var(--ink-3); font-style: italic; }

.scene-bar .btn.primary { min-width: 7.2rem; }

/* exit-cost calculator */
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 12px 24px; margin-bottom: 12px; }
.calc-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 0.95rem; color: var(--ink-2); }
.calc-grid input[type=range] { accent-color: var(--chain); }
p.note { padding: 0.8rem 1.1rem; }

details.precise code, .sources code { white-space: normal; overflow-wrap: anywhere; }
.sources a { overflow-wrap: anywhere; }
.scene-body > div { min-width: 0; }

/* theme switch in the header */
.theme-switch { margin-left: auto; font-family: var(--serif); font-size: 0.88rem; color: var(--ink-2); background: transparent; border: 1px solid var(--rule); border-radius: 999px; padding: 0.25rem 0.75rem; cursor: pointer; }
.theme-switch:hover { color: var(--ink); border-color: var(--rule-strong); }
html { background: var(--bg); }
