:root {
  --bg: #f6f4f0; --panel: #ffffff; --fg: #1d1b18; --muted: #6f6a62; --line: #e2ddd4;
  --accent: #a0522d; --grid: #ebe6dd; --mark: #b8b0a2;
  --c-modal: #c2410c; --warn: #b45309;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412; --panel: #1e1c19; --fg: #ece8e1; --muted: #9a948a; --line: #34302b;
    --accent: #e0915c; --grid: #2a2723; --mark: #5c564e;
    --c-modal: #fb923c; --warn: #fbbf24;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 13px/1.4 system-ui, -apple-system, sans-serif; }
main { display: grid; grid-template-columns: 1fr 340px; height: 100vh; }
.stage { display: grid; grid-template-rows: 1fr auto; grid-template-columns: minmax(0, 1fr); min-width: 0; position: relative; }
#view { min-height: 300px; position: relative; overflow: hidden; }
#view canvas { position: absolute; inset: 0; }
.hint { position: absolute; top: 10px; left: 14px; color: var(--muted); font-size: 12px; pointer-events: none; }
.plots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; border-top: 1px solid var(--line); }
.plot { min-width: 0; }
.plot canvas { width: 100%; height: 170px; display: block; }
.ptitle { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.panel { background: var(--panel); border-left: 1px solid var(--line); padding: 14px 16px; overflow-y: auto; }
h1 { font-size: 17px; margin: 0 0 10px; }
h2 { font-size: 13px; margin: 18px 0 6px; padding-top: 10px; border-top: 1px solid var(--line); }
h2 small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.row { display: grid; grid-template-columns: 130px 1fr 64px; align-items: center; gap: 8px; margin: 3px 0; }
.row .lab { color: var(--muted); font-size: 12px; }
.row .val { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=text] { width: 100%; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; }
select { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 7px; padding: 7px 11px; font: inherit; font-weight: 600; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
button.small { padding: 2px 8px; font-size: 12px; background: var(--muted); }
.progress { height: 4px; background: var(--grid); border-radius: 2px; overflow: hidden; margin-top: 8px; }
#bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.status { min-height: 36px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.kv { display: flex; justify-content: space-between; font-size: 12px; margin: 2px 0 4px; }
.muted { color: var(--muted); }
.info { font-size: 11px; color: var(--muted); margin: 6px 0; font-variant-numeric: tabular-nums; }
.warn { color: var(--warn); font-size: 12px; margin: 4px 0; }
.warn:empty { display: none; }
@media (max-width: 800px) {
  main { grid-template-columns: 1fr; height: auto; }
  .stage { grid-template-rows: 55vh auto; }
  .plots { grid-template-columns: 1fr; padding: 10px 16px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); padding: 14px 16px; }
}
