:root {
  --navy-950: #070d1c;
  --navy-900: #0b1428;
  --navy-850: #101b34;
  --navy-800: #15223f;
  --navy-700: #1f2f52;
  --navy-600: #2c3f68;
  --text: #e8eefc;
  --text-muted: #8d9bbd;
  --blue: #1e5bff;
  --blue-600: #1544d6;
  --cyan: #00c8ff;
  --grad: linear-gradient(120deg, #1230ff 0%, #1e7bff 55%, #00d4ff 100%);
  --live: #ff2d55;
  --ok: #2bd98a;
  --warn: #ffb020;
  --radius: 12px;
  --radius-sm: 8px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* Tablets: the real visible height (Safari's toolbars change 100%/100vh). */
@supports (height: 100dvh) { body { height: 100dvh; } }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  overscroll-behavior: none; /* no rubber-band / pull-to-refresh while working the studio */
  margin: 0;
  background: var(--navy-950);
  color: var(--text);
  font-size: 14px;
  display: flex;
  flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
/* Touch: no double-tap-to-zoom delay on controls, no grey flash on tap. */
button, a, label, select, input, textarea, .tab, .layout-btn, .lib-item, canvas { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
code { background: var(--navy-800); padding: 1px 6px; border-radius: 4px; font-size: 0.92em; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }
/* Tablets (html.tablet, set by app.js): no recording; they stream only. */
html.tablet .desktop-only { display: none !important; }
.tablet-only { display: none; }
html.tablet .tablet-only { display: block; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 20px;
  background: var(--navy-900);
  border-bottom: 1px solid var(--navy-700);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { height: 30px; }
.brand-word { font-weight: 800; font-size: 19px; letter-spacing: -0.02em; white-space: nowrap; }
.brand-live { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.health { font-size: 12px; color: var(--text-muted); }

.session-status { display: flex; align-items: center; gap: 12px; }
.live-pill {
  background: var(--live); color: #fff; font-weight: 800; font-size: 12px;
  padding: 4px 10px; border-radius: 999px; letter-spacing: 0.08em;
  animation: pulse 1.6s ease-in-out infinite;
}
.live-pill.rec { background: var(--navy-600); animation: none; }
@keyframes pulse { 50% { opacity: 0.65; } }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.out-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--navy-800); border: 1px solid var(--navy-600);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.chip.live::before { background: var(--ok); }
.chip.failed { border-color: var(--live); cursor: help; }
.chip.failed::before { background: var(--live); }
.chip.finished::before { background: var(--text-muted); }
.stats { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.warning {
  background: #3a2a06; color: #ffd98a; padding: 10px 20px; border-bottom: 1px solid #6b4d0a;
}

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: var(--radius-sm); padding: 9px 16px; font-weight: 700;
  cursor: pointer; background: var(--navy-700); transition: filter .15s, background .15s;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, .tab:focus-visible, .layout-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-live { background: var(--grad); color: #fff; padding: 9px 22px; }
.btn-end { background: var(--live); color: #fff; }
.btn-soft { background: var(--navy-800); border: 1px solid var(--navy-600); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn .count { font-weight: 500; color: var(--text-muted); font-size: 12px; }
.icon-btn {
  border: 0; background: rgba(7, 13, 28, 0.75); color: var(--text); width: 28px; height: 28px;
  border-radius: 6px; cursor: pointer; display: grid; place-items: center; font-size: 14px;
}
.icon-btn:hover { background: var(--navy-600); }

/* ---------- layout ---------- */
.studio { flex: 1; display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
.stage-col { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: 0; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
/* Never squeeze the stage (or anything else) to fit: the column scrolls instead,
   so the stage always keeps its 16:9 shape. */
.stage-col > * { flex-shrink: 0; }

.stage-wrap {
  position: relative; width: 100%; max-width: calc((100vh - 330px) * 16 / 9); min-width: 320px;
  margin: 0 auto; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: #000; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
#stage { width: 100%; height: 100%; display: block; }
.stage-empty {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px;
  text-align: center; color: var(--text-muted); pointer-events: none; padding: 20px;
}
.stage-empty img { width: 70px; opacity: 0.85; }
.stage-empty p { margin: 0; max-width: 340px; }

.layout-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  width: 100%; max-width: calc((100vh - 330px) * 16 / 9); min-width: 320px; margin: 0 auto;
}
.layout-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius-sm);
  padding: 7px 10px; cursor: pointer; color: var(--text-muted); font-size: 11px; font-weight: 600;
}
.layout-btn svg { width: 34px; height: 19px; }
.layout-btn svg rect { fill: var(--navy-600); }
.layout-btn svg rect.inner { fill: var(--text-muted); }
.layout-btn.active { border-color: var(--blue); color: var(--text); background: var(--navy-800); }
.layout-btn.active svg rect { fill: var(--blue); }
.layout-btn.active svg rect.inner { fill: var(--cyan); }
.spacer { flex: 1; }

.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--blue); width: 16px; height: 16px; }

/* ---------- backstage ---------- */
.backstage { background: var(--navy-900); border: 1px solid var(--navy-700); border-radius: var(--radius); padding: 14px; }
.backstage-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.backstage-head h2 { margin: 0; font-size: 15px; }
.add-btns { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tray:empty::before, .mic-tray:empty::before {
  content: attr(data-empty); color: var(--text-muted); font-size: 13px;
}
.src-card {
  background: var(--navy-850); border: 2px solid var(--navy-700); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
}
.src-card.on-stage { border-color: var(--blue); }
.src-video { position: relative; aspect-ratio: 16 / 9; background: #000; }
.src-video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.src-video video.mirror { transform: scaleX(-1); }
/* Slides and local videos: shown whole in the card, like on stage. */
.src-card.slides .src-video canvas, .src-card.media .src-video video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.slide-nav { display: flex; align-items: center; gap: 4px; }
.slide-nav .btn { flex: none; padding-left: 9px; padding-right: 9px; }
.slide-count { flex: 1; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }
.media-ctl { display: flex; flex-direction: column; gap: 6px; }
.media-ctl .row { gap: 6px; }
.media-time { margin-left: auto; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.media-seek, .media-vol { accent-color: var(--blue); }
.media-seek { width: 100%; }
.media-vol { width: 70px; flex: 1; min-width: 50px; }
.media-opts { flex-wrap: wrap; font-size: 12px; }
.media-opts .toggle input { width: 15px; height: 15px; }
label.btn.busy { opacity: .7; cursor: progress; pointer-events: none; }
.src-video .src-tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.src-video .badge {
  position: absolute; top: 6px; left: 6px; font-size: 10px; font-weight: 800; letter-spacing: .06em;
  background: var(--blue); color: #fff; padding: 2px 7px; border-radius: 4px;
}
.src-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.src-name {
  background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; font-weight: 700; width: 100%;
}
.src-name:hover, .src-name:focus { border-color: var(--navy-600); background: var(--navy-900); outline: none; }
.src-body select { background: var(--navy-900); border: 1px solid var(--navy-700); border-radius: 6px; padding: 5px; font-size: 12px; width: 100%; }
.src-body .row { display: flex; gap: 6px; align-items: center; }
.stage-toggle { width: 100%; justify-content: center; }
.src-card.on-stage .stage-toggle { background: var(--navy-700); }

.mic-tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 12px; }
.mic-card {
  background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius); padding: 10px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; align-items: center;
}
.mic-card .mic-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-700); display: grid; place-items: center; }
.mic-card.muted .mic-icon { background: #4a1020; }
.mic-card .src-name { padding: 2px 4px; }
.mic-card select { grid-column: 1 / -1; background: var(--navy-900); border: 1px solid var(--navy-700); border-radius: 6px; padding: 5px; font-size: 12px; }
.mic-card .mic-row { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.mic-card input[type=range] { flex: 1; accent-color: var(--blue); }
.mic-card .vol { font-size: 12px; width: 38px; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.mic-card .mic-fx { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.fx-btn {
  border: 1px solid var(--navy-600); background: var(--navy-900); color: var(--text-muted);
  border-radius: 999px; padding: 3px 9px 3px 7px; font: inherit; font-size: 11px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.fx-btn::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--navy-600); }
.fx-btn:hover { color: var(--text); }
.fx-btn.on { border-color: var(--blue); color: var(--text); background: rgba(30, 91, 255, 0.15); }
.fx-btn.on::before { background: var(--cyan); }
.fx-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
/* Guest mic: waiting for the guest's device to confirm the change. */
.fx-btn.pending { opacity: .6; cursor: progress; }
.fx-btn.pending::before { animation: fx-wait .8s ease-in-out infinite alternate; }
@keyframes fx-wait { to { opacity: .2; } }

.meter { height: 6px; background: var(--navy-700); border-radius: 3px; overflow: hidden; grid-column: 1 / -1; }
.meter.master { height: 10px; }
.meter-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--ok) 0%, var(--ok) 65%, var(--warn) 82%, var(--live) 100%);
  background-size: 100% 100%; transition: width 60ms linear;
}

/* ---------- sidebar ---------- */
.sidebar { background: var(--navy-900); border-left: 1px solid var(--navy-700); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 10px 10px 0; border-bottom: 1px solid var(--navy-700); }
.tab {
  background: none; border: 0; padding: 9px 10px; cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: 13px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--text); border-bottom-color: var(--cyan); }
.panel { display: none; padding: 16px; overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.panel.active { display: block; }

.field { margin-bottom: 18px; }
.field > label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 7px; }
.field small { font-weight: 500; color: var(--text-muted); }
.field input:not([type=color]):not([type=checkbox]), .field select, .banner-form textarea {
  width: 100%; background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius-sm); padding: 8px 10px;
}
.field input:focus, .field select:focus, textarea:focus { outline: none; border-color: var(--blue); }
.row { display: flex; align-items: center; gap: 8px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
input[type=color] { width: 44px; height: 34px; padding: 2px; background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: 6px; cursor: pointer; }
.hex { width: 100px !important; font-family: ui-monospace, Consolas, monospace; text-transform: uppercase; }
.hint { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }
.hint.warn { color: var(--warn); }
.hint a { color: var(--cyan); }

.speedtest { background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius); padding: 12px; }
.speedtest > .row > label { font-weight: 700; font-size: 13px; }
.st-progress { height: 6px; background: var(--navy-700); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.st-bar { height: 100%; width: 0; background: var(--grad); transition: width .3s; }
.st-result { margin-top: 10px; }
.st-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.st-metrics > div { background: var(--navy-900); border-radius: var(--radius-sm); padding: 8px 4px; }
.st-num { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.st-unit { font-size: 11px; color: var(--text-muted); }
.st-label { font-size: 12px; margin: 10px 0 6px; line-height: 1.35; }
.st-label:first-child { margin-top: 0; }
.st-label span { color: var(--text-muted); }
.st-metrics-net .st-num { font-size: 16px; color: var(--text-muted); }
.st-rec { margin-top: 10px; font-size: 13px; line-height: 1.5; }
.st-rec strong { color: var(--cyan); }
.st-rec .warn { color: var(--warn); }
.st-actions { margin-top: 8px; flex-wrap: wrap; }
.rate-out { float: right; font-weight: 800; color: var(--cyan); font-variant-numeric: tabular-nums; }
.range { width: 100%; accent-color: var(--blue); }
.range-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.seg { display: inline-flex; background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: 13px; }
.seg button.active { background: var(--blue); color: #fff; }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.seg button.active:disabled { opacity: 0.7; } /* the current choice stays readable while live */
.seg button:disabled:not(.active) { text-decoration: line-through; }
.seg-sm { margin-top: 8px; }
.seg-sm button { padding: 4px 10px; font-size: 12px; }

.asset { display: flex; gap: 10px; align-items: center; }
.asset-thumb {
  width: 96px; aspect-ratio: 16 / 9; border-radius: 6px; border: 1px dashed var(--navy-600);
  background: var(--navy-850) center / contain no-repeat;
}
.asset-thumb.has { border-style: solid; background-color: #000; }
.asset-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.field .row + .asset { margin-top: 8px; }

/* overlay / background libraries */
.lib-head { display: flex; align-items: baseline; justify-content: space-between; }
.lib-head label { margin: 0; }
.lib-hint { margin: 2px 0 8px; }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.lib-item {
  position: relative; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; padding: 0; cursor: pointer;
  border: 2px solid var(--navy-600);
  background: #000 repeating-conic-gradient(#1b2640 0 25%, #121a2e 0 50%) 0 0 / 12px 12px; /* checkerboard shows transparency */
}
.lib-item img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lib-item:hover { border-color: var(--navy-500, #3a4a70); }
.lib-item:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.lib-item.on { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.lib-item .lib-on {
  position: absolute; left: 4px; top: 4px; display: none; padding: 1px 5px; border-radius: 4px;
  background: var(--blue); color: #fff; font-size: 9px; font-weight: 700; letter-spacing: .04em;
}
.lib-item.on .lib-on { display: block; }
.lib-del {
  position: absolute; right: 3px; top: 3px; width: 20px; height: 20px; border: 0; border-radius: 4px;
  background: rgba(7, 13, 28, 0.8); color: var(--text); font-size: 11px; cursor: pointer; display: none;
  place-items: center; padding: 0;
}
.lib-cell { position: relative; }
.lib-cell:hover .lib-del, .lib-del:focus-visible { display: grid; }
.lib-add {
  aspect-ratio: 16 / 9; border-radius: 6px; border: 1px dashed var(--navy-600); background: var(--navy-850);
  color: var(--text-muted); display: grid; place-items: center; cursor: pointer; font-size: 12px; text-align: center;
}
.lib-add:hover { color: var(--text); border-color: var(--blue); }
.lib-add.busy { cursor: progress; opacity: .7; }
.lib-color { margin-top: 10px; }
.lib-logos .lib-item img { padding: 8%; } /* breathing room around logos in their thumbnails */
.logo-pos-row { margin-top: 10px; gap: 10px; align-items: flex-start; }
.logo-pos-row > span { padding-top: 6px; }
/* Four corners as a 2×2 grid that mirrors where the logo goes */
.seg.logo-pos { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.seg.logo-pos button { justify-content: center; }

/* camera effects */
.icon-btn.on { background: var(--blue); }
.fx-cam { font-size: 14px; font-weight: 500; }
.fx-mode { flex-wrap: wrap; }
#fxDialog { width: min(480px, calc(100vw - 32px)); }
#fxDialog input[type=range] { width: 100%; accent-color: var(--blue); }
#fxKeyRow label { display: block; margin-top: 8px; }
.fx-key { flex-wrap: wrap; }
.fx-key label { margin: 0 !important; }
.fx-bgs { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.fx-bgs .lib-item span.fx-stage { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; color: var(--text); text-align: center; padding: 2px; }

/* video clips library */
.lib-videos { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.lib-item video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; pointer-events: none; }
.lib-item .lib-dur {
  position: absolute; right: 4px; bottom: 4px; padding: 1px 5px; border-radius: 4px;
  background: rgba(7, 13, 28, 0.85); color: #fff; font-size: 10px; font-variant-numeric: tabular-nums;
}
.lib-item .lib-play {
  position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 22px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); opacity: 0; transition: opacity 0.15s;
}
.lib-item:hover .lib-play, .lib-item.on .lib-play { opacity: 1; }
.lib-item.on .lib-play { background: rgba(7, 13, 28, 0.35); }
.lib-item .lib-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--blue); }
.lib-item.loading { cursor: progress; }
.lib-videos .lib-name { display: block; font-size: 11px; color: var(--text-muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: none) { .lib-del { display: grid; } }

/* banners */
.banner-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.banner-form textarea { resize: vertical; }
.banner-form .row { justify-content: space-between; }
.banner-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.banner-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--navy-850); border: 1px solid var(--navy-700); cursor: pointer;
}
.banner-item:hover { border-color: var(--navy-600); }
.banner-item.active { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 18%, var(--navy-850)); }
.banner-item .txt { flex: 1; word-break: break-word; }
.banner-item .tag { font-size: 10px; font-weight: 800; color: var(--cyan); letter-spacing: .05em; display: block; margin-bottom: 2px; }

/* destinations */
.dest-list, .rec-list, .pick-list { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 8px; }
.dest-item, .rec-item, .pick-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--navy-850); border: 1px solid var(--navy-700);
}
.dest-item .meta, .rec-item .meta, .pick-item .meta { flex: 1; min-width: 0; }
.dest-item .name, .rec-item .name, .pick-item .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dest-item .sub, .rec-item .sub, .pick-item .sub { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plat { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; color: #fff; }
.plat svg { width: 18px; height: 18px; fill: currentColor; }
.plat.youtube { background: #ff0033; }
.plat.facebook { background: #1877f2; }
.plat.custom { background: var(--navy-600); }
.dest-add summary { list-style: none; width: 100%; justify-content: center; }
.dest-add summary::-webkit-details-marker { display: none; }
.dest-add[open] summary { display: none; }
.dest-add form { background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius); padding: 14px; }
.dest-add .field input, .dest-add .field select { background: var(--navy-900); }

/* dialogs */
.dialog {
  background: var(--navy-900); color: var(--text); border: 1px solid var(--navy-600); border-radius: 16px;
  padding: 24px; width: min(460px, calc(100vw - 32px));
}
.dialog::backdrop { background: rgba(3, 6, 14, 0.7); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog h2 { margin: 0 0 4px; }
.dialog .row.end { margin-top: 18px; }
.pick-item { cursor: pointer; }
.pick-item input { accent-color: var(--blue); width: 18px; height: 18px; }
.pick-rec { margin-top: 4px; }
.pick-clips { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.sched-clips .toggle { display: flex; margin-bottom: 6px; }
.clip-tags { display: flex; gap: 6px; margin-top: 4px; }
.clip-tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--navy-600); color: var(--text-muted); }

/* ---------- intro / outro videos ---------- */
.clip { display: flex; gap: 10px; align-items: center; }
.clip-thumb {
  width: 128px; flex: none; aspect-ratio: 16 / 9; border-radius: 6px; border: 1px dashed var(--navy-600);
  background: var(--navy-850); overflow: hidden;
}
.clip-thumb video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.clip:not(.has) .clip-thumb video { visibility: hidden; }
.clip.has .clip-thumb { border-style: solid; }
.clip-meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.clip { flex-wrap: wrap; }
.clip .row { gap: 4px 6px; }
.clip-pick { flex: 1 0 100%; width: 100%; min-width: 0; background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius-sm); padding: 6px 8px; color: var(--text); }
.clip-pick:focus { outline: none; border-color: var(--blue); }
.clip-name { white-space: normal; }
.clip [data-upload].busy { cursor: progress; opacity: .7; }
/* In the video clips: which one is the intro / outro */
.lib-item .lib-tag {
  position: absolute; left: 4px; bottom: 4px; padding: 1px 5px; border-radius: 4px;
  background: var(--cyan, #19c3ff); color: #04101f; font-size: 9px; font-weight: 700; letter-spacing: .04em;
}
.clip .row { flex-wrap: wrap; gap: 6px; }

/* toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--navy-700); border: 1px solid var(--navy-600); padding: 10px 18px; border-radius: 10px;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #4a1020; border-color: var(--live); }

/* "USB camera connected · Use it / Not now" */
.device-prompt {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 11;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: var(--navy-800); border: 1px solid var(--blue); border-radius: 12px; padding: 10px 12px 10px 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); max-width: calc(100vw - 32px); font-weight: 600;
}
.device-prompt-icon { font-size: 18px; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 50% -10%, #12204a 0%, var(--navy-950) 60%); }
.login-card {
  width: min(380px, 100%); background: var(--navy-900); border: 1px solid var(--navy-700);
  border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.login-brand { justify-content: center; margin-bottom: 24px; }
.login-btn { width: 100%; justify-content: center; margin-top: 4px; }
.login-foot { margin: 18px 0 0; text-align: center; }
.login-card .hint.warn:empty { display: none; }
.login-pw-label { margin-bottom: 7px; }
.login-pw-label label { font-weight: 700; font-size: 13px; }
.login-note { background: rgba(43, 166, 64, 0.15); border: 1px solid #2ba640; color: var(--text); border-radius: var(--radius-sm); padding: 8px 10px; margin: 0 0 14px; }
.reset-h { font-size: 18px; margin: 0 0 14px; text-align: center; }
.link-btn { background: none; border: 0; padding: 0; color: var(--cyan); font: inherit; font-size: 13px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.hint.ok { color: #7ee2a0; }
/* Password field with a show/hide (eye) button */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px !important; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 38px; height: 34px;
  border: 0; background: none; color: var(--text-muted); cursor: pointer; display: grid; place-items: center; border-radius: 6px;
}
.pw-eye:hover { color: var(--text); background: var(--navy-800); }
.pw-eye:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.login-card .field input, #forgotDialog .field input { width: 100%; background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 16px; }
.login-card .field input:focus, #forgotDialog .field input:focus { outline: none; border-color: var(--blue); }
#forgotDialog { width: min(420px, calc(100vw - 32px)); background: var(--navy-900); border: 1px solid var(--navy-700); border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55); }
#forgotDialog h2 { text-align: center; font-size: 20px; }
#forgotDialog > form > p.muted { text-align: center; margin-top: 4px; }
.dialog-brand { margin-bottom: 18px; }
#forgotDialog .row.end { justify-content: stretch; gap: 10px; }
#forgotDialog .row.end .btn { flex: 1; justify-content: center; }
#forgotDialog #forgotSend { background: var(--grad); }
/* Settings → Account */
.acct-block { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.acct-block > label:first-child { font-weight: 700; font-size: 13px; }
.acct-block label.sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.acct-block input, .acct-block select { width: 100%; background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius-sm); padding: 8px 10px; }
.acct-block input:focus, .acct-block select:focus { outline: none; border-color: var(--blue); }
.acct-block .btn { align-self: flex-start; margin-top: 4px; }
.acct-block .hint { margin: 0; }
.acct-row { display: grid; grid-template-columns: 1fr 110px; gap: 8px; }
.acct-row label { display: block; margin-bottom: 4px; }
.acct-mail-status { font-weight: 600; }
.acct-who { margin: 0 0 16px; }
.acct-who b { color: var(--text); word-break: break-all; }
.acct-add { display: flex; gap: 8px; align-items: center; }
.acct-add input { flex: 1; min-width: 0; }
.acct-block .acct-add .btn { margin-top: 0; flex-shrink: 0; }
.acct-users { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.acct-users li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius-sm); }
.acct-users .who { flex: 1 0 100%; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.acct-users .who b { font-size: 13px; overflow-wrap: anywhere; }
.acct-users .who span { font-size: 11px; color: var(--text-muted); }
.acct-users .who span.pending { color: var(--warn, #f5b400); }
.acct-users .btn { margin-top: 0; flex-shrink: 0; }
.acct-link { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; padding: 10px; border: 1px dashed var(--navy-700); border-radius: var(--radius-sm); }

/* ---------- connected accounts ---------- */
.panel-h { margin: 4px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.panel-h + .hint { margin-bottom: 10px; }
.panel-h.media-h { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--navy-700); }
.conn-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.conn-card { background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius); padding: 10px 12px; }
.conn-head { display: flex; align-items: center; gap: 10px; }
.conn-head b { flex: 1; }
.conn-accts { list-style: none; padding: 0; margin: 10px 0 4px; display: flex; flex-direction: column; gap: 6px; }
.conn-acct { display: flex; align-items: center; gap: 8px; }
.conn-acct img, .conn-pic { width: 24px; height: 24px; border-radius: 50%; background: var(--navy-600); flex: none; }
.conn-acct .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tag-warn { font-size: 10px; font-weight: 800; color: #1b1200; background: var(--warn); border-radius: 4px; padding: 2px 6px; }
.conn-setup { margin-top: 8px; }
.conn-setup summary { cursor: pointer; font-size: 12px; color: var(--text-muted); }
.conn-setup .field { margin: 10px 0 0; }
.conn-setup .field label { font-size: 12px; }
.conn-setup .row input { flex: 1; min-width: 0; font-size: 11px; }
.conn-setup > .btn { margin-top: 10px; }
.plat.sm { width: 18px; height: 18px; border-radius: 4px; display: inline-grid; vertical-align: -4px; margin-right: 4px; }

/* ---------- schedule ---------- */
.sched-new { width: 100%; justify-content: center; margin-bottom: 14px; }
.sched-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.sched-item { background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius); overflow: hidden; }
.sched-thumb { aspect-ratio: 16 / 9; background: var(--navy-800); display: grid; place-items: center; color: var(--text-muted); font-size: 12px; }
.sched-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sched-thumb:not(:has(img)) { aspect-ratio: auto; height: 30px; }
.sched-meta { padding: 10px 12px; }
.sched-meta .name { font-weight: 800; word-break: break-word; }
.sched-meta .sub { font-size: 12px; color: var(--cyan); margin-top: 2px; }
.sched-targets { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 5px; }
.sched-target { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }
.sched-target .plat { width: 20px; height: 20px; border-radius: 5px; }
.sched-target .plat svg { width: 12px; height: 12px; }
.sched-target .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-target .st { font-weight: 700; color: var(--ok); }
.sched-target.waiting .st { color: var(--text-muted); }
.sched-target.error .st { color: var(--live); }
.sched-target a { color: var(--cyan); }
.sched-target .err { flex-basis: 100%; color: #ff8fa3; padding-left: 26px; }
.sched-target .err.soft { color: var(--warn); }
.sched-actions { margin-top: 10px; flex-wrap: wrap; }
.sched-past { margin-top: 16px; }
.ads-tag { font-size: 10px; font-weight: 800; color: #062; background: var(--ok); border-radius: 4px; padding: 1px 6px; }
.ads-tag.off { color: #1b1200; background: var(--warn); }
.money { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--navy-700); }
.money-head { margin-bottom: 8px; }
.money .hint a { color: var(--cyan); }
.adbreak-pop { padding: 18px; width: min(360px, calc(100vw - 32px)); }
.adbreak-pop .row { flex-wrap: wrap; margin-top: 10px; }
.sched-past summary { cursor: pointer; margin-bottom: 8px; }

.dialog-wide { width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
.sched-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-top: 14px; }
.sched-grid .field input:not([type=checkbox]), .sched-grid textarea, .sched-opts .field input, .sched-opts .field select { width: 100%; }
.sched-grid textarea { resize: vertical; }
.sched-label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 7px; }
.row.wrap { flex-wrap: wrap; }
.row.wrap input[type=datetime-local] { width: auto !important; flex: 1 1 200px; }
.thumb-pick { display: flex; gap: 12px; align-items: center; }
.thumb-box {
  width: 192px; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); border: 1px dashed var(--navy-600); background: var(--navy-850);
  display: grid; place-items: center; overflow: hidden; color: var(--text-muted); font-size: 12px; flex: none;
}
.thumb-box img { width: 100%; height: 100%; object-fit: cover; }
.sched-opts { border: 1px solid var(--navy-700); border-radius: var(--radius); padding: 10px 14px; margin-top: 12px; background: var(--navy-850); }
.sched-opts summary { cursor: pointer; font-weight: 700; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 14px; margin-top: 12px; }
.opt-grid .field { margin-bottom: 12px; }
.opt-toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 14px; }

/* ---------- stage tile controls ---------- */
.tile-tools {
  position: absolute; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px;
  background: rgba(7, 13, 28, 0.88); border: 1px solid var(--navy-600); border-radius: 8px; z-index: 2;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.tile-tools .btn { background: var(--navy-700); padding: 4px 9px; font-size: 12px; }
.tile-tools .btn-end { background: var(--live); }
.tile-name { font-size: 12px; font-weight: 700; padding: 0 6px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- guests (studio side) ---------- */
.guest-tag {
  position: absolute; top: 6px; left: 6px; background: #7b2ff7; color: #fff; font-size: 10px; font-weight: 800;
  letter-spacing: .06em; padding: 2px 7px; border-radius: 4px;
}
.guest-tag.inline { position: static; align-self: center; justify-self: end; }
.src-card.guest .badge { top: 28px; }

/* ---------- camera switcher ---------- */
.sw-tag {
  position: absolute; top: 6px; left: 6px; background: var(--live); color: #fff; font-size: 10px; font-weight: 800;
  letter-spacing: .06em; padding: 2px 7px; border-radius: 4px;
}
.src-card.switcher .badge { top: 28px; }
.src-card.switcher .src-video canvas { width: 100%; height: 100%; display: block; object-fit: cover; }
.sw-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.sw-in {
  position: relative; padding: 0; border: 2px solid var(--navy-700); border-radius: 6px; background: #000;
  cursor: pointer; overflow: hidden; color: var(--text); text-align: left; font: inherit;
}
.sw-in canvas { width: 100%; aspect-ratio: 16 / 9; display: block; }
.sw-in .sw-num {
  position: absolute; left: 4px; top: 4px; min-width: 18px; padding: 0 4px; border-radius: 4px;
  background: rgba(7, 13, 28, 0.85); font-size: 11px; font-weight: 800; text-align: center;
}
.sw-in .sw-name { display: block; padding: 3px 6px; font-size: 11px; background: var(--navy-850); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw-in:hover:not(.live) { border-color: var(--blue); }
.sw-in.live { border-color: var(--live); }
.sw-in.live .sw-num { background: var(--live); color: #fff; }
.sw-in.live .sw-name { background: #4a1020; }
.sw-row { justify-content: space-between; }
.sw-trans.seg-sm { margin-top: 0; }
.sw-hint { margin: 0; }
html.tablet .sw-in .sw-name { padding: 6px; font-size: 12px; }
.src-status { font-size: 12px; color: var(--text-muted); }
.src-status.warn { color: var(--warn); }
.tab-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 3px;
  border-radius: 9px; background: var(--live); color: #fff; font-size: 11px; font-weight: 800;
}
.guest-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.guest-item {
  display: flex; align-items: center; gap: 10px; background: var(--navy-850); border: 1px solid var(--navy-700);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.guest-item .meta { flex: 1; min-width: 0; }
.guest-item .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest-item .sub { font-size: 12px; color: var(--text-muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--warn); }
.dot.ok { background: var(--ok); }
#inviteUrl { font-size: 12px; font-family: ui-monospace, Consolas, monospace; min-width: 0; flex: 1; }
.chat-log {
  height: 220px; overflow-y: auto; background: var(--navy-850); border: 1px solid var(--navy-700);
  border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; font-size: 13px;
}
.chat-line { line-height: 1.4; word-break: break-word; }
.chat-line b { margin-right: 6px; color: var(--cyan); }
.chat-line.host b { color: #ffb020; }
.chat-line.mine b { color: var(--text-muted); }
.chat-line.system { color: var(--text-muted); font-size: 12px; font-style: italic; }
.chat-form { display: flex; gap: 6px; margin-top: 6px; }
.chat-form input {
  flex: 1; min-width: 0; background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: 6px; padding: 7px 9px;
}
.chat-form input:focus { outline: none; border-color: var(--blue); }

/* ---------- guest page ---------- */
.guest-page main[hidden] { display: none; }
.guest-join { flex: 1; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 50% -10%, #12204a 0%, var(--navy-950) 60%); }
.join-card {
  width: min(520px, 100%); background: var(--navy-900); border: 1px solid var(--navy-700);
  border-radius: 16px; padding: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.join-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.01em; }
.join-card > p { margin: 0 0 16px; }
.join-card.center { text-align: center; }
.join-card .field input, .join-card .field select { width: 100%; }
.end-mark { width: 64px; margin-bottom: 12px; }
.join-preview { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius-sm); overflow: hidden; }
.join-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.join-preview-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-muted); background: var(--navy-850); }
video.mirror { transform: scaleX(-1); }
.join-meter { margin: 8px 0 16px; }
.join-devices { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.join-toggles { margin: -4px 0 16px; flex-wrap: wrap; }
.btn.off { background: #4a1020; border-color: var(--live); }
.join-btn { width: 100%; justify-content: center; font-size: 16px; padding: 12px; }

.guest-room { flex: 1; display: grid; grid-template-columns: 1fr 320px; min-height: 0; }
.room-main { padding: 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; overflow-y: auto; }
.room-stage { position: relative; max-width: calc((100vh - 210px) * 16 / 9); min-width: 0; }
.room-stage #programVideo { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.room-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px;
  background: rgba(7, 13, 28, 0.82); color: var(--text); font-weight: 600;
}
.room-badge {
  position: absolute; top: 10px; left: 10px; background: var(--navy-700); color: var(--text); font-size: 11px; font-weight: 800;
  letter-spacing: .06em; padding: 4px 9px; border-radius: 5px;
}
.room-badge.on { background: var(--blue); }
.self-view {
  position: absolute; right: 10px; bottom: 10px; width: 22%; min-width: 120px; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: 8px; border: 2px solid var(--navy-600); background: #000; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.room-note { margin: 0; }
.room-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.room-controls select { background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: 6px; padding: 7px; max-width: 220px; }
.room-controls input[type=range] { width: 110px; height: auto; accent-color: var(--blue); }
.room-chat { background: var(--navy-900); border-left: 1px solid var(--navy-700); padding: 16px; display: flex; flex-direction: column; min-height: 0; }
.room-chat h2 { margin: 0 0 2px; font-size: 15px; }
.room-chat .chat-log { flex: 1; height: auto; min-height: 160px; margin-top: 10px; }

/* ---------- YouTube comments ---------- */
.panel[data-panel="comments"].active { display: flex; flex-direction: column; gap: 10px; }
.yt-src { margin-bottom: 0; }
.yt-src select { flex: 1; min-width: 0; }
.yt-chat-wrap { position: relative; flex: 1; min-height: 240px; display: flex; }
.yt-chat {
  list-style: none; margin: 0; padding: 6px; flex: 1; overflow-y: auto; overscroll-behavior: contain;
  background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: 2px;
}
.yt-chat:empty::before { content: attr(data-empty); color: var(--text-muted); font-size: 13px; padding: 10px; }
.yt-msg {
  display: grid; grid-template-columns: 32px 1fr; gap: 2px 9px; align-items: start; text-align: left;
  width: 100%; border: 1px solid transparent; background: none; color: inherit; font: inherit;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
}
.yt-msg:hover { background: var(--navy-800); }
.yt-msg.on { background: rgba(30, 91, 255, 0.18); border-color: var(--blue); }
.yt-msg.paid { background: rgba(255, 202, 40, 0.1); }
.yt-msg.paid.on { background: rgba(30, 91, 255, 0.22); }
.yt-msg img, .yt-msg .yt-av { grid-row: span 2; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--navy-700); }
.yt-msg .yt-av { display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.yt-who { font-size: 12px; font-weight: 700; color: var(--text-muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.yt-who .owner { color: #ffd600; }
.yt-who .mod { color: #5e84f1; }
.yt-who .member { color: #2ba640; }
.yt-tag { font-size: 10px; font-weight: 800; padding: 0 5px; border-radius: 4px; background: var(--navy-700); color: var(--text); }
.yt-amount { background: #ffca28; color: #3a2a00; }
.yt-ch { background: transparent; border: 1px solid var(--navy-600); color: var(--text-muted); font-weight: 600; }
.yt-text { font-size: 13.5px; line-height: 1.35; overflow-wrap: anywhere; }
.yt-msg .yt-onair { font-size: 10px; font-weight: 800; color: #fff; background: var(--blue); padding: 0 5px; border-radius: 4px; display: none; }
.yt-msg.on .yt-onair { display: inline-block; }
.yt-chat-new { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.yt-onscreen { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: rgba(30, 91, 255, 0.14); border: 1px solid var(--blue); border-radius: var(--radius-sm); padding: 6px 6px 6px 12px; font-size: 13px; }
.yt-onscreen b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; display: inline-block; vertical-align: bottom; }
.yt-reply input { flex: 1; min-width: 0; background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: var(--radius-sm); padding: 8px 10px; }
.yt-reply input:focus { outline: none; border-color: var(--blue); }
.yt-opts { flex-wrap: wrap; gap: 6px 8px; }
.yt-opts .hint { margin: 0; flex: 1 1 100%; }
.yt-opts select { background: var(--navy-850); border: 1px solid var(--navy-700); border-radius: 6px; padding: 4px 6px; }
html.tablet .yt-msg { padding: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  /* Tablet portrait: stage + sources on top (~60%), tabs + panels below (~40%),
     each scrolling on its own, so the stage stays in view while you work a panel. */
  .studio { grid-template-columns: 1fr; grid-template-rows: minmax(0, 3fr) minmax(0, 2fr); }
  .sidebar { border-left: 0; border-top: 1px solid var(--navy-700); }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-top: 4px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; }
  .stage-wrap, .layout-bar { max-width: 100%; }
  .guest-room { grid-template-columns: 1fr; }
  .room-chat { border-left: 0; border-top: 1px solid var(--navy-700); }
  .room-chat .chat-log { min-height: 200px; }
}
/* Short screens (tablet landscape keyboards, small tablets): one page scroll instead of two panes. */
@media (max-width: 980px) and (max-height: 640px) {
  body { height: auto; min-height: 100%; }
  .studio { grid-template-rows: auto auto; }
  .stage-col, .panel { overflow: visible; }
}

/* Tablets (html.tablet, set by app.js; also any touch-only screen): finger-sized controls.
   16px text in fields stops Safari zooming in when a field is tapped. */
@media (min-width: 981px) { html.tablet .studio { grid-template-columns: 1fr 380px; } }
/* Tabs as an even grid of big targets: 4 per row in the sidebar, all 8 in one row in portrait. */
html.tablet .tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 0; padding: 4px 6px 0; overflow: visible; }
html.tablet .tab { padding: 13px 4px; text-align: center; }
html.tablet .btn { padding: 11px 18px; }
html.tablet .btn-sm { padding: 9px 14px; font-size: 14px; min-height: 40px; }
html.tablet .btn-live { padding: 11px 24px; }
html.tablet .icon-btn { width: 40px; height: 40px; font-size: 17px; }
html.tablet .src-video .src-tools { gap: 6px; }
html.tablet .tab { font-size: 14px; }
html.tablet .layout-btn { padding: 10px 14px; }
html.tablet .toggle { min-height: 40px; }
html.tablet .toggle input { width: 22px; height: 22px; }
html.tablet input:not([type=color]):not([type=checkbox]):not([type=range]):not([type=file]),
html.tablet select, html.tablet textarea { font-size: 16px; min-height: 44px; }
html.tablet input[type=range] { height: 36px; }
html.tablet input[type=color] { width: 52px; height: 44px; }
html.tablet .fx-btn { padding: 8px 13px 8px 10px; font-size: 13px; }
html.tablet .lib { gap: 8px; }
html.tablet .lib-del { display: grid; width: 32px; height: 32px; font-size: 13px; }
html.tablet .lib-item .lib-play { opacity: 1; }
html.tablet .seg button { min-height: 40px; }
html.tablet .chip { padding: 5px 11px; }
html.tablet .tile-tools .btn { min-height: 40px; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .brand-word { font-size: 16px; }
  .session-status { order: 3; width: 100%; flex-wrap: wrap; }
  .stage-col { padding: 16px; }
  .stage-wrap, .layout-bar { min-width: 0; }
  .add-btns { margin-left: 0; }
  .room-main { padding: 12px; }
  .join-card { padding: 18px; }
  .join-devices { grid-template-columns: 1fr; }
  .room-controls select { max-width: 100%; flex: 1 1 140px; }
  .sched-grid { grid-template-columns: 1fr; }
  .thumb-pick { flex-wrap: wrap; }
}
