/* The playground, and the bundle's test pages. One stylesheet for the page wherever it is served: at
   playground.simien.dev, by `simien playground` on localhost, or inside the file `simien playground --once` writes.
   No network: system fonts, and nothing fetched from here. */
:root {
  color-scheme: light;
  --ground: #fafaf8; --panel: #ffffff; --code: #f4f2ec; --stage: #efece5;
  --ink: #17181b; --soft: #5a5d66; --faint: #a19d93; --edge: #dedbd4;
  --accent: #9a6b0c; --bad: #b42318; --good: #12b76a;
  --kw: #b4410f; --str: #4d7c0f; --com: #8a8577; --num: #1d4ed8;
  /* A tensor's values: below zero, at zero, above zero. */
  --heat-below: #2563c9; --heat-zero: #f7f5ef; --heat-above: #d9600a;
  --font: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --display: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
/* Dark: the system's choice unless the reader chose light, or the reader's own choice. The two blocks are one list. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0b0c0e; --panel: #14161a; --code: #101215; --stage: #07080a;
    --ink: #eceae4; --soft: #b9b6ae; --faint: #6f6b62; --edge: #262930;
    --accent: #e2b54a; --bad: #f97066;
    --kw: #f7941d; --str: #a3c76d; --com: #6f6b62; --num: #8fb4ff;
    --heat-below: #4f9bff; --heat-zero: #14161a; --heat-above: #ff9a2e;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0b0c0e; --panel: #14161a; --code: #101215; --stage: #07080a;
  --ink: #eceae4; --soft: #b9b6ae; --faint: #6f6b62; --edge: #262930;
  --accent: #e2b54a; --bad: #f97066;
  --kw: #f7941d; --str: #a3c76d; --com: #6f6b62; --num: #8fb4ff;
  --heat-below: #4f9bff; --heat-zero: #14161a; --heat-above: #ff9a2e;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--ground); color: var(--ink); font: 13px/1.5 var(--font); }
body.playground { display: grid; grid-template-rows: auto auto minmax(0, 1fr); overflow: hidden; }
/* The banner is usually hidden: the main area keeps the last row, the one that takes the height. */
body.playground > main { grid-row: 3; }
header { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--edge); flex-wrap: wrap; }
header b { font-family: var(--display); font-size: 15px; white-space: nowrap; }
.mark { width: 18px; height: 18px; border-radius: 4px; background: linear-gradient(#ef4136 0 25%, #f15a29 25% 50%, #f7941d 50% 72%, #fbb040 72%); flex: none; }
.meta { color: var(--soft); }
.meta.error { color: var(--bad); }
.spacer { flex: 1; }
.pick { color: var(--soft); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
select, button { font: 12px var(--font); color: var(--ink); background: var(--panel); border: 1px solid var(--edge); border-radius: 6px; padding: 4px 10px; }
button { cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--faint); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--ground); font-weight: 600; }
button:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--soft); white-space: nowrap; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.live.on i { background: var(--good); }
.live.slow i { background: var(--accent); }
.live.bad i { background: var(--bad); }
.banner { padding: 8px 14px; border-bottom: 1px solid var(--edge); white-space: pre-wrap; max-height: 30vh; overflow: auto; }
.banner.error { color: var(--bad); }
.banner.note { color: var(--soft); }
main { display: grid; grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1.08fr); min-height: 0; }

/* ---- the program ---- */
.code { border-right: 1px solid var(--edge); background: var(--code); min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.tabs { display: flex; gap: 2px; padding: 4px 8px 0; border-bottom: 1px solid var(--edge); overflow-x: auto; min-height: 31px; }
.tabs button { border: 0; border-radius: 0; background: none; color: var(--soft); padding: 5px 10px; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button.unsaved::after { content: " •"; color: var(--accent); }
.editor { position: relative; min-width: 0; min-height: 0; }
.editor > .monaco { position: absolute; inset: 0; }
/* Lines the page marks in Monaco: where the block under the pointer was made, and where a run failed. */
.editor .made-here { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.editor .made-here-edge { border-left: 2px solid var(--accent); margin-left: 3px; }
.editor .failed-here { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.editor .failed-here-edge { border-left: 2px solid var(--bad); margin-left: 3px; }
/* The plain editor: a textarea over a coloured copy of its text. What the page shows without Monaco. */
.editor pre, .editor textarea { position: absolute; inset: 0; margin: 0; border: 0; font: 12px/1.6 var(--font); tab-size: 2; }
.editor pre { padding: 10px 0; overflow: hidden; counter-reset: n; pointer-events: none; }
.editor textarea { padding: 10px 14px 10px 54px; background: transparent; color: transparent; caret-color: var(--ink); resize: none; outline: none; overflow: auto; white-space: pre; width: 100%; height: 100%; }
.editor textarea::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); color: transparent; }
.ln { display: block; padding: 0 14px 0 52px; position: relative; border-left: 2px solid transparent; white-space: pre; }
.ln::before { counter-increment: n; content: counter(n); position: absolute; left: 10px; width: 30px; text-align: right; color: var(--faint); }
.ln.on { background: color-mix(in srgb, var(--accent) 16%, transparent); border-left-color: var(--accent); }
.ln.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); border-left-color: var(--bad); }
.kw { color: var(--kw); } .str { color: var(--str); } .com { color: var(--com); font-style: italic; } .num { color: var(--num); }

