/* zorch playground — "proving instrument"
   A warm technical plate with a dark editor inset. Monospace carries the
   readout; a cobalt signal marks activity; verified-green appears only on an
   accepted proof. The signature is the execution gauge + the round ticks,
   whose count equals the sumcheck rounds (LOG_N). */

:root {
  --plate:   #ece7db;   /* warm instrument plate */
  --plate-2: #e3ddcd;   /* recessed panel */
  --ink:     #17181e;   /* editor ground */
  --ink-2:   #1e1f28;   /* editor gutter */
  --text:    #1b1c22;   /* on plate */
  --text-inv:#e8e7ea;   /* on ink */
  --muted:   #736c5b;   /* labels on plate */
  --muted-2: #8b8397;   /* dim on ink */
  --line:    #cfc6b1;   /* hairline on plate */
  --signal:  #2f2bd4;   /* cobalt — active / accent */
  --signal-ink:#8f8cff; /* signal legible on ink */
  --verify:  #0d7a49;   /* accepted proof only */
  --reject:  #c23a2b;

  --mono: "SFMono-Regular", "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--plate);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ---- top bar ---------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.wordmark { font-family: var(--mono); letter-spacing: -0.01em; }
.wordmark b { font-weight: 600; }
.wordmark span { color: var(--muted); margin-left: 6px; font-size: 0.85em; }

.rig {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.rig-sep { color: var(--line); }
.rig-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--verify);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--verify) 22%, transparent);
}

/* ---- bench (two panes) ------------------------------------------------ */
.bench {
  flex: 1;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  min-height: 0;
}

