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

:root {
  --bg: #0d0f16;
  --surface: #161820;
  --surface2: #1e2028;
  --border: #272a34;
  --accent: #D85A30;
  --accent-hover: #e07040;
  --danger: #ef5b5b;
  --live: #e63946;
  --record: #e63946;
  --text: #ece9e4;
  --text-dim: #6b6e7a;
  --radius: 8px;
  --sidebar-w: 272px;
  --controls-h: 56px;
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

.screen { display: none; height: 100%; }
.screen.active { display: flex; }

/* ── Join ── */
#join-screen { align-items: center; justify-content: center; }
.join-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px 36px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 20px;
}
.join-card h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.brand-lockup { display: flex; align-items: center; padding: 4px 0 2px; }
.sidebar-brand {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-brand svg { width: 200px; height: auto; display: block; }
.subtitle { color: var(--text-dim); margin-top: -12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.field input {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; color: var(--text); font-size: 14px; outline: none; transition: border-color 0.15s; width: 100%;
}
.field input:focus { border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; }
.join-actions { display: flex; gap: 10px; }
.hint { font-size: 12px; color: var(--text-dim); line-height: 1.5; }

/* Role picker */
.role-picker { display: flex; gap: 8px; }
.role-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 12px 8px; border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--surface2); color: var(--text-dim); cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.role-btn:hover { border-color: var(--accent); color: var(--text); }
.role-btn.active { border-color: var(--accent); background: rgba(216,90,48,.12); color: var(--text); }
.role-icon { font-size: 22px; line-height: 1; }
.role-title { font-size: 13px; font-weight: 700; }
.role-desc  { font-size: 11px; color: var(--text-dim); text-align: center; }
.role-btn.active .role-desc { color: var(--accent); }

/* Guest mode — hide host-only sidebar sections */
#studio-screen.guest-mode .host-only { display: none; }

/* ── Buttons ── */
.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  padding: 11px 24px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.15s; flex: 1;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent; color: var(--text-dim); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; font-size: 14px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s; white-space: nowrap;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }
.btn-ghost.small { padding: 4px 10px; font-size: 12px; }
.btn-ghost.danger:hover { color: var(--danger); border-color: var(--danger); }
.btn-live {
  background: var(--live); color: #fff; border: none; border-radius: var(--radius);
  padding: 8px 16px; font-weight: 600; cursor: pointer; font-size: 13px; transition: opacity 0.15s;
}
.btn-live:hover { opacity: 0.85; }
.btn-live:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-stop {
  background: var(--surface2); color: var(--danger); border: 1px solid var(--danger);
  border-radius: var(--radius); padding: 8px 16px; font-weight: 600; cursor: pointer; font-size: 13px;
}
.btn-record {
  background: var(--surface2); color: var(--record); border: 1px solid var(--record);
  border-radius: var(--radius); padding: 7px 14px; font-weight: 600; cursor: pointer; font-size: 13px;
}
.btn-record:hover, .btn-stop:hover { opacity: 0.85; }

.hidden { display: none !important; }
.hidden-file { display: none; }

