/* ======================================================================
   LiveDeck Studio — design system
   ====================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  /* core palette — dark */
  --bg-0: #0a0d11;
  --bg-1: #11151b;
  --bg-2: #181d25;
  --bg-3: #1f2630;
  --bg-4: #2a323e;
  --line: #2c3441;
  --line-soft: #1e2530;

  --ink-0: #f4f6f9;
  --ink-1: #c8cfdb;
  --ink-2: #8b94a5;
  --ink-3: #5d6675;
  --ink-dim: #3a4250;

  --accent: #1ad17a;
  --accent-strong: #0fb37a;
  --accent-soft: rgba(26, 209, 122, 0.16);
  --live: #ff3b58;
  --live-soft: rgba(255, 59, 88, 0.18);
  --rec: #ffa940;
  --rec-soft: rgba(255, 169, 64, 0.18);
  --info: #66a6ff;
  --warn: #f3c969;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-glow-live: 0 0 0 1px var(--live), 0 0 24px var(--live-soft);
  --shadow-glow-acc: 0 0 0 1px var(--accent), 0 0 22px var(--accent-soft);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --transition: 160ms cubic-bezier(.2,.6,.2,1);
}

:root[data-theme="light"] {
  --bg-0: #f3f5f8;
  --bg-1: #ffffff;
  --bg-2: #f6f8fb;
  --bg-3: #eef1f6;
  --bg-4: #e3e8ef;
  --line: #d8dee7;
  --line-soft: #e8ecf2;

  --ink-0: #0f1620;
  --ink-1: #2a3340;
  --ink-2: #5a6473;
  --ink-3: #7e8694;
  --ink-dim: #a3aab6;

  --accent: #0a9b5d;
  --accent-strong: #07875b;
  --accent-soft: rgba(10, 155, 93, 0.14);
  --live: #d22640;
  --live-soft: rgba(210, 38, 64, 0.15);
  --rec: #d4810a;
  --rec-soft: rgba(212, 129, 10, 0.15);

  --shadow: 0 6px 24px rgba(15, 22, 32, 0.10), 0 2px 6px rgba(15, 22, 32, 0.06);
}

html, body {
  margin: 0;
  background: var(--bg-0);
  color: var(--ink-0);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: -1000px;
  top: 8px;
  background: var(--accent);
  color: #042217;
  padding: 8px 14px;
  border-radius: 6px;
  z-index: 100;
  font-weight: 600;
}
.skip-link:focus { left: 8px; }

/* ======================================================================
   Header
   ====================================================================== */
.app-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(80px, 1fr);
  align-items: center;
  padding: 12px 18px;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-bottom: 1px solid var(--line);
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #0e7f57);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(255,255,255,0.08);
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.25), transparent 50%);
}
.brand-mark .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.25), 0 0 12px rgba(255,255,255,0.45);
}
.brand-text h1 { margin: 0; font-size: 15px; letter-spacing: 0.2px; }
.brand-text .tagline { margin: 0; font-size: 11.5px; color: var(--ink-2); }