/* editor: dark ink inset */
.editor {
  display: flex;
  flex-direction: column;
  min-width: 0; min-height: 0;
  background: var(--ink);
  border-right: 1px solid var(--line);
}
.editor-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  border-bottom: 1px solid #262732;
  overflow-x: auto;
}
.editor-tabs .tab {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 5px 10px 7px;
  cursor: pointer;
  white-space: nowrap;
}
.editor-tabs .tab:hover { color: var(--text-inv); }
.editor-tabs .tab.active {
  color: var(--text-inv);
  border-bottom-color: var(--signal-ink);
}
.CodeMirror {
  flex: 1;
  height: auto;
  background: var(--ink);
  color: var(--text-inv);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
}
.CodeMirror-gutters { background: var(--ink); border: none; }
.CodeMirror-linenumber { color: #3c3d4a; }
.CodeMirror-cursor { border-left: 2px solid var(--signal-ink); }
.CodeMirror-selected { background: #2b2c3a !important; }
.cm-comment { color: #6d6a8a; font-style: italic; }
.cm-keyword { color: #c7a2ff; }
.cm-def, .cm-variable-2 { color: #8fd6ff; }
.cm-string { color: #b7d98a; }
.cm-number { color: #ffb27a; }
.cm-builtin, .cm-variable { color: var(--text-inv); }
.cm-operator { color: var(--muted-2); }

.controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-top: 1px solid #262732;
  background: var(--ink-2);
}
.run {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--signal);
  border: none;
  padding: 9px 22px;
  cursor: pointer;
  transition: filter .15s ease;
}
.run:hover { filter: brightness(1.12); }
.run:disabled { background: #3a3b49; color: #8a8a99; cursor: progress; }
.run:focus-visible { outline: 2px solid var(--signal-ink); outline-offset: 2px; }
.status { font-family: var(--mono); font-size: 12px; color: var(--muted-2); }
.status[data-kind="error"] { color: #ff8f7a; }

/* ---- readout ---------------------------------------------------------- */
.readout {
  display: flex;
  flex-direction: column;
  min-width: 0; min-height: 0;
  overflow: hidden;
}
.results {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 22px 20px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

/* plates — fixed sections of the readout (machine nameplate, execution).
   One shared visual language: lowercase mono head + terse rows. Running a
   job never replaces a section, it only fills the execution plate in. */
.plate { font-family: var(--mono); }
.sec-head {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.idle-specs {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0 18px;
  margin: 0;
  font-size: 12px;
}
.idle-specs dt {
  color: var(--muted);
  padding: 5px 0;
  border-top: 1px dashed var(--line);
}
.idle-specs dd {
  color: var(--text);
  margin: 0;
  padding: 5px 0;
  border-top: 1px dashed var(--line);
}

/* signature: the execution gauge */
.gauge-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.gauge-value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(48px, 8vw, 76px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.gauge-value .unit {
  font-size: 0.28em;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--muted);
}
#exec { color: var(--text); }
#exec:not(.is-set) { color: var(--line); }   /* faint idle placeholder */
#exec.is-set { color: var(--signal); }

.gauge-note {
  font-family: var(--mono);
  font-size: 0.5em;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-left: 6px;
}

.gauge { margin-bottom: 12px; }

/* verdict */
.verdict {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 13px;
  padding-top: 4px;
}
.verdict-mark {
  width: 10px; height: 10px; border-radius: 2px;
  background: var(--line);
}
.verdict[data-state="ok"] .verdict-mark { background: var(--verify); }
.verdict[data-state="ok"] #verdict-text { color: var(--verify); }
.verdict[data-state="bad"] .verdict-mark { background: var(--reject); }
.verdict[data-state="bad"] #verdict-text { color: var(--reject); }
.verdict[data-state] #verdict-text { color: var(--muted); }

/* execution trace — event-driven step list. Rows freeze in as phases land
   (queued shows as a pulsing row too); the bottom row ticks wall-clock.
   Ratio bars (vs the longest phase) animate in only with the final result,
   so nothing rescales mid-run. */
.trace-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
}
.trow {
  display: grid;
  grid-template-columns: 76px 1fr 84px;
  gap: 10px;
  align-items: center;
}
.trow .nm { color: var(--muted); white-space: nowrap; }
.trow .ms { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.trow .bar {
  height: 6px;
  border-radius: 3px;
  background: var(--plate-2);
  overflow: hidden;
}
.trow .fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  min-width: 2px;
  width: 0;
  transition: width .55s cubic-bezier(.22, .61, .36, 1);
}
.trow.exec .nm,
.trow.exec .ms { color: var(--signal); font-weight: 600; }
.trow.total .nm,
.trow.total .ms { color: var(--text); }
.trow.total { border-top: 1px dashed var(--line); padding-top: 4px; }
.trow.running .nm { color: var(--text); }
.trow.running .ms { animation: row-pulse 1s ease-in-out infinite; }
@keyframes row-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* output panel — a distinct terminal-style pane, clearly split from the readout */
.output-panel {
  flex: 0 0 38%;
  display: flex;
  flex-direction: column;
  min-height: 96px;
  background: var(--ink);
  border-top: 2px solid var(--signal);
}
.output-head {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 9px 16px 7px;
  border-bottom: 1px solid #262732;
}
.console {
  flex: 1;
  margin: 0;
  padding: 12px 16px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: #b9c2b0;
  white-space: pre-wrap;
  word-break: break-word;
}
.console .err { color: #ff8f7a; }

/* ---- footer ----------------------------------------------------------- */
.foot {
  padding: 11px 20px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.foot a { color: var(--signal); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--signal) 35%, transparent); }

/* ---- responsive / iframe ---------------------------------------------- */
@media (max-width: 820px) {
  .bench { grid-template-columns: 1fr; grid-template-rows: 1.1fr 1fr; }
  .editor { border-right: none; border-bottom: 1px solid var(--line); }
  .rig span:not(.rig-dot) { display: none; }
  .rig::after { content: "GPU"; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; color: var(--muted); }
}

@media (prefers-reduced-motion: reduce) {
  .run { transition: none; }
  .trow .fill { transition: none; }
  .trow.running .ms { animation: none; }
}
