:root {
  --bg: #0b1016; --panel: #141b23; --panel2: #1a232d; --line: rgba(255, 255, 255, .1);
  --text: #e8eef4; --mut: #8d9aa7; --accent: #8f7bff;
  --p: #4cc9f0; --s: #ffe14d; --l: #ff8a3d; --ok: #4ade80; --bad: #fb7185;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: 100vh; overflow: hidden; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; }

/* stage */
#stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: radial-gradient(ellipse at 50% 45%, #1a1b33 0%, #0b1016 70%); }
#topbar { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: space-between; align-items: center; padding: 10px 12px 6px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 7px 14px; background: rgba(20, 27, 35, .75); border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--mut); }
.tab:hover { color: var(--text); background: rgba(255, 255, 255, .07); }
.tab[aria-selected="true"] { color: #12082e; background: linear-gradient(180deg, #b6a8ff, #8f7bff); border-color: transparent; }
#readout { display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.clock { padding: 5px 12px; background: rgba(20, 27, 35, .75); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 10px; min-width: 76px; }
.clock small { display: block; font-size: 10px; color: var(--mut); white-space: nowrap; }
.clock b { font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap; }
.clock.ok b { color: var(--ok); }
.clock.bad b { color: var(--bad); }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view[hidden] { display: none; }
.row2 { flex: 1; min-height: 0; display: flex; gap: 8px; padding: 0 8px; }
.cwrap { position: relative; min-height: 0; min-width: 0; }
.cwrap.grow { flex: 1; }
.cwrap.sub { flex: 0 0 28%; }
.cwrap.strip { flex: 0 0 170px; }
.cwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#c1.draw { cursor: crosshair; }
#c3.cloud { cursor: grab; }
.tag { position: absolute; top: 8px; right: 14px; padding: 5px 10px; font-size: 12px; background: rgba(14, 20, 27, .9); border: 1px solid var(--line); border-radius: 8px; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; padding: 8px 14px 10px; font-size: 11.5px; color: var(--mut); }
.mut { color: var(--mut); }
.sw { display: inline-flex; align-items: center; gap: 6px; }
.sw i { width: 14px; height: 11px; border-radius: 3px; }
.sw i.line { height: 3px; width: 16px; border-radius: 2px; }
.sw i.line.dash { background: repeating-linear-gradient(90deg, var(--p) 0 4px, transparent 4px 7px) !important; }

/* side panel */
#side { overflow-y: auto; padding: 14px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.ctl { display: flex; flex-direction: column; gap: 12px; }
#side header h1 { font-size: 19px; letter-spacing: .01em; }
#side header p { margin: 4px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--mut); }
.card { padding: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; }
.card h2 { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); margin-bottom: 8px; }
.row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.btn { padding: 9px 12px; background: #243140; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; }
.btn:hover { background: #2d3c4e; }
.btn[aria-pressed="true"] { background: #3a3470; border-color: var(--accent); }
.btn.primary { flex: 1; background: linear-gradient(180deg, #a999ff, #7a62e8); border-color: transparent; color: #12082e; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary[aria-pressed="true"] { background: linear-gradient(180deg, #a999ff, #7a62e8); }
.field { display: block; margin-bottom: 10px; }
.field > span { display: flex; justify-content: space-between; font-size: 12px; color: var(--mut); margin-bottom: 4px; }
.field output { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
input[type=range] { width: 100%; margin: 0; accent-color: var(--accent); }
select { width: 100%; padding: 6px 8px; background: #0f151c; border: 1px solid var(--line); border-radius: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { padding: 5px 10px; font-size: 12px; background: transparent; border: 1px solid var(--line); border-radius: 999px; color: var(--text); }
.chip:hover { background: rgba(255, 255, 255, .07); }
.chip[aria-pressed="true"] { background: rgba(143, 123, 255, .28); border-color: var(--accent); }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; }
.toggles label, .check { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; }
.toggles input, .check input { accent-color: var(--accent); margin: 0; }
.toggles i { width: 14px; height: 3px; border-radius: 2px; }
.toggles i.hollow { height: 9px; width: 9px; border: 1.5px solid var(--mut); border-radius: 50%; background: none; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 3px 0; color: var(--mut); }
.kv b { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; }
.kv .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: #0f151c; margin-bottom: 8px; }
.bar i { display: block; height: 100%; }
#barR { background: #ff8a3d; } #barI { background: #6b7a8c; } #barT { background: #4cc9f0; }
.orb { display: flex; justify-content: space-between; align-items: baseline; margin: 2px 0 10px; }
.orb b { font-size: 24px; }
.orb span { color: var(--p); font-weight: 600; font-variant-numeric: tabular-nums; }
.note { margin: 8px 0 0; font-size: 12px; line-height: 1.45; color: var(--mut); }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.facts { margin: 10px 0 0; padding-left: 18px; font-size: 12.5px; line-height: 1.5; display: flex; flex-direction: column; gap: 6px; }

:focus-visible { outline: 2px solid var(--p); outline-offset: 2px; }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; height: auto; overflow: auto; }
  #stage { height: 88vh; min-height: 520px; }
  #side { overflow: visible; border-left: 0; border-top: 1px solid var(--line); }
  #readout { gap: 6px; }
  .clock { padding: 4px 8px; min-width: 0; }
  .clock b { font-size: 13px; }
  .tab { padding: 6px 10px; font-size: 12px; }
  .cwrap.strip { flex-basis: 96px; }
  .cwrap.sub { flex-basis: 24%; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