.status-cluster {
  display: flex; gap: 8px;
  justify-self: center;
}
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.3px;
  transition: var(--transition);
}
.pill-label { color: var(--ink-2); font-weight: 600; text-transform: uppercase; }
.pill-value { font-family: var(--font-mono); font-size: 12px; color: var(--ink-0); }
.pill-quiet { background: transparent; }
.pip {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-dim);
  transition: var(--transition);
}
.pip-rec { background: var(--ink-dim); }
.pip-live { background: var(--ink-dim); }
#status-rec[data-active="true"] { border-color: var(--rec); background: var(--rec-soft); color: var(--ink-0); }
#status-rec[data-active="true"] .pip-rec { background: var(--rec); box-shadow: 0 0 12px var(--rec); animation: blink 1.3s ease-in-out infinite; }
#status-live[data-active="true"] { border-color: var(--live); background: var(--live-soft); }
#status-live[data-active="true"] .pip-live { background: var(--live); box-shadow: 0 0 12px var(--live); animation: blink 1.0s ease-in-out infinite; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.header-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ======================================================================
   Buttons
   ====================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink-0);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-4); border-color: var(--ink-dim); }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-primary { background: var(--accent); color: #062317; border-color: var(--accent-strong); font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); color: #062317; }
.btn-danger { background: transparent; color: var(--live); border-color: var(--live); }
.btn-danger:hover { background: var(--live-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-1); }
.btn-ghost:hover { background: var(--bg-3); color: var(--ink-0); }
.btn-icon { padding: 6px; width: 34px; height: 34px; border-radius: 8px; }
.btn-icon svg { width: 18px; height: 18px; display: block; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-live { background: linear-gradient(135deg, var(--live), #c41931); color: #fff; border-color: transparent; font-weight: 600; }
.btn-live:hover { filter: brightness(1.08); }
.btn-live[aria-pressed="true"] { box-shadow: var(--shadow-glow-live); }

/* ======================================================================
   Workspace 3-column
   ====================================================================== */
.workspace {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.panel-head h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 600;
}
.panel-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-2);
}

/* Scenes */
.panel-scenes { min-width: 0; }
.scene-list {
  list-style: none; margin: 0; padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
  flex: 1;
}
.scene-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  background: transparent;
  position: relative;
}
.scene-item:hover { background: var(--bg-2); }
.scene-item[aria-selected="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.scene-thumb {
  width: 38px; height: 24px;
  border-radius: 4px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: 11px; color: var(--ink-3);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.scene-thumb svg { width: 14px; height: 14px; color: var(--ink-2); }
.scene-item[aria-selected="true"] .scene-thumb { border-color: var(--accent); color: var(--accent); }
.scene-item[aria-selected="true"] .scene-thumb svg { color: var(--accent); }
.scene-name { flex: 1; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-del {
  opacity: 0; visibility: hidden;
  padding: 2px 6px; font-size: 11px;
  background: transparent; color: var(--ink-3);
  border: 1px solid transparent;
  border-radius: 4px;
  transition: var(--transition);
}
.scene-item:hover .scene-del { opacity: 1; visibility: visible; }
.scene-del:hover { color: var(--live); }

/* Program */
.panel-program { min-width: 0; }
.program-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.3px;
}
.program-stage {
  position: relative;
  flex: 1;
  background: #000;
  margin: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 340px;
}
#program-video, #program-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
#program-canvas { display: none; }

.program-stage[data-live="true"]::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--live), inset 0 0 80px rgba(255,59,88,0.20);
}

.program-overlay {
  position: absolute; inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr 1fr;
  padding: 16px;
  pointer-events: none;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.overlay-corner { display: flex; align-items: center; gap: 8px; }
.overlay-tl { grid-row: 1; grid-column: 1; }
.overlay-tr { grid-row: 1; grid-column: 2; justify-content: flex-end; }
.overlay-bl { grid-row: 3; grid-column: 1; }
.overlay-br { grid-row: 3; grid-column: 2; justify-content: flex-end; font-family: var(--font-mono); font-size: 11px; opacity: 0.75; }
.overlay-center {
  grid-row: 2; grid-column: 1 / -1;
  align-self: end;
  font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
  opacity: 0.65;
  padding-bottom: 6px;
}
.overlay-label { font-size: 10px; letter-spacing: 0.6px; opacity: 0.7; }
.rec-dot {
  width: 10px; height: 10px;
  background: var(--live);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--live);
  animation: blink 1.0s ease-in-out infinite;
}
.signal-bars {
  display: inline-flex; align-items: flex-end; gap: 2px;
  height: 14px;
}
.signal-bars span {
  width: 3px; background: rgba(255,255,255,0.5);
  border-radius: 1px;
}
.signal-bars span:nth-child(1) { height: 30%; }
.signal-bars span:nth-child(2) { height: 55%; }
.signal-bars span:nth-child(3) { height: 80%; }
.signal-bars span:nth-child(4) { height: 100%; }

