/* Shared course stylesheet — Tufte-inspired. Every lesson & reference links this. */

:root {
  --ink: #1a1a1a;
  --paper: #fffdf8;
  --faint: #f3efe4;
  --rule: #d8d2c4;
  --accent: #b5651d;       /* bitcoin-ish burnt orange */
  --accent-soft: #f6e6d4;
  --ix: #1f6feb;           /* interactive blue — explainer affordance + panels */
  --ix-soft: #dce9fb;
  --good: #2e7d4f;
  --bad: #b3261e;
  --muted: #6b6356;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --serif: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.55;
  max-width: 720px;
  margin: 0 auto;
  padding: 4rem 1.5rem 8rem;
}

.kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

h1 { font-size: 2.1rem; line-height: 1.15; margin: 0 0 0.4rem; font-weight: 600; }
h2 { font-size: 1.35rem; margin: 2.6rem 0 0.6rem; font-weight: 600; }
h3 { font-size: 1.05rem; margin: 1.8rem 0 0.4rem; font-weight: 600; color: var(--muted); }

.subtitle { color: var(--muted); font-style: italic; font-size: 1.1rem; margin-top: 0; }

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
a:hover { border-bottom-color: var(--accent); }

hr { border: none; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

code { font-family: var(--mono); font-size: 0.82em; background: var(--faint); padding: 0.1em 0.35em; border-radius: 3px; }
pre { font-family: var(--mono); font-size: 0.8rem; line-height: 1.45; background: #2b2620; color: #f0e9dc; padding: 1rem 1.2rem; border-radius: 6px; overflow-x: auto; }
pre code { background: none; padding: 0; color: inherit; }

blockquote {
  margin: 1.4rem 0; padding: 0.4rem 0 0.4rem 1.2rem;
  border-left: 3px solid var(--accent); color: var(--muted); font-style: italic;
}

.aside {
  background: var(--faint); border: 1px solid var(--rule); border-radius: 8px;
  padding: 1rem 1.3rem; margin: 1.6rem 0; font-size: 0.92rem;
}
.aside .label { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); display: block; margin-bottom: 0.3rem; }

.takeaway {
  background: var(--accent-soft); border-radius: 8px; padding: 1.1rem 1.3rem; margin: 1.8rem 0;
}
.takeaway .label { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); display: block; margin-bottom: 0.3rem; }

