/* Stages (body[data-stage]):
   start   - the hero and one input, nothing else;
   working - conversation on the left, the result pane waiting on the right;
   ready   - a valid spec: graph and spec tabs, the summary on the graph. */

:root {
  --bg: #faf9fc;
  --panel: #ffffff;
  --text: #1c1c1e;
  --muted: #6e6e75;
  --faint: #a3a3a9;
  --border: #e6e2ec;
  /* A violet next to the Leios site's, a touch bluer and softer. */
  --accent: #7434d4;
  --accent-soft: #f1eafc;
  --on-accent: #ffffff;
  --source: #e9f0ff;
  --source-line: #7aa2e8;
  --tx: #ffffff;
  --tx-line: #8a8a90;
  --conflict: #d8443a;
  --orphan: #d98b12;
  --user: #f1ecfa;
  --error: #fdecec;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px rgb(0 0 0 / 0.06);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 14px;
  --ink: #3a3a3e;
  --ink-line: #b9b9bd;
  --ink-faint: #c4c4c8;
  --contest: #c2413a;
  --up: #2f9e5b;
  --partial: #c98a1b;
  --y-string: #2f7d5b;
  --y-expr: #b0532a;
  --y-number: #9a5b00;
  --y-ref: #2c6aa8;
  --y-pattern: #b03a72;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141416;
    --panel: #1d1d20;
    --text: #ececef;
    --muted: #a0a0a8;
    --faint: #6a6a72;
    --border: #313136;
    --accent: #b08af2;
    --accent-soft: #2b2240;
    --on-accent: #1a1022;
    --source: #1d2840;
    --source-line: #5a7fc4;
    --tx: #242428;
    --tx-line: #77777f;
    --conflict: #ff6b61;
    --orphan: #f0a43a;
    --user: #2a2340;
    --error: #3b2224;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
    --ink: #d4d4d8;
    --ink-line: #55555c;
    --ink-faint: #4a4a50;
    --contest: #ff7b70;
    --up: #4cc47f;
    --partial: #e0a23a;
    --y-string: #7fcf9f;
    --y-expr: #f0a070;
    --y-number: #e6b45a;
    --y-ref: #7fb2e8;
    --y-pattern: #f08cbc;
  }
}
:root[data-theme="dark"] {
  --bg: #141416;
  --panel: #1d1d20;
  --text: #ececef;
  --muted: #a0a0a8;
  --faint: #6a6a72;
  --border: #313136;
  --accent: #b08af2;
  --accent-soft: #2b2240;
  --on-accent: #1a1022;
  --source: #1d2840;
  --source-line: #5a7fc4;
  --tx: #242428;
  --tx-line: #77777f;
  --conflict: #ff6b61;
  --orphan: #f0a43a;
  --user: #2a2340;
  --error: #3b2224;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
  --ink: #d4d4d8;
  --ink-line: #55555c;
  --ink-faint: #4a4a50;
  --contest: #ff7b70;
  --up: #4cc47f;
  --partial: #e0a23a;
  --y-string: #7fcf9f;
  --y-expr: #f0a070;
  --y-number: #e6b45a;
  --y-ref: #7fb2e8;
  --y-pattern: #f08cbc;
  }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 160ms var(--ease), border-color 160ms var(--ease), transform 160ms var(--ease), opacity 160ms;
}
button:hover:not(:disabled) { border-color: var(--faint); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
button.quiet:hover { color: var(--text); }
button.icon { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border-radius: 50%; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Top bar: only once there is a conversation. */
.topbar {
  /* Above the result pane: the view transition gives it its own layer. */
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  view-transition-name: topbar;
}
.brand { display: flex; align-items: center; gap: 9px; border: none; background: none; padding: 2px 4px; font-weight: 650; font-size: 17px; letter-spacing: -0.01em; view-transition-name: logo; }
.wordmark { display: inline-flex; align-items: baseline; font-weight: 650; letter-spacing: -0.02em; line-height: 1; }
.brand .wordmark { font-size: 21px; }
/* The x of the wordmark is the Crossing mark: two strands that cross, one landing on the accent.
   It is one x-height tall and sits on the baseline (an inline SVG's baseline is its bottom edge). */
/* Nudged down a hair: the dots' round bottoms read as floating at the flat
   baseline of t, f and l. */
.wordmark .mark { width: 1.04ex; height: 1ex; margin: 0 0.05em 0 0.04em; overflow: visible; translate: 0 0.03em; }
.mark .hub { fill: var(--accent); }
/* "flow" takes the accent, like the Run button and the dot the strands land on. */
.wordmark .flow { color: var(--accent); }
/* On the start page the logo is shown large above the tagline instead of in the top bar; the two share
   a view-transition name, so it moves between them when an experiment starts or the page returns. */
.hero-logo { margin: 0 0 12px; font-size: 56px; color: var(--text); view-transition-name: logo; }
body[data-stage="start"] .brand { visibility: hidden; view-transition-name: none; }
@media (max-width: 520px) { .hero-logo { font-size: 48px; margin-bottom: 12px; } }
body[data-stage="start"] .topbar { border-bottom-color: transparent; }
body[data-stage="start"] #new { visibility: hidden; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.topnav { display: flex; align-items: center; gap: 2px; margin-right: 6px; padding-right: 8px; border-right: 1px solid var(--border); }
.topnav a, .topnav button { transition: color 160ms var(--ease), background 160ms var(--ease); }
.topnav a:hover, .topnav button:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }

/* Network picker: one network for now, the rest announced. */
.network { position: relative; }
.network-button { display: flex; align-items: center; gap: 7px; font-size: 13.5px; }
.network-button .live, .relay-list .live { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; transition: background 300ms var(--ease); }
.live[data-state="up"] { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 18%, transparent); }
.live[data-state="partial"] { background: var(--partial); }
.live[data-state="down"] { background: var(--contest); }
.relay-list { list-style: none; margin: 0 0 4px; padding: 0 10px; display: grid; gap: 7px; font-size: 13px; }
.relay-list li { display: flex; align-items: center; gap: 8px; }
.relay-list li { color: var(--muted); }
.relay-state { margin-left: auto; padding-left: 12px; color: var(--faint); font-size: 12px; }
.network-button svg { color: var(--faint); transition: transform 200ms var(--ease); }
.network-button[aria-expanded="true"] svg { transform: rotate(180deg); }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 10;
  min-width: 260px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  transform-origin: top right;
  animation: menu-in 160ms var(--ease);
}
.menu[hidden], .shapes[hidden], .pasted[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: scale(0.97) translateY(-4px); } }
.menu-item { display: grid; gap: 2px; width: 100%; text-align: left; border: none; background: none; padding: 8px 10px; border-radius: 7px; }
.menu-item:hover:not(:disabled) { background: var(--bg); }
.menu-item strong { font-weight: 600; font-size: 13.5px; }
.menu-item span { color: var(--muted); font-size: 12px; }
.menu-soon { padding: 8px 10px 6px; margin-top: 4px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12.5px; }

main { flex: 1; min-height: 0; display: grid; }
main > section { min-width: 0; }

/* Start: hero over one centred input. */
body[data-stage="start"] main {
  grid-template-columns: minmax(0, 680px);
  grid-auto-rows: max-content;
  justify-content: center;
  /* Centred while it fits; on a short or narrow screen it scrolls from the top. */
  align-content: safe center;
  overflow-y: auto;
  padding: 24px 16px max(12px, 8vh - 40px);
  gap: 22px;
}
.hero { text-align: center; }

/* The author, muted, under the start screen and the spec reference only. */
.site-foot { padding: 0 16px 18px; display: flex; flex-direction: column; align-items: center; font-size: 12px; color: var(--faint); text-align: center; }
.site-foot a { color: inherit; text-decoration: none; transition: color 160ms var(--ease); }
.site-foot a:hover, .site-foot a:focus-visible { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
body[data-stage="start"] .site-foot { padding: 0 16px 12px; margin-top: 4px; }
body:not([data-stage="start"]):not(.doc-page) .site-foot { display: none; }
.doc-page .site-foot { margin-top: -56px; }

/* The building blocks, drawn by the graph renderer, above the input. */
/* Wider than the input column, centred on it, so the drawings have room. */
.shapes {
  --wide: min(860px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  width: var(--wide);
  margin: 20px 0 0 50%;
  translate: -50% 0;
  text-align: left;
}
.shape {
  display: grid;
  gap: 2px;
  padding: 8px 12px 9px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: inherit;
  font: inherit;
  text-align: left;
  animation: rise 420ms var(--ease) backwards;
  animation-delay: calc(var(--i) * 40ms + 80ms);
}
/* A pasted spec with problems, in place of the example cards. */
.pasted {
  --wide: min(760px, calc(100vw - 32px));
  width: var(--wide);
  margin: 26px 0 0 50%;
  translate: -50% 0;
  text-align: left;
}
.pasted-card {
  color: var(--text);
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--conflict) 45%, var(--border));
  border-radius: 12px;
  background: var(--panel);
  animation: rise 360ms var(--ease) backwards;
}
.pasted-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pasted-head strong { font-size: 14px; font-weight: 600; color: var(--conflict); }
.pasted-count { font-size: 12px; color: var(--muted); }
.pasted-spec {
  margin: 0;
  max-height: 300px;
  overflow: auto;
  padding: 8px 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 3%, var(--panel));
  font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  counter-reset: line;
}
.pasted-line { display: block; padding: 0 12px 0 44px; position: relative; white-space: pre; transition: background 200ms var(--ease); }
.pasted-line::before {
  counter-increment: line;
  content: counter(line);
  position: absolute;
  left: 0;
  width: 32px;
  text-align: right;
  color: var(--faint);
}
.pasted-line.bad { background: color-mix(in srgb, var(--conflict) 12%, transparent); box-shadow: inset 3px 0 0 var(--conflict); }
.pasted-line.bad::before { color: var(--conflict); }
.pasted-why { display: block; padding: 2px 12px 4px 44px; color: var(--conflict); font-family: inherit; white-space: pre-wrap; font-size: 11.5px; }
.pasted-rest { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--conflict); display: grid; gap: 2px; }
.pasted-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pasted-actions button { font-size: 13px; }
.msg.pasted-msg { padding: 0; background: none; border: 0; max-width: 100%; }
.msg.pasted-msg .pasted-spec { max-height: 220px; }
.shape { transition: border-color 240ms var(--ease), transform 240ms var(--ease), box-shadow 240ms var(--ease); }
.shape:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-2px); box-shadow: 0 6px 18px -10px color-mix(in srgb, var(--accent) 60%, transparent); }
.shape .mini { height: 60px; display: grid; place-items: center; margin-bottom: 6px; }
.shape .mini svg { width: 100%; height: 60px; }
.shape .mini svg text { display: none; }
.shape .mini svg .group-label { display: none; }
.shape strong { font-size: 13.5px; font-weight: 600; }
.shape span { font-size: 12px; color: var(--muted); line-height: 1.35; }
/* The flow: each column's edges draw in the accent colour once the column
   before has arrived, then the transactions they reach light up. Leaving
   the card fades it all back at once. */