.audio-bar {
  width: 140px; height: 6px;
  background: rgba(255,255,255,0.16);
  border-radius: 4px;
  overflow: hidden;
}
.audio-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--rec) 75%, var(--live));
  width: 0%;
  transition: width 60ms linear;
}

.program-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center; align-content: center;
  gap: 8px; padding: 24px; text-align: center;
  color: var(--ink-1);
  background: radial-gradient(circle at center, var(--bg-2), var(--bg-0) 70%);
}
.program-empty svg { width: 48px; height: 48px; color: var(--ink-2); margin-bottom: 8px; }
.program-empty p { margin: 0; font-size: 14px; }
.program-empty .muted { font-size: 12px; color: var(--ink-2); }
.program-empty .btn { margin-top: 12px; }

.transition-flash {
  position: absolute; inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.transition-flash[data-playing="true"] {
  animation: flash 420ms ease-out;
}
@keyframes flash {
  0% { opacity: 0; transform: scale(1.08); }
  20% { opacity: 0.85; }
  100% { opacity: 0; transform: scale(1); }
}

.program-toolbar {
  display: flex; gap: 8px; padding: 12px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-2);
  flex-shrink: 0;
}

/* Audio mixer */
.panel-audio { min-width: 0; }
.channels {
  display: flex; flex-direction: column;
  padding: 12px;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}
.channel {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  gap: 6px 10px;
  align-items: center;
}
.channel-name {
  font-size: 12px; font-weight: 600;
  color: var(--ink-0);
  display: flex; align-items: center; gap: 8px;
}
.channel-name .src-icon {
  width: 14px; height: 14px;
  color: var(--ink-2);
}
.channel-mute {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--ink-2);
}
.channel-mute[aria-pressed="true"] {
  background: var(--live-soft);
  border-color: var(--live);
  color: var(--live);
}
.channel-meter {
  grid-column: 1 / -1;
  height: 8px;
  background: var(--bg-0);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.channel-meter::before, .channel-meter::after {
  content: "";
  position: absolute; top: 0; bottom: 0;
  width: 1px; background: var(--ink-dim);
  opacity: 0.5;
}
.channel-meter::before { left: 70%; }   /* -3 db marker */
.channel-meter::after { left: 50%; background: var(--accent); opacity: 0.4; }
.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 60%, var(--rec) 75%, var(--live) 95%);
  width: 0%;
  transition: width 50ms linear;
  border-radius: 4px;
}
.channel-meter[data-muted="true"] .meter-fill { background: var(--ink-dim); opacity: 0.5; }
.channel-fader {
  grid-column: 1 / -1;
  width: 100%;
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px;
  background: var(--bg-3);
}
.channel-fader::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink-0); border: 2px solid var(--bg-1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.channel-fader::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink-0); border: 2px solid var(--bg-1);
}

.check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-1);
  cursor: pointer; user-select: none;
}
.check input { accent-color: var(--accent); width: 14px; height: 14px; }

.range {
  display: grid;
  grid-template-columns: 60px 1fr 32px;
  gap: 10px; align-items: center;
  font-size: 12px;
}
.range input[type=range] {
  -webkit-appearance: none; appearance: none;
  height: 4px; background: var(--bg-3); border-radius: 2px;
}
.range input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-1);
}
.range input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-1);
}
.range output { font-family: var(--font-mono); color: var(--ink-2); text-align: right; }

/* ======================================================================
   Deck
   ====================================================================== */
.deck-region {
  margin: 0 14px 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.deck-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-2);
  gap: 12px;
  flex-wrap: wrap;
}
.deck-titlebar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.deck-titlebar h2 {
  margin: 0; font-size: 12px; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--ink-2); font-weight: 600;
}
.page-pills { display: flex; gap: 4px; }
.page-pill {
  padding: 4px 10px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 12px;
  font-family: var(--font-mono);
  position: relative;
}
.page-pill[aria-selected="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.page-pill .x {
  margin-left: 6px; opacity: 0.5;
}
.deck-tools { display: flex; align-items: center; gap: 14px; }