/* Interactive quiz widget */
.quiz { border: 1px solid var(--rule); border-radius: 8px; padding: 1.3rem 1.4rem; margin: 1.8rem 0; background: #fff; }
.quiz .q { font-weight: 600; margin-bottom: 0.9rem; }
.quiz .opt {
  display: block; width: 100%; text-align: left; font-family: var(--serif); font-size: 0.95rem;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 6px;
  padding: 0.6rem 0.9rem; margin: 0.4rem 0; cursor: pointer; transition: all 0.12s;
}
.quiz .opt:hover { border-color: var(--accent); }
.quiz .opt.correct { background: #e3f3e8; border-color: var(--good); color: var(--good); }
.quiz .opt.wrong { background: #f9e3e1; border-color: var(--bad); color: var(--bad); }
.quiz .fb { margin-top: 0.8rem; font-size: 0.9rem; min-height: 1.2em; }
.quiz .fb.show { animation: fade 0.3s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.footer-nav { margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-size: 0.9rem; color: var(--muted); }
.footer-nav a { font-family: var(--mono); font-size: 0.82rem; }

.ask {
  font-family: var(--mono); font-size: 0.82rem; color: var(--muted);
  background: var(--faint); border-radius: 6px; padding: 0.7rem 1rem; margin-top: 2.5rem;
  border-left: 3px solid var(--accent);
}

.primary-source {
  border: 1px dashed var(--accent); border-radius: 8px; padding: 1rem 1.3rem; margin: 1.8rem 0;
}
.primary-source .label { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); display: block; margin-bottom: 0.3rem; }

table { border-collapse: collapse; width: 100%; font-size: 0.9rem; margin: 1.4rem 0; }
th, td { text-align: left; padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--rule); }
th { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ─── Explorable paper: verbatim text + interactive diagrams ─── */

/* Sticky table-of-contents (single-page paper). Floats left on wide screens. */
.paper-toc {
  position: fixed; top: 2rem; left: max(1rem, calc(50% - 620px));
  width: 190px; font-family: var(--mono); font-size: 0.74rem; line-height: 1.5;
  border-left: 2px solid var(--rule); padding-left: 0.9rem;
}
.paper-toc a { display: block; color: var(--muted); border: none; padding: 0.18rem 0; }
.paper-toc a:hover { color: var(--accent); }
.paper-toc a.active { color: var(--accent); font-weight: 600; }
.paper-toc .toc-head { color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.66rem; margin-bottom: 0.4rem; }
@media (max-width: 1180px) { .paper-toc { display: none; } }

/* "Fork on GitHub" call-to-action in the header — a badge plus a short note.
 * Not sticky; it scrolls away with the rest of the header. */
.gh-cta { display: flex; align-items: center; gap: 0.5rem 0.85rem; flex-wrap: wrap; margin: 1.1rem 0 0; }
.gh-badge {
  display: inline-flex; align-items: center; gap: 0.45rem; flex-shrink: 0;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.03em;
  color: var(--ink); background: #fff;
  border: 1px solid var(--rule); border-radius: 999px;
  padding: 0.42rem 0.8rem;
  transition: border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.gh-badge:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 1px 6px rgba(0,0,0,0.1); }
.gh-badge svg { width: 15px; height: 15px; fill: currentColor; }
.gh-note { font-size: 0.84rem; color: var(--muted); }

/* Editorial pointer to an interactive explainer, set apart from the verbatim
 * paper text. Used where an inline figure used to sit. */
.explainer-cue {
  font-size: 0.92rem; color: var(--muted);
  border-left: 3px solid var(--ix-soft); padding-left: 0.95rem;
  margin: 1.5rem 0;
}
@media print { .gh-cta { display: none; } }
.paper-section { scroll-margin-top: 1.5rem; }


.paper-body p { margin: 0 0 1.1rem; }
.paper-body .secnum { font-family: var(--mono); font-size: 0.8rem; color: var(--accent); letter-spacing: 0.05em; }
.paper-abstract { background: var(--faint); border-radius: 8px; padding: 1.2rem 1.4rem; font-size: 0.92rem; margin: 1.5rem 0 2.5rem; }
.paper-abstract .label { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); display: block; margin-bottom: 0.4rem; }

/* References list — bracketed [n] markers with a hanging indent, mapping to the
 * inline [n] citations in the body. */
.paper-refs { list-style: none; padding-left: 0; counter-reset: ref; font-size: 0.92rem; }
.paper-refs li { counter-increment: ref; padding-left: 2.4rem; text-indent: -2.4rem; margin: 0 0 0.6rem; line-height: 1.5; }
.paper-refs li::before { content: "[" counter(ref) "]\00a0"; font-family: var(--mono); color: var(--muted); }

/* Glossary hover terms */
.term {
  border-bottom: 1px dotted var(--accent); cursor: help; color: inherit;
}
.term:hover { background: var(--accent-soft); }
#tooltip {
  position: fixed; z-index: 50; max-width: 300px; pointer-events: none;
  background: #2b2620; color: #f4eee2; font-family: var(--serif); font-size: 0.82rem;
  line-height: 1.4; padding: 0.6rem 0.8rem; border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25); opacity: 0; transition: opacity 0.12s;
}
#tooltip .t-term { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); display: block; margin-bottom: 0.25rem; }
#tooltip .t-cta { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.04em; color: #8ab4f8; display: block; margin-top: 0.5rem; padding-top: 0.45rem; border-top: 1px solid rgba(255,255,255,0.14); }
#tooltip.show { opacity: 1; }

/* Keywords that also have a click-to-expand interactive explainer: render them
 * as a small tappable chip — soft fill, border, rounded, with the ⊕ inside — so
 * they read as a button, clearly distinct from the dotted hover-only terms. */