.shape { --step: 260ms; --run: 620ms; }
.shape .mini .flow {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.9;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0;
  transition: opacity 260ms var(--ease), stroke-dashoffset 0s linear 260ms;
}
.shape:hover .mini .flow {
  opacity: 1;
  stroke-dashoffset: 0;
  transition:
    opacity 0s,
    stroke-dashoffset var(--run) cubic-bezier(0.45, 0, 0.25, 1) calc((var(--column, 1) - 1) * var(--step));
}
.shape .mini .box, .shape .mini .utxo, .shape .mini .relay-pin { transition: stroke 260ms var(--ease), fill 260ms var(--ease); }
.shape:hover .mini .node-source .utxo { stroke: var(--accent); fill: var(--accent); transition-delay: 0ms; }
.shape:hover .mini .node-tx .box,
.shape:hover .mini .node-tx .utxo,
.shape:hover .mini .relay-pin {
  stroke: var(--accent);
  transition-duration: 320ms;
  transition-delay: calc((var(--column, 1) - 1) * var(--step) + var(--run) * 0.7);
}
.shape:hover .mini .node-tx .utxo.spent { fill: var(--accent); }
/* A colour-tagged transaction draws in its tag, at rest and on hover. */
.shape .mini .node-tx.tagged .box { stroke: var(--tag); fill: color-mix(in srgb, var(--tag) 10%, var(--panel)); }
.shape:hover .mini .node-tx.tagged .box,
.shape:hover .mini .node-tx.tagged .utxo { stroke: var(--tag); }
/* A hover plays one outcome where outputs are contested: the winners land in
   the accent colour, and the losers, with all that builds on them, stay grey
   and turn dashed as their turn comes. A transaction that could have been
   orphaned and landed draws solid. */
.shape:hover .mini .flow.lost { opacity: 0; }
.shape:hover .mini .orphan:not(.lost) .box { stroke-dasharray: none; }
.shape:hover .mini .node-tx.lost .box { stroke: var(--faint); stroke-dasharray: 4 3; }
.shape:hover .mini .node-tx.lost .utxo,
.shape:hover .mini .relay-pin.lost { stroke: var(--faint); }
.shape:hover .mini .node-tx.lost .utxo.spent { fill: var(--faint); }
.modifiers { margin: 12px auto 0; max-width: 600px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.modifiers code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); }
.modifiers a { color: var(--accent); text-decoration: none; white-space: nowrap; margin-left: 4px; }
.modifiers a::after { content: " →"; }
@media (max-width: 720px) {
  .shapes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Phones: the templates are one row to swipe through, so the input stays on the first screen. */
@media (max-width: 600px) {
  .shapes {
    --wide: 100vw;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 42%;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    padding: 2px max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px));
    scroll-padding-inline: max(16px, env(safe-area-inset-left, 0px));
    scrollbar-width: none;
  }
  .shapes::-webkit-scrollbar { display: none; }
  .shape { scroll-snap-align: start; }
  .shape:hover { transform: none; }
}
.tagline { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.015em; color: var(--text); }
.subline { max-width: 560px; margin: 8px auto 0; color: var(--muted); font-size: 15px; line-height: 1.45; text-wrap: balance; }
body:not([data-stage="start"]) .hero { display: none; }

/* The site's totals: a quiet line in the start page's footer, above the byline,
   numbers that roll up. */
.tally {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 auto 4px;
  color: var(--faint); font-size: 12px; line-height: 1.4;
  animation: fade 420ms var(--ease) backwards;
}
.tally[hidden] { display: none; }
.tally-items { display: inline-flex; flex-wrap: wrap; justify-content: center; column-gap: 10px; }
.tally-items > span + span::before { content: "·"; margin-right: 10px; color: var(--faint); }
.tally b { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.tally-dot { flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); animation: tally-pulse 2.4s var(--ease) infinite; }
@keyframes tally-pulse { 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .tally, .tally-dot { animation: none; } }

/* Not found: an address that names no experiment saved in this browser. */
body[data-missing] .hero, body[data-missing] .composer { display: none; }
.missing { display: grid; justify-items: center; gap: 10px; text-align: center; animation: rise 420ms var(--ease) backwards; }
.missing[hidden] { display: none; }
.missing h1 { margin: 6px 0 0; font-size: 24px; font-weight: 600; letter-spacing: -0.015em; }
.missing p { max-width: 520px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; text-wrap: pretty; }
.missing p code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); overflow-wrap: anywhere; }
.missing-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.missing-start { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.missing-graph { overflow: visible; }
.mg-edge { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; }
.mg-edge.is-lost { stroke: var(--faint); stroke-dasharray: 2 5; }
.mg-tx { fill: var(--accent); }
.mg-utxo { fill: var(--panel); stroke: var(--muted); stroke-width: 1.6; }
.mg-missing { fill: none; stroke: var(--faint); stroke-width: 1.6; stroke-dasharray: 3 3; transform-box: fill-box; transform-origin: center; animation: mg-spin 9s linear infinite; }
.mg-mark { fill: var(--muted); font: 600 11px ui-sans-serif, system-ui, sans-serif; text-anchor: middle; }
@keyframes mg-spin { to { rotate: 1turn; } }
@media (prefers-reduced-motion: reduce) { .missing, .mg-missing { animation: none; } }
body[data-stage="start"] .result,
body[data-stage="start"] .log { display: none; }

/* Working and ready: conversation left, result right. */
body:not([data-stage="start"]) main { grid-template-columns: clamp(300px, 28vw, 400px) minmax(0, 1fr); }
@media (max-width: 860px) {
  body:not([data-stage="start"]) main { grid-template-columns: 1fr; grid-template-rows: minmax(320px, auto) minmax(420px, 1fr); }
}

.chat { display: flex; flex-direction: column; min-height: 0; }
/* Phones only (see the phone rules): Chat or Experiment. */
.view-switch { display: none; gap: 2px; margin: 8px 12px 0; padding: 3px; border-radius: 11px; background: color-mix(in srgb, var(--text) 6%, transparent); }
.view-switch button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: background 200ms var(--ease), color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.view-switch button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 14%, transparent); }
.view-new { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.view-switch .has-new .view-new { display: block; }
body:not([data-stage="start"]) .chat { border-right: 1px solid var(--border); }
.log { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; }

.composer {
  view-transition-name: composer;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 10px 8px 14px;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.composer:focus-within { border-color: var(--accent); }
body:not([data-stage="start"]) .composer { margin: 10px 16px 16px; }
.composer textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  padding: 4px 0;
}
body[data-stage="start"] .composer textarea { font-size: 17px; min-height: 84px; }
.composer textarea::placeholder { color: var(--faint); }
.run-context[hidden] { display: none; }
.run-context { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.run-context::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.composer-row { display: flex; align-items: center; gap: 8px; }

/* One button: a microphone while the input is empty, an arrow once there is
   text. The two glyphs share the slot and swap with a blur and scale. */
.action { margin-left: auto; position: relative; flex: none; color: var(--text); }
.action .glyph {
  grid-area: 1 / 1;
  transition: opacity 250ms ease-in-out, transform 250ms ease-in-out, filter 250ms ease-in-out;
}
.action[data-mode="send"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.action[data-mode="send"].empty:not(.busy) { background: var(--panel); border-color: var(--border); color: var(--faint); }
.action[data-mode="send"] .mic,
.action[data-mode="mic"] .arrow { opacity: 0; transform: scale(0.6); filter: blur(2px); }
.action.busy .arrow { animation: pulse 1s var(--ease) infinite; }
.action.listening { color: var(--contest); border-color: var(--contest); animation: breathe 1.4s ease-in-out infinite; }

/* The rotating example under the input, on the start screen only. */
.example {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
  border: none;
  background: none;
  padding: 4px 2px;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}
.example-label { color: var(--accent); font-weight: 600; flex: none; }
.example-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: opacity 280ms var(--ease), transform 280ms var(--ease); }
.example-text.out { opacity: 0; transform: translateY(6px); }
.example:hover .example-text { color: var(--text); }
body:not([data-stage="start"]) .example { display: none; }

/* Messages. */
.msg { padding: 9px 13px; border-radius: 12px; max-width: 92%; white-space: pre-wrap; overflow-wrap: anywhere; animation: rise 320ms var(--ease) both; }
.msg.user { background: var(--user); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.model { background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.note { color: var(--muted); font-size: 13px; padding: 0 4px; }
.msg.note summary { cursor: pointer; }
.msg.note pre { white-space: pre-wrap; font-size: 12px; margin: 6px 0 0; }
.msg.note ul { margin: 6px 0 0; padding-left: 18px; font-size: 12px; display: grid; gap: 4px; }
.msg.note.warn { border-left: 2px solid var(--partial); padding-left: 10px; }
.msg.error { background: var(--error); }
.msg.budget { background: var(--panel); border: 1px solid var(--border); color: var(--muted); font-size: 14px; white-space: normal; }
.msg.budget strong { color: var(--text); font-weight: 600; }
/* Only shown with the budget message: quiet, in the page's own button style. */
.sponsor {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  padding: 5px 11px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); font-size: 13px; text-decoration: none;
  animation: sponsor-in 420ms var(--ease) 240ms both;
  transition: color 160ms var(--ease), border-color 160ms var(--ease), background 160ms var(--ease);
}
.sponsor svg { fill: var(--accent); transition: transform 220ms var(--ease); }
.sponsor:hover, .sponsor:focus-visible { color: var(--text); border-color: var(--faint); background: var(--accent-soft); }
.sponsor:hover svg { transform: scale(1.15); }
@keyframes sponsor-in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .sponsor, .sponsor svg { animation: none; transition: none; } }
.msg .options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
/* Writing: three dots that brighten in a wave. One dot and two shadows of it,
   with room kept for the shadows; colours ease from one dot to the next. */
.msg.model.streaming:empty::after {
  content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 22px 0 2px; border-radius: 50%; vertical-align: 2px;
  --dot: var(--muted); --dot-dim: color-mix(in srgb, var(--muted) 28%, transparent);
  background: var(--dot); box-shadow: 10px 0 var(--dot-dim), 20px 0 var(--dot-dim);
  animation: fade 260ms var(--ease) both, typing 1.2s ease-in-out 120ms infinite;
}
@media (prefers-reduced-motion: reduce) { .msg.model.streaming:empty::after { animation: none; } }

/* Result pane. */
.result { display: flex; flex-direction: column; min-height: 0; view-transition-name: result; }
.placeholder { flex: 1; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
body[data-stage="ready"] .placeholder { display: none; }
.placeholder .idle, .placeholder.is-idle .drawing { display: none; }
.placeholder.is-idle .idle { display: block; }
.placeholder.is-idle .build-graph { opacity: 0.35; }
.placeholder.is-idle .build-graph * { animation: none !important; }
body:not([data-stage="ready"]) .tabs,
body:not([data-stage="ready"]) .tab { display: none; }
/* Waiting for a spec: a small UTxO graph that builds itself left to right
   (dots are transactions, rings are outputs), holds, fades, and starts over. */
.build-graph { overflow: visible; }
.build-graph > * { animation: build 2.8s var(--ease) infinite both; animation-delay: calc(var(--i) * 140ms); }
.bg-edge { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 1; }
.bg-utxo { fill: var(--panel); stroke: var(--muted); stroke-width: 1.6; transform-box: fill-box; transform-origin: center; }
.bg-tx { fill: var(--text); transform-box: fill-box; transform-origin: center; }
@keyframes build {
  0% { opacity: 0; stroke-dashoffset: 1; transform: scale(0.4); }
  14% { opacity: 1; stroke-dashoffset: 0; transform: scale(1); }
  72% { opacity: 1; stroke-dashoffset: 0; transform: scale(1); }
  88%, 100% { opacity: 0; stroke-dashoffset: 0; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .build-graph > * { animation: none; opacity: 0.7; }
}

.tabs { display: flex; align-items: center; gap: 2px; padding: 10px 16px 0; border-bottom: 1px solid var(--border); }
.tabs button[role="tab"] { border: none; background: none; border-radius: 0; padding: 8px 12px; color: var(--muted); box-shadow: inset 0 -2px 0 transparent; transition: color 160ms, box-shadow 200ms var(--ease); }
.tabs button[aria-selected="true"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.budget { margin-left: auto; font-size: 12px; color: var(--muted); }
.tabs { position: relative; z-index: 5; }
/* Run: one large button at the bottom right of the result, on every tab. */
.result { position: relative; }
.run-dock[hidden] { display: none; }
/* Its bottom right corner sits as far in from the graph's as the legend's
   bottom left. */
.run-dock { animation: rise 260ms var(--ease) both; position: absolute; right: 26px; bottom: 26px; z-index: 6; display: flex; flex-direction: column; align-items: flex-end; }
.run {
  padding: 15px 26px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16.5px;
  font-weight: 600;
  box-shadow: 0 10px 28px -10px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), filter 180ms;
}
.run.running {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: background 320ms var(--ease), color 320ms var(--ease), transform 180ms var(--ease);
}
.run-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: waiting-dot 1.6s var(--ease) infinite; }
@keyframes waiting-dot { 50% { opacity: 0.35; transform: scale(0.8); } }
@media (prefers-reduced-motion: reduce) { .run-dot { animation: none; } }
.run span { display: inline-block; transition: transform 200ms var(--ease); }
.run:hover { transform: translateY(-1px); box-shadow: 0 14px 32px -10px color-mix(in srgb, var(--accent) 80%, transparent); }
.run:hover span { transform: translateX(3px); }
.run:active { transform: translateY(0); }
.run:hover { filter: brightness(1.08); }
.run-note { margin: 12px 0 10px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--text); font-size: 12.5px; }
.run-start { width: 100%; padding: 8px; border-radius: 8px; }
.run-funds { margin: 8px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.run-events { margin: 10px 0; padding-left: 18px; display: grid; gap: 4px; font-size: 12.5px; }
.run-events li::marker { color: var(--muted); font-weight: 400; }
.run-start:disabled { opacity: 0.55; cursor: not-allowed; }
.run-start:enabled:not(.run-close) { border: none; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.tab { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 16px 16px; animation: fade 260ms var(--ease) both; }
.tab[hidden] { display: none; }
.graph-wrap { position: relative; flex: 1; min-height: 300px; display: flex; }
.graph { flex: 1; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); display: flex; flex-direction: column; }
.graph-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; cursor: grab; touch-action: none; user-select: none; }
.graph-stage.dragging { cursor: grabbing; }
.graph-stage svg { display: block; width: 100%; height: 100%; }
.graph .note { padding: 6px 12px 8px; margin: 0; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--border); }
.graph-controls { position: absolute; top: 10px; right: 10px; display: grid; gap: 4px; }
.graph-controls button { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 8px; font-size: 15px; line-height: 1; color: var(--muted); background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(6px); }
.graph-controls button:hover { color: var(--text); }
.graph-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  max-width: 300px;
  display: grid;
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
  pointer-events: none;
  animation: fade 140ms var(--ease);
}
.graph-tip[hidden] { display: none; }
.graph-tip strong { color: var(--text); font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
/* The legend floats in a corner of the graph instead of taking a row. */
.legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  /* Clear of the Run button in the bottom right; three items to a row. */
  max-width: calc(100% - 280px);
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  gap: 4px 14px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: blur(6px);
  font-size: 11.5px;
  color: var(--muted);
  pointer-events: none;
}
.sw { display: inline-block; width: 14px; height: 10px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; }
.sw.spent { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); vertical-align: 0; }
.sw.unspent { width: 8px; height: 8px; border-radius: 50%; border: 1.2px solid var(--ink); vertical-align: 0; }
.sw.tx { background: var(--panel); border: 1px solid var(--ink-line); }
.sw.conflict { width: 9px; height: 9px; border-radius: 50%; background: var(--contest); vertical-align: 0; }
.sw.orphan { border: 1px dashed var(--ink-line); }
.sw.mint { width: 7px; height: 7px; border-radius: 1px; margin: 0 7px 0 2px; background: var(--ink); rotate: 45deg; vertical-align: 0; }
.sw.relay { width: auto; height: auto; font-style: normal; color: var(--muted); vertical-align: 0; }
.sw.load { border: 1px solid var(--ink-line); background: linear-gradient(90deg, color-mix(in srgb, var(--partial) 24%, var(--panel)) 40%, var(--panel) 40%); }