.learn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-dim);
  transition: var(--transition);
}
#learn-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
#learn-btn[aria-pressed="true"] .learn-dot {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: blink 1.0s ease-in-out infinite;
}
body[data-learn="true"] .deck-region {
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 1px var(--accent);
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.deck-btn {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 10px 8px 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-1);
  cursor: pointer;
  overflow: hidden;
  transition: transform 100ms ease, box-shadow 150ms ease, background 150ms ease;
  user-select: none;
}
.deck-btn:hover {
  transform: translateY(-1px);
  border-color: var(--ink-dim);
}
.deck-btn:active {
  transform: translateY(0);
  filter: brightness(1.2);
}
.deck-btn[data-empty="true"] {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--ink-3);
}
.deck-btn[data-empty="true"] .deck-glyph { opacity: 0.4; }
.deck-btn[data-empty="true"] .deck-label { color: var(--ink-3); }

.deck-btn[data-color="green"]  { --b: 26,209,122; }
.deck-btn[data-color="red"]    { --b: 255,59,88; }
.deck-btn[data-color="amber"]  { --b: 255,169,64; }
.deck-btn[data-color="blue"]   { --b: 102,166,255; }
.deck-btn[data-color="purple"] { --b: 168,130,255; }
.deck-btn[data-color="pink"]   { --b: 255,120,180; }
.deck-btn[data-color="cyan"]   { --b: 80,210,230; }
.deck-btn[data-color="slate"]  { --b: 130,142,160; }

.deck-btn:not([data-empty="true"]) {
  background: linear-gradient(180deg, rgba(var(--b), 0.22), rgba(var(--b), 0.08));
  border-color: rgba(var(--b), 0.45);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.deck-btn[data-active="true"] {
  box-shadow: 0 0 0 2px rgb(var(--b)), 0 0 28px rgba(var(--b), 0.5);
  background: linear-gradient(180deg, rgba(var(--b), 0.50), rgba(var(--b), 0.20));
}
.deck-btn[data-firing="true"] {
  animation: deckFire 340ms ease-out;
}
@keyframes deckFire {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.6); }
  40%  { box-shadow: 0 0 0 6px rgba(255,255,255,0.1), 0 0 30px rgba(var(--b, 26,209,122), 0.8); transform: scale(0.97); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}