.term.has-explainer {
  border-bottom: none; cursor: pointer; color: var(--ix);
  background: var(--ix-soft);
  border: 1px solid #b9d4fb;
  border-radius: 6px;
  padding: 0.04em 0.42em;
  /* Clone the fill/border/padding onto each fragment if the chip wraps a line. */
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.term.has-explainer .ex-glyph {
  font-family: var(--mono); font-size: 0.78em; vertical-align: baseline;
  color: inherit; margin-left: 0.32em; opacity: 0.85;
}
.term.has-explainer:hover {
  background: #cadffb; border-color: var(--ix);
}
.term.has-explainer:hover .ex-glyph { opacity: 1; }
/* Open state: solid accent fill so the keyword whose panel is showing stands out. */
.term.ex-active, .term.has-explainer.ex-active:hover {
  background: var(--ix); border-color: var(--ix); color: #fff;
}
.term.ex-active .ex-glyph { opacity: 1; }

/* Inert chip used in the lede to show the reader what a clickable explainer
 * chip looks like. Matches .term.has-explainer visually but is not interactive. */
.chip-demo {
  color: var(--ix); background: var(--ix-soft);
  border: 1px solid #b9d4fb; border-radius: 6px;
  padding: 0.04em 0.42em; font-style: normal; white-space: nowrap;
}
.chip-demo .ex-glyph {
  font-family: var(--mono); font-size: 0.78em; color: inherit;
  margin-left: 0.32em; opacity: 0.85;
}

/* The expandable panel inserted below a paragraph when its keyword is clicked. */
.explainer-panel {
  border: 1px solid var(--ix); border-left-width: 3px; border-radius: 12px;
  margin: 1.4rem 0; background: linear-gradient(180deg, #fff, var(--paper));
  overflow: hidden; animation: ex-in 0.18s ease-out;
}
@keyframes ex-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.explainer-panel .ex-head {
  display: flex; align-items: baseline; gap: 0.7rem; flex-wrap: wrap;
  padding: 0.7rem 1.1rem; border-bottom: 1px solid var(--rule); background: #fff;
}
.explainer-panel .ex-title {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ix);
}
.explainer-panel .ex-blurb { font-size: 0.9rem; color: var(--muted); }
.explainer-panel .ex-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: 1rem; line-height: 1; color: var(--muted); padding: 0.2rem 0.3rem;
}
.explainer-panel .ex-close:hover { color: var(--ink); }
.explainer-panel .ex-body .explorable { border: none; border-radius: 0; margin: 0; background: none; }
.explainer-panel .caption .step-label { color: var(--ix); }
.explainer-panel .dots i.on { background: var(--ix); }
.explainer-panel .ex-error { padding: 1rem 1.1rem; color: var(--bad); }

/* Interactive explainer widgets — HTML-based panels stepped with next/prev.
 * Light theme; reuses the paper's variables. Used by explainers that run real
 * interactivity (inputs, buttons, live computation) instead of animated SVG. */