/* The spec editor: a transparent textarea over its highlighted copy. Both
   share font, padding and wrapping so every character lines up. */
.editor { position: relative; flex: 1; min-height: 300px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); overflow: hidden; }
.editor:focus-within { border-color: var(--accent); }
.editor pre, #spec {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}
.editor pre { pointer-events: none; color: var(--text); }
#spec { resize: none; border: none; outline: none; background: transparent; color: transparent; caret-color: var(--text); }
/* See-through, so the highlighted text underneath stays readable. */
#spec::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); color: transparent; }
.yaml .y-key { color: var(--accent); }
.yaml .y-string { color: var(--y-string); }
.yaml .y-expr { color: var(--y-expr); }
.yaml .y-number, .yaml .y-keyword { color: var(--y-number); }
.yaml .y-comment { color: var(--faint); font-style: italic; }
.yaml .y-punct { color: var(--faint); }
.yaml .y-ref { color: var(--y-ref); }
.yaml .y-pattern { color: var(--y-pattern); }
.yaml .y-bytes { color: var(--y-number); }
/* A colour value sits on a wash of itself. No padding or border: the editor's
   highlighted copy must line up with the text area character for character. */
.yaml .y-color {
  background: color-mix(in srgb, var(--swatch) 26%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--swatch) 60%, transparent);
  border-radius: 3px;
}

/* The result's bottom edge lines up with the composer's (its 16px margin). */
body:not([data-stage="start"]) .tab { padding-bottom: 16px; }
.spec-buttons { display: flex; gap: 8px; align-items: flex-start; padding-top: 10px; min-height: 30px; }
#spec-status { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
/* Copy and download, at the editor's top right. */
.editor-tools { position: absolute; top: 8px; right: 14px; z-index: 2; display: flex; gap: 4px; }
.icon-button { position: relative; width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border-radius: 8px; color: var(--muted); background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(6px); transition: color 160ms, background 160ms; }
.icon-button:hover { color: var(--text); }
.icon-button svg { grid-area: 1 / 1; transition: opacity 180ms var(--ease), transform 220ms var(--ease); }
#copy .i-done { opacity: 0; transform: scale(0.5); color: var(--up); }
#copy.copied .i-copy { opacity: 0; transform: scale(0.5); }
#copy.copied .i-done { opacity: 1; transform: scale(1); }
/* Lines the check found wrong, behind the highlighted text. */
.spec-marks { position: absolute; inset: 0; overflow: hidden; pointer-events: none; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.spec-marks i { position: absolute; left: 0; right: 0; height: 1.5em; top: calc(12px + var(--line) * 1.5em); background: color-mix(in srgb, var(--contest) 14%, transparent); box-shadow: inset 3px 0 0 var(--contest); animation: fade 200ms var(--ease) both; }
/* The automatic check's verdict: a green tick or a red cross. */
.spec-mark { width: 20px; height: 20px; flex: none; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--faint); transform: scale(0); transition: transform 220ms var(--ease), background 200ms; }
.spec-mark svg { grid-area: 1 / 1; opacity: 0; transition: opacity 160ms; }
.spec-mark[data-state="checking"] { transform: scale(0.6); background: var(--faint); }
.spec-mark[data-state="ok"] { transform: scale(1); background: var(--up); }
.spec-mark[data-state="ok"] .m-ok { opacity: 1; }
.spec-mark[data-state="bad"] { transform: scale(1); background: var(--contest); }
.spec-mark[data-state="bad"] .m-bad { opacity: 1; }

/* Graph: monochrome; contested outputs are the only accented marks.
   Nodes and edges fade in column by column (--column set per node). */
svg text { fill: var(--text); font: 12px system-ui, sans-serif; }
svg text.amount { fill: var(--muted); font-size: 10.5px; }
svg text.relay, svg text.fund-amount { fill: var(--muted); font-size: 10.5px; letter-spacing: 0.01em; }
svg .box { fill: var(--panel); stroke: var(--ink-line); stroke-width: 1; }
svg .orphan .box { stroke-dasharray: 4 3; }
svg .tag { fill: var(--tag); stroke: none; }
/* Script load: a tint filling the box from the left, as much as the script uses. */
svg .load { fill: color-mix(in srgb, var(--partial) 24%, transparent); stroke: none; pointer-events: none; }
svg .orphan .label { fill: var(--muted); }
/* A validity window, in slots after its anchor, beside the tx's name. */
svg text.window { fill: var(--muted); font-size: 10px; }
/* Native assets: filled where a tx mints them, hollow where it only burns. */
svg .mint { fill: var(--ink); stroke: var(--panel); stroke-width: 1.5; }
svg .mint.burn { fill: var(--panel); stroke: var(--ink); stroke-width: 1.2; }
svg .edge { stroke: var(--ink-faint); stroke-width: 1.1; fill: none; }
svg .edge.conflict { stroke: var(--contest); stroke-width: 1.5; }
svg .edge.reference { stroke-dasharray: 3 3; }
svg .edge.funding { stroke-dasharray: 2 3; opacity: 0.8; }
svg .utxo { stroke: var(--ink); stroke-width: 1.2; }
svg .utxo.spent { fill: var(--ink); }
svg .utxo.unspent { fill: var(--panel); }
svg .utxo.contested { fill: var(--contest); stroke: var(--panel); stroke-width: 1.5; }
svg .group-label { fill: var(--muted); font-size: 11px; letter-spacing: 0.02em; }
svg .node-source, svg .node-tx, svg .node-fund, svg .edge { animation: fade 420ms var(--ease) both; animation-delay: calc(var(--column, 0) * 45ms); }

/* A run on the graph: each box takes its transaction's state. Colours ease
   in, and a tx waiting for a block breathes gently. */
svg .node-tx .box, svg .node-fund .box, svg .node-source .utxo { transition: stroke 480ms var(--ease), fill 480ms var(--ease), stroke-width 480ms var(--ease); }
svg [data-run] .box { stroke-dasharray: none; }
svg [data-run="queued"] .box { stroke-dasharray: 3 3; }
svg [data-run="sending"] .box { stroke: var(--accent); }
svg [data-run="accepted"] .box {
  stroke: var(--accent);
  stroke-width: 1.6;
  fill: color-mix(in srgb, var(--accent) 7%, var(--panel));
  animation: waiting 1.8s var(--ease) infinite;
}
svg.calm [data-run="accepted"] .box { animation: none; }
svg [data-run="landed"] .box { stroke: var(--up); stroke-width: 1.6; fill: color-mix(in srgb, var(--up) 10%, var(--panel)); }
svg [data-run="rejected"] .box { stroke: var(--contest); stroke-width: 1.6; fill: color-mix(in srgb, var(--contest) 9%, var(--panel)); }
/* Never landed: still held when the run ended. Dropped: every relay let it
   go, red like a lost conflict and dashed. */
svg [data-run="unlanded"] .box { stroke: var(--partial); stroke-width: 1.6; fill: color-mix(in srgb, var(--partial) 9%, var(--panel)); }
svg [data-run="dropped"] .box { stroke: var(--contest); stroke-width: 1.6; stroke-dasharray: 4 3; fill: color-mix(in srgb, var(--contest) 5%, var(--panel)); }
/* No answer in time: amber and dashed, it may still have gone in. Relay
   unreachable: grey and dashed, the infrastructure, not the transaction. */
