:root {
  color-scheme: dark;
  --bg: #14171d;
  --panel: #1b1f27;
  --panel-2: #1e232c;
  --line: #2c313d;
  --text: #eef1f6;
  --muted: #8b93a3;
  --accent: #8a6fd1;
  --accent-soft: rgba(138,111,209,0.14);
  --marker: #f2b866;
  --red: #e8778a;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --mono: "IBM Plex Mono", "Roboto Mono", "Fira Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { overflow: hidden; }
.shell { width: 100vw; height: calc(100vh - 30px); display: grid; grid-template-rows: 86px 1fr; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); background: var(--panel); }
.eyebrow { margin: 0 0 6px; color: var(--accent); text-transform: uppercase; letter-spacing: .1em; font-size: 11px; font-weight: 600; }
h1 { margin: 0; font-size: clamp(20px, 2.6vw, 34px); font-weight: 600; letter-spacing: -0.01em; }
.status-card { min-width: 210px; display: grid; gap: 4px; justify-items: end; color: var(--muted); }
.status-card strong { color: var(--accent); font-size: 20px; font-weight: 600; }
.grid { min-height: 0; display: grid; grid-template-columns: 320px 1.45fr .85fr; grid-template-rows: 1fr 150px 250px; gap: 12px; padding: 12px; }
.panel { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: hidden; }
.controls { grid-row: 1 / span 3; padding: 16px; overflow: auto; }
.plot-panel { padding: 0; }
.resid-panel { padding: 0; }
.heat-panel { padding: 0; grid-row: 1 / span 2; }
.telemetry { grid-column: 2 / span 2; padding: 16px; display: grid; grid-template-rows: auto 1fr; }
.panel-title { height: 46px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 11px; font-weight: 600; }
.panel-title span { color: var(--text); text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 13px; }
.panel-title b { color: var(--accent); font-weight: 600; }
canvas { width: 100%; height: calc(100% - 46px); display: block; background: var(--panel-2); }
label { display: grid; gap: 8px; margin: 16px 0; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
label output { color: var(--text); float: right; font-family: var(--mono); text-transform: none; font-weight: 400; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
button { width: 100%; margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--text); padding: 12px 14px; font: 600 13px var(--sans); cursor: pointer; transition: border-color .12s ease, color .12s ease; }
button:hover { border-color: var(--accent); color: var(--accent); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); padding: 12px; min-height: 78px; }
.metric span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.metric strong { display: block; margin-top: 8px; color: var(--accent); font-size: 19px; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
pre { margin: 12px 0 0; white-space: pre-wrap; color: var(--muted); line-height: 1.55; font-size: 12px; font-family: var(--mono); }
@media (max-width: 1100px) {
  body { overflow: auto; }
  .shell { height: auto; min-height: 100vh; }
  .grid { grid-template-columns: 1fr; grid-template-rows: auto 520px 420px auto; }
  .controls, .plot-panel, .heat-panel, .telemetry { grid-column: auto; grid-row: auto; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.site-footer { height: 30px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-top: 1px solid var(--line); background: var(--panel); font-size: 11px; color: var(--muted); }
.site-footer nav { display: flex; gap: 16px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