/* ── Host auth (join screen) ── */
#host-auth-wrap {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; background: rgba(255,255,255,.03); display: flex; flex-direction: column; gap: 10px;
}
.auth-tabs { display: flex; gap: 6px; }
.auth-tab {
  flex: 1; padding: 6px 0; background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-dim); font-size: 13px; cursor: pointer;
  transition: background .15s, color .15s;
}
.auth-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.auth-tab:hover:not(.active) { border-color: var(--accent); color: var(--text); }
.btn-primary.full-width { width: 100%; }
.auth-error { font-size: 12px; color: #ff6b6b; padding: 6px 8px; background: rgba(255,100,100,.1); border-radius: 4px; }
.auth-signed-in {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: 13px; color: var(--text);
}
.auth-check { color: #4caf50; font-size: 16px; }
.auth-email-label { flex: 1; color: var(--text-dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-divider {
  display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-size: 11px; margin: 4px 0;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
#g_id_signin { display: flex; justify-content: center; }
.pin-input { width: 100px; text-align: center; letter-spacing: 6px; font-size: 18px; font-weight: 600; padding: 6px 10px; }
.room-pin-row { margin-top: 6px; align-items: center; }
#room-pin-status { flex: 1; }
#room-pin-edit { gap: 6px; margin-top: 4px; }
#room-pin-edit .pin-input { width: 80px; font-size: 16px; letter-spacing: 4px; }
.btn-ghost.small.danger { color: #ff6b6b; }
.btn-ghost.small.danger:hover { background: rgba(255,100,100,.12); border-color: #ff6b6b; }

/* ── Studio layout ── */
#studio-screen { flex-direction: row; height: 100vh; overflow: hidden; position: relative; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; padding-bottom: 16px;
}
.sidebar-section { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.sidebar-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); }
.room-id { font-size: 13px; font-family: monospace; color: var(--accent-hover); word-break: break-all; }

/* Output resolution select */
#resolution-select {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; color: var(--text); font-size: 13px; outline: none; width: 100%;
}
#resolution-select:focus { border-color: var(--accent); }
#resolution-select option { background: var(--surface2); }

/* Layout buttons */
.layout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.layout-btn {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-dim); font-size: 12px; padding: 7px 6px; cursor: pointer; transition: all 0.15s;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.layout-btn:hover { color: var(--text); border-color: var(--text-dim); }
.layout-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Scene controls */
.upload-label {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 8px 10px; font-size: 12px; color: var(--text-dim); cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.upload-label:hover { border-color: var(--accent); color: var(--text); }
.upload-label.has-file { border-color: var(--accent); color: var(--accent-hover); border-style: solid; }
.scene-row { align-items: center; gap: 6px; flex-wrap: nowrap; }
.scene-row .hint { white-space: nowrap; flex-shrink: 0; }
.color-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); cursor: pointer; white-space: nowrap; }
.color-label input[type="color"] { width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 4px; background: none; padding: 1px; cursor: pointer; }
.logo-controls { display: flex; flex-direction: column; gap: 6px; background: var(--surface2); border-radius: var(--radius); padding: 8px; }
.logo-controls select { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 8px; color: var(--text); font-size: 12px; flex: 1; outline: none; }
.logo-controls input[type="range"] { flex: 1; accent-color: var(--accent); cursor: pointer; }
.logo-controls span { font-size: 11px; color: var(--text-dim); white-space: nowrap; }

/* Saved scenes */
.scene-name-input {
  flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 8px; color: var(--text); font-size: 12px; outline: none;
}
.scene-name-input:focus { border-color: var(--accent); }
.scenes-list { display: flex; flex-direction: column; gap: 5px; }
.scene-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 8px;
}
.scene-item-name { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-item-load {
  background: var(--accent); color: #fff; border: none; border-radius: 5px;
  padding: 3px 9px; font-size: 11px; cursor: pointer; white-space: nowrap;
}
.scene-item-load:hover { background: var(--accent-hover); }
.scene-item-del {
  background: transparent; color: var(--text-dim); border: 1px solid var(--border);
  border-radius: 5px; padding: 3px 7px; font-size: 11px; cursor: pointer;
}
.scene-item-del:hover { color: var(--danger); border-color: var(--danger); }

/* Participants */
#participants-list { display: flex; flex-direction: column; gap: 6px; }
.participant-row {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 9px; border-radius: var(--radius);
  background: var(--surface2); border: 1px solid var(--border);
}
.participant-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.participant-name { flex: 1; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.participant-badges { display: flex; gap: 4px; font-size: 11px; }
.participant-actions { display: flex; gap: 3px; flex-shrink: 0; }
.p-action-btn {
  background: var(--surface); border: 1px solid var(--border);
  padding: 3px 6px; font-size: 12px; cursor: pointer;
  color: var(--text-dim); border-radius: 4px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1;
}
.p-action-btn:hover { background: var(--surface2); border-color: var(--text-dim); color: var(--text); }
.p-action-btn.active { background: rgba(216,90,48,0.18); border-color: var(--accent); color: var(--accent); }
.name-edit-input {
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: 4px; padding: 2px 6px;
  color: var(--text); font-size: 12px; outline: none;
}

/* Stream */
.stream-section select, .stream-section input[type="text"], .stream-section input[type="password"] {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; color: var(--text); font-size: 13px; outline: none; width: 100%;
}
.stream-section select:focus, .stream-section input:focus { border-color: var(--accent); }
.stream-section select option { background: var(--surface2); }
.stream-actions { display: flex; gap: 8px; margin-top: 6px; }
.stream-status { font-size: 12px; min-height: 16px; }
.stream-status.live { color: var(--live); font-weight: 600; }
.stream-status.error { color: var(--danger); }

/* ── Audio Mixer ── */
#mixer-channels { display: flex; flex-direction: column; gap: 6px; }

.mixer-channel {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 7px 9px;
}

.mixer-ch-name {
  font-size: 11px; font-weight: 700; color: var(--text);
  width: 60px; min-width: 60px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Fader wrap — meter fill + peak pip + slider all stacked */
.mixer-fader-wrap {
  flex: 1; position: relative;
  height: 22px; display: flex; align-items: center;
}

/* Dark track background (sits behind fill and slider) */
.mixer-fader-wrap::before {
  content: '';
  position: absolute; left: 0; right: 0;
  top: 50%; transform: translateY(-50%);
  height: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; pointer-events: none; z-index: 0;
}

/* Meter level fill — grows left-to-right inside the track */
.mixer-meter-fill {
  position: absolute; left: 0; width: 0%;
  top: 50%; transform: translateY(-50%);
  height: 8px; border-radius: 4px;
  background: linear-gradient(to right, #00c853 0%, #8bc34a 45%, #ffd600 70%, #ff6d00 85%, #ff1744 93%);
  opacity: 0.75; pointer-events: none; z-index: 1;
}

/* Peak-hold pip — a thin bright vertical line at the recent peak */
.mixer-peak-hold {
  position: absolute;
  width: 3px; height: 14px;
  top: 50%; transform: translateY(-50%);
  background: #ffd600; border-radius: 2px;
  opacity: 0; pointer-events: none; z-index: 2;
  transition: opacity 0.25s;
}
.mixer-peak-hold.visible { opacity: 0.95; }
.mixer-peak-hold.over { background: #ff1744; }

/* Volume slider sits on top — track transparent so fill shows through */
.mixer-vol {
  position: relative; z-index: 3;
  width: 100%; height: 22px;
  -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
.mixer-vol::-webkit-slider-runnable-track {
  height: 8px; background: transparent; border-radius: 4px;
}
.mixer-vol::-moz-range-track {
  height: 8px; background: transparent; border-radius: 4px; border: none;
}
.mixer-vol::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
  cursor: pointer; box-shadow: 0 1px 6px rgba(0,0,0,0.7);
  margin-top: -4px;
}
.mixer-vol::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
  cursor: pointer; box-shadow: 0 1px 6px rgba(0,0,0,0.7);
}

.mixer-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 6px; font-size: 13px;
  cursor: pointer; color: var(--text); line-height: 1.2;
  transition: background 0.15s, border-color 0.15s;
}
.mixer-btn:hover { background: var(--surface2); border-color: var(--accent); color: #fff; }
.mixer-btn.muted { background: rgba(239,91,91,0.15); border-color: var(--danger); color: var(--danger); }
.mixer-btn.cam-off { background: rgba(239,91,91,0.15); border-color: var(--danger); color: var(--danger); }

/* Multi-destination rows */
#stream-destinations { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }

.stream-dest-row {
  display: flex; flex-direction: column; gap: 5px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px;
  position: relative;
}
.stream-dest-row select,
.stream-dest-row input { width: 100%; box-sizing: border-box; }
.stream-dest-remove {
  position: absolute; top: 6px; right: 6px;
  padding: 2px 7px !important; font-size: 11px !important;
  color: var(--text-dim);
}
.stream-dest-remove:hover { color: var(--danger); border-color: var(--danger); }
.stream-add-btn { width: 100%; justify-content: center; }

/* Recording */
.rec-option { background: var(--surface2); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.rec-option-label { font-size: 12px; font-weight: 600; color: var(--text); }
.rec-settings { display: flex; flex-direction: column; gap: 5px; }
.rec-settings select {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 5px 8px; color: var(--text); font-size: 12px; flex: 1; outline: none;
}
.rec-settings select:focus { border-color: var(--accent); }
.rec-settings select option { background: var(--surface); }
.rec-check-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-dim); cursor: pointer;
}
.rec-check-label input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.sidebar-bottom { margin-top: auto; padding: 14px; }

/* ── Stage ── */
#stage {
  flex: 1;
  /* Explicit height so children can resolve max-height percentages */
  height: calc(100vh - var(--controls-h));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000; /* letterbox colour */
  position: relative;
}

/* Fixed-ratio canvas area — letterbox-contained inside the stage */
#canvas-area {
  position: relative;
  /* aspect-ratio set dynamically by setResolution() */
  aspect-ratio: 16 / 9;
  /* max constraints let CSS pick whichever axis is the bottleneck */
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  flex-shrink: 0;
  outline: 1px solid rgba(255,255,255,0.08);
}

/* Background layer */
#stage-bg {
  position: absolute; inset: 0;
  background-color: #0f1117;
  background-size: cover; background-position: center; background-repeat: no-repeat;
  z-index: 0;
  transition: background-color 0.2s;
}

/* Video grid sits above background */
#video-grid {
  position: absolute; inset: 0;
  z-index: 1;
  display: grid; gap: 4px; padding: 8px; overflow: hidden;
  background: transparent;
  transition: grid-template-columns 0.25s ease;
}

/* Video background layer */
#stage-bg-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 1;
  display: none;
}
#stage-bg-video.visible { display: block; }

