﻿:root {
  --bg: #0e0f13;
  --panel: #16181f;
  --panel-2: #1d2029;
  --border: #2a2d38;
  --text: #eef0f5;
  --text-dim: #9599a8;
  --accent: #6c5ce7;
  --accent-rgb: 108, 92, 231;
  --accent-hover: #7d6ef2;
  --live: #ff4757;
  --ok: #2ed573;
  --tile-bg: #202330;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Console color themes — a personal, per-browser preference for the studio's
   own UI chrome (see theme-picker in studio.js), completely separate from
   Brand tab's background/overlay controls, which style the actual broadcast
   output. --text/--text-dim/--live/--ok stay fixed across every theme: the
   first two read fine against any sufficiently dark background regardless of
   hue, and the last two are semantic (live/recording, success) rather than
   decorative, so recoloring them per-theme would undermine the one thing
   they're for — staying instantly recognizable no matter what else changes. */
:root[data-theme="ocean"] {
  --bg: #0a0f16; --panel: #121b26; --panel-2: #182432; --border: #253244;
  --tile-bg: #1c2a3a; --accent: #2f8fe0; --accent-rgb: 47, 143, 224; --accent-hover: #4aa3ee;
}
:root[data-theme="emerald"] {
  --bg: #0a120f; --panel: #0f1c19; --panel-2: #142722; --border: #223a33;
  --tile-bg: #18291f; --accent: #14b391; --accent-rgb: 20, 179, 145; --accent-hover: #22cca6;
}
:root[data-theme="rose"] {
  --bg: #130b0f; --panel: #1d1017; --panel-2: #26151d; --border: #3a2029;
  --tile-bg: #2c1620; --accent: #e0447e; --accent-rgb: 224, 68, 126; --accent-hover: #ec5f92;
}
:root[data-theme="amber"] {
  --bg: #120f0a; --panel: #1c160f; --panel-2: #251d13; --border: #3a2e1c;
  --tile-bg: #261e13; --accent: #d98a24; --accent-rgb: 217, 138, 36; --accent-hover: #eb9d34;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, select {
  font-family: inherit;
}

a { color: inherit; }

/* ---------- Landing page ---------- */

.landing {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.landing-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff6b81);
}

.brand h1 {
  font-size: 20px;
  margin: 0;
  flex: 1;
}

.hidden { display: none !important; }

.user-button-slot {
  display: flex;
  align-items: center;
}

.signed-out-prompt {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
}

.landing-card h2 {
  font-size: 16px;
  color: var(--text-dim);
  margin: 24px 0 10px;
  font-weight: 600;
}

.landing-card h2:first-of-type { margin-top: 0; }

.field {
  width: 100%;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 10px;
}

.field:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: white;
  transition: background 0.15s ease;
  text-decoration: none; /* .btn now also gets used on <a> tags (marketing pages) — no-op on <button> */
  display: inline-block;
  text-align: center;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: #262a38; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  line-height: 1.5;
}

.error-text {
  color: var(--live);
  font-size: 13px;
  margin: 6px 0 0;
  min-height: 16px;
}

/* ---------- Pre-join (green room) ---------- */

.prejoin-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}

.prejoin-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
}

.prejoin-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--tile-bg);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 8px;
}

#prejoin-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.audio-warn {
  font-size: 12px;
  color: #ffb84d;
  background: rgba(255, 184, 77, 0.1);
  border: 1px solid rgba(255, 184, 77, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 10px 0 0;
  line-height: 1.5;
  text-align: left;
}

.prejoin-video-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- Studio layout ---------- */