svg [data-run="timeout"] .box { stroke: var(--partial); stroke-width: 1.6; stroke-dasharray: 5 3; fill: color-mix(in srgb, var(--partial) 6%, var(--panel)); }
svg [data-run="failed"] .box { stroke: var(--ink-line); stroke-width: 1.6; stroke-dasharray: 2 3; fill: color-mix(in srgb, var(--ink-line) 12%, var(--panel)); }
svg [data-run="failed"] .label { fill: var(--muted); }
svg [data-run="rejected"] .label { fill: var(--contest); }
svg .node-source[data-run="landed"] .utxo { stroke: var(--up); fill: var(--up); }
svg .node-source[data-run="accepted"] .utxo { stroke: var(--accent); fill: var(--accent); }
/* The spread bar: a segment per relay, furthest along first. */
svg .relay-dot { stroke: none; fill: color-mix(in srgb, var(--ink-line) 45%, transparent); transition: fill 400ms var(--ease); }
svg .relay-dot.is-mempool { fill: var(--accent); }
svg .relay-dot.is-ledger { fill: var(--up); }
svg .relay-dot.is-rejected { fill: var(--contest); }
svg .relay-dot.is-dropped { fill: color-mix(in srgb, var(--contest) 50%, transparent); }
svg .relay-dot.is-timeout { fill: var(--partial); }
svg .relay-dot.is-failed { fill: var(--ink-line); }
/* The relays in the details panel: one row each, earliest first, opening
   into a timeline of what it did with the tx. */