/* Logo overlay */
#stage-logo-overlay {
  position: absolute; inset: 0;
  z-index: 3; pointer-events: none;
}
#stage-logo-img,
#stage-logo-video {
  position: absolute;
  object-fit: contain;
  display: none;
}
#stage-logo-img.visible,
#stage-logo-video.visible { display: block; }

/* ── Layout modes ── */
#video-grid.layout-grid-mode  { grid-template-columns: repeat(var(--grid-cols, 2), 1fr); grid-auto-rows: 1fr; align-content: stretch; }
#video-grid.layout-interview   { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; align-content: stretch; }
#video-grid.layout-spotlight   { grid-template-columns: 1fr 180px; }
#video-grid.layout-spotlight .video-tile:first-child { grid-row: 1 / span 99; }

/* Screen-share layout: screen fill left column, camera/guest feeds stack in right sidebar */
#video-grid.layout-screenshare { grid-template-columns: 1fr 172px; grid-auto-rows: auto; }
#video-grid.layout-screenshare .video-tile { grid-column: 2; }
#video-grid.layout-screenshare [data-peer="screen"] { grid-column: 1; grid-row: 1 / span 99; }
#video-grid.layout-sidebar     { grid-template-columns: 1fr; grid-auto-rows: 1fr; }
#canvas-area.landscape #video-grid.layout-sidebar { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-template-rows: 1fr; grid-auto-rows: unset; }
#video-grid.layout-quad        { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
#video-grid.layout-quad .video-tile:nth-child(n+5) { display: none; }
#video-grid.layout-solo        { grid-template-columns: 1fr; }
#video-grid.layout-solo .video-tile:not(:first-child) { display: none; }