.studio {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: 56px 1fr 84px;
  grid-template-areas:
    "topbar topbar"
    "stage  sidebar"
    "controls sidebar";
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-picker { position: relative; display: inline-block; vertical-align: middle; margin-right: 8px; }
.theme-picker-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-picker-btn:hover { background: #262a38; }
.theme-picker-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.theme-picker-btn.active { border-color: var(--accent); color: var(--accent); }
.theme-picker-popover {
  position: absolute;
  top: 40px;
  right: 0;
  z-index: 50;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.theme-swatch-row { display: flex; gap: 8px; }
.theme-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.theme-swatch.active { border-color: var(--text); }
.theme-picker-divider { height: 1px; background: var(--border); }
.theme-bg-row { display: flex; align-items: center; gap: 8px; }
.theme-bg-row label { font-size: 12px; color: var(--text-dim); flex: 1; }
.theme-bg-row input[type="color"] {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-bg-row .small-btn { flex-shrink: 0; }

.audio-settings-popover { min-width: 260px; max-width: 300px; }
.audio-settings-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.audio-device-list { display: flex; flex-direction: column; }
.audio-device-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
}
.audio-device-row span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-device-row:hover { background: #262a38; }
.audio-device-row:disabled { opacity: 0.4; cursor: not-allowed; }
.audio-device-row .audio-device-check { width: 14px; flex-shrink: 0; visibility: hidden; color: var(--accent); }
.audio-device-row.active .audio-device-check { visibility: visible; }

.room-code {
  font-size: 13px;
  color: var(--text-dim);
  background: var(--panel-2);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.live-badge {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--live);
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}
.live-badge.on { display: inline-flex; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: white;
  animation: pulse 1.4s infinite ease-in-out;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.stage-wrap {
  grid-area: stage;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  min-height: 0;
  min-width: 0;
  background: #000;
  position: relative;
}

/* Caps how much of the available space the monitors claim by default —
   smaller, with visible negative space around them, rather than stretching
   edge to edge. The resize handle still works within this: it's bounded by
   this container's own width, so dragging Preview wider scales relative to
   this cap rather than fighting it. */
.stage-monitors {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 1040px;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.stage-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  height: 100%;
}

/* Preview gets a fixed, JS-adjustable basis (see the resize handle below);
   Program (id'd, no fixed basis) just fills whatever space is left. */
#preview-panel {
  flex: 0 0 42%;
  min-width: 160px;
  max-width: 75%;
}

/* Shrink-wraps exactly to the canvas's own rendered size (not the panel,
   which is taller because of the label above it) so the drag handle's
   percentage-based position maps 1:1 to the canvas's own coordinate space. */
.canvas-wrap {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  max-height: calc(100% - 24px);
}

.caption-drag-handle {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid white;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  cursor: grab;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  touch-action: none;
  user-select: none;
  z-index: 5;
}

.caption-drag-handle:active,
.caption-drag-handle.dragging {
  cursor: grabbing;
  background: var(--accent-hover);
  transform: translate(-50%, -50%) scale(1.15);
}

/* Distinct colors so the three draggable handles are tellable apart at a
   glance when more than one is visible on the Preview canvas at once. */
.logo-drag-handle {
  background: #00b894;
}
.logo-drag-handle:active,
.logo-drag-handle.dragging {
  background: #05c9a4;
}

.banner-drag-handle {
  background: #e17055;
}
.banner-drag-handle:active,
.banner-drag-handle.dragging {
  background: #f2825f;
}

.comment-drag-handle {
  background: #0984e3;
}
.comment-drag-handle:active,
.comment-drag-handle.dragging {
  background: #2a9ff5;
}

.frame-move-handle {
  background: #fdcb6e;
}
.frame-move-handle:active,
.frame-move-handle.dragging {
  background: #ffd88a;
}

.frame-resize-handle {
  background: #0984e3;
  cursor: nwse-resize;
}
.frame-resize-handle:active,
.frame-resize-handle.dragging {
  cursor: nwse-resize;
  background: #2aa3ff;
}

.frame-size-shape-row { display: flex; gap: 4px; flex-basis: 100%; margin-left: 44px; }

.volume-control { display: flex; align-items: center; gap: 6px; flex-basis: 100%; margin-left: 44px; margin-top: 4px; }
.volume-mute-btn { flex-shrink: 0; padding: 3px 6px; font-size: 12px; }
.volume-control input[type="range"] { flex: 1; max-width: 130px; }
.frame-size-shape-row .small-btn { padding: 4px 8px; font-size: 11px; }
.frame-size-shape-row .small-btn.active { border-color: var(--accent); color: var(--text); background: rgba(var(--accent-rgb),0.15); }

/* A wider hit zone than the visible grip itself — easier to grab without
   needing pixel-perfect aim, standard practice for a drag divider. A faint
   always-on tint (not just on hover) is what makes this discoverable as
   "adjustable" at a glance instead of reading as empty space. */
.stage-resize-handle {
  width: 20px;
  flex-shrink: 0;
  height: 70%;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  transition: background 0.15s ease;
}

.stage-resize-handle:hover,
.stage-resize-handle.dragging {
  background: rgba(var(--accent-rgb), 0.14);
}

/* Three short bars (a central one plus two shadow-drawn copies) read as a
   grip/drag icon rather than a stray line. */
.stage-resize-grip {
  width: 3px;
  height: 32px;
  border-radius: 2px;
  background: var(--text-dim);
  box-shadow: -7px 0 0 var(--text-dim), 7px 0 0 var(--text-dim);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.stage-resize-handle:hover .stage-resize-grip,
.stage-resize-handle.dragging .stage-resize-grip {
  background: var(--accent);
  box-shadow: -7px 0 0 var(--accent), 7px 0 0 var(--accent);
}

.stage-panel canvas {
  max-width: 100%;
  max-height: calc(100% - 24px);
  background: #000;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

/* The preview canvas sits inside .canvas-wrap now, which already accounts
   for the label's height — without this override the 24px would get
   subtracted a second time (once for the wrap, once for the canvas). */
.canvas-wrap canvas {
  max-height: 100%;
}

.stage-panel-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.program-label {
  color: var(--live);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.live-dot-small {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
  display: inline-block;
}

.cut-btn {
  flex-shrink: 0;
  padding: 12px 22px;
  border-radius: 24px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}
.cut-btn:hover {
  background: var(--accent-hover);
}

.controls {
  grid-area: controls;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 0 16px;
}

.action-toast {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 10px;
  background: var(--live);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.ctrl-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ctrl-btn:hover { background: #262a38; }
.ctrl-btn.off { background: var(--live); border-color: var(--live); }

.camera-select {
  height: 46px;
  padding: 0 10px;
  border-radius: 23px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  max-width: 130px;
}
.camera-select:disabled { opacity: 0.5; }

.vu-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.vu-meter-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-dim);
}

.vu-meter-track {
  width: 64px;
  height: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.vu-meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ok), #ffd166 75%, var(--live));
}

.no-audio-pill {
  font-size: 11px;
  font-weight: 700;
  color: #ffb84d;
  background: rgba(255, 184, 77, 0.12);
  border: 1px solid rgba(255, 184, 77, 0.35);
  border-radius: 12px;
  padding: 4px 10px;
  white-space: nowrap;
}

.go-live-btn {
  padding: 0 22px;
  height: 46px;
  border-radius: 23px;
  border: none;
  background: var(--live);
  color: white;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.3px;
}
.go-live-btn.recording { background: var(--ok); }
.go-live-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.record-btn {
  padding: 0 18px;
  height: 46px;
  border-radius: 23px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}
.record-btn.recording { background: var(--live); border-color: var(--live); color: white; }
.record-btn.paused { background: var(--panel-2); border-color: var(--live); color: var(--live); }

.pause-btn {
  padding: 0 16px;
  height: 46px;
  border-radius: 23px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}
.pause-btn.paused { background: var(--ok); border-color: var(--ok); color: white; }

.leave-btn {
  padding: 0 18px;
  height: 46px;
  border-radius: 23px;
  border: none;
  background: #3a1620;
  color: #ff8a94;
  font-weight: 600;
  font-size: 13px;
}

/* ---------- Sidebar ---------- */

.sidebar {
  grid-area: sidebar;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 12px 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab-btn:hover { color: var(--text); background: rgba(var(--accent-rgb), 0.06); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); background: rgba(var(--accent-rgb), 0.1); }

.tab-panel { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
.tab-panel.active { display: flex; }

/* People list */
.people-list { overflow-y: auto; padding: 8px; flex: 1; }

.pending-request {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  margin: 8px 8px 0;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
}
.pending-request-name { flex: 1; font-size: 13px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-request .small-btn { flex-shrink: 0; }
.pending-request .small-btn.accept { border-color: var(--ok); color: var(--ok); }

.scene-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.scene-name { flex: 1; font-size: 13px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-row .small-btn { flex-shrink: 0; }
.scene-row .small-btn.accept { border-color: var(--ok); color: var(--ok); }

.person-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
}
.person-row:hover { background: var(--panel-2); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}

.person-meta { flex: 1; min-width: 0; }
.person-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-role { font-size: 11px; color: var(--text-dim); }

.stage-toggle {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  flex-shrink: 0;
}
.stage-toggle.on { background: rgba(46,213,115,0.15); border-color: var(--ok); color: var(--ok); }

.ptt-btn { flex-shrink: 0; user-select: none; touch-action: none; }
.ptt-btn.active { background: var(--live); border-color: var(--live); color: white; }

.vbg-mode-btn.active { border-color: var(--accent); color: var(--text); background: rgba(var(--accent-rgb), 0.15); }

.cohost-btn { flex-shrink: 0; }
.cohost-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb),0.15); }

/* Chat */
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { font-size: 13px; line-height: 1.4; }
.chat-msg .who { font-weight: 700; margin-right: 6px; }
.chat-msg .when { color: var(--text-dim); font-size: 11px; margin-left: 6px; }
.feature-comment-btn { display: block; margin-top: 6px; }
.feature-comment-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb),0.15); }
.chat-input-row { display: flex; border-top: 1px solid var(--border); padding: 10px; gap: 8px; }
.chat-input-row input { flex: 1; }
.chat-input-row button { padding: 0 14px; border-radius: 8px; border: none; background: var(--accent); color: white; font-weight: 600; }

/* Brand / settings panel */
/* Brand tab's sub-tabs — that panel grew into six sections stacked in one
   long scroll (layout, background, lower third, captions, overlays); this
   splits them into their own switchable panes instead, with .settings-panel
   below scrolling only within whichever one is active. A pill row rather
   than the main .tabs underline style, so it doesn't read as a second set of
   the same top-level tabs. */
.subtabs { display: flex; gap: 6px; padding: 10px 14px 0; flex-wrap: wrap; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.subtab-btn {
  padding: 6px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}
.subtab-btn.active { border-color: var(--accent); color: var(--text); background: rgba(var(--accent-rgb), 0.15); }
.subtab-panel { display: none; }
.subtab-panel.active { display: block; }

.settings-panel { overflow-y: auto; padding: 14px; flex: 1; }
.settings-panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); margin: 18px 0 8px; }
.settings-panel h3:first-child { margin-top: 0; }
.settings-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.settings-row label { font-size: 13px; }
.layout-options { display: flex; gap: 8px; }
.layout-opt { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text-dim); font-size: 12px; }
.layout-opt.active { border-color: var(--accent); color: var(--text); background: rgba(var(--accent-rgb),0.15); }
.color-swatch { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border); padding: 0; background: none; }
.small-btn { font-size: 12px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }

