:root {
  color-scheme: dark;
  --bg: #04090d;
  --panel: #09131a;
  --panel-hi: #0d1c25;
  --line: #18303c;
  --line-hi: #275162;
  --ink: #d9e4ee;
  --muted: #708593;
  --cyan: #4de6ff;
  --blue: #668fff;
  --violet: #a875ff;
  --orange: #ffb45e;
  --green: #6ee7ac;
  --red: #ff718d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; background: var(--bg); }
body { padding: 14px 18px 18px; overflow-x: hidden; background-image: radial-gradient(circle at 72% 26%, #0b2630 0, transparent 32%), linear-gradient(#04090d, #050c11); }
button, select, input { font: inherit; }
button, select { color: var(--ink); }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
h1, h2, p { margin: 0; }

.topbar { display: flex; max-width: 1600px; align-items: center; justify-content: space-between; gap: 18px; margin: 0 auto 10px; }
.brand { color: var(--ink); font: 500 21px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.05em; }
.brand span { color: var(--cyan); }
.run-stamp { display: flex; align-items: center; gap: 14px; color: var(--muted); font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; }
.network-badge { border: 1px solid var(--green); padding: 6px 8px 5px; color: var(--green); background: rgba(110,231,172,.06); }

.lifecycle { max-width: 1600px; margin: 0 auto 8px; border: 1px solid var(--line); background: linear-gradient(120deg, rgba(11,27,36,.96), rgba(6,14,20,.98)); }
.state-machine { display: grid; grid-template-columns: repeat(4, 1fr); }
.state-machine button { position: relative; display: grid; min-height: 62px; grid-template-columns: 13px 1fr; grid-template-rows: 1fr 1fr; align-content: center; column-gap: 9px; border: 0; border-right: 1px solid var(--line); padding: 9px 14px; color: var(--muted); background: transparent; text-align: left; cursor: pointer; }
.state-machine button:last-child { border-right: 0; }
.state-machine button::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; content: ""; background: transparent; }
.state-machine button i { grid-row: 1 / 3; align-self: center; width: 8px; height: 8px; border: 1px solid #3b5360; border-radius: 50%; background: #0b1820; }
.state-machine button span { align-self: end; font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.state-machine button small { align-self: start; margin-top: 5px; color: #506875; font: 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; }
.state-machine button.done i { border-color: var(--cyan); background: var(--cyan); box-shadow: 0 0 8px rgba(77,230,255,.5); }
.state-machine button.active { color: var(--ink); background: linear-gradient(90deg, rgba(77,230,255,.09), transparent); }
.state-machine button.active::after { background: var(--cyan); box-shadow: 0 0 12px rgba(77,230,255,.6); }
.state-machine button.active i { border-color: var(--cyan); background: var(--cyan); box-shadow: 0 0 10px rgba(77,230,255,.65); }
.state-caption { display: flex; min-height: 39px; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); padding: 7px 14px; }
.state-caption > div { display: flex; min-width: 0; align-items: center; gap: 10px; }
.state-caption span { color: var(--cyan); font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .09em; }
.state-caption strong { overflow: hidden; color: #a8bac5; font: 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.state-caption time { flex: none; color: var(--muted); font: 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }

.playback { display: grid; max-width: 1600px; grid-template-columns: 72px 34px 82px auto minmax(180px, 1fr) 115px auto; align-items: center; gap: 7px; margin: 0 auto 10px; border: 1px solid var(--line); padding: 7px 9px; background: rgba(7,17,23,.84); }
.playback button, .playback select { height: 29px; border: 1px solid var(--line-hi); background: #0a1922; font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .07em; cursor: pointer; }
.playback button:hover, .playback select:hover { border-color: var(--cyan); }
.playback .primary { border-color: var(--cyan); color: var(--cyan); }
.speed { display: flex; align-items: center; gap: 6px; color: var(--muted); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.speed select { padding: 0 6px; }
#seek { width: 100%; height: 4px; accent-color: var(--cyan); cursor: pointer; }
#clock { color: var(--ink); font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
.timing-badge { border: 1px solid #5b4825; padding: 6px 7px 5px; color: var(--orange); background: rgba(255,180,94,.05); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; white-space: nowrap; }

.replay-grid { display: grid; max-width: 1600px; grid-template-columns: minmax(270px, .82fr) minmax(520px, 1.75fr) minmax(285px, .88fr); gap: 10px; margin: 0 auto; }
.panel { min-width: 0; height: 650px; overflow: hidden; border: 1px solid var(--line); background: linear-gradient(135deg, rgba(11,27,36,.95), rgba(6,14,20,.98)); box-shadow: 0 20px 65px rgba(0,0,0,.17); }
.panel-heading { display: flex; height: 45px; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding: 0 13px; }
.panel-heading > div { display: flex; align-items: center; gap: 8px; }
.panel-heading span { color: var(--cyan); font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.panel-heading h1, .panel-heading h2 { color: var(--ink); font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.panel-heading strong { color: var(--muted); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .07em; }

.transcript-panel { position: relative; display: flex; flex-direction: column; }
.token-section { display: flex; min-height: 0; flex-direction: column; padding: 11px 13px; }
.prompt-section { height: 235px; border-bottom: 1px solid var(--line); }
.output-section { flex: 1; background: linear-gradient(180deg, rgba(168,117,255,.025), transparent); }
.section-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .09em; }
.section-label strong { color: var(--ink); font-size: 8px; }
.token-strip { display: flex; min-height: 0; flex: 1; align-content: flex-start; flex-wrap: wrap; gap: 4px; overflow-y: auto; padding: 10px 2px 2px; scrollbar-color: var(--line-hi) transparent; }
.token { display: inline-flex; min-height: 22px; max-width: 150px; align-items: center; overflow: hidden; border: 1px solid #263e49; padding: 3px 5px; color: #718692; background: #091720; font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: pre; transition: color .08s, background .08s, border-color .08s; }
.token.queued { border-color: #5b4825; color: #a78151; background: #17150f; }
.token.filled { border-color: #895d28; color: var(--orange); background: #241c11; }
.token.active { border-color: var(--cyan); color: #dffbff; background: #0b3a48; box-shadow: 0 0 11px rgba(77,230,255,.35); animation: token-pulse .8s ease-in-out infinite; }
.output-stream { min-height: 0; flex: 1; overflow-y: auto; padding: 11px 12px 35px 2px; color: #eadfff; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; scrollbar-color: var(--violet) transparent; }
.output-token { border-radius: 2px; }
.output-token.latest { color: #fff; outline: 1px solid rgba(77,230,255,.6); background: rgba(77,230,255,.12); }
.transcript-foot { position: absolute; right: 13px; bottom: 10px; left: 13px; display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; color: var(--muted); font: 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.transcript-foot span:first-child { color: var(--cyan); }

.kernel-panel { display: flex; flex-direction: column; }
#execution-view, #commitment-view { min-height: 0; flex: 1; }
.kernel-caption { min-height: 39px; overflow: hidden; border-bottom: 1px solid var(--line); padding: 12px 14px; color: var(--orange); font: 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.kernel-workbench { display: grid; height: 276px; grid-template-columns: 180px 1fr; gap: 10px; border-bottom: 1px solid var(--line); padding: 11px 13px; }
.active-kernel { display: flex; min-width: 0; flex-direction: column; border: 1px solid var(--line-hi); padding: 12px; background: #071117; }
.active-kernel > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.active-kernel span, .active-kernel small, .commitment-heading span, .root-card span, .confirmation-card > span { color: var(--muted); font: 700 8px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.active-kernel strong { color: var(--cyan); font: 700 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.active-kernel code { display: block; overflow: hidden; margin: 19px 0 7px; color: var(--ink); font: 600 17px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.active-kernel small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.position-meter { height: 5px; margin-top: auto; overflow: hidden; border: 1px solid #1c3e4b; background: #081219; }
.position-meter i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--blue)); box-shadow: 0 0 10px rgba(77,230,255,.45); }
.layer-map { min-width: 0; border: 1px solid var(--line); padding: 10px; background: #071117; }
.layer-strips { display: grid; height: 220px; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 5px; padding-top: 9px; }
.layer-strip { position: relative; display: grid; min-width: 0; grid-template-columns: 26px 1fr; align-items: center; gap: 5px; border: 1px solid #17303b; padding: 3px 4px; color: var(--muted); background: #091b24; font: 7px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.layer-strip b { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.layer-strip i { display: block; width: 7%; height: 7px; border-radius: 50%; background: #29414c; }
.layer-strip.done i { background: #397187; }
.layer-strip.active { border-color: var(--cyan); color: var(--ink); box-shadow: 0 0 10px rgba(77,230,255,.16); }
.layer-strip.active i { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.trace-panel { height: 288px; padding: 10px 13px 13px; }
#kernel-trace { display: block; width: 100%; height: 230px; margin-top: 8px; border: 1px solid #17303b; background: #050e13; }

.commitment-view { padding: 14px; }
.commitment-heading { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.commitment-heading strong { color: var(--cyan); }
.position-roots { display: grid; height: 206px; grid-template-columns: repeat(49, minmax(0, 1fr)); grid-template-rows: repeat(13, 1fr); gap: 3px; margin-top: 13px; padding: 10px; border: 1px solid var(--line); background: #071117; }
.position-root { min-width: 0; border: 1px solid #1c5868; background: rgba(77,230,255,.18); }
.position-root:nth-child(9n) { background: rgba(102,143,255,.2); }
.fold-arrow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; height: 40px; color: var(--muted); font: 700 7px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.fold-arrow i { height: 1px; background: linear-gradient(90deg, transparent, var(--line-hi)); }
.fold-arrow i:last-child { background: linear-gradient(90deg, var(--line-hi), transparent); }
.fold-groups { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; }
.fold-group { min-width: 0; border: 1px solid #315b69; padding: 7px 4px; color: var(--muted); background: #0a1b24; font: 7px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; }
.fold-group b { display: block; margin-top: 3px; color: var(--ink); font-size: 7px; }
.document-root { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 9px; margin-top: 12px; border: 1px solid #27616f; padding: 12px; background: rgba(77,230,255,.07); }
.document-root span { color: var(--muted); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.document-root code { overflow: hidden; color: var(--cyan); font: 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.document-root small { color: var(--green); font: 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }

.rail-panel { display: flex; flex-direction: column; }
.cursor-grid { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.cursor-grid > div { min-width: 0; min-height: 66px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px; }
.cursor-grid > div:nth-child(2n) { border-right: 0; }
.cursor-grid span { display: block; margin-bottom: 7px; color: var(--muted); font: 700 7px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.cursor-grid strong { display: block; overflow: hidden; color: var(--ink); font: 600 12px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.challenge-card { display: grid; grid-template-columns: 55px 1fr; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding: 15px 13px; }
.countdown-ring { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 50%; background: conic-gradient(var(--orange) var(--fill, 100%), #1b303a 0); }
.countdown-ring::after { width: 42px; height: 42px; border-radius: 50%; content: ""; background: #08141b; }
.challenge-card span, .challenge-card small { display: block; color: var(--muted); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .07em; }
.challenge-card strong { display: block; margin: 5px 0; color: var(--orange); font: 500 25px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.05em; }
.dispute-events { border-bottom: 1px solid var(--line); }
.dispute-events article { display: grid; min-height: 61px; grid-template-columns: 8px 1fr auto; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); padding: 9px 12px; opacity: .2; transition: opacity .25s, background .25s; }
.dispute-events article:last-child { border-bottom: 0; }
.dispute-events article.visible { opacity: 1; background: rgba(110,231,172,.035); }
.dispute-events i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(110,231,172,.5); }
.dispute-events span { display: block; color: var(--muted); font: 7px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.dispute-events strong { display: block; margin-top: 5px; color: var(--ink); font: 9px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.dispute-events a { color: var(--cyan); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-decoration: none; }
.confirmation-card { border-bottom: 1px solid var(--line); padding: 15px 13px; background: rgba(110,231,172,.05); }
.confirmation-card strong { display: block; margin: 8px 0; color: var(--green); font: 700 17px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.confirmation-card p { color: #a8bac5; font: 9px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.confirmation-card a { display: inline-block; margin-top: 12px; color: var(--cyan); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.root-card { display: grid; grid-template-columns: 88px 1fr; align-items: center; gap: 7px 9px; border-bottom: 1px solid var(--line); padding: 12px; }
.root-card code { overflow: hidden; color: var(--ink); font: 8px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.details { margin-top: auto; color: var(--muted); font: 8px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; }
.details summary { padding: 12px; color: var(--muted); cursor: pointer; letter-spacing: .06em; }
.details dl { margin: 0; border-top: 1px solid var(--line); }
.details dl div { display: grid; grid-template-columns: 90px 1fr; gap: 8px; border-bottom: 1px solid var(--line); padding: 8px 12px; }
.details dt { color: var(--muted); }
.details dd { overflow-wrap: anywhere; margin: 0; color: var(--ink); }
.error { max-width: 1600px; margin: 8px auto 0; border: 1px solid var(--red); padding: 10px; color: #ffc0cc; background: rgba(255,113,141,.08); font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }

body[data-state="committed"] #execution-view, body[data-state="challenge"] #execution-view, body[data-state="confirmed"] #execution-view { display: none; }
body[data-state="generating"] #commitment-view { display: none; }
#commitment-view[hidden] { display: none; }

@keyframes token-pulse { 0%, 100% { box-shadow: 0 0 0 rgba(77,230,255,0); } 50% { box-shadow: 0 0 13px rgba(77,230,255,.5); } }

@media (max-width: 1120px) {
  .replay-grid { grid-template-columns: 270px 1fr; }
  .rail-panel { grid-column: 1 / -1; height: auto; min-height: 310px; }
  .rail-panel .cursor-grid { grid-template-columns: repeat(4, 1fr); }
  .rail-panel .cursor-grid > div { border-bottom: 0; }
  .details { margin-top: 0; }
}

@media (max-width: 720px) {
  body { padding: 8px; }
  .run-stamp span:not(.network-badge) { display: none; }
  .state-machine button { min-height: 56px; grid-template-columns: 9px 1fr; padding: 7px; }
  .state-machine button small { display: none; }
  .state-caption strong { display: none; }
  .playback { grid-template-columns: 70px 32px 75px 1fr; }
  .speed, #clock, .timing-badge { grid-column: 1 / -1; }
  .replay-grid { display: flex; flex-direction: column; }
  .panel { height: 620px; }
  .kernel-workbench { grid-template-columns: 1fr; height: auto; }
  .active-kernel { min-height: 140px; }
  .layer-strips { height: 170px; grid-template-columns: repeat(2, 1fr); }
  .trace-panel { height: 245px; }
  #kernel-trace { height: 185px; }
  .position-roots { grid-template-columns: repeat(32, 1fr); grid-template-rows: repeat(20, 1fr); }
  .fold-groups { grid-template-columns: repeat(4, 1fr); }
}
.md-bold { font-weight: 700; color: #fff; }
.output-token.eot { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid var(--violet); border-radius: 3px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--violet); }
.document-root a { color: var(--green); font: 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-decoration: none; }
.document-root a:hover { text-decoration: underline; }
.mmr { display: flex; gap: 5px; margin-top: 10px; position: relative; }
.mmr-column { flex: 1 1 0; min-width: 0; display: grid; gap: 5px; align-content: start; }
.mmr-children { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
.mmr-node { min-width: 0; border: 1px solid #315b69; background: #0a1b24; padding: 6px 5px; display: grid; gap: 3px; text-align: center; }
.mmr-node.peak { border-color: #27616f; background: rgba(77,230,255,.06); }
.mmr-node span { color: var(--ink); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mmr-node code { color: var(--cyan); font: 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mmr-children .mmr-node span, .mmr-children .mmr-node code { font-size: 7px; }
