/* openrcs control surface — dark, single-theme by design (live-show environment). */

:root {
  --bg:        #0d1015;
  --panel:     #151a21;
  --panel-2:   #1b222c;
  --raised:    #212a35;
  --line:      #242c37;
  --line-hi:   #35424f;

  --text:      #e6ebf2;
  --muted:     #8b96a5;
  --faint:     #5b6673;

  --pgm:       #e5484d;   /* program  */
  --pvw:       #3fb950;   /* preview  */
  --armed:     #f0a020;   /* armed / save */
  --valid:     #3fb950;   /* memory present */

  --accent:    #22b8cf;   /* selection / focus — never program/preview */
  --accent-dim:#12414d;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r: 4px;
  --gap: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--sans);
  font-size: 14px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

button { font-family: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.app {
  display: grid;
  /* minmax(0,1fr) forces the row min to 0 so it clamps to the viewport instead of
     growing to content — lets a full-height view pin its own footer on screen */
  grid-template-rows: 48px minmax(0, 1fr);
  grid-template-columns: 188px 1fr;
  grid-template-areas: "head head" "nav main";
  height: 100vh;
}
.app.nav-hidden { grid-template-columns: 0 1fr; }
.app.nav-hidden .nav { display: none; }

/* menu collapse toggle */
.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; margin-left: -4px;
  background: none; border: 1px solid transparent; border-radius: var(--r); color: var(--muted);
}
.nav-toggle:hover { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.nav-toggle .burger { position: relative; width: 16px; height: 2px; background: currentColor; border-radius: 2px; }
.nav-toggle .burger::before, .nav-toggle .burger::after {
  content: ''; position: absolute; left: 0; width: 16px; height: 2px; background: currentColor; border-radius: 2px;
}
.nav-toggle .burger::before { top: -5px; }
.nav-toggle .burger::after  { top: 5px; }

/* ---- header ---- */
.head {
  grid-area: head;
  display: flex; align-items: center; gap: 18px;
  padding: 0 16px;
  background: linear-gradient(var(--panel), var(--panel-2));
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .5px; }
.brand span { color: var(--accent); }
.dev-id { display: flex; flex-direction: column; line-height: 1.15; }
.dev-id .model { font-weight: 600; }
.dev-id .sub { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.head .spacer { flex: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 100px;
  font-size: 12px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.chip.on  .dot { background: var(--valid); box-shadow: 0 0 8px var(--valid); }
.chip.off .dot { background: var(--faint); }
.chip.off { color: var(--muted); }
.chip.bad .dot { background: var(--pgm); box-shadow: 0 0 8px var(--pgm); }
.chip.bad { color: var(--pgm); }

.legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); }
.legend b { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.legend .pgm b { background: var(--pgm); }
.legend .pvw b { background: var(--pvw); }

/* ---- nav ---- */
.nav {
  grid-area: nav;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 10px 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.nav button {
  text-align: left; background: none; border: 0;
  padding: 9px 12px; border-radius: var(--r);
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.nav button:hover { background: var(--panel-2); color: var(--text); }
.nav button.active { background: var(--accent-dim); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav .grow { flex: 1; }
.nav .foot { font-size: 11px; color: var(--faint); padding: 8px 12px; font-family: var(--mono); }
.nav-sec { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--faint); padding: 12px 12px 4px; font-weight: 600; }
.nav-sec:first-child { padding-top: 2px; }

/* key/value rows (System) */
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); font-size: 13px; }
.kv .v { font-family: var(--mono); font-size: 13px; }
tr.dim td { opacity: .5; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr.sel-row { background: var(--accent-dim); box-shadow: inset 2px 0 0 var(--accent); }

/* ---- main ---- */
/* min-height:0 lets the 1fr grid row clamp to the viewport instead of growing to
   content, so a full-height view (Workspace) can pin its own footer on screen */
.main { grid-area: main; overflow: auto; padding: 16px; min-height: 0; }
.view-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.view-head h1 { font-size: 18px; margin: 0; font-weight: 650; }
.view-head .hint { color: var(--muted); font-size: 12px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 14px; margin-bottom: 16px;
}
.panel > h2 {
  margin: 0 0 12px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
  display: flex; align-items: center; gap: 10px;
}
.row { display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap; }
.spacer { flex: 1; }

/* segmented control (grid mode) */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: none; padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--muted); }
.seg button.on { color: var(--bg); }
.seg button.on.recall { background: var(--pvw); }
.seg button.on.take   { background: var(--pgm); }
.seg button.on.save   { background: var(--armed); }

.btn {
  background: var(--raised); border: 1px solid var(--line-hi);
  border-radius: var(--r); padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn.pgm { background: var(--pgm); border-color: var(--pgm); color: #fff; }
.btn.pvw { background: color-mix(in srgb, var(--pvw) 22%, var(--panel)); border-color: var(--pvw); }
.btn.ghost { background: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

label.field { display: inline-flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
select, input[type=number], input[type=text] {
  background: var(--bg); color: var(--text); border: 1px solid var(--line-hi);
  border-radius: var(--r); padding: 6px 8px; font-family: var(--mono); font-size: 13px;
}

/* ---- memory grid ---- */
.mem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 6px;
}
.slot {
  aspect-ratio: 1 / 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; position: relative;
  font-family: var(--mono); color: var(--faint);
  transition: transform .04s;
}
.slot:hover { border-color: var(--line-hi); }
.slot:active { transform: scale(.96); }
.slot .num { font-size: 15px; font-weight: 700; }
.slot .lbl { font-size: 9px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.valid { background: color-mix(in srgb, var(--valid) 12%, var(--panel-2)); border-color: color-mix(in srgb, var(--valid) 45%, var(--line)); color: var(--text); }
.slot.pgm { border-color: var(--pgm); box-shadow: inset 0 0 0 1px var(--pgm); }
.slot.pvw { border-color: var(--pvw); box-shadow: inset 0 0 0 1px var(--pvw); }
.slot.sel { outline: 2px solid var(--accent); outline-offset: -1px; }
/* mode-tinted hover affordance */
.mode-recall .slot.valid:hover { border-color: var(--pvw); }
.mode-take   .slot.valid:hover { border-color: var(--pgm); }
.mode-save   .slot:hover       { border-color: var(--armed); }

/* ---- layers ---- */
.layers { display: flex; flex-direction: column; gap: 6px; }
.layer {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px;
}
.layer .tag { font-family: var(--mono); font-weight: 700; color: var(--muted); }
.layer.on { border-color: var(--line-hi); }
.layer .src { font-family: var(--mono); }
.empty-state { color: var(--faint); font-size: 13px; padding: 20px; text-align: center; border: 1px dashed var(--line); border-radius: 6px; }

.layer.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.layer { cursor: pointer; }

/* ---- Tally ---- */
.tally-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.tally-tile {
  aspect-ratio: 16 / 9; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--panel-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.tally-tile .tally-src { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.tally-tile .tally-state { font-family: var(--mono); font-size: 11px; font-weight: 700; }
.tally-tile.pgm { background: color-mix(in srgb, var(--pgm) 30%, var(--panel-2)); border-color: var(--pgm); }
.tally-tile.pgm .tally-src, .tally-tile.pgm .tally-state { color: #fff; }
.tally-tile.pvw { background: color-mix(in srgb, var(--pvw) 22%, var(--panel-2)); border-color: var(--pvw); }
.tally-tile.pvw .tally-src { color: var(--text); }
.tally-tile.pvw .tally-state { color: var(--pvw); }

/* ---- User keys ---- */
.key-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.user-key {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 8px;
  min-height: 84px; padding: 12px 14px; text-align: left;
  background: var(--raised); border: 1px solid var(--line-hi); border-radius: 6px;
}
.user-key:hover { border-color: var(--accent); }
.user-key:active { transform: scale(.98); }
.user-key.add { background: none; border-style: dashed; color: var(--muted); justify-content: center; align-items: center; }
.user-key-name { font-weight: 600; font-size: 15px; }
.user-key-sub { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.action-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0; }
.action-item { display: flex; align-items: center; gap: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 10px; }
.action-n { font-family: var(--mono); color: var(--muted); width: 20px; text-align: right; }
.action-desc { flex: 1; font-size: 13px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---- Cues ---- */
.cue-list { display: flex; flex-direction: column; gap: 6px; }
.cue { display: flex; align-items: center; gap: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; }
.cue.current { border-color: var(--pgm); box-shadow: inset 3px 0 0 var(--pgm); }
.cue-n { font-family: var(--mono); color: var(--muted); width: 24px; text-align: right; }
.cue-main { flex: 1; min-width: 0; }
.cue-label { font-weight: 600; }
.cue-target { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.cue-ord { display: flex; gap: 4px; }
.cue-ord .btn { padding: 4px 8px; }
.cue-next-label { font-size: 15px; font-weight: 600; padding: 6px 0; }

/* ---- Stage overview ---- */
.stage-grid { display: flex; flex-wrap: wrap; gap: 18px; }
.stage-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px; cursor: pointer; transition: border-color .1s; }
.stage-card:hover { border-color: var(--accent); }
.stage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.stage-name { font-weight: 600; }
.stage-dim { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.stage-screen {
  position: relative; border: 1px solid var(--line-hi); border-radius: 3px; overflow: hidden;
  background: repeating-conic-gradient(#0e1116 0% 25%, #0b0e12 0% 50%) 50% / 24px 24px;
}
.stage-layer { position: absolute; box-sizing: border-box; border: 1px solid #ffffff40; display: flex; align-items: flex-start; opacity: .82; }
.stage-layer span { font-family: var(--mono); font-size: 10px; background: #000a; color: #fff; padding: 0 4px; border-radius: 0 0 3px 0; }

/* ---- graphical layer arrangement ---- */
.split-wide { display: grid; grid-template-columns: minmax(400px, 1fr) minmax(280px, 380px); gap: 16px; align-items: start; }
.canvas-wrap { display: flex; justify-content: center; }
.screen-canvas {
  position: relative; background:
    repeating-conic-gradient(#0e1116 0% 25%, #0b0e12 0% 50%) 50% / 32px 32px;
  border: 1px solid var(--line-hi); border-radius: 3px; overflow: hidden;
  box-shadow: inset 0 0 0 1px #000, 0 8px 30px #0007;
}
.lrect {
  position: absolute; box-sizing: border-box;
  border: 1.5px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  display: flex; align-items: flex-start; cursor: move; user-select: none;
  min-width: 8px; min-height: 8px;
}
.lrect.off { border-style: dashed; border-color: var(--faint); background: color-mix(in srgb, var(--faint) 10%, transparent); }
.lrect.sel { border-color: #fff; box-shadow: 0 0 0 1px var(--accent), 0 0 14px color-mix(in srgb, var(--accent) 60%, transparent); z-index: 999 !important; }
.lrect-tag { font-family: var(--mono); font-size: 11px; background: #000a; color: var(--text); padding: 1px 5px; border-radius: 0 0 3px 0; pointer-events: none; white-space: nowrap; }
.handle { position: absolute; width: 12px; height: 12px; background: var(--accent); border: 1px solid #000; border-radius: 2px; }
.lrect:not(.sel) .handle { display: none; }
.handle.nw { left: -6px; top: -6px; cursor: nwse-resize; }
.handle.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.handle.sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.handle.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
@media (max-width: 1100px) { .split-wide { grid-template-columns: 1fr; } }

/* ---- layer editor ---- */
.split { display: grid; grid-template-columns: minmax(240px, 360px) 1fr; gap: 16px; align-items: start; }
.editor { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.sub-head { font-size: 10px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 600; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
input[type=color].swatch { width: 46px; height: 30px; padding: 2px; background: var(--bg); border: 1px solid var(--line-hi); border-radius: var(--r); cursor: pointer; }
label.field.slider { gap: 6px; }
label.field.slider > span { display: flex; justify-content: space-between; align-items: baseline; }
label.field.slider .sv { font-family: var(--mono); color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } .grid2 { grid-template-columns: 1fr; } }

/* ---- take bar ---- */
.takebar { display: flex; align-items: stretch; gap: 12px; }
.takebar .tbar { flex: 1; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.take-btn { font-size: 15px; font-weight: 700; padding: 0 28px; }

/* ---- console ---- */
.console { display: grid; grid-template-rows: 1fr auto; gap: 10px; height: calc(100vh - 130px); }
.log { background: #0a0d11; border: 1px solid var(--line); border-radius: 6px; padding: 10px; overflow: auto; font-family: var(--mono); font-size: 12px; }
.log .tx { color: var(--accent); }
.log .rx { color: var(--muted); }
.log .er { color: var(--pgm); }
.log .line { white-space: pre-wrap; }

/* ---- generic tables (setup) ---- */
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.grid td { padding: 6px 10px; border-bottom: 1px solid var(--line); font-family: var(--mono); }
.val { font-variant-numeric: tabular-nums; }

/* ---- still capture ---- */
.cap-frame { position: relative; width: 100%; max-width: 480px; background: var(--bg);
  border: 1px solid var(--line-hi); border-radius: var(--r);
  background-image: linear-gradient(45deg, var(--panel-2) 25%, transparent 25%, transparent 75%, var(--panel-2) 75%),
    linear-gradient(45deg, var(--panel-2) 25%, transparent 25%, transparent 75%, var(--panel-2) 75%);
  background-size: 24px 24px; background-position: 0 0, 12px 12px; }
.cap-frame[onclick], .cap-frame { cursor: crosshair; }
.cap-region { position: absolute; border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--bg) 55%, transparent); box-sizing: border-box; }
.cap-region.full { inset: 0; box-shadow: none; cursor: default; }
.cap-dim { position: absolute; top: 2px; left: 4px; font: 600 11px var(--mono); color: var(--accent);
  background: color-mix(in srgb, var(--bg) 80%, transparent); padding: 1px 4px; border-radius: 3px; }
.cap-presets { flex-wrap: wrap; gap: 6px; }
.btn.big { padding: 10px 20px; font-size: 14px; font-weight: 700; }

/* ---- multiviewer memories ---- */
.mon-mem { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mon-mem-cell { border: 1px solid var(--line); border-radius: var(--r); padding: 8px; background: var(--bg); }
.mon-mem-cell.saved { border-color: var(--accent-dim); background: var(--panel-2); }
.mon-mem-cell .mm-n { font: 600 12px var(--mono); color: var(--muted); }
.mon-mem-cell.saved .mm-n { color: var(--accent); }
.mm-btns { display: flex; gap: 6px; margin-top: 6px; }
.mm-btns .btn { flex: 1; }
@media (max-width: 720px) { .mon-mem { grid-template-columns: repeat(2, 1fr); } }

/* ---- soft edge map ---- */
.se-screen { position: relative; width: 100%; max-width: 560px; aspect-ratio: 16/9;
  background: var(--bg); border: 1px solid var(--line-hi); border-radius: var(--r); overflow: hidden; }
.se-mid { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font: 600 12px var(--mono); pointer-events: none; }
.se-edge { position: absolute; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.se-edge .se-lbl { font: 600 10px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; opacity: 0; transition: opacity .12s; }
.se-edge:hover .se-lbl, .se-edge.sel .se-lbl { opacity: 1; }
.se-edge.left   { left: 0; top: 0; bottom: 0; width: 20%; }
.se-edge.right  { right: 0; top: 0; bottom: 0; width: 20%; }
.se-edge.top    { top: 0; left: 20%; right: 20%; height: 24%; }
.se-edge.bottom { bottom: 0; left: 20%; right: 20%; height: 24%; }
.se-edge.left.on   { background: linear-gradient(to right, color-mix(in srgb, var(--accent) 42%, transparent), transparent); }
.se-edge.right.on  { background: linear-gradient(to left,  color-mix(in srgb, var(--accent) 42%, transparent), transparent); }
.se-edge.top.on    { background: linear-gradient(to bottom, color-mix(in srgb, var(--accent) 42%, transparent), transparent); }
.se-edge.bottom.on { background: linear-gradient(to top,    color-mix(in srgb, var(--accent) 42%, transparent), transparent); }
.se-edge.sel { box-shadow: inset 0 0 0 2px var(--accent); z-index: 2; }

/* ---- edid number input ---- */
.num-in { width: 74px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--text); font: 600 13px var(--mono); padding: 4px 6px; }
.num-in:focus { outline: none; border-color: var(--accent); }

/* ---- memory content preview ---- */
.mem-thumb { flex: 0 0 auto; }
.swatch-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }

/* ---- EDID hex dump ---- */
.edid-hex { margin-top: 10px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r); font: 12px/1.5 var(--mono); color: var(--muted); overflow-x: auto;
  letter-spacing: .5px; white-space: pre; }

/* ---- Midra still/logo store ---- */
.still-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.still-cell { border: 1px solid var(--line); border-radius: var(--r); padding: 10px; background: var(--bg);
  display: flex; flex-direction: column; gap: 4px; min-height: 54px; }
.still-cell.valid { border-color: var(--accent-dim); background: var(--panel-2); }
.still-cell .num { font: 600 12px var(--mono); color: var(--muted); }
.still-cell.valid .num { color: var(--accent); }
.still-cell .still-meta { font: 11px var(--mono); color: var(--muted); }
@media (max-width: 720px) { .still-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---- Workspace (working page) ---- */
/* the whole page fills its pane: bar on top, screens grow to fill, memories pinned below.
   height:100% resolves against .main (whose grid row is minmax(0,1fr), so it's clamped to
   the pane, not content) — which is also correct under the demo's shorter, bannered app */
.ws-page { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; gap: 12px; }
.ws-bar { margin: 0; padding: 9px 12px; display: flex; align-items: center; gap: 14px; flex: 0 0 auto; flex-wrap: wrap; }
.ws-armed { font-size: 12px; }
.ws-toggles { display: flex; align-items: center; gap: 6px; }
.ws-bar-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); font-weight: 600; }
.ws-tog { padding: 6px 11px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 600; }
.ws-tog:hover { border-color: var(--line-hi); color: var(--text); }
.ws-tog.on { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }
.ws-tog.pgm.on { border-color: var(--pgm); background: color-mix(in srgb, var(--pgm) 20%, var(--panel)); }
.ws-tog.pvw.on { border-color: var(--pvw); background: color-mix(in srgb, var(--pvw) 20%, var(--panel)); }

.ws-ttime { min-width: 150px; }
.ws-flash { font-size: 12px; color: var(--accent); background: var(--accent-dim); padding: 3px 10px; border-radius: 100px; }

/* sources | screens | layer properties */
.ws-body { flex: 1 1 auto; min-height: 0; display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr) minmax(240px, 300px); gap: 14px; }

.ws-rail { margin: 0; padding: 12px; display: flex; flex-direction: column; min-height: 0; }
.src-tabs { display: flex; gap: 4px; flex: 0 0 auto; }
.src-tab { flex: 1 1 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg);
  color: var(--muted); font-size: 12px; font-weight: 600; }
.src-tab:hover { border-color: var(--line-hi); color: var(--text); }
.src-tab.on { color: var(--text); border-color: var(--accent); background: var(--accent-dim); box-shadow: inset 0 -2px 0 var(--accent); }
.src-list { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.src-tile { display: flex; align-items: center; gap: 8px; text-align: left; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: var(--r); background: var(--bg); color: var(--text); font-size: 12px; flex: 0 0 auto; }
.src-tile:hover { border-color: var(--line-hi); }
.src-tile.armed { border-color: var(--accent); background: var(--accent-dim); color: var(--text); }
.src-sw { flex: 0 0 auto; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.3); }
/* live thumbnail from the device, where it serves one */
.src-sw.shot { width: 32px; height: 18px; background-size: cover; background-position: center; }
.lrect.shot { background-size: cover; background-position: center; }
.src-tile { cursor: grab; }
/* a source with no signal: the device will refuse to put it on a layer */
.src-tile.nosig { color: var(--muted); border-style: dashed; }
.src-tile.nosig .src-ix { color: var(--armed); }
.src-tile:active { cursor: grabbing; }
.src-nm { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-ix { flex: 0 0 auto; font: 600 10px var(--mono); color: var(--faint); }
.ws-rail-foot { flex: 0 0 auto; margin-top: 8px; font-size: 11px; }
/* anything a source can be dropped on lights up while it is under the pointer */
.drop-hot { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-dim) !important; }

.ws-screens { min-width: 0; min-height: 0; display: flex; gap: 14px; overflow-x: auto; overflow-y: hidden; }
.ws-screen { flex: 1 1 0; min-width: 300px; min-height: 0; margin: 0; padding: 10px 12px;
  display: flex; flex-direction: column; overflow: hidden; }
.ws-screen-head { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; flex: 0 0 auto; }
.ws-screen-head h2 { margin: 0; font-size: 14px; white-space: nowrap; }
.ws-dim { font: 500 10px var(--mono); white-space: nowrap; }
.ws-busy { font: 700 12px var(--mono); color: var(--accent); }
.ws-tbar { flex: 0 1 auto; min-width: 0; display: flex; align-items: center; }
.ws-tbar input { width: 100%; min-width: 44px; max-width: 110px; }
.ws-warn { padding: 2px 7px; border: 1px solid var(--armed); border-radius: 100px; background: transparent;
  color: var(--armed); font: 600 10px var(--sans); }
.ws-warn:hover { background: color-mix(in srgb, var(--armed) 22%, var(--panel)); }
.lrect.missing { border-style: dashed; border-color: var(--armed); }
.lrect-tag.bad { background: color-mix(in srgb, var(--armed) 75%, #000); }
.ws-mini.pgm-b { border-color: var(--pgm); color: var(--pgm); }
.ws-mini.pgm-b:hover { background: color-mix(in srgb, var(--pgm) 22%, var(--panel)); color: var(--text); }
.ws-mini.pvw-b { border-color: var(--pvw); color: var(--pvw); }
.ws-mini.pvw-b:hover { background: color-mix(in srgb, var(--pvw) 22%, var(--panel)); color: var(--text); }
/* program sits above preview, so the two read as one stack per screen. When the window
   is too short for both, the card scrolls rather than letting the canvases collide. */
.ws-ctxs { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; flex-direction: column;
  gap: 12px; overflow-y: auto; overflow-x: hidden; }
.ws-ctx { flex: 1 1 0; min-width: 0; min-height: 168px; display: flex; flex-direction: column; }
.ws-ctx-head { flex: 0 0 auto; margin-bottom: 5px; display: flex; align-items: center; gap: 7px; }
.ws-onair { font: 600 9px var(--mono); letter-spacing: .8px; color: var(--pgm);
  border: 1px solid color-mix(in srgb, var(--pgm) 50%, transparent); padding: 1px 6px; border-radius: 100px; }
.ws-mini { padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg);
  color: var(--muted); font: 600 11px var(--sans); }
.ws-mini:hover { border-color: var(--accent); color: var(--text); }
.ws-mini.on { border-color: var(--accent); background: var(--accent-dim); color: var(--text); }
.ws-ctx-tag { font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .7px; padding: 2px 8px; border-radius: 100px; }
.ws-ctx-tag.pgm { color: var(--pgm); background: color-mix(in srgb, var(--pgm) 16%, transparent); }
.ws-ctx-tag.pvw { color: var(--pvw); background: color-mix(in srgb, var(--pvw) 16%, transparent); }
/* scope the fill-to-fit behaviour to the workspace so the Layers editor is untouched */
.ws-screen .canvas-wrap { flex: 1 1 0; min-height: 64px; align-items: center; overflow: hidden; }
.ws-screen .screen-canvas { box-shadow: inset 0 0 0 1px #000, 0 6px 22px #0006; }
.ws-cv-pgm { border-color: color-mix(in srgb, var(--pgm) 55%, var(--line-hi)); }
.ws-cv-pvw { border-color: color-mix(in srgb, var(--pvw) 55%, var(--line-hi)); }
.ws-slots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; flex: 0 0 auto; align-items: center; }
.ws-slot { position: relative; padding: 4px 8px 4px 11px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg); color: var(--muted); font: 600 11px var(--mono); overflow: hidden; }
.ws-slot.filled { color: var(--text); }
.ws-slot.filled::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.ws-slot.sel { border-color: var(--accent); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.ws-lay { padding: 4px 7px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); color: var(--muted); font: 600 10px var(--sans); }
.ws-lay:hover { border-color: var(--accent); color: var(--text); }

/* ---- layer inspector ---- */
.ws-insp { margin: 0; padding: 12px; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.insp-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.insp-title h2 { margin: 0; }
.insp-title, .insp-src { flex: 0 0 auto; }
.insp-src { display: flex; flex-direction: column; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
/* sections must keep their natural height inside the scrolling column, not squash */
.insp-sec { flex: 0 0 auto; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.insp-sec.open { border-color: var(--line-hi); }
.insp-head { width: 100%; text-align: left; display: flex; align-items: center; gap: 7px; padding: 7px 10px;
  background: var(--panel-2); color: var(--text); font: 600 12px var(--sans); }
.insp-head:hover { color: var(--accent); }
.insp-caret { color: var(--faint); font-size: 10px; }
.insp-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; }
.nrow { display: flex; gap: 8px; }
.nfield { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.nfield input { width: 100%; padding: 5px 7px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg); color: var(--text); font: 500 12px var(--mono); }
.nfield input:focus { outline: none; border-color: var(--accent); }
.nunit { font-size: 10px; }
.cbox { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.cbox input { accent-color: var(--accent); }
.row.wrap { flex-wrap: wrap; }
/* nine-point placement pad */
.pos9 { display: grid; grid-template-columns: repeat(3, 14px); grid-template-rows: repeat(3, 14px); gap: 2px; }
.pos9 button { border: 1px solid var(--line); border-radius: 2px; background: var(--bg); padding: 0; }
.pos9 button:hover { background: var(--accent); border-color: var(--accent); }

/* ---- memories ---- */
.ws-membar { margin: 0; padding: 8px 12px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 7px; }
.ws-membar-head { display: flex; align-items: center; gap: 8px; }
.ws-membar-head h2 { margin: 0; }
.ws-membar-head select { padding: 4px 6px; font-size: 12px; }
.ws-membar-head .hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-filters { display: flex; flex-wrap: wrap; gap: 4px; }
.ws-mem { display: flex; flex-wrap: wrap; gap: 4px; max-height: 74px; overflow-y: auto; }
.ws-mslot { flex: 0 0 auto; width: 44px; height: 32px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg);
  color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 600 11px var(--mono); line-height: 1.1; overflow: hidden; }
.ws-mslot.valid { border-color: var(--accent-dim); background: var(--panel-2); color: var(--accent); }
.ws-mslot:hover { border-color: var(--accent); }
.ws-mslot.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--text); }
.ws-mslot.arm { border-color: var(--pgm); }
.ws-mslot .mlbl { font-size: 8px; color: var(--faint); max-width: 40px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-memdetail { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--line); }
.ws-memname { font: 600 12px var(--sans); }
.lbl-in { padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg);
  color: var(--text); font: 500 12px var(--sans); width: 150px; }
.lbl-in:focus { outline: none; border-color: var(--accent); }

@media (max-width: 1280px) { .ws-body { grid-template-columns: minmax(140px, 170px) minmax(0, 1fr) minmax(220px, 260px); } }
@media (max-width: 980px) { .ws-body { grid-template-columns: 1fr; } .ws-screens { flex-wrap: wrap; } .ws-insp { max-height: 340px; } }

/* ---------- Shows (state snapshot / restore) ---------- */
.scope-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; }
.scope-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: var(--r); background: var(--bg); cursor: pointer; }
.scope-row:hover { border-color: var(--line-hi); }
.scope-main { flex: 1; min-width: 0; }
.scope-label { font: 600 13px var(--sans); color: var(--text); display: flex; align-items: baseline; gap: 8px; }
.scope-n { font: 500 11px var(--mono); color: var(--faint); }
.scope-hint { font-size: 11px; color: var(--muted); margin-top: 2px; }

.file-btn { position: relative; overflow: hidden; }

.show-prog { margin-top: 10px; height: 22px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg); position: relative; overflow: hidden; }
.show-prog-bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-dim); transition: width .1s linear; }
.show-prog-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 500 11px var(--mono); color: var(--text); }
.show-note { margin-top: 8px; font-size: 12px; color: var(--muted); }

.show-list { display: flex; flex-direction: column; gap: 6px; }
.show-item { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.show-item.open { border-color: var(--line-hi); }
.show-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; }
.show-main { flex: 1; min-width: 0; }
.show-name { background: none; border: 1px solid transparent; border-radius: var(--r); color: var(--text);
  font: 600 13px var(--sans); padding: 2px 4px; width: 100%; max-width: 380px; }
.show-name:hover { border-color: var(--line); }
.show-name:focus { outline: none; border-color: var(--accent); background: var(--panel-2); }
.show-meta { font: 500 11px var(--mono); color: var(--faint); margin-top: 2px; padding-left: 4px; }
.show-caret { font: 600 16px var(--mono); color: var(--muted); width: 16px; text-align: center; }
.show-detail { display: flex; flex-direction: column; gap: 10px; padding: 4px 10px 12px; border-top: 1px solid var(--line); }

.conf-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: var(--r); background: var(--bg); }
.conf-row .show-main { flex: 1; min-width: 0; }
.conf-name { font: 600 13px var(--sans); color: var(--text); text-transform: capitalize; }

/* ---------- Show mode (touch / FOH) ---------- */
.sm-transport { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; margin-bottom: 14px; }
.sm-big { border: none; border-radius: 8px; font: 800 26px var(--sans); letter-spacing: .04em; color: #fff;
  min-height: 96px; cursor: pointer; }
.sm-big.take { background: var(--pgm); }
.sm-big.cut { background: var(--raised); color: var(--text); border: 1px solid var(--line-hi); }
.sm-big:active { transform: translateY(1px); }
.sm-dests { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.sm-dest { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 16px; min-height: 96px;
  border: 1px solid var(--line-hi); border-radius: 8px; background: var(--panel-2); color: var(--text); cursor: pointer; }
.sm-dest.transit { border-color: var(--armed); }
.sm-dest-name { font: 700 17px var(--sans); }
.sm-dest-scr { font: 600 12px var(--mono); color: var(--muted); }
.sm-dest-go { margin-top: auto; align-self: stretch; text-align: center; font: 800 18px var(--sans); color: #fff;
  background: var(--pgm); border-radius: 6px; padding: 8px 0; }
.sm-section { font: 700 13px var(--sans); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 6px 0 10px; }
.sm-mems { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.sm-mem { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 76px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--faint); font: 700 20px var(--mono); cursor: default; }
.sm-mem.valid { color: var(--text); border-color: var(--accent-dim); background: var(--panel-2); cursor: pointer; }
.sm-mem.valid:active { background: var(--accent-dim); }
.sm-mem-l { font: 500 11px var(--sans); color: var(--muted); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Wall (screen output-position map) ---------- */
.wall-wrap { overflow-x: auto; }
.wall-canvas { position: relative; background: var(--bg); border: 1px solid var(--line-hi); border-radius: var(--r); }
.wall-gline { position: absolute; background: var(--line); }
.wall-gline.v { top: 0; bottom: 0; width: 1px; }
.wall-gline.h { left: 0; right: 0; height: 1px; }
.wall-screen { position: absolute; border: 2px solid rgba(255,255,255,.35); border-radius: 3px; cursor: grab;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); touch-action: none; overflow: hidden; }
.wall-screen:active { cursor: grabbing; }
.wall-screen.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); z-index: 5; }
.wall-name { font: 700 13px var(--sans); }
.wall-dim { font: 600 10px var(--mono); opacity: .85; }
.wall-sel-name { font: 700 13px var(--sans); color: var(--text); }
.wall-ro { font: 600 12px var(--mono); color: var(--text); padding: 0 6px; }

/* ---------- Cue autofollow ---------- */
.cue.following { border-color: var(--armed); box-shadow: inset 0 0 0 1px var(--armed); }
.cue-follow { display: flex; align-items: center; gap: 5px; }
.cue-notes { font-size: 11px; color: var(--faint); margin-top: 2px; }
.cue-following-note { font: 500 11px var(--mono); color: var(--armed); margin-top: 3px; }

/* ---------- Plan (offline planning) ---------- */
.chip.plan { color: var(--armed); border-color: var(--armed); cursor: pointer; }
.chip.plan .dot { background: var(--armed); box-shadow: 0 0 8px var(--armed); }
.plan-switch { display: flex; align-items: center; gap: 8px; font: 500 13px var(--sans); color: var(--text); }
.plan-list { display: flex; flex-direction: column; gap: 2px; max-height: 460px; overflow-y: auto; margin-top: 8px; }
.plan-row { display: grid; grid-template-columns: 140px 1fr 90px; gap: 10px; align-items: center;
  padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.plan-mnem { font: 600 12px var(--mono); color: var(--accent); }
.plan-name { font: 500 11px var(--sans); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-val { font: 600 12px var(--mono); color: var(--text); text-align: right; }

/* ---------- Destinations (screen groups) ---------- */
.dest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 10px; }
.dest-card { border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.dest-card.transit { border-color: var(--armed); }
.dest-head { display: flex; flex-direction: column; gap: 6px; }
.dest-title { font: 600 14px var(--sans); color: var(--text); display: flex; align-items: baseline; gap: 8px; }
.dest-status { font: 500 11px var(--mono); color: var(--muted); }
.dest-card.transit .dest-status { color: var(--armed); }
.dest-screens { display: flex; flex-wrap: wrap; gap: 4px; }
.dest-chip { font: 600 11px var(--mono); padding: 2px 7px; border-radius: var(--r); background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.dest-chip.grp { color: var(--accent); border-color: var(--accent-dim); }
.dest-tbar input[type=range] { width: 100%; }
.dest-controls { display: flex; gap: 6px; }
.dest-controls .take-btn { flex: 1; }

.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin-top: 8px; }
.group-cell { display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.group-scr { font: 600 12px var(--sans); color: var(--text); }

.diff-chip { font: 600 11px var(--mono); padding: 3px 8px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.diff-change { color: var(--armed); border-color: var(--armed); }
.diff-missing { color: var(--faint); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