.detail details.relay { margin: 0; font-size: 13px; border: 1px solid var(--border); border-radius: 9px; transition: border-color 200ms var(--ease); }
.detail details.relay[open] { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.relay summary { list-style: none; cursor: pointer; padding: 8px 10px 7px; display: grid; gap: 7px; border-radius: 9px; }
.relay summary::-webkit-details-marker { display: none; }
.relay summary:hover { background: var(--bg); }
.relay-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.relay-head b { font-weight: 600; }
.relay-state-word { color: var(--muted); font-size: 12px; }
.relay-first { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.relay-head::after { content: ""; flex: none; width: 6px; height: 6px; margin-left: 2px; border-right: 1.4px solid var(--faint); border-bottom: 1.4px solid var(--faint); rotate: -45deg; transition: rotate 200ms var(--ease); }
.relay-first:empty + * { margin-left: auto; }
.relay[open] .relay-head::after { rotate: 45deg; translate: 0 -2px; }
.relay-strip { position: relative; height: 8px; margin: 0 3px; }
.relay-strip::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--border); }
.relay-strip i { position: absolute; top: 50%; left: calc(var(--at) * 100%); width: 7px; height: 7px; border-radius: 50%; translate: -50% -50%; background: var(--panel); border: 1.4px solid var(--tone, var(--ink-line)); }
.relay-timeline { list-style: none; margin: 0; padding: 2px 10px 10px 10px; display: grid; }
.relay-timeline li { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 3px 0 3px 18px; }
.relay-timeline li::before { content: ""; position: absolute; left: 3px; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--tone, var(--ink-line)); }
.relay-timeline li:not(:last-child)::after { content: ""; position: absolute; left: 6px; top: 16px; bottom: -8px; width: 1px; background: var(--border); }
.relay-timeline li span { min-width: 0; }
.relay-timeline small { display: block; color: var(--muted); font-size: 11.5px; }
/* The EB or block a step names, opening on the explorer. */
.relay-timeline li a, .relay-timeline li code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.relay-timeline li a { color: var(--accent); text-decoration: none; }
.relay-timeline li a:hover { text-decoration: underline; }
.relay-timeline time { flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.relay-timeline .relay-empty { color: var(--muted); padding-left: 0; }
.relay-timeline .relay-empty::before { display: none; }
.relay-note { font-size: 12px; }
.tone-sent { --tone: var(--ink-line); }
.tone-mempool { --tone: var(--accent); }
.tone-eb { --tone: color-mix(in srgb, var(--accent) 50%, var(--up)); }
.tone-ledger { --tone: var(--up); }
.tone-left { --tone: var(--partial); }
.tone-bad { --tone: var(--contest); }
.relay-strip .tone-mempool, .relay-strip .tone-ledger, .relay-strip .tone-bad, .relay-strip .tone-eb { background: var(--tone); }
.relay-chip { display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--ink-line); }
.relay-chip.is-mempool { background: var(--accent); border-color: var(--accent); }
.relay-chip.is-ledger { background: var(--up); border-color: var(--up); }
.relay-chip.is-rejected { background: var(--contest); border-color: var(--contest); }
.relay-chip.is-dropped { border-color: var(--contest); }
.relay-chip.is-timeout { border-color: var(--partial); border-style: dashed; }
.relay-chip.is-failed { background: var(--ink-line); border-color: var(--ink-line); }
svg .run-link { cursor: pointer; animation: fade 320ms var(--ease) both; }
svg .run-link circle { fill: var(--panel); stroke: var(--ink-line); stroke-width: 1; transition: fill 160ms var(--ease), stroke 160ms var(--ease); }
svg .run-link path { fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; transition: stroke 160ms var(--ease); }
svg .run-link:hover circle { fill: var(--accent); stroke: var(--accent); }
svg .run-link:hover path { stroke: var(--on-accent); }
.run-links { margin: 6px 0; font-size: 12.5px; color: var(--muted); }
.run-links a { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; text-decoration: none; }
.run-links a:hover { text-decoration: underline; }
.legend [hidden] { display: none; }
/* Bigger screens, bigger legend. */
@media (min-width: 1400px) { .legend { font-size: 12.5px; gap: 5px 16px; padding: 7px 12px; } }
@media (min-width: 1800px) { .legend { font-size: 13.5px; } }
@media (max-width: 900px) { .legend { grid-template-columns: repeat(2, auto); max-width: calc(100% - 20px); bottom: 64px; } }
.sw.run-accepted { border: 1.6px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.sw.run-landed { border: 1.6px solid var(--up); background: color-mix(in srgb, var(--up) 10%, var(--panel)); }
.sw.run-rejected { border: 1.6px solid var(--contest); background: color-mix(in srgb, var(--contest) 9%, var(--panel)); }
.sw.run-dropped { border: 1.6px dashed var(--contest); background: color-mix(in srgb, var(--contest) 5%, var(--panel)); }
.sw.run-unlanded { border: 1.6px solid var(--partial); background: color-mix(in srgb, var(--partial) 9%, var(--panel)); }
.sw.run-timeout { border: 1.6px dashed var(--partial); background: color-mix(in srgb, var(--partial) 6%, var(--panel)); }
.sw.run-failed { border: 1.6px dashed var(--ink-line); background: color-mix(in srgb, var(--ink-line) 12%, var(--panel)); }
.sw.relay-dropped { width: 8px; height: 3px; border-radius: 1.5px; background: color-mix(in srgb, var(--contest) 50%, transparent); vertical-align: 1px; }
@keyframes waiting { 50% { stroke-opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
  svg [data-run="accepted"] .box { animation: none; }
  svg .node-tx .box, svg .node-fund .box, svg .node-source .utxo { transition: none; }
}

/* Details of one transaction or funding output: a panel that slides in over
   the right of the graph, without resizing it. */
.detail {
  position: absolute;
  top: 10px;
  right: 10px;
  /* Clear of the Run button under it. */
  bottom: 74px;
  z-index: 5;
  width: min(360px, calc(100% - 20px));
  overflow-y: auto;
  padding: 14px 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 320ms var(--ease), transform 400ms var(--ease);
}
.detail.open { opacity: 1; transform: none; }
.detail[hidden] { display: none; }
.detail header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.detail-title { display: grid; gap: 3px; min-width: 0; }
/* The name with its state trailing it, centred on the name's line. */
.detail-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 28px; }
.detail-title strong { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.detail-title > span { color: var(--muted); font-size: 12px; }
.run-elapsed { font-variant-numeric: tabular-nums; }
.detail-badge { flex: none; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--bg); color: var(--muted); transition: background 320ms var(--ease), color 320ms var(--ease); }
.detail-badge.is-accepted, .detail-badge.is-sending { background: var(--accent-soft); color: var(--accent); }
.detail-badge.is-landed { background: color-mix(in srgb, var(--up) 14%, var(--panel)); color: var(--up); }
.detail-badge.is-rejected { background: color-mix(in srgb, var(--contest) 14%, var(--panel)); color: var(--contest); }
.detail-badge.is-unlanded { background: color-mix(in srgb, var(--partial) 16%, var(--panel)); color: var(--partial); }
.detail-badge.is-dropped { background: color-mix(in srgb, var(--contest) 10%, var(--panel)); color: var(--contest); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--contest) 40%, transparent); }
.detail-badge.is-timeout { background: color-mix(in srgb, var(--partial) 12%, var(--panel)); color: var(--partial); }
.detail-badge.is-failed { background: color-mix(in srgb, var(--ink-line) 22%, var(--panel)); color: var(--muted); }
.detail-nav { display: flex; gap: 2px; flex-shrink: 0; }
.detail-nav button { width: 28px; height: 28px; padding: 0; border: none; border-radius: 7px; background: none; color: var(--muted); font-size: 17px; line-height: 1; transition: background 160ms var(--ease), color 160ms var(--ease); }
.detail-nav button:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.detail-nav button:disabled { opacity: 0.35; }
.detail section { padding: 10px 0 2px; border-top: 1px solid var(--border); margin-top: 10px; display: grid; gap: 6px; }
.detail h4 { margin: 0 0 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
/* "2 inputs · 30 tADA": quiet, on the heading's right. */
.detail-tally { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.detail-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.detail-label { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.detail-value { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.detail-value a, .detail-value code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.detail-value a { color: var(--accent); text-decoration: none; }
.detail-value a:hover { text-decoration: underline; }
.detail-race { color: var(--muted); font-size: 12px; }
.detail-muted { margin: 0; color: var(--muted); }
.chip { padding: 1px 7px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; transition: border-color 160ms var(--ease), color 160ms var(--ease); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.detail-copy { padding: 0 4px; border: none; background: none; color: var(--faint); font-size: 13px; transition: color 160ms var(--ease); }
.detail-copy:hover { color: var(--text); }
/* Key facts under the header: a grid of small cells, the id across both. */
.detail-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 8px; background: var(--border); border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.detail-fact { display: grid; gap: 1px; min-width: 0; padding: 6px 10px; background: var(--panel); }
.detail-fact.wide, .detail-fact:last-child:nth-child(even) { grid-column: 1 / -1; }
.detail-fact-label { color: var(--muted); font-size: 11px; }
.detail-fact-value { display: flex; align-items: center; gap: 4px; min-width: 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.detail-fact-value a, .detail-fact-value code { font: 500 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.detail-fact-value a { color: var(--accent); text-decoration: none; }
.detail-fact-value a:hover { text-decoration: underline; }
/* Contents and Diffusion. */
.detail-tabs { display: flex; gap: 2px; margin-top: 12px; padding: 2px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); }
.detail-tabs button { flex: 1; display: flex; justify-content: center; align-items: baseline; gap: 6px; padding: 5px 8px; border: 0; border-radius: 7px; background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; transition: background 160ms var(--ease), color 160ms var(--ease); }
.detail-tabs button:hover { color: var(--text); }
.detail-tabs button[aria-selected="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.detail-tabs em { font-style: normal; font-weight: 500; color: var(--faint); font-variant-numeric: tabular-nums; }
.detail-tab-panel > :first-child { margin-top: 4px; }
.detail-tab-panel > p.detail-muted:first-child { margin-top: 12px; }
/* A Contents group folds to its heading. */
.detail details.detail-group { border-top: 1px solid var(--border); margin-top: 10px; }
.detail-group summary { list-style: none; cursor: pointer; padding: 10px 0 2px; }
.detail-group summary::-webkit-details-marker { display: none; }
.detail-group summary h4 { justify-content: flex-start; }
.detail-group summary h4::before { content: ""; flex: none; align-self: center; width: 5px; height: 5px; margin-right: 2px; border-right: 1.4px solid var(--faint); border-bottom: 1.4px solid var(--faint); rotate: -45deg; transition: rotate 200ms var(--ease); }
.detail-group[open] summary h4::before { rotate: 45deg; translate: 0 -2px; }
.detail-group summary h4 .detail-tally { margin-left: auto; }
.detail-group-body { display: grid; gap: 8px; padding: 6px 0 2px; }
/* An input or output: name and amount on a line, its chain ref and links under it. */
.detail-io { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: baseline; }
.detail-io-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; min-width: 0; }
.detail-io-main code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.detail-amount { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.detail-io-sub { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px; min-width: 0; color: var(--muted); font-size: 12px; }
.detail-io-sub a, .detail-io-sub code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.detail-io-sub a { color: var(--accent); text-decoration: none; }
.detail-io-sub a:hover { text-decoration: underline; }
.detail-total { display: flex; justify-content: space-between; gap: 8px; padding-top: 6px; border-top: 1px dashed var(--border); color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.detail-meta { margin: 0; padding: 4px 7px; overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font: 11.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; }
.detail-row:has(.detail-meta) .detail-label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.detail-swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12); }
/* Where it was sent and what the relay said, one line each. */
.detail-submits { display: grid; gap: 4px; margin-top: 12px; padding: 8px 10px; border-radius: 9px; background: var(--bg); }
.detail-submit { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.detail-submit span:last-child { flex: none; color: var(--muted); font-size: 12px; }
.detail-submit.is-rejected span:last-child { color: var(--contest); }
.detail-submit.is-timeout span:last-child { color: var(--partial); }
/* The relays' shared time scale, over their strips. */
.relay-axis { position: relative; height: 13px; margin: 0 14px; color: var(--faint); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.relay-axis span { position: absolute; left: calc(var(--at) * 100%); translate: -50% 0; white-space: nowrap; }
.detail-send { margin-top: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; display: grid; gap: 4px; transition: border-color 320ms var(--ease); }
.detail-send.is-accepted { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.detail-send.is-rejected { border-color: color-mix(in srgb, var(--contest) 45%, var(--border)); }
.detail-send-head { display: flex; justify-content: space-between; gap: 8px; }
.detail-send-head span { color: var(--muted); font-size: 12px; }
.detail-send.is-rejected .detail-send-head span { color: var(--contest); }
.detail-send.is-timeout { border-color: color-mix(in srgb, var(--partial) 45%, var(--border)); border-style: dashed; }
.detail-send.is-timeout .detail-send-head span { color: var(--partial); }
.detail-send.is-failed { border-color: var(--ink-line); border-style: dashed; }
.detail-send.is-failed .detail-send-head span { color: var(--muted); }
.detail-send p { margin: 0; }
.detail-send summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.detail-send pre { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11.5px; color: var(--muted); }
svg .selected .box { stroke: var(--accent); stroke-width: 2.2; }
svg .node-source.selected .utxo { stroke: var(--accent); stroke-width: 2.5; }
svg .node-tx, svg .node-source { cursor: pointer; }
@media (max-width: 720px) { .detail { left: 10px; width: auto; } }
@media (prefers-reduced-motion: reduce) { .detail { transition: none; transform: none; } }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pulse { 0%, 100% { transform: scale(0.8); opacity: 0.5; } 50% { transform: scale(1); opacity: 1; } }
@keyframes breathe { 50% { box-shadow: 0 0 0 6px rgb(216 68 58 / 0.15); } }
@keyframes typing {
  0%, 100% { background: var(--dot); box-shadow: 10px 0 var(--dot-dim), 20px 0 var(--dot-dim); }
  33% { background: var(--dot-dim); box-shadow: 10px 0 var(--dot), 20px 0 var(--dot-dim); }
  66% { background: var(--dot-dim); box-shadow: 10px 0 var(--dot-dim), 20px 0 var(--dot); }
}

::view-transition-old(root), ::view-transition-new(root) { animation-duration: 280ms; animation-timing-function: var(--ease); }
::view-transition-group(composer), ::view-transition-group(logo), ::view-transition-group(result) { animation-duration: 420ms; animation-timing-function: var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
}

/* ---- Spec reference page ---------------------------------------------------- */

a.quiet-link, .topbar a.quiet-link { color: var(--muted); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
a.quiet-link:hover { color: var(--text); }
a.brand { color: inherit; text-decoration: none; }
body.doc-page { display: block; overflow: auto; height: auto; min-height: 100vh; }
.doc-page .topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); }
.doc-layout { display: grid; grid-template-columns: 200px minmax(0, 760px); gap: 48px; justify-content: center; padding: 32px 24px 96px; }
.doc-layout.single { grid-template-columns: minmax(0, 760px); }
.toc { position: sticky; top: 76px; align-self: start; font-size: 13.5px; }
.toc-title { font-weight: 600; margin: 0 0 10px; }
.toc-title span { color: var(--faint); font-weight: 400; margin-left: 4px; }
.toc-title span:not(:empty)::before { content: "· "; }
.toc .toc-title a { display: inline; padding: 0; margin: 0; border: 0; color: inherit; text-decoration: none; }
.toc .toc-title a::before { content: none; }
.toc .toc-title a:hover { color: var(--accent); text-decoration: underline; }
.toc ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--text); }
.doc { line-height: 1.6; font-size: 15px; }
.doc h1 { font-size: 30px; letter-spacing: -0.02em; margin: 0 0 12px; }
.doc h2 { font-size: 21px; letter-spacing: -0.01em; margin: 48px 0 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.doc h3 { font-size: 15.5px; margin: 26px 0 8px; }
.doc section, .doc h3 { scroll-margin-top: 64px; }
.doc .lede { font-size: 17px; color: var(--text); }
.doc .doc-note { color: var(--muted); font-size: 13.5px; }
/* The machine-readable schema, one click from the top of the reference. */
.doc .doc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.doc .schema-button { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 13px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel); color: var(--text); font-size: 13.5px; font-weight: 500; text-decoration: none; transition: border-color 160ms var(--ease), color 160ms var(--ease); }
.doc .schema-button svg { color: var(--accent); flex-shrink: 0; }
.doc .schema-button:hover, .doc .schema-button:focus-visible { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--accent); }
.doc .doc-actions-note { color: var(--muted); font-size: 12.5px; }
.doc code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.doc pre.code { font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow-x: auto; }
.doc a { color: var(--accent); }
.doc .muted { color: var(--faint); }
.doc .primitives { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
.doc .primitives dt { font-weight: 600; }
.doc .primitives dd { margin: 0; color: var(--muted); }
.doc .rules li, .doc .steps li { margin-bottom: 6px; }
.doc .table-wrap { overflow-x: auto; margin: 8px 0 4px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.doc th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.doc th, .doc td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc td:first-child { white-space: nowrap; }
.doc .pattern { margin-top: 18px; }

/* Reading aids, after the Rust book: numbered contents that follow the
   reader, listings with a file name and buttons, notes, chapter endings. */
.toc ol { counter-reset: chapter; }
.toc li { counter-increment: chapter; }
.toc a::before { content: counter(chapter) ". "; color: var(--faint); font-variant-numeric: tabular-nums; }
.toc a { display: block; padding: 2px 0 2px 10px; margin-left: -10px; border-left: 2px solid transparent; transition: color 160ms, border-color 160ms; }
.toc a.active { color: var(--text); border-left-color: var(--accent); }
.doc .listing { margin: 14px 0 18px; }
.doc .listing pre.code { margin: 0; border-radius: 0 0 8px 8px; }
.doc .listing figcaption { margin-top: 8px; text-align: center; font-size: 13px; color: var(--muted); font-style: italic; }
.listing-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border: 1px solid var(--border); border-bottom: none; border-radius: 8px 8px 0 0; background: var(--bg); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.listing-bar span { margin-right: auto; }
.listing-bar button { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.doc .listing-bar a.listing-open { padding: 3px 9px; border-radius: 6px; background: var(--accent); color: var(--on-accent); text-decoration: none; font: 600 12px system-ui, sans-serif; }
.doc pre.code .line { display: block; }
.doc pre.code .line.added { background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 2px 0 0 var(--accent); margin: 0 -16px; padding: 0 16px; }
.doc pre.code.terminal { background: color-mix(in srgb, var(--text) 4%, var(--panel)); }
.doc pre.code.terminal .prompt { color: var(--faint); user-select: none; }
.doc .callout { margin: 14px 0; padding: 10px 14px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--accent-soft); font-size: 14px; }
.doc .next-chapter { display: block; margin-top: 28px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; text-align: right; text-decoration: none; color: var(--text); font-weight: 600; transition: border-color 160ms; }
.doc .next-chapter:hover { border-color: var(--accent); }
.doc .next-chapter span { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.doc .pattern p { margin: 4px 0; }
.doc .emits { color: var(--muted); font-size: 13.5px; }
.toc-toggle { display: none; }
.short { display: none; }
@media (max-width: 860px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); padding: 0 16px 64px; gap: 16px; }
  /* The contents fold into a bar under the top bar that names where you are. */
  .toc { position: sticky; top: var(--topbar-height, 57px); z-index: 4; margin: 0 -16px; padding: 8px 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
  .toc-title { display: none; }
  .toc-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px;
    padding: 8px 12px; border-radius: 10px; text-align: left; font-size: 14px;
  }
  .toc-toggle-label { color: var(--muted); }
  .toc-current { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
  .toc-current:not(:empty)::before { content: "· "; color: var(--faint); font-weight: 400; }
  .toc-toggle svg { color: var(--faint); transition: transform 200ms var(--ease); }
  .toc.is-open .toc-toggle svg { transform: rotate(180deg); }
  .toc ol {
    position: absolute; left: 16px; right: 16px; top: calc(100% - 4px);
    max-height: min(70vh, 520px); overflow-y: auto; padding: 8px 10px 8px 22px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
    opacity: 0; transform: translateY(-6px); visibility: hidden; pointer-events: none;
    transition: opacity 180ms var(--ease), transform 220ms var(--ease), visibility 0s linear 220ms;
  }
  .toc.is-open ol { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition: opacity 180ms var(--ease), transform 220ms var(--ease); }
  .toc a { padding: 9px 0 9px 10px; font-size: 15px; }
  .doc h1 { margin-top: 20px; }
  .doc section, .doc h3 { scroll-margin-top: calc(var(--topbar-height, 57px) + 68px); }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .toc ol, .toc.is-open ol, .toc-toggle svg { transition: none; transform: none; }
}

/* Phones: shorter labels, the graph's legend in the flow under it, the Run
   button pinned to the bottom, and a spec editor that wraps long lines. */
@media (max-width: 600px) {
  .long, .network-button .protocol { display: none; }
  .short { display: inline; }
  .topbar { padding: 8px 10px; }
  .topnav { margin-right: 2px; padding-right: 4px; }
  .topnav a, .topnav button, .network-button { padding: 6px 8px; }
  .tabs { padding: 6px 10px 0; }
  .version-bar { margin: 10px 10px 0; }
  .tabs button[role="tab"] { padding: 8px 10px; }
  /* Wraps under itself rather than pushing the page wider than the screen. */
  .budget { min-width: 0; padding-left: 6px; font-size: 11.5px; line-height: 1.3; text-align: right; }
  .tab { padding: 10px 10px 12px; }
  .graph-wrap { flex-direction: column; min-height: 0; }
  .graph { min-height: 360px; }
  .legend { position: static; max-width: none; margin-top: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); background: none; backdrop-filter: none; }
  .run-dock { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  body[data-stage="ready"] .result { padding-bottom: 76px; }
  .editor pre, #spec { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12.5px; }
  .editor { min-height: 360px; }
  .run-dock .run { padding: 11px 18px; font-size: 15px; }
  /* One view at a time under a Chat / Experiment switch: the conversation
     with a compact input at the bottom, or the experiment, which scrolls. */
  body:not([data-stage="start"]) main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
  body:not([data-stage="start"]) .view-switch { display: flex; }
  body:not([data-stage="start"]) .chat, body:not([data-stage="start"]) .result { grid-row: 2; grid-column: 1; min-height: 0; }
  body:not([data-stage="start"])[data-view="chat"] .result, body:not([data-stage="start"])[data-view="experiment"] .chat { display: none; }
  body:not([data-stage="start"]) .chat { border-right: none; }
  body:not([data-stage="start"]) .result { overflow-y: auto; }
  body[data-view="chat"] .run-dock { display: none; }
  body:not([data-stage="start"]) .composer {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin: 6px 12px calc(10px + env(safe-area-inset-bottom));
    padding: 5px 5px 5px 16px;
    border-radius: 22px;
  }
  body:not([data-stage="start"]) .composer textarea { flex: 1; min-width: 0; height: 36px; padding: 7px 0; line-height: 22px; }
  body:not([data-stage="start"]) .composer-row { flex: none; }
}
/* The narrowest phones: the crossing mark alone says txflow. */
@media (max-width: 420px) {
  .topbar .brand .wordmark { font-size: 0; }
  .topbar .brand .mark { width: 20px; height: 20px; margin: 0; top: 0; translate: none; }
  .topnav a, .topnav button, .network-button { padding: 6px 5px; }
}
svg .edge.send { stroke-dasharray: 2 3; }
svg .relay-pin { fill: none; stroke: var(--ink); stroke-width: 1.5; }
/* Drawn small, so strokes keep their screen width and dots grow. */
.shape .mini svg * { vector-effect: non-scaling-stroke; }
.shape .mini .edge { stroke: var(--ink-line); stroke-width: 1.2; }
.shape .mini .edge.conflict { stroke: var(--contest); }
.shape .mini .box { stroke: var(--ink-line); stroke-width: 1.1; }
.shape .mini .utxo { r: 6px; }
.shape .mini .utxo.unspent { stroke-width: 1.2; }
.shape .mini .relay-pin { r: 7px; stroke-width: 1.3; }
/* The expiring card's clock, on the corner of each tx with a window. */
.shape .mini .clock { fill: var(--panel); stroke: var(--ink); stroke-width: 1.2; }
.shape .mini .mint, .shape .mini .clock {
  transform-box: fill-box;
  transform-origin: center;
  scale: 2;
  transition: stroke 260ms var(--ease), fill 260ms var(--ease);
}
.shape:hover .mini .node-tx .mint {
  fill: var(--accent);
  transition-duration: 320ms;
  transition-delay: calc((var(--column, 1) - 1) * var(--step) + var(--run) * 0.7);
}
.shape:hover .mini .clock.lost { stroke: var(--contest); }

/* ---- Saved experiments: a drawer from the left ------------------------------ */

.topbar-left { display: flex; align-items: center; gap: 6px; }
#library-toggle { width: 34px; height: 34px; color: var(--muted); border-color: transparent; background: none; }
#library-toggle:hover { color: var(--text); }
.library {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: min(300px, 86vw);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(-102%);
  transition: transform 260ms var(--ease);
}
body.library-open .library { transform: none; }
.library-backdrop { position: fixed; inset: 0; z-index: 25; background: rgb(0 0 0 / 0.12); opacity: 0; transition: opacity 260ms var(--ease); }
body.library-open .library-backdrop { opacity: 1; }
.library-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 10px 16px; border-bottom: 1px solid var(--border); }
.library-head strong { font-size: 14px; }
#library-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; display: grid; gap: 2px; align-content: start; flex: 1; }
#library-list li { display: flex; align-items: center; border-radius: 9px; }
#library-list li:hover, #library-list li.current { background: var(--bg); }
#library-list li.current .library-item strong { color: var(--accent); }
.library-item { flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left; border: none; background: none; padding: 8px 10px; }
.library-item strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-item span { font-size: 12px; color: var(--muted); }
.library-action {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--faint);
  opacity: 0;
  transition: opacity 160ms var(--ease), color 160ms var(--ease), background 160ms var(--ease);
}
.library-delete { margin-right: 4px; }
#library-list li:hover .library-action, .library-action:focus-visible { opacity: 1; }
.library-action:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.library-delete:hover { color: var(--contest); }
#library-list li.renaming .library-item, #library-list li.renaming .library-action { display: none; }
.library-name-input {
  flex: 1;
  min-width: 0;
  margin: 4px;
  padding: 7px 9px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: 600 13.5px/1.3 inherit;
  font-family: inherit;
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: rise 200ms var(--ease);
}
.library-empty { margin: 0; padding: 4px 16px 16px; color: var(--muted); font-size: 13px; }
.graph-stage .node-tx:hover .box { stroke: var(--accent); }
.graph-stage .utxo:hover { stroke: var(--accent); stroke-width: 2; }
.library[hidden], .library-backdrop[hidden] { display: none; }

/* Theme toggle: one icon per choice, swapped with a short fade and turn. */
.theme-toggle { position: relative; width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); border-color: transparent; background: none; }
.theme-toggle:hover { color: var(--text); }
a.icon-link { width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); border-radius: 50%; text-decoration: none; }
a.icon-link:hover, a.icon-link:focus-visible { color: var(--text); }
.theme-icon { grid-area: 1 / 1; opacity: 0; transform: rotate(-40deg) scale(0.7); transition: opacity 220ms var(--ease), transform 320ms var(--ease); }
.theme-toggle[data-theme="system"] .is-system,
.theme-toggle[data-theme="light"] .is-light,
.theme-toggle[data-theme="dark"] .is-dark { opacity: 1; transform: none; }
.topnav a[aria-current="page"] { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .theme-icon { transition: none; } }
.sw.relays { display: inline-flex; gap: 1.5px; width: auto; height: auto; vertical-align: 1px; }
.sw.relays b { width: 6px; height: 3px; border-radius: 1.5px; background: color-mix(in srgb, var(--ink-line) 45%, transparent); }
.sw.relays b:first-child { background: var(--up); }
.sw.relays b:nth-child(2) { background: var(--accent); }

/* Runs that survive a reload: a spinner in the library, a history in the run panel. */
.library-spinner { display: none; }
#library-list li.running .library-spinner {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border: 1.6px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.5px;
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  #library-list li.running .library-spinner { animation: none; border-color: var(--accent); background: var(--accent); width: 7px; height: 7px; }
}
.run-history { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.run-history strong { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.run-history li { display: flex; align-items: center; gap: 4px; border-radius: 7px; }
.run-history li.current { background: var(--accent-soft); }
.run-history-item {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 5px 8px;
  border: none;
  background: none;
  text-align: left;
  font-size: 12.5px;
}
.run-history-item:enabled:hover { color: var(--accent); }
.run-history-item:disabled { opacity: 0.55; cursor: default; }
.run-history-state { font-weight: 600; }
.run-history-state.is-done { color: var(--up); }
.run-history-state.is-failed, .run-history-state.is-lost { color: var(--contest); }
.run-history-facts { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-history-link { padding: 4px 8px; color: var(--muted); text-decoration: none; }
.run-history-link:hover { color: var(--accent); }
.run-relays { margin: 4px 0 0; padding-left: 16px; display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
/* Runs grouped by the version of the spec they ran. */
.run-history-version { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 10px 0 0; padding: 0 8px; font-size: 12.5px; }
.run-history-version b { font-weight: 600; }
.run-history-version span { color: var(--muted); font-size: 12px; }
.run-history-version.viewing b { color: var(--accent); }
.detail .run-history .run-history-version + ol { margin-top: 2px; }

/* Under the tabs while an older version is on screen. */
.version-bar[hidden] { display: none; }
.version-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin: 12px 16px 0; padding: 7px 8px 7px 14px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); font-size: 13px; }
.version-bar p { margin: 0; }
body:not([data-stage="ready"]) .version-bar { display: none; }
.version-bar div { display: flex; flex-wrap: wrap; gap: 6px; }
.version-bar button { padding: 4px 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--panel); color: inherit; font-size: 12.5px; }
.version-bar .version-back { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.version-bar button:hover { border-color: var(--accent); }

/* The run view in the details panel: a checklist of the run's steps. */
.run-checklist { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 9px; }
.run-checklist li { display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 8px; row-gap: 1px; align-items: baseline; }
.run-checklist i { grid-row: span 2; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink-line); translate: 0 2px; transition: background 300ms var(--ease), border-color 300ms var(--ease); }
.run-checklist b { font-weight: 600; font-size: 13px; }
.run-checklist span { grid-column: 2; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.run-checklist span a { color: var(--accent); text-decoration: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.run-checklist .is-now i { border-color: var(--accent); border-right-color: transparent; animation: spin 900ms linear infinite; }
.run-checklist .is-done i { border-color: var(--up); background: var(--up); }
.run-checklist .is-failed i { border-color: var(--contest); background: var(--contest); }
.run-checklist .is-todo b { color: var(--muted); font-weight: 500; }
@media (prefers-reduced-motion: reduce) { .run-checklist .is-now i { animation: none; border-color: var(--accent); background: var(--accent-soft); } }
.detail .run-note { margin: 12px 0 0; }
.detail .run-start { margin-top: 12px; }
.detail details { margin-top: 10px; font-size: 12.5px; }
.detail details p { margin: 4px 0 0; overflow-wrap: anywhere; }
.detail .run-links { margin: 0; font-size: 12.5px; }
.detail .run-links a { color: var(--accent); text-decoration: none; }
.slot-line.is-busy { color: var(--partial); }
.slot-line.is-low { color: var(--contest); }
.slot-line.is-empty { color: var(--faint); }
/* One mark per lane: free (outlined), in use (filled amber), low (red), empty (faint). */
.lane-summary { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.lane-strip { display: inline-flex; flex-wrap: wrap; gap: 2px; max-width: 220px; }
.lane-strip i { width: 7px; height: 7px; border-radius: 2px; border: 1.2px solid var(--up); }
.lane-strip i.is-busy { background: var(--partial); border-color: var(--partial); }
.lane-strip i.is-low { border-color: var(--contest); }
.lane-strip i.is-empty { border-color: var(--ink-faint); }
.detail details.lane-all { margin-top: 4px; }
.detail details.lane-all summary { cursor: pointer; color: var(--muted); }
.detail .run-history { margin-top: 14px; }
.detail .run-history ol { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 2px; }

/* ---- How it works: one experiment, start to finish ---------------------------- */

.how-layout { max-width: 760px; margin: 0 auto; padding: 40px 24px 96px; }
.how .eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.how h1 { text-wrap: balance; }
.how h2 { display: flex; align-items: center; gap: 10px; }
.how section { scroll-margin-top: 72px; }
.step-no { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 650; flex: none; }
.how-steps { list-style: none; padding: 0; margin: 22px 0 8px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; counter-reset: step; }
.how-steps li { counter-increment: step; }
.how-steps a { display: grid; gap: 1px; height: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); text-decoration: none; transition: border-color 160ms var(--ease), transform 160ms var(--ease); }
.how-steps a:hover { border-color: var(--accent); transform: translateY(-1px); }
.how-steps b::before { content: counter(step) "  "; color: var(--accent); }
.how-steps span { color: var(--muted); font-size: 13px; }
.how .ask { margin: 12px 0; padding: 12px 16px; border-radius: 14px 14px 14px 4px; background: var(--user); font-size: 15.5px; line-height: 1.5; }
.how-notes { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 16px 0; font-size: 14.5px; }
.how-notes dt { padding-top: 1px; }
.how-notes dd { margin: 0; color: var(--muted); }
.how-graph { position: relative; height: 280px; margin: 14px 0 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); overflow: hidden; display: flex; }
.how-graph .graph-stage { flex: 1; }
.how-legend { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 8px; font-size: 14px; color: var(--muted); }
.how-legend li { display: flex; gap: 10px; align-items: baseline; }
.how-legend .sw { flex: none; }
.how-legend b { color: var(--text); font-weight: 600; }
.how .run-steps { padding-left: 20px; }
.how .run-steps li { margin-bottom: 8px; }
.how .state { display: inline-block; padding: 0 7px; border-radius: 6px; font-size: 13.5px; white-space: nowrap; }
.how .state.accepted { border: 1.4px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.how .state.landed { border: 1.4px solid var(--up); background: color-mix(in srgb, var(--up) 10%, var(--panel)); }
.how .state.rejected { border: 1.4px solid var(--contest); background: color-mix(in srgb, var(--contest) 9%, var(--panel)); }
.how .state:is(.dropped, .unlanded) { border: 1.4px dashed var(--ink-line); color: var(--muted); }
.how-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 18px; color: var(--muted); font-size: 14px; }
.how .how-open { display: inline-flex; align-items: center; padding: 8px 14px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 14px; text-decoration: none; transition: transform 160ms var(--ease), box-shadow 160ms var(--ease); }
.how .how-open:hover { transform: translateY(-1px); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 30%, transparent); }
.how-variants { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.how-variant { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.how-variant h3 { margin: 0; font-size: 15px; }
.how-variant p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.how .how-diff { margin: 0; padding: 8px 10px; font-size: 11.5px; overflow-x: auto; }
.how .how-diff .line { display: block; white-space: pre; }
.how .how-diff .line.removed { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--contest) 60%, transparent); }
.how .how-diff .line.added { margin: 0 -10px; padding: 0 10px; background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 2px 0 0 var(--accent); }
.how-mini { height: 110px; display: grid; place-items: center; }
.how-mini svg { width: 100%; height: 110px; }
.how-mini svg text, .how-mini svg .group-label { display: none; }
.how-mini svg * { vector-effect: non-scaling-stroke; }
.how-variant .how-open { align-self: flex-start; margin-top: auto; padding: 6px 11px; font-size: 13px; }
.how-next { padding-left: 20px; }
.how-next li { margin-bottom: 6px; }
@media (max-width: 860px) {
  .how-variants { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .how-layout { padding: 24px 16px 64px; }
  .how-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .how-notes { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .how-notes dd { margin-bottom: 10px; }
  .how-graph { height: 220px; }
  .hide-narrow, #new { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .how-steps a, .how .how-open { transition: none; }
  .how-steps a:hover, .how .how-open:hover { transform: none; }
}

/* How it works: a run played on the race's graph, with the step it is at
   marked in the list above it. */
.how-run { margin: 18px 0 6px; }
.how-run figcaption { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13.5px; min-height: 2.6em; }
.how-run #run-caption { transition: color 240ms var(--ease); }
.how-run #run-replay { flex: none; padding: 4px 10px; font-size: 13px; }
.how .run-steps li { transition: color 240ms var(--ease); }
.how .run-steps li::marker { transition: color 240ms var(--ease); }
.how .run-steps li.is-current { color: var(--text); }
.how .run-steps li.is-current::marker { color: var(--accent); }
.how .run-steps li.is-current b { color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .how .run-steps li, .how .run-steps li::marker, .how-run #run-caption { transition: none; }
}

/* Sharing a run: an icon by the panel's close button, on each run row and
   in the menu; at the foot of the run view, labelled buttons to share it and,
   once it is over, to download its data. A copied link ticks for a moment. */
.share { display: inline-grid; place-items: center; }
.share-icon { display: inline-grid; place-items: center; }
.share-icon svg { display: block; }
/* Trimmed to the capitals, so centring the label centres what the eye sees
   (the line box sits higher than the letters in most fonts). */
.button-label { text-box: trim-both cap alphabetic; }
.detail-nav .share.copied, .share.copied { color: var(--up); }
.run-share { display: grid; gap: 8px; margin-top: 14px; }
.run-downloads { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.run-share-link, .run-download {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 160ms var(--ease), color 160ms var(--ease), background 160ms var(--ease);
}
.run-share-link { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--accent); }
.run-share-link:hover { background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.run-share-link.copied { border-color: color-mix(in srgb, var(--up) 45%, var(--border)); color: var(--up); }
.run-download:hover { border-color: var(--faint); }
.run-download .share-icon { color: var(--muted); }
.run-history-share { width: 26px; height: 26px; padding: 0; border: none; background: none; color: var(--muted); border-radius: 6px; }
.run-history-share:hover { color: var(--accent); background: var(--bg); }
.library-share:hover { color: var(--accent); }

/* The mempool overlap page (mempools.html). */
.mempools .mp-status { color: var(--muted); font-size: 14px; }
.mp-scroll { overflow-x: auto; }
.mp-heat, .mp-relays { border-collapse: separate; border-spacing: 2px; font-variant-numeric: tabular-nums; font-size: 14px; }
.mp-heat th, .mp-relays th { font-weight: 500; color: var(--muted); text-align: left; padding: 6px 10px; white-space: nowrap; }
.mp-heat td { height: 44px; text-align: center; color: var(--text); background: var(--panel); outline-offset: 1px; }
.mp-heat td.mp-dark { color: var(--on-accent); }
.mp-heat td.mp-self { color: var(--muted); background: transparent; border: 1px dashed var(--border); }
.mp-heat td:hover, .mp-heat td:focus-visible { outline: 2px solid var(--text); }
.mp-heat .mp-corner { font-size: 12px; color: var(--faint); width: 8.5em; }
/* The grid takes the page's width, never more: on a narrow page the names
   shorten and the cells shrink rather than the last columns falling off. */
#heat-area { container-type: inline-size; }
.mp-heat { width: 100%; table-layout: fixed; }
.mp-heat th { overflow: hidden; text-overflow: ellipsis; }
.mp-heat thead th { font-size: 12px; padding: 6px 2px; }
.mp-heat thead th:not(.mp-corner) { text-align: center; }
.mp-heat .mp-corner { white-space: normal; line-height: 1.3; padding-left: 10px; }
.mp-short { display: none; text-decoration: none; }
@container (max-width: 700px) {
  .mp-heat { font-size: 12px; border-spacing: 1px; }
  .mp-heat th { padding: 4px 2px; }
  .mp-heat td { height: 36px; }
  .mp-heat .mp-corner { width: 3.6em; }
  .mp-heat .mp-full { display: none; }
  .mp-heat .mp-short { display: inline; }
}
.mp-readout { color: var(--muted); font-size: 14px; min-height: 1.6em; }
.mp-chart { margin: 0; position: relative; }
.mp-chart svg { width: 100%; height: auto; display: block; }
.mp-grid { stroke: var(--border); stroke-width: 1; }
.mp-tick { fill: var(--muted); font-size: 11px; }
.mp-band { fill: color-mix(in oklab, var(--accent) 18%, transparent); }
.mp-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.mp-dot { fill: var(--accent); stroke: var(--bg); stroke-width: 2; }
.mp-guide { stroke: var(--faint); stroke-width: 1; }
.mp-tip { position: absolute; top: 4px; right: 12px; font-size: 13px; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; }
.mp-chart .mp-legend { margin-top: 4px; }
.mp-key-line { display: inline-block; width: 16px; height: 2px; background: var(--accent); vertical-align: middle; }
.mp-key-band { display: inline-block; width: 16px; height: 10px; margin-left: 10px; background: color-mix(in oklab, var(--accent) 18%, transparent); vertical-align: middle; }
/* EB tx sources: one hue each, checked for colour-blind separation in both
   themes; segments are also labelled and gapped. */
.mempools { --mp-mempool: #7434d4; --mp-cache: #3a8fd6; --mp-fetched: #d98b12; --mp-alone: #2e9b62; --mp-waiting: #d6457a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mempools { --mp-mempool: #9470e0; --mp-cache: #2a96b8; --mp-fetched: #c48522; --mp-alone: #3fae74; --mp-waiting: #e0628f; }
}
:root[data-theme="dark"] .mempools { --mp-mempool: #9470e0; --mp-cache: #2a96b8; --mp-fetched: #c48522; --mp-alone: #3fae74; --mp-waiting: #e0628f; }
.mp-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.mp-legend span { display: inline-flex; align-items: center; gap: 6px; }
.mp-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.mp-s-mempool { background: var(--mp-mempool); }
.mp-s-cache { background: var(--mp-cache); }
.mp-s-fetched { background: var(--mp-fetched); }
.mp-relays { width: 100%; }
.mp-relays td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.mp-relays th[scope="row"] { color: var(--text); }
.mp-relays td.mp-eb { width: 50%; min-width: 180px; }
.mp-relays td.mp-n { text-align: right; color: var(--muted); }
.mp-fill-wrap { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.mp-fill { flex: 0 0 72px; height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; }
.mp-fill span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.mp-fill-cache span { background: var(--mp-cache); }
.mp-fill-wrap + .mp-fill-wrap { margin-top: 6px; }
.mp-num { font-size: 13px; color: var(--muted); white-space: nowrap; }
.mp-bar { display: flex; gap: 2px; height: 22px; }
.mp-seg { display: flex; align-items: center; justify-content: center; min-width: 2px; font-size: 12px; color: #fff; border-radius: 4px; overflow: hidden; }
.mp-none { color: var(--faint); font-size: 13px; }
.mp-wait { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px dashed var(--border); border-radius: 10px; font-size: 14px; color: var(--muted); }
.mp-wait strong { color: var(--text); font-weight: 600; }
.mp-aside { font-size: 13px; color: var(--muted); }
.mp-notes { margin-top: 40px; font-size: 14px; color: var(--muted); }
.mp-seg { font-weight: 600; }
.mp-seg.mp-s-fetched { color: #1c1c1e; }
.mp-chart .mp-legend { display: block; }
/* In dark the cells lighten as they fill, so their text stays light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mp-heat td.mp-dark { color: var(--text); }
}
:root[data-theme="dark"] .mp-heat td.mp-dark { color: var(--text); }
.mp-fill-wrap[hidden], .mp-bar[hidden], .mp-none[hidden], .mp-aside[hidden] { display: none; }
.mp-seg.mp-zero { min-width: 0; margin-left: -2px; }
.mp-seg .t-digit-group { overflow: hidden; }

/* Tx by tx: a column per sampled tx, a row per relay. */
.mp-tile-sum { font-size: 14px; color: var(--muted); }
.mp-tile-sum strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.mp-tiles { display: grid; grid-template-columns: max-content repeat(var(--cols), minmax(0, 1fr)) max-content; gap: 2px 1px; align-items: center; font-size: 13px; }
.mp-tile-label { color: var(--muted); padding-right: 10px; white-space: nowrap; }
.mp-tile-only { color: var(--muted); padding-left: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 6.5em; }
.mp-tile { display: block; height: 16px; background: color-mix(in oklab, var(--mp-fetched) 55%, var(--panel)); transition: opacity var(--duration-quick) var(--ease); }
.mp-tile.is-held { background: var(--mp-mempool); }
.mp-tile.is-alone { background: var(--mp-alone); }
.mp-tiles:hover .mp-tile:not(.is-col) { opacity: 0.55; }
.mp-swatch.mp-tile { height: 10px; }
/* The family tree. */
.mp-tree-sum { font-size: 14px; color: var(--muted); }
.mp-tree-label { fill: var(--text); font-size: 13px; }
.mp-tree-label.is-on { font-weight: 600; }
.mp-tree-leaf { fill: var(--muted); }
.mp-tree-arm { fill: none; stroke: color-mix(in oklab, var(--accent) var(--mix), var(--border)); stroke-width: 2; stroke-linejoin: round; }
.mp-tree-node { fill: color-mix(in oklab, var(--accent) var(--mix), var(--border)); stroke: var(--bg); stroke-width: 2; }
.mp-tree-hit { fill: transparent; }
.mp-tree-join { outline: none; cursor: default; }
.mp-tree-join.is-on .mp-tree-arm, .mp-tree-join:focus-visible .mp-tree-arm { stroke: var(--text); stroke-width: 3; }
.mp-tree-join.is-on .mp-tree-node, .mp-tree-join:focus-visible .mp-tree-node { fill: var(--text); }
/* How long txs wait. */
.mp-sum { font-size: 14px; color: var(--muted); }
.mp-wait-label { fill: var(--text); font-size: 13px; }
.mp-wait-hit { fill: transparent; }
.mp-s-landed { background: var(--mp-mempool); }
.mp-s-waiting { background: var(--mp-waiting); }
.mp-wait-landed { stroke: var(--mp-mempool); stroke-width: 6; stroke-linecap: round; opacity: 0.55; }
.mp-wait-dot { fill: var(--mp-mempool); stroke: var(--bg); stroke-width: 2; }
.mp-wait-waiting { stroke: var(--mp-waiting); stroke-width: 4; stroke-linecap: round; }
.mp-wait-end { fill: var(--mp-waiting); }
.mp-wait-row { outline: none; }
.mp-wait-row.is-on .mp-wait-hit, .mp-wait-row:focus-visible .mp-wait-hit { fill: color-mix(in oklab, var(--text) 6%, transparent); }
.mp-wait-row.is-on .mp-wait-label { font-weight: 600; }

/* The Chain tab (blocks.js): ranking blocks in a row, each endorser block
   under the RB that certified it; picking one opens its totals below. RBs are
   blue (the spec's reference colour), EBs the accent and dashed. */
:root { --rb: var(--y-ref); --eb: var(--accent); }
.block-kind { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; padding: 1px 6px; border-radius: 5px; }
.block-kind.is-rb { color: var(--rb); background: color-mix(in srgb, var(--rb) 12%, var(--panel)); }
.block-kind.is-eb { color: var(--eb); background: var(--accent-soft); }
.chain-view { display: flex; flex-direction: column; min-height: 0; overflow: auto; }
.chain-scroll { overflow-x: auto; padding: 6px 2px 14px; }
.chain-row { display: flex; align-items: flex-start; gap: 0; width: max-content; }
.chain-col { display: flex; flex-direction: column; align-items: stretch; position: relative; padding-right: 30px; }
.chain-col:not(:last-child)::after { content: ""; position: absolute; top: 34px; right: 0; width: 30px; border-top: 1.5px solid var(--ink-line); }
.chain-tie { align-self: center; font-size: 11px; color: var(--muted); padding: 4px 0 4px 12px; border-left: 1.5px dashed var(--eb); margin: 2px 0; }
.chain-block { width: 138px; display: grid; gap: 3px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--text); text-align: left; cursor: pointer; font: inherit; box-shadow: none; transition: border-color 200ms var(--acc-ease), box-shadow 200ms var(--acc-ease); }
.chain-block.is-rb { border-top: 3px solid var(--rb); }
.chain-block.is-eb { border: 1px dashed var(--eb); border-top: 3px dashed var(--eb); }
.chain-block:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.chain-block[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chain-block:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chain-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.chain-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chain-fee { font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chain-fee small { font-weight: 500; font-size: 11px; color: var(--muted); margin-left: 3px; }
.chain-fee.is-big { font-size: 20px; }
.chain-count { font-size: 11.5px; color: var(--muted); }
.chain-empty { color: var(--muted); font-size: 13px; margin: 8px 2px; }
.chain-panel { border-top: 1px solid var(--border); }
.chain-detail { display: grid; gap: 8px; padding: 12px 2px 4px; max-width: 640px; }
.chain-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.chain-sub, .chain-where { font-size: 12.5px; color: var(--muted); margin: 0; }
.chain-where a { color: var(--accent); text-decoration: none; }
.chain-where a:hover { text-decoration: underline; }
.chain-hash { font-size: 11.5px; overflow-wrap: anywhere; }
.chain-facts { display: grid; gap: 8px; padding: 4px 0; }
.chain-fact { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 12.5px; }
.chain-k { color: var(--muted); }
.chain-v { min-width: 15ch; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.chain-v.is-left { text-align: left; min-width: 0; }
.chain-bar { height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
.chain-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--accent); }
.chain-bar i.is-high { background: var(--partial); }
.chain-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.chain-links button { border: 0; box-shadow: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; padding: 2px 8px; border-radius: 6px; cursor: pointer; }
.chain-tx { color: var(--accent); background: var(--accent-soft); }
.chain-pattern { color: var(--text); background: var(--bg); outline: 1px solid var(--border); }
.chain-links button:hover { text-decoration: underline; }
@media (max-width: 560px) { .chain-fact { grid-template-columns: 1fr auto; } .chain-fact .chain-bar { grid-column: 1 / -1; grid-row: 2; } }
/* On the graph: the kind of block a landed tx is in, which opens it in the Chain tab. */
svg .block-mark { cursor: pointer; animation: fade 320ms var(--ease) both; }
svg .block-mark rect { stroke-width: 1; transition: stroke-width 150ms var(--ease); }
svg .block-mark text { font-size: 7.5px; font-weight: 700; letter-spacing: 0.04em; font-family: ui-sans-serif, system-ui, sans-serif; }
svg .block-mark[data-kind="rb"] rect { fill: color-mix(in srgb, var(--rb) 12%, var(--panel)); stroke: var(--rb); }
svg .block-mark[data-kind="rb"] text { fill: var(--rb); }
svg .block-mark[data-kind="eb"] rect { fill: var(--accent-soft); stroke: var(--eb); stroke-dasharray: 2 1.5; }
svg .block-mark[data-kind="eb"] text { fill: var(--eb); }
svg .block-mark:hover rect, svg .block-mark:focus-visible rect { stroke-width: 1.8; }
svg .block-mark:focus-visible { outline: none; }
/* Under the spec: where each pattern landed. */
.spec-landed { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; font-size: 12.5px; }
.spec-landed p { margin: 0 0 6px; color: var(--muted); }
.spec-landed ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.spec-landed li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.spec-landed button { font: inherit; font-size: 11.5px; cursor: pointer; box-shadow: none; }
.spec-landed-pattern { font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important; border: 0; background: none; color: var(--text); padding: 0 4px 0 0; min-width: 6em; text-align: left; }
.spec-landed-pattern:hover { color: var(--accent); }
.spec-landed-block { border-radius: 99px; padding: 0 8px; border: 1px solid; }
.spec-landed-block.is-rb { color: var(--rb); border-color: var(--rb); background: color-mix(in srgb, var(--rb) 10%, var(--panel)); }
.spec-landed-block.is-eb { color: var(--eb); border-color: var(--eb); border-style: dashed; background: var(--accent-soft); }

/* Motion, after transitions.dev: one set of tokens for every page. */
:root {
  --duration-quick: 150ms;
  --digit-dur: 500ms;
  --digit-distance: 8px;
  --digit-stagger: 70ms;
  --digit-blur: 2px;
  --digit-ease: cubic-bezier(0.34, 1.45, 0.64, 1);
  --digit-dir-x: 0;
  --digit-dir-y: 1;
  --resize-dur: 300ms;
  --resize-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --acc-expand: 250ms;
  --acc-collapse: 250ms;
  --acc-chevron: 250ms;
  --acc-ease: cubic-bezier(0.22, 1, 0.36, 1);
}
/* Number pop-in: the digits that changed slide in, blurred, with a bounce. */
@keyframes t-digit-pop-in {
  0% { transform: translate(calc(var(--digit-distance) * var(--digit-dir-x)), calc(var(--digit-distance) * var(--digit-dir-y))); opacity: 0; filter: blur(var(--digit-blur)); }
  100% { transform: translate(0, 0); opacity: 1; filter: blur(0); }
}
.t-digit-group { display: inline-flex; align-items: baseline; }
.t-digit { display: inline-block; white-space: pre; will-change: transform, opacity, filter; }
.t-digit-group.is-animating .t-digit { animation: t-digit-pop-in var(--digit-dur) var(--digit-ease) both; }
.t-digit-group.is-animating .t-digit[data-stagger="1"] { animation-delay: var(--digit-stagger); }
.t-digit-group.is-animating .t-digit[data-stagger="2"] { animation-delay: calc(var(--digit-stagger) * 2); }
.t-digit-group.is-animating .t-digit[data-same] { animation: none; }
/* Card resize: bars ease to each new reading. */
.t-resize, .mp-seg { transition: width var(--resize-dur) var(--resize-ease), flex-grow var(--resize-dur) var(--resize-ease), margin var(--resize-dur) var(--resize-ease); }
.mp-heat td { transition: background var(--resize-dur) var(--resize-ease), color var(--resize-dur) var(--resize-ease); }
/* Accordion expand: the notes grow open via grid rows, the chevron flips. */
.t-acc-head { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer; }
.t-acc-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--acc-collapse) var(--acc-ease); }
.t-acc[data-open="true"] .t-acc-panel { grid-template-rows: 1fr; transition: grid-template-rows var(--acc-expand) var(--acc-ease); }
.t-acc-panel-inner { overflow: hidden; opacity: 0; filter: blur(2px); transition: opacity var(--acc-collapse) var(--acc-ease), filter var(--acc-collapse) var(--acc-ease); }
.t-acc[data-open="true"] .t-acc-panel-inner { opacity: 1; filter: blur(0); transition: opacity var(--acc-expand) var(--acc-ease), filter var(--acc-expand) var(--acc-ease); }
.t-acc-chevron { display: inline-flex; transform: scaleY(1); transform-origin: center; transition: transform var(--acc-chevron) var(--acc-ease); }
.t-acc-chevron path { vector-effect: non-scaling-stroke; }
.t-acc[data-open="true"] .t-acc-chevron { transform: scaleY(-1); }
@media (prefers-reduced-motion: reduce) {
  .t-digit-group .t-digit { animation: none !important; }
  .t-resize, .mp-seg, .mp-heat td, .mp-tile,
  .t-acc-panel, .t-acc-panel-inner, .t-acc-chevron, .chain-block { transition: none !important; }
}
.mp-status .t-digit-group { flex-wrap: wrap; }
/* On a narrow page the relay table fits too: numbers under their bars, and
   the EB count, which the stacked bar's title also gives, left out. */
#relays { container-type: inline-size; }
@container (max-width: 600px) {
  .mp-relays { font-size: 13px; }
  .mp-relays th, .mp-relays td { padding-left: 4px; padding-right: 4px; }
  .mp-fill-wrap { flex-wrap: wrap; gap: 2px 8px; min-width: 0; }
  .mp-relays td.mp-eb { width: auto; min-width: 0; }
  .mp-relays tr > :last-child { display: none; }
}