.dest-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.dest-preset { font-size: 11px; padding: 5px 9px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text-dim); }
.dest-preset.active { border-color: var(--accent); color: var(--text); }

.destination-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--panel-2); }
.destination-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.destination-card-title-input {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 2px 0;
  flex: 1;
  min-width: 0;
}
.destination-card-title-input:hover,
.destination-card-title-input:focus {
  outline: none;
  color: var(--text);
  border-bottom-color: var(--border);
}
.destination-card .field { margin-bottom: 8px; }
.destination-card .field:last-child { margin-bottom: 0; }
.destination-card .field:disabled { opacity: 0.55; }
.destination-card .dest-preset:disabled { opacity: 0.55; }

.destination-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.destination-card-status { font-size: 11px; color: var(--text-dim); }
.destination-card-status.ok { color: var(--ok); }
.destination-card-status.error { color: var(--live); }
.dest-live-btn { flex-shrink: 0; min-width: 70px; }
.dest-live-btn.live { border-color: var(--ok); color: var(--ok); background: rgba(0,184,148,0.12); }
.dest-live-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.status-line { font-size: 12px; color: var(--text-dim); margin-top: 8px; line-height: 1.5; }
.status-line.error { color: var(--live); }
.status-line.ok { color: var(--ok); }

.empty-state {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 24px 12px;
}

/* Toggle switch */
.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: 22px; transition: 0.15s; }
.slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: var(--text-dim); border-radius: 50%; transition: 0.15s; }
.switch input:checked + .slider { background: rgba(var(--accent-rgb),0.3); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); background: var(--accent); }

/* Local video sources (hidden, used only to feed the canvas compositor) */
.source-pool { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

@media (max-width: 860px) {
  .studio {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 1fr 84px 240px;
    grid-template-areas:
      "topbar"
      "stage"
      "controls"
      "sidebar";
  }
  .sidebar { border-left: none; border-top: 1px solid var(--border); }
}
