/* Shortage Bridge recorded-run viewer. Colours, type and spacing live in the tokens below; components read var(--…). */
@font-face { font-family: "Figtree"; src: url("assets/fonts/figtree-latin.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("assets/fonts/geist-mono-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --font: "Figtree", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  --h1: clamp(2.6rem, 1.4rem + 4.6vw, 5.5rem);
  --h2: clamp(1.625rem, 1.3rem + 1.2vw, 2.2rem);
  --h3: 1.375rem;
  --body: clamp(1rem, 0.96rem + 0.18vw, 1.1rem);
  --small: clamp(0.75rem, 0.73rem + 0.08vw, 0.8rem);
  --u: 8px;
  --section: 65px;
  --max: 1280px;
  --radius: 14px;
  --radius-sm: 8px;

  --bg: #fffcf6;
  --ink: #181818;
  --muted: #55524c;
  --soft: #ffdfd4;
  --line: #e3e1db;
  --panel: #fff;
  --accent: #ff2f00;
  --on-accent: #fff;
  --a: #c42400;          /* plant A text on paper */
  --a-fill: #ff2f00;     /* plant A marks */
  --a-tint: #ffe9e2;
  --b: #0c6e58;          /* plant B text on paper */
  --b-fill: #129c7d;
  --b-tint: #def3ec;
  --ok: #0c6e58;
  --bad: #c42400;
  --shadow: 0 10px 30px -12px rgba(24, 24, 24, 0.22);
  --world-sky: #fff6ea;
  --world-ground: #efe7d8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1010; --ink: #fafafa; --muted: #a9b1ae; --soft: #2d140e; --line: #282c2c; --panel: #121818;
    --a: #ff7a59; --a-fill: #ff4a1f; --a-tint: #2d140e; --b: #5fd4b4; --b-fill: #2fb894; --b-tint: #0f2a24;
    --ok: #5fd4b4; --bad: #ff7a59; --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
    --world-sky: #0f1717; --world-ground: #182222;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1010; --ink: #fafafa; --muted: #a9b1ae; --soft: #2d140e; --line: #282c2c; --panel: #121818;
  --a: #ff7a59; --a-fill: #ff4a1f; --a-tint: #2d140e; --b: #5fd4b4; --b-fill: #2fb894; --b-tint: #0f2a24;
  --ok: #5fd4b4; --bad: #ff7a59; --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
  --world-sky: #0f1717; --world-ground: #182222;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--body)/1.55 var(--font); overflow-x: hidden; }
::selection { background: var(--accent); color: var(--on-accent); }
a { color: inherit; text-underline-offset: 0.2em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
img, canvas { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.05; text-wrap: balance; }
h2 { font-size: var(--h2); font-weight: 750; letter-spacing: -0.02em; }
h3 { font-size: var(--h3); font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
code, pre, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: calc(var(--u) * 2); top: calc(var(--u) * 2); background: var(--panel); padding: var(--u) calc(var(--u) * 2); z-index: 10; }

/* Header: solid, no glass. */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: calc(var(--u) * 3); padding: calc(var(--u) * 1.5) clamp(16px, 4vw, 40px); }
.mark { display: flex; align-items: center; gap: var(--u); text-decoration: none; font-weight: 800; letter-spacing: -0.02em; font-size: 1.1rem; min-width: 0; }
.mark img { border-radius: 9px; flex: none; }
.nav { display: flex; gap: calc(var(--u) * 3); margin-left: auto; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 600; padding: var(--u) 0; }
.nav a:hover { color: var(--ink); }
.tools { display: flex; gap: var(--u); align-items: center; }
.chip-btn, .icon-btn, .mini-btn { font: inherit; color: var(--ink); background: transparent; border: 1px solid var(--line); cursor: pointer; }
.chip-btn { min-width: 44px; height: 44px; border-radius: 999px; font-weight: 700; font-size: 0.9rem; padding: 0 var(--u); }
.icon-btn { width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center; }
.chip-btn:hover, .icon-btn:hover { border-color: var(--ink); }

main, .foot { max-width: var(--max); margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }

/* Hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px);
  align-items: center; padding: calc(var(--section) * 0.9) 0 var(--section); }
.kinetic { font-size: var(--h1); font-weight: 850; letter-spacing: -0.04em; line-height: 0.94; }
.kinetic .w { display: inline-block; opacity: 0; transform: translateY(0.35em); animation: rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .kinetic .w { animation: none; opacity: 1; transform: none; } }
.lede { margin-top: calc(var(--u) * 3); max-width: 60ch; color: var(--muted); font-size: 1.08em; }
.actions { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 1.5); margin-top: calc(var(--u) * 4); }
.btn { display: inline-flex; align-items: center; min-height: 48px; padding: 0 calc(var(--u) * 3); border-radius: 999px;
  font-weight: 700; text-decoration: none; border: 2px solid transparent; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--ink); color: var(--bg); }
.btn-line { border-color: var(--ink); }
.btn-line:hover { background: var(--ink); color: var(--bg); }

/* Browser frame around the replay */
.frame { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow);
  overflow: hidden; min-width: 0; }
.frame-bar { display: flex; align-items: center; gap: calc(var(--u) * 1.5); padding: var(--u) calc(var(--u) * 1.5); border-bottom: 1px solid var(--line); }
.dots { display: flex; gap: 6px; flex: none; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.frame-title { font-size: var(--small); color: var(--muted); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-btn { border-radius: 999px; font-size: var(--small); font-weight: 700; min-height: 32px; padding: 0 calc(var(--u) * 1.5); }
#world { width: 100%; height: auto; aspect-ratio: 2 / 1; background: var(--world-sky); }
.ticker { list-style: none; margin: 0; padding: calc(var(--u) * 1.5); font-family: var(--mono); font-size: var(--small);
  height: calc(5 * 1.9em + var(--u) * 3); overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
  border-top: 1px solid var(--line); }
.ticker li { display: flex; gap: var(--u); white-space: nowrap; min-width: 0; line-height: 1.7; }
.ticker li .t { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ticker li .ms { margin-left: auto; color: var(--muted); flex: none; }
.ticker li.final { color: var(--ok); font-weight: 600; }
.frame-note { font-size: var(--small); color: var(--muted); padding: 0 calc(var(--u) * 1.5) calc(var(--u) * 1.5); }

.sys { display: inline-flex; align-items: center; justify-content: center; flex: none; font-family: var(--mono); font-weight: 700;
  font-size: var(--small); min-width: 1.9em; height: 1.7em; border-radius: 5px; padding: 0 4px; }
.sys-A { background: var(--a-tint); color: var(--a); }
.sys-B { background: var(--b-tint); color: var(--b); }

/* Bands */
.band { padding: var(--section) 0; border-top: 1px solid var(--line); }
.band-head { display: grid; gap: calc(var(--u) * 1.5); max-width: 70ch; margin-bottom: calc(var(--u) * 4); }
.band-head p { color: var(--muted); }

.picker { display: grid; gap: calc(var(--u) * 1.5); margin-bottom: calc(var(--u) * 4); }
.qtabs { display: flex; flex-wrap: wrap; gap: var(--u); }
.qtab { font: inherit; font-weight: 650; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 999px;
  min-height: 44px; padding: 0 calc(var(--u) * 2); cursor: pointer; display: inline-flex; gap: var(--u); align-items: center; }
.qtab .id { font-family: var(--mono); color: var(--muted); }
.qtab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.qtab[aria-selected="true"] .id { color: inherit; }
.qtext { font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem); font-weight: 500; max-width: 68ch; line-height: 1.45; }
.qnote { font-size: var(--small); color: var(--muted); }
.runstrip { display: flex; flex-wrap: wrap; gap: 6px; }
.run { font: 600 var(--small) var(--mono); width: 44px; height: 44px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1.5px solid var(--ok); background: transparent; color: var(--ok); display: grid; place-items: center; }
.run.fail { border-color: var(--bad); color: var(--bad); background: repeating-linear-gradient(135deg, transparent 0 5px, var(--a-tint) 5px 8px); }
.run[aria-pressed="true"] { background: var(--ok); color: var(--bg); }
.run.fail[aria-pressed="true"] { background: var(--bad); color: var(--bg); }

.state { color: var(--muted); }
.state.error { color: var(--bad); }

.trace { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 48px); align-items: start; }
.stats { color: var(--muted); font-size: var(--small); margin: var(--u) 0 calc(var(--u) * 2); font-variant-numeric: tabular-nums; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.turn-head { font-size: var(--small); color: var(--muted); font-weight: 700; padding: calc(var(--u) * 2) 0 var(--u); }
.turn-note { font-size: 0.92em; color: var(--muted); padding: 0 0 var(--u); max-width: 62ch; }
.call { border-top: 1px solid var(--line); padding: calc(var(--u) * 1.25) 0; scroll-margin-top: 96px; }
.call.lit { background: var(--soft); }
.call summary { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: var(--u); align-items: baseline; cursor: pointer; list-style: none; }
.call summary::-webkit-details-marker { display: none; }
.call .n { font-family: var(--mono); font-size: var(--small); color: var(--muted); min-width: 2.2em; }
.call .tool { font-family: var(--mono); font-size: 0.9em; overflow-wrap: anywhere; min-width: 0; }
.call .args { color: var(--muted); }
.call .ms { font-family: var(--mono); font-size: var(--small); color: var(--muted); }
.call pre { margin: var(--u) 0 0; padding: calc(var(--u) * 1.5); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: var(--small); line-height: 1.5; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.call .cut { font-size: var(--small); color: var(--muted); margin-top: 4px; }

.answer-col { position: sticky; top: 88px; min-width: 0; }
.answer { margin-top: calc(var(--u) * 2); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: calc(var(--u) * 2.5); }
.verdict { display: flex; align-items: center; gap: var(--u); font-weight: 750; font-size: 1.15rem; margin-bottom: calc(var(--u) * 2); }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.fields { display: grid; gap: 0; margin: 0; }
.frow { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--u) calc(var(--u) * 1.5); padding: calc(var(--u) * 1.25) 0; border-top: 1px solid var(--line); }
.frow dt { grid-column: 2; font-size: var(--small); color: var(--muted); font-weight: 700; }
.frow .mark-ok, .frow .mark-bad { grid-row: span 2; width: 22px; height: 22px; margin-top: 2px; }
.mark-ok { color: var(--ok); } .mark-bad { color: var(--bad); }
.frow dd { grid-column: 2; margin: 0; font-family: var(--mono); font-size: 0.88em; overflow-wrap: anywhere; min-width: 0; }
.frow dd ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.frow dd .why { font-family: var(--font); color: var(--muted); font-size: 0.95em; }
.frow .want { color: var(--bad); font-size: var(--small); margin-top: 4px; }
.cites { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.cite { font: 600 var(--small) var(--mono); border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 6px;
  min-height: 28px; padding: 0 6px; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.cite:hover { border-color: var(--ink); }
.untraced { color: var(--bad); font-family: var(--font); font-size: var(--small); }
.narr { margin-top: calc(var(--u) * 2); border-top: 1px solid var(--line); padding-top: calc(var(--u) * 2); }
.narr h4 { margin: 0 0 var(--u); font-size: var(--small); color: var(--muted); }
.narr p { font-size: 0.96em; }
.trace-file { margin-top: calc(var(--u) * 1.5); font-size: var(--small); color: var(--muted); overflow-wrap: anywhere; }

/* Live update */
.update { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(16px, 3vw, 32px); }
.side { border: 1px solid var(--line); border-radius: var(--radius); padding: calc(var(--u) * 2.5); background: var(--panel); min-width: 0; }
.side h3 { display: flex; align-items: baseline; gap: var(--u); }
.side .count { font-family: var(--mono); font-size: 2.6rem; font-weight: 600; letter-spacing: -0.04em; color: var(--b); line-height: 1; margin: calc(var(--u) * 2) 0 var(--u); }
.side .count small { font-family: var(--font); font-size: var(--small); color: var(--muted); letter-spacing: 0; font-weight: 600; margin-left: var(--u); }
.toollist { list-style: none; margin: 0 0 calc(var(--u) * 2); padding: 0; display: grid; gap: 4px; font-family: var(--mono); font-size: 0.85em; }
.toollist li { display: flex; gap: var(--u); align-items: center; overflow-wrap: anywhere; min-width: 0; }
.toollist .new { color: var(--a); font-family: var(--font); font-weight: 750; font-size: var(--small); border: 1px solid currentColor; border-radius: 999px; padding: 0 8px; flex: none; }
.side dl { margin: 0; display: grid; gap: var(--u); border-top: 1px solid var(--line); padding-top: calc(var(--u) * 2); }
.side dt { font-size: var(--small); color: var(--muted); font-weight: 700; }
.side dd { margin: 0; font-family: var(--mono); font-size: 0.88em; overflow-wrap: anywhere; }
.side dd.changed { color: var(--a); font-weight: 600; }
.qchip { font-family: var(--mono); font-size: var(--small); font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; }
.update-note { grid-column: 1 / -1; color: var(--muted); font-size: var(--small); }

/* Numbers */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: calc(var(--u) * 2); }
.numbers { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; min-width: 560px; }
.numbers th, .numbers td { text-align: right; padding: calc(var(--u) * 1.25) calc(var(--u) * 2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.numbers th:first-child, .numbers td:first-child { text-align: left; }
.numbers thead th { font-size: var(--small); color: var(--muted); font-weight: 700; }
.numbers tbody tr:last-child td { border-bottom: 0; font-weight: 750; }
.numbers td { font-family: var(--mono); font-size: 0.92em; }
.text-link { font-weight: 700; color: var(--a); }

.foot { border-top: 1px solid var(--line); padding-top: calc(var(--u) * 5); padding-bottom: calc(var(--u) * 6); display: grid; gap: var(--u); color: var(--muted); font-size: 0.95em; }
.foot img { border-radius: 7px; margin-bottom: var(--u); }

@media (max-width: 960px) {
  .hero, .trace, .update { grid-template-columns: minmax(0, 1fr); }
  .answer-col { position: static; order: -1; }
  .nav { display: none; }
  .tools { margin-left: auto; }
}
@media (max-width: 420px) {
  .mark span { font-size: 1rem; }
  .call summary { grid-template-columns: auto auto minmax(0, 1fr); }
  .call .ms { grid-column: 3; }
}