/* PiP — base grid keeps position:absolute;inset:0 from #video-grid rule */
#video-grid.layout-pip { display: block; padding: 0; }
#video-grid.layout-pip .video-tile { position: absolute; border-radius: var(--radius); }
#video-grid.layout-pip .video-tile:first-child { inset: 0; border-radius: var(--radius); }
#video-grid.layout-pip .video-tile:nth-child(2) { width: 24%; aspect-ratio: 16/9; bottom: 16px; right: 16px; z-index: 2; }
#video-grid.layout-pip .video-tile:nth-child(3) { width: 24%; aspect-ratio: 16/9; bottom: 16px; right: calc(24% + 20px); z-index: 2; }
#video-grid.layout-pip .video-tile:nth-child(4) { width: 24%; aspect-ratio: 16/9; bottom: 16px; right: calc(48% + 24px); z-index: 2; }
#video-grid.layout-pip .video-tile:nth-child(n+5) { display: none; }

/* Custom — base grid keeps position:absolute;inset:0 from #video-grid rule */
#video-grid.layout-custom { display: block; padding: 0; }
#video-grid.layout-custom .video-tile {
  position: absolute;
  border-radius: var(--radius);
  cursor: move;
  user-select: none;
  min-height: unset;
}

/* ── Video tiles ── */
.video-tile {
  position: relative; background: var(--surface); border-radius: var(--radius);
  overflow: visible; border: 2px solid transparent; transition: border-color 0.2s; min-height: 60px;
}
.video-tile.speaking { border-color: var(--accent); }
.video-tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; border-radius: calc(var(--radius) - 2px); }
.tile-label {
  position: absolute; bottom: 8px; left: 8px;
  background: rgba(0,0,0,0.6); color: #fff; padding: 3px 8px;
  border-radius: 4px; font-size: 12px; font-weight: 600; pointer-events: none; z-index: 2;
}
.tile-muted-icon { position: absolute; top: 8px; right: 8px; font-size: 14px; opacity: 0.85; pointer-events: none; z-index: 2; }
.tile-no-video {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--surface2); font-size: 48px; border-radius: calc(var(--radius) - 2px);
}