.deck-glyph {
  display: grid; place-items: center;
  font-size: 26px;
  line-height: 1;
}
.deck-glyph svg { width: 28px; height: 28px; }
.deck-label {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.2px;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.deck-badge {
  position: absolute;
  top: 4px; right: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.3px;
}
.deck-btn[data-empty="true"] .deck-badge { color: var(--ink-dim); }
.deck-shortcut {
  position: absolute;
  bottom: 4px; left: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: rgba(255,255,255,0.45);
}
.deck-btn[data-empty="true"] .deck-shortcut { color: var(--ink-dim); }

body[data-learn="true"] .deck-btn::after {
  content: "";
  position: absolute; inset: -2px;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  animation: pulseBorder 1.4s ease-in-out infinite;
  pointer-events: none;
}
body[data-learn="true"] .deck-btn[data-await="true"]::after {
  border-color: var(--rec);
  border-style: solid;
}
@keyframes pulseBorder {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.deck-foot {
  padding: 8px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-2);
  font-size: 12px;
  color: var(--ink-2);
  min-height: 32px;
}

/* ======================================================================
   Status bar
   ====================================================================== */
.status-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 16px;
  background: var(--bg-1);
  border-top: 1px solid var(--line);
  font-size: 11.5px;
}
.status-cell {
  display: flex; align-items: center; gap: 6px;
  color: var(--ink-2);
}
.status-cell .label { color: var(--ink-2); font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; font-size: 10.5px; }
.status-cell .value { color: var(--ink-0); font-family: var(--font-mono); font-size: 11px; }
.led {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-dim);
}
.led[data-state="on"] { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.led[data-state="connected"] { background: var(--info); box-shadow: 0 0 8px var(--info); }
.led[data-state="learn"] { background: var(--rec); box-shadow: 0 0 8px var(--rec); animation: blink 1s ease-in-out infinite; }
.status-spacer { flex: 1; }
.copyright { color: var(--ink-3); font-size: 11px; }
.status-cell-quiet .value { color: var(--ink-2); }

/* ======================================================================
   Modal
   ====================================================================== */
.modal {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 50;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(5, 8, 12, 0.65);
  backdrop-filter: blur(4px);
  animation: fadein 200ms ease;
}
.modal-card {
  position: relative;
  width: min(520px, 100%);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 32px);
  animation: slidein 220ms ease;
}
.modal-card-lg { width: min(700px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-2);
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes slidein {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.field { margin-bottom: 14px; }
.field > label, .field > legend {
  display: block;
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 6px;
  font-weight: 600;
}
.field input[type=text], .field select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  color: var(--ink-0);
}
.field input[type=text]:focus, .field select:focus {
  border-color: var(--accent);
  outline: none;
}

.icon-row, .color-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.icon-tile {
  aspect-ratio: 1;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 18px;
  transition: var(--transition);
}
.icon-tile svg { width: 18px; height: 18px; color: var(--ink-1); }
.icon-tile:hover { background: var(--bg-3); }
.icon-tile[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.icon-tile[aria-pressed="true"] svg { color: var(--accent); }

.color-tile {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}
.color-tile[aria-pressed="true"] {
  border-color: var(--ink-0);
  transform: scale(1.07);
}

.bindings-field { border: 1px solid var(--line); padding: 14px; border-radius: 10px; }
.binding-row {
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
}
.binding-row + .binding-row { border-top: 1px solid var(--line-soft); }
.binding-label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.binding-value {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-2);
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--ink-0);
  border: 1px solid var(--line-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.binding-row.awaiting .binding-value {
  border-color: var(--rec);
  color: var(--rec);
  animation: blink 1.2s ease-in-out infinite;
}

/* Onboard */
.onboard-options {
  display: grid; gap: 10px;
}
.onboard-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: left;
  display: flex; flex-direction: column;
  gap: 4px;
  transition: var(--transition);
}
.onboard-card:hover { background: var(--bg-3); border-color: var(--accent); }
.onboard-card strong { font-size: 14px; }
.onboard-card span { font-size: 12px; color: var(--ink-2); }

/* Help */
.help-body { line-height: 1.6; }
.help-body h4 {
  margin: 18px 0 6px;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--ink-2);
  text-transform: uppercase;
}
.help-body p { margin: 0 0 10px; font-size: 13px; }
.help-body ul { padding-left: 18px; margin: 0 0 10px; }
.help-body li { font-size: 13px; margin-bottom: 4px; }
.help-grid { columns: 2; column-gap: 24px; padding: 0; list-style: none; }
.help-grid li { padding-left: 0; margin-bottom: 8px; break-inside: avoid; }
.kb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kb-table td { padding: 4px 8px; border-bottom: 1px solid var(--line-soft); }
.kb-table td:first-child { width: 130px; }
kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-0);
  margin-right: 2px;
}

/* ======================================================================
   Toasts
   ====================================================================== */
.toasts {
  position: fixed;
  bottom: 60px; right: 20px;
  display: flex; flex-direction: column;
  gap: 10px;
  z-index: 60;
  pointer-events: none;
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  min-width: 220px;
  animation: toastin 220ms ease;
  pointer-events: auto;
}
.toast.toast-warn { border-left-color: var(--rec); }
.toast.toast-err { border-left-color: var(--live); }
@keyframes toastin {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ======================================================================
   Responsive
   ====================================================================== */
@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .panel-scenes { order: 2; max-height: 240px; }
  .panel-program { order: 1; }
  .panel-audio { order: 3; max-height: 280px; }
  .deck-grid { grid-template-columns: repeat(6, 1fr); }
  .status-cluster { display: none; }
}
@media (max-width: 720px) {
  .app-header { grid-template-columns: 1fr auto; }
  .status-cluster { display: none; }
  .deck-grid { grid-template-columns: repeat(4, 1fr); }
  .help-grid { columns: 1; }
  .channel-meter { height: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