.exw { padding: 1.1rem 1.3rem 1.3rem; font-size: 0.95rem; }
.exw-nav { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1rem; }
.exw-nav button {
  font-family: var(--mono); font-size: 0.8rem; cursor: pointer;
  background: var(--ink); color: var(--paper); border: none; border-radius: 6px; padding: 0.45rem 0.9rem;
}
.exw-nav button:disabled { opacity: 0.3; cursor: default; }
.exw-stepname { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ix); }
.exw-dots { display: flex; gap: 0.4rem; margin-left: auto; }
.exw-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--rule); transition: background 0.15s, transform 0.15s; }
.exw-dots i.on { background: var(--ix); transform: scale(1.25); }
.exw-step { display: none; }
.exw-step.on { display: block; animation: ex-in 0.18s ease-out; }
.exw-step h3 { margin: 0 0 0.6rem; font-size: 1.05rem; }
.exw p { margin: 0 0 0.8rem; line-height: 1.5; }
.exw-grid { display: grid; gap: 0.8rem; margin-bottom: 0.8rem; }
@media (min-width: 540px) { .exw-grid.cols2 { grid-template-columns: 1fr 1fr; } .exw-grid.cols3 { grid-template-columns: 1fr 1fr 1fr; } }
.exw-card { border: 1px solid var(--rule); border-radius: 10px; padding: 0.9rem; background: #fff; }
.exw-label { font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 0.35rem; }
.exw-input, .exw-textarea {
  width: 100%; font-family: var(--mono); font-size: 0.88rem; padding: 0.5rem 0.6rem;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); color: var(--ink);
}
.exw-input:focus, .exw-textarea:focus { outline: none; border-color: var(--ix); }
.exw-textarea { resize: vertical; }
.exw-btn {
  font-family: var(--mono); font-size: 0.82rem; cursor: pointer; border: none; border-radius: 6px;
  padding: 0.5rem 0.9rem; color: #fff; background: var(--ix); display: inline-flex; align-items: center; gap: 0.4rem; margin-top: 0.6rem;
}
.exw-btn:disabled { opacity: 0.5; cursor: default; }
.exw-btn.sign { background: #6b4fa0; }
.exw-btn.verify { background: var(--good); }
.exw-btn.danger { background: var(--bad); }
.exw-btn.ghost { background: none; color: var(--muted); border: 1px solid var(--rule); }
.exw-key { border-radius: 8px; padding: 0.7rem 0.8rem; }
.exw-key.priv { background: #ece6f5; border: 1px solid #6b4fa0; }
.exw-key.pub { background: var(--accent-soft); border: 1px solid var(--accent); }
.exw-key h4 { margin: 0 0 0.3rem; font-size: 0.92rem; }
.exw-key p { margin: 0; font-size: 0.8rem; color: var(--muted); }
.exw-hex { font-family: var(--mono); font-size: 0.72rem; word-break: break-all; line-height: 1.55; background: var(--faint); border-radius: 6px; padding: 0.5rem; }
.exw-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.exw-result { display: flex; gap: 0.7rem; border-radius: 8px; padding: 0.8rem; margin-top: 0.8rem; }
.exw-result.ok { background: #e8f0ec; border: 1px solid var(--good); }
.exw-result.bad { background: #f9e3e1; border: 1px solid var(--bad); }
.exw-result b { display: block; margin-bottom: 0.2rem; }
.exw-result.ok b { color: var(--good); } .exw-result.bad b { color: var(--bad); }
.exw-result .small { font-size: 0.82rem; color: var(--muted); }
.exw-tag { font-family: var(--mono); font-size: 0.66rem; color: var(--bad); }
.exw-note { font-size: 0.85rem; color: var(--muted); background: var(--faint); border-radius: 6px; padding: 0.6rem 0.7rem; }
.explainer-panel .ex-src { font-size: 0.72rem; font-family: var(--mono); color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--muted); }
.explainer-panel .ex-src:hover { color: var(--ix); border-bottom-color: var(--ix); }
.exw-arrow { color: var(--muted); text-align: center; font-size: 1.1rem; }

/* End-to-end flow diagram — HTML/CSS boxes + arrows, wraps responsively */
.exw-flow .exw-label { display: block; margin: 0.6rem 0 0.4rem; }
.exw-flowrow { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.exw-fcol { display: flex; flex-direction: column; gap: 0.4rem; }
.exw-fbox {
  font-family: var(--mono); font-size: 0.78rem; padding: 0.45rem 0.6rem;
  border: 1px solid var(--rule); border-radius: 8px; background: #fff; white-space: nowrap;
}
.exw-fbox.sign { background: #ece6f5; border-color: #6b4fa0; }
.exw-fbox.verify { background: var(--ix-soft); border-color: var(--ix); }
.exw-fbox.pub { background: #e8f0ec; border-color: var(--good); }
.exw-fbox.ok { background: #e8f0ec; border-color: var(--good); color: var(--good); }
.exw-fbox.bad { background: #f9e3e1; border-color: var(--bad); color: var(--bad); }
.exw-farrow { color: var(--muted); font-family: var(--mono); font-size: 0.72rem; white-space: nowrap; }
.exw-wire { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); border-top: 1px dashed var(--rule); margin: 0.7rem 0; padding-top: 0.5rem; text-align: center; }

/* Merkle tree widget (merkle-tree.js) */
.exw-mtree { display: flex; flex-direction: column; align-items: center; gap: 0.55rem; }
.exw-mrow { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.exw-mcap { font-family: var(--mono); font-size: 0.64rem; color: var(--muted); }
.exw-mnode {
  font-family: var(--mono); font-size: 0.72rem; text-align: center; min-width: 88px;
  border: 1px solid var(--rule); border-radius: 8px; padding: 0.4rem 0.5rem; background: #fff;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.exw-mnode .lab { display: block; font-size: 0.56rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.2rem; }
.exw-mnode.root { border-color: var(--ix); background: var(--ix-soft); }
.exw-mnode.changed { border-color: var(--bad); background: #f9e3e1; color: var(--bad); }
.exw-mnode.changed .lab { color: var(--bad); }
.exw-mnode.branch { border-color: var(--accent); background: var(--accent-soft); }
.exw-mnode.proven { border-color: var(--good); background: #e8f0ec; }

/* Proof-of-work widget (proof-of-work.js) */
.exw-hashbig { font-family: var(--mono); font-size: 0.82rem; word-break: break-all; line-height: 1.55; background: var(--faint); border-radius: 6px; padding: 0.55rem 0.6rem; }
.exw-hashbig .z { color: var(--good); font-weight: 700; }
.exw-hashbig .zno { color: var(--accent); font-weight: 700; }
.exw-hashbig .rest { color: var(--ink); }
.exw-counter { font-family: var(--mono); font-size: 1.5rem; font-weight: 700; color: var(--ix); font-variant-numeric: tabular-nums; }

/* Chain-of-blocks widget (timestamp-server.js) */
.exw-chain { display: flex; flex-direction: column-reverse; gap: 0; }
.exw-block { border: 1px solid var(--rule); border-radius: 10px; padding: 0.55rem 0.7rem; background: #fff; transition: background 0.15s, border-color 0.15s; }
.exw-block.genesis { border-style: dashed; }
.exw-block.changed { border-color: var(--bad); background: #f9e3e1; }
.exw-block .bk-head { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.35rem; }
.exw-block.changed .bk-head { color: var(--bad); }
.exw-block .bk-field { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.25rem; }
.exw-block .bk-lab { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); width: 2.6rem; flex: none; }
.exw-block .bk-prev, .exw-block .bk-hash { font-family: var(--mono); font-size: 0.72rem; word-break: break-all; }
.exw-block .bk-prev { color: var(--muted); }
.exw-block .bk-hash { color: var(--ix); }
.exw-block.changed .bk-hash { color: var(--bad); }
.exw-block .bk-data { font-size: 0.85rem; }
.exw-block .bk-field .exw-input { margin: 0; }
.exw-blink { font-family: var(--mono); font-size: 0.62rem; color: var(--muted); text-align: center; padding: 0.2rem 0; }
.exw-blink.broken { color: var(--bad); }

/* Shared small helpers used across explainers */
.exw .small { font-size: 0.82rem; color: var(--muted); }
.exw .ok { color: var(--good); font-weight: 600; }
.exw .bad { color: var(--bad); font-weight: 600; }
.exw-mono { font-family: var(--mono); }

/* Electronic-coin widget (electronic-coin.js) */
.exw-person { display: inline-flex; flex-direction: column; gap: 0.1rem; border: 1px solid var(--rule); border-radius: 8px; padding: 0.35rem 0.6rem; margin: 0 0.4rem 0.4rem 0; background: #fff; }
.exw-person .pn { font-weight: 600; font-size: 0.85rem; }
.exw-person .pk { font-family: var(--mono); font-size: 0.62rem; color: var(--muted); }
.exw-person.mint { border-color: var(--ix); }
.exw-person.mallory { border-color: var(--bad); background: #f9e3e1; }
.exw-coin { overflow-x: auto; }
.exw-coinrow { display: flex; align-items: stretch; gap: 0; min-width: min-content; }
.exw-tx { border: 1px solid var(--rule); border-radius: 10px; padding: 0.5rem 0.65rem; background: #fff; min-width: 9.5rem; flex: none; transition: background 0.15s, border-color 0.15s; }
.exw-tx.ok { border-color: var(--good); background: #e8f0ec; }
.exw-tx.bad { border-color: var(--bad); background: #f9e3e1; }
.exw-tx .tx-head { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.35rem; }
.exw-tx .tx-line { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.2rem; font-size: 0.78rem; }
.exw-tx .tx-lab { font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); width: 4.2rem; flex: none; }
.exw-tx .tx-hash { font-family: var(--mono); font-size: 0.66rem; color: var(--muted); word-break: break-all; }
.exw-tx .tx-by { color: #6b4fa0; font-weight: 600; }
.exw-tx .exw-redir { font-size: 0.72rem; padding: 0.1rem 0.25rem; height: auto; }
.exw-clink { display: flex; align-items: center; font-family: var(--mono); font-size: 0.6rem; color: var(--muted); padding: 0 0.35rem; }
.exw-clink.broken { color: var(--bad); }

/* Gambler's-ruin random-walk widget (gamblers-ruin.js) */
.exw-walk { border: 1px solid var(--rule); border-radius: 10px; padding: 0.7rem 0.8rem; background: var(--faint); }
.exw-leadbox { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); display: flex; align-items: baseline; gap: 0.6rem; }
.exw-lead { font-size: 1.9rem; font-weight: 700; color: var(--good); font-variant-numeric: tabular-nums; }
.exw-lead.caught { color: var(--bad); }
.exw-track { display: flex; flex-wrap: wrap; gap: 0.2rem; margin: 0.5rem 0; min-height: 1.4rem; }
.exw-chip { font-family: var(--mono); font-size: 0.64rem; font-weight: 700; border-radius: 4px; padding: 0.05rem 0.3rem; color: #fff; }
.exw-chip.up { background: var(--good); }
.exw-chip.down { background: var(--bad); }
.exw-chip.more { background: none; color: var(--muted); font-weight: 400; }
.exw-walkmsg { font-size: 0.85rem; color: var(--ink); margin-top: 0.3rem; }
.exw-controls2 { display: flex; flex-wrap: wrap; gap: 1.4rem; font-family: var(--mono); font-size: 0.82rem; margin-top: 0.4rem; }
.exw-controls2 label { display: flex; flex-direction: column; gap: 0.2rem; }
.exw-controls2 input[type=range] { width: 190px; }
.exw-barrow { display: flex; align-items: center; gap: 0.6rem; margin: 0.35rem 0; }
.exw-barlab { font-family: var(--mono); font-size: 0.72rem; width: 11rem; flex: none; color: var(--muted); }
.exw-bartrack { flex: 1; height: 0.85rem; background: #fff; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.exw-bar { display: block; height: 100%; }
.exw-barval { font-family: var(--mono); font-size: 0.75rem; width: 6rem; flex: none; text-align: right; }

/* Longest-chain widget (longest-chain.js) */
.exw-lc { display: flex; flex-direction: column; gap: 0.4rem; }
.exw-lcrow { display: flex; align-items: center; flex-wrap: wrap; gap: 0.15rem; }
/* Fork view: a shared trunk on the left and a bracket that splits into the two
 * branches. The bracket is the border-left on .exw-lcbranches; centering the
 * tree vertically puts #2 at the midpoint between branch A and branch B. */
.exw-lctree { display: flex; align-items: center; flex-wrap: wrap; gap: 0.2rem 0.1rem; }
.exw-lctrunk { display: flex; flex-direction: column; gap: 0.3rem; align-items: flex-start; }
.exw-lctrunkrow { display: flex; align-items: center; gap: 0.15rem; }
.exw-lctrunk .exw-lctag { margin-left: 0; }
.exw-lcbranches { display: flex; flex-direction: column; gap: 0.55rem; border-left: 2px solid var(--muted); padding-left: 0.85rem; margin-left: 0.1rem; }
.exw-lcbranch { display: flex; align-items: center; flex-wrap: wrap; gap: 0.15rem; }
.exw-lcblk { font-family: var(--mono); font-size: 0.72rem; font-weight: 700; border: 1px solid var(--rule); border-radius: 6px; padding: 0.3rem 0.5rem; background: #fff; color: var(--ink); }
.exw-lcblk.shared { border-color: var(--muted); }
.exw-lcblk.active { border-color: var(--good); background: #e8f0ec; color: var(--good); }
.exw-lcblk.stale { border-color: var(--rule); background: var(--faint); color: var(--muted); text-decoration: line-through; }
.exw-lcblk.tie { border-color: var(--ix); background: var(--ix-soft); color: var(--ix); }
.exw-lcarrow { font-family: var(--mono); color: var(--muted); font-size: 0.7rem; }
.exw-lcbl { font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-right: 0.3rem; }
.exw-lctag { font-family: var(--mono); font-size: 0.62rem; color: var(--muted); margin-left: 0.5rem; }
.exw-lctag.active { color: var(--good); }
.exw-lctag.stale { color: var(--muted); }

/* Incentive widget (incentive.js) */
.exw-cb { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; font-family: var(--mono); font-size: 0.82rem; margin-top: 0.3rem; }
.exw-cb-from { color: var(--muted); }
.exw-cb-to { color: var(--good); font-weight: 700; border: 1px solid var(--good); background: #e8f0ec; border-radius: 6px; padding: 0.2rem 0.5rem; }
.exw-statgrid { display: flex; flex-wrap: wrap; gap: 1.4rem; }
.exw-statgrid > div { display: flex; flex-direction: column; gap: 0.1rem; }
.exw-big { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }

/* Inputs-outputs widget (inputs-outputs.js) */
.exw-chunks { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.exw-chunk { font-family: var(--mono); font-size: 0.82rem; border: 1px solid var(--rule); border-radius: 8px; padding: 0.35rem 0.6rem; background: #fff; }
.exw-chunk.pick { cursor: pointer; color: var(--ink); }
.exw-chunk.pick.sel { border-color: var(--ix); background: var(--ix-soft); color: var(--ix); font-weight: 700; }
.exw-txio { display: flex; align-items: stretch; gap: 0.8rem; flex-wrap: wrap; }
.exw-txio .io-side { flex: 1; min-width: 11rem; border: 1px solid var(--rule); border-radius: 10px; padding: 0.5rem 0.65rem; background: #fff; }
.exw-txio .io-cap { font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.4rem; }
.exw-txio .io-item { font-family: var(--mono); font-size: 0.8rem; border-radius: 6px; padding: 0.25rem 0.45rem; margin-top: 0.25rem; background: var(--faint); }
.exw-txio .io-item.in { border-left: 3px solid var(--muted); }
.exw-txio .io-item.pay { border-left: 3px solid var(--ix); }
.exw-txio .io-item.change { border-left: 3px solid var(--good); }
.exw-txio .io-item.empty { color: var(--muted); background: none; }
.exw-txio .io-fee { font-family: var(--mono); font-size: 0.74rem; color: var(--accent); margin-top: 0.4rem; }
.exw-txio .io-eq { display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: var(--muted); min-width: 1.4rem; }
/* §9 build-a-transaction controls: each input on its own labelled row. */
.io-controls { display: flex; flex-direction: column; gap: 1rem; }
.io-ctl-inline { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: flex-end; }
.io-field { display: flex; flex-direction: column; }
.io-field .exw-label { margin-bottom: 0.4rem; }
.io-num { display: inline-flex; align-items: center; gap: 0.4rem; }
.io-num .exw-input { width: 5rem; margin: 0; }
.io-num .io-unit { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); }
.io-field-fee { flex: 1; min-width: 13rem; }
.io-field-fee input[type=range] { width: 100%; margin: 0; }

/* Explorable diagram frame + stepper */
.explorable {
  border: 1px solid var(--rule); border-radius: 12px; margin: 2rem 0;
  background: linear-gradient(180deg, #fff, var(--paper)); overflow: hidden;
}
.explorable .stage { padding: 0.5rem 0.5rem 0; }
.explorable svg { width: 100%; height: auto; display: block; }
.explorable .caption {
  min-height: 3.2em; padding: 0.9rem 1.4rem; font-size: 0.98rem;
  border-top: 1px solid var(--rule); background: #fff;
}
.explorable .caption .step-label { font-family: var(--mono); font-size: 0.68rem; color: var(--accent); letter-spacing: 0.1em; display: block; margin-bottom: 0.2rem; }
.explorable .controls {
  display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 1.4rem 1rem; background: #fff;
}
.explorable .controls button {
  font-family: var(--mono); font-size: 0.8rem; cursor: pointer;
  background: var(--ink); color: var(--paper); border: none; border-radius: 6px; padding: 0.45rem 0.9rem;
  transition: opacity 0.12s;
}
.explorable .controls button:hover { opacity: 0.85; }
.explorable .controls button:disabled { opacity: 0.3; cursor: default; }
.explorable .controls .replay { background: none; color: var(--muted); border: 1px solid var(--rule); }
.explorable .dots { display: flex; gap: 0.4rem; margin-left: auto; }
.explorable .dots i {
  width: 9px; height: 9px; border-radius: 50%; background: var(--rule); cursor: pointer; transition: background 0.15s, transform 0.15s;
}
.explorable .dots i.on { background: var(--accent); transform: scale(1.25); }

/* SVG diagram element styling (Bitcoin Figure 1 reimagined) */
.dg-card { fill: #fff; stroke: var(--rule); stroke-width: 1.5; }
.dg-card-head { fill: var(--faint); }
.dg-label { font-family: var(--mono); font-size: 12px; fill: var(--ink); }
.dg-sub { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
.dg-title { font-family: var(--serif); font-weight: 600; font-size: 13px; fill: var(--ink); }
.dg-key { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.2; }
.dg-priv { fill: #ece6f5; stroke: #6b4fa0; stroke-width: 1.2; }
.dg-hash { fill: #e8f0ec; stroke: var(--good); stroke-width: 1.2; }
.dg-sig { fill: #fbeede; stroke: var(--accent); stroke-width: 1.2; }
.dg-arrow { fill: none; stroke: var(--muted); stroke-width: 2; }
.dg-arrow-verify { stroke: var(--good); stroke-dasharray: 5 4; }
.dg-arrow-sign { stroke: #6b4fa0; }
.dg-arrow-label { font-family: var(--mono); font-size: 10px; }
.dg-ghost { fill: #f9e3e1; stroke: var(--bad); stroke-width: 1.5; }
.dg-bad { fill: var(--bad); font-family: var(--mono); font-size: 12px; }

/* --- Ethereum account cards (accounts explainer) --- */
.exw-acct { border: 1px solid var(--rule); border-radius: 10px; padding: 0.7rem 0.85rem; background: #fff; transition: box-shadow 0.2s, border-color 0.2s; }
.exw-acct.contract { border-color: var(--ix); background: #fbfdff; }
.exw-acct.eoa { border-color: #6b4fa0; }
.exw-acct.hit { box-shadow: 0 0 0 3px var(--ix-soft); }
.exw-acct-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.exw-acct-head b { font-family: var(--serif); font-size: 1rem; }
.exw-acct-f { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; font-family: var(--mono); font-size: 0.76rem; padding: 0.2rem 0; border-top: 1px solid var(--faint); }
.exw-acct-f.top { align-items: flex-start; }
.exw-acct-f > span { color: var(--muted); }
.exw-acct-f > b { font-variant-numeric: tabular-nums; }
.exw-acct-store { text-align: right; font-family: var(--mono); font-size: 0.72rem; color: var(--ix); word-break: break-all; }

/* non-fungible-assets: ownership registry table (item -> owner) */
.exw-reg { border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: #fff; }
.exw-reghead, .exw-regrow { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; padding: 0.4rem 0.7rem; font-family: var(--mono); font-size: 0.78rem; align-items: center; }
.exw-reghead { background: var(--faint); color: var(--muted); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; }
.exw-regrow { border-top: 1px solid var(--faint); transition: background 0.2s; }
.exw-regrow.hot { background: var(--ix-soft); }
.exw-regrow .exw-regkey { color: var(--ink); font-weight: 600; word-break: break-all; }
.exw-regrow .exw-regown { text-align: right; font-weight: 700; }
.exw-regempty { padding: 0.55rem 0.7rem; color: var(--muted); font-family: var(--mono); font-size: 0.78rem; }

/* --- Whitepaper figures, tables, and deep TOC (Ethereum) --- */
.paper-fig { margin: 1.8rem 0; text-align: center; }
.paper-fig img { max-width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 8px; background: #fff; }
.paper-table { width: 100%; border-collapse: collapse; margin: 1.6rem 0; font-family: var(--mono); font-size: 0.8rem; }
.paper-table th, .paper-table td { border: 1px solid var(--rule); padding: 0.45rem 0.7rem; text-align: left; }
.paper-table th { background: var(--faint); color: var(--accent); font-weight: 600; }
.paper-toc { max-height: calc(100vh - 4rem); overflow-y: auto; }
.paper-toc a.sub { padding-left: 0.85rem; font-size: 0.68rem; color: var(--muted); }
.paper-toc a.sub:hover { color: var(--accent); }

/* --- Landing page: list of papers --- */
.paper-grid { display: grid; gap: 1rem; margin: 2.2rem 0; }
.paper-card {
  display: block; border: 1px solid var(--rule); border-radius: 10px;
  padding: 1.3rem 1.5rem; background: #fff; color: inherit;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s;
}
a.paper-card { border-bottom: 1px solid var(--rule); }
a.paper-card:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(0,0,0,0.07); transform: translateY(-1px); }
.paper-card .pc-kicker { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.paper-card h2 { font-size: 1.3rem; margin: 0.25rem 0 0.15rem; }
.paper-card .pc-by { color: var(--muted); font-style: italic; font-size: 0.95rem; margin: 0 0 0.6rem; }
.paper-card .pc-desc { font-size: 0.95rem; margin: 0 0 0.7rem; }
.paper-card .pc-foot { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.04em; }
.paper-card.pending { opacity: 0.72; }
.paper-card.pending .pc-foot { color: var(--ix); }
.pc-badge { display: inline-block; font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; padding: 0.12em 0.5em; border-radius: 999px; vertical-align: middle; margin-left: 0.5em; }
.pc-badge.live { background: #e8f0ec; color: var(--good); }
.pc-badge.soon { background: var(--ix-soft); color: var(--ix); }
.crumb { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 1.2rem; }
.crumb a { color: var(--muted); border-bottom-color: var(--rule); }
.crumb a:hover { color: var(--accent); }

@media print {
  body { font-size: 11pt; max-width: none; padding: 0; }
  .quiz, .ask, .footer-nav, .explorable .controls, .explorable .dots { display: none; }
  .explorable svg * { opacity: 1 !important; }
  a { color: var(--ink); border: none; }
}