/* Drag handle (top bar, custom mode only) */
.tile-drag-handle {
  display: none;
  position: absolute; top: 0; left: 0; right: 20px; height: 22px;
  background: rgba(216,90,48,0.7); border-radius: calc(var(--radius) - 2px) 0 0 0;
  cursor: move; z-index: 10; align-items: center; justify-content: center;
  font-size: 11px; color: rgba(255,255,255,0.8); letter-spacing: 1px;
}
.tile-drag-handle::after { content: '⠿⠿⠿'; }

/* Resize handle (bottom-right corner, custom mode only) */
.tile-resize-handle {
  display: none;
  position: absolute; bottom: -4px; right: -4px;
  width: 18px; height: 18px;
  background: var(--accent); border-radius: 4px;
  cursor: se-resize; z-index: 10;
}
.tile-resize-handle::after { content: '⤡'; font-size: 11px; color: #fff; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }

/* Show handles in custom mode — hidden for guests */
#video-grid.layout-custom .tile-drag-handle,
#video-grid.layout-custom .tile-resize-handle { display: flex; }
#video-grid.layout-custom .tile-resize-handle { display: flex; align-items: center; justify-content: center; }
#studio-screen.guest-mode .tile-drag-handle,
#studio-screen.guest-mode .tile-resize-handle { display: none !important; }

/* Hide handles when toggled off (overrides the layout-custom rule) */
#video-grid.layout-custom.handles-hidden .tile-drag-handle,
#video-grid.layout-custom.handles-hidden .tile-resize-handle { display: none !important; }

/* Canvas wrapper — stacks toolbar above canvas-area */
#canvas-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-height: 100%;
}

/* Custom layout toolbar */
#custom-toolbar {
  display: flex; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px;
  flex-shrink: 0;
}
.toolbar-btn {
  background: var(--surface2); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 4px 12px; font-size: 12px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.toolbar-btn:hover { color: var(--text); border-color: var(--accent); }

/* Canvas */
#composite-canvas { display: none; }

/* ── Controls bar ── */
#controls {
  position: absolute; bottom: 0; left: var(--sidebar-w); right: 0; height: var(--controls-h);
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 10px; z-index: 5;
}
.ctrl-btn {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 18px; width: 40px; height: 40px; cursor: pointer;
  transition: all 0.15s; display: flex; align-items: center; justify-content: center;
}
.ctrl-btn:hover { border-color: var(--text-dim); }
.ctrl-btn.active { background: var(--accent); border-color: var(--accent); }
.ctrl-btn.muted  { background: #9b1c1c; border-color: #7f1d1d; color: #fca5a5; }
.ctrl-btn-text   { font-size: 12px; padding: 0 10px; width: auto; letter-spacing: .01em; }
.ctrl-sep { width: 1px; height: 28px; background: var(--border); margin: 0 4px; }
#status-bar { font-size: 12px; color: var(--text-dim); margin-left: 8px; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.recording-pulse { animation: pulse 1.2s infinite; }

@media (max-width: 800px) {
  :root { --sidebar-w: 220px; }
}

/* ── Staging area (green room) ── */
.staging-toggle-row { margin-bottom: 6px; }

/* ── Below-canvas staging bar ── */
#staging-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px 12px;
  flex-shrink: 0;
}
#staging-section.hidden { display: none; }