/* ---- the model, the training, the output ---- */
.right { display: grid; grid-template-rows: minmax(0, 1.35fr) auto minmax(96px, 0.5fr); min-width: 0; min-height: 0; }
.stage { position: relative; min-width: 0; min-height: 0; background: var(--stage); container-type: inline-size; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.stage canvas:active { cursor: grabbing; }
.tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tools button { background: color-mix(in srgb, var(--panel) 88%, transparent); color: var(--soft); padding: 3px 9px; }
.tools button:hover { color: var(--ink); }
.tools button[aria-pressed="true"] { color: var(--ink); border-color: var(--faint); }
.tools button[aria-pressed="false"] { text-decoration: line-through; }
.tools #outputs { margin-right: 8px; }
/* The model's name and size, quietly, beside the tools. The parts are named in the stage's margins (renderer.js). */
.caption { position: absolute; left: 12px; top: 12px; max-width: calc(100% - 340px); color: var(--soft); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.caption b { color: var(--ink); font-weight: 600; }
@container (max-width: 640px) { .caption span { display: none; } }
.legend { position: absolute; left: 12px; bottom: 9px; display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--soft); font-size: 11px; max-width: calc(100% - 24px); pointer-events: none; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.legend i.ramp { width: 54px; background: linear-gradient(90deg, var(--heat-below), var(--heat-zero), var(--heat-above)); border: 1px solid var(--edge); }
.legend i.sum { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--soft); font-style: normal; font-size: 10px; line-height: 9px; text-align: center; color: var(--soft); }
.legend i.stream { width: 16px; height: 3px; border-radius: 2px; background: var(--soft); opacity: 0.6; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--soft); text-align: center; padding: 24px; pointer-events: none; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; padding: 5px 14px; border-bottom: 1px solid var(--edge); color: var(--soft); font-size: 11px; white-space: nowrap; overflow: hidden; }
.panel-head .meta { overflow: hidden; text-overflow: ellipsis; }
.training { border-top: 1px solid var(--edge); background: var(--panel); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); height: 176px; min-height: 0; }
.training .chart { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.training .chart + .chart { border-left: 1px solid var(--edge); }
.training #loss { width: 100%; height: 100%; display: block; }
.training .rows { overflow-y: auto; min-height: 0; padding: 2px 0; }
.training #layers { width: 100%; display: block; }
.console { border-top: 1px solid var(--edge); background: var(--panel); display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
.console pre { margin: 0; padding: 8px 14px; overflow: auto; font: 12px/1.6 var(--font); white-space: pre-wrap; overflow-wrap: anywhere; }
body.alone .right { grid-template-rows: minmax(0, 1fr) auto; }
body.alone .console { display: none; }
.console .warn { color: var(--accent); }
.console .error { color: var(--bad); }
.console .stderr { color: var(--soft); }
@media (max-width: 800px) {
  body.playground { grid-template-rows: auto auto auto; height: auto; overflow: auto; }
  main { grid-template-columns: minmax(0, 1fr); }
  .code { border-right: 0; border-bottom: 1px solid var(--edge); height: 52vh; }
  .right { grid-template-rows: 62vh auto auto; }
  .training { grid-template-columns: minmax(0, 1fr); height: auto; }
  .training .chart { height: 170px; }
  .training .chart + .chart { border-left: 0; border-top: 1px solid var(--edge); }
  .console pre { max-height: 50vh; min-height: 96px; }
}

/* The test pages (conformance.html, bench.html): a report, not an app. */
body.report { height: auto; }
body.report main { display: block; padding: 16px; max-width: 1100px; }
body.report table { border-collapse: collapse; margin: 10px 0 22px; }
body.report th, body.report td { text-align: left; padding: 3px 14px 3px 0; border-bottom: 1px solid var(--edge); vertical-align: top; }
body.report th { color: var(--soft); font-weight: 400; }
body.report .ok { color: var(--good); }
body.report .fail { color: var(--bad); }
body.report h2 { font: 600 14px var(--display); margin: 18px 0 4px; }
body.report pre { white-space: pre-wrap; overflow-wrap: anywhere; }