.staging-header {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px;
}
.staging-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-dim);
}
.staging-hint {
  font-size: 11px; color: var(--text-dim); opacity: .6;
}

.staging-badge {
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: rgba(216,90,48,.18); border-radius: 10px;
  padding: 1px 7px; margin-left: 4px;
}

/* Horizontal scrolling row of cards */
#staging-list {
  display: flex; flex-direction: row; gap: 8px;
  overflow-x: auto; padding-bottom: 2px;
}
#staging-list::-webkit-scrollbar { height: 4px; }
#staging-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.staging-row {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px; flex-shrink: 0; width: 120px;
}

.staging-preview {
  width: 100%; height: 68px;
  border-radius: 4px; overflow: hidden; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.staging-preview video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.staging-avatar {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: var(--text-dim);
  background: var(--surface);
}

.staging-name {
  font-size: 12px; font-weight: 600; width: 100%;
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.staging-actions { display: flex; gap: 4px; width: 100%; }

.staging-admit {
  flex: 1;
  background: rgba(216,90,48,.18); border-color: var(--accent);
  color: var(--accent); font-weight: 700; font-size: 11px;
  padding: 3px 6px;
}
.staging-admit:hover { background: var(--accent); color: #fff; }

/* Staged tiles are hidden from canvas preview and compositor */
.video-tile.staged { display: none !important; }

/* Local tile hidden when host camera is off */
.video-tile.cam-off { display: none !important; }

/* Screen share tile — subtle cyan border so it's identifiable in the preview */
.video-tile.screen-share-tile { outline: 2px solid rgba(0,200,255,.45); outline-offset: -2px; }
.video-tile.screen-share-tile .tile-label::before { content: '🖥 '; }

/* Screen share participant row */
.screen-share-row { border-color: rgba(0,200,255,.3) !important; }

/* ── Toast notification ── */
#studio-toast {
  position: absolute; bottom: calc(var(--controls-h) + 16px); left: 50%; transform: translateX(-50%);
  background: rgba(20,21,30,.92); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 13px; padding: 10px 20px; z-index: 300;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.25s;
}
#studio-toast.visible { opacity: 1; }

/* Storage warning banner */
[id="storage-banner"] {
  display: none; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  border-radius: var(--radius); font-size: 13px; padding: 8px 14px; z-index: 301;
  gap: 10px; align-items: center; white-space: nowrap;
}
[id="storage-banner"].visible { display: flex; }
.storage-banner-warning { background: rgba(255,180,0,.13); border: 1px solid rgba(255,180,0,.5); color: var(--text); }
.storage-banner-critical { background: rgba(255,60,60,.15); border: 1px solid rgba(255,60,60,.5); color: #ff8080; }

/* Orphaned recording recovery banner */
#recovery-banner {
  display: none; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(255,180,0,.12); border: 1px solid rgba(255,180,0,.45);
  border-radius: var(--radius); color: var(--text); font-size: 13px;
  padding: 8px 14px; z-index: 300; gap: 10px; align-items: center; white-space: nowrap;
}
#recovery-banner.visible { display: flex; }

/* Room host section */
#room-host-section { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

/* ── Staging overlay (guest green-room notice) ── */
#staging-overlay {
  position: absolute; inset: 0; z-index: 200;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(10, 11, 18, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#staging-overlay.visible { display: flex; }

.staging-overlay-inner {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center; padding: 40px 48px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 16px; max-width: 380px;
}
.staging-overlay-icon { font-size: 48px; line-height: 1; }
.staging-overlay-inner h2 { margin: 0; font-size: 20px; font-weight: 700; color: var(--text); }
.staging-overlay-inner p  { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.6; }

.staging-overlay-pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); margin-top: 4px;
  animation: pulse 1.8s ease-in-out infinite;
}

/* Danger action button (remove participant) */
.p-action-btn.p-action-danger { color: var(--danger); }
.p-action-btn.p-action-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* Staging panel kick button */
.staging-kick {
  flex-shrink: 0; color: var(--danger);
  border-color: transparent; background: transparent;
}
.staging-kick:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
