:root {
  --bg: #0b0c0f;
  --bg-2: #111216;
  --panel: #15161b;
  --panel-2: #1c1d23;
  --panel-3: #25262e;
  --line: #262730;
  --line-2: #32333d;
  --text: #f1f1f4;
  --muted: #9b9ca8;
  --faint: #6c6d78;
  --accent: #2ee6a6;
  --accent-ink: #062418;
  --accent-soft: rgba(46, 230, 166, .12);
  --info: #5aa9ff;
  --warn: #ffb547;
  --warn-soft: rgba(255, 181, 71, .12);
  --danger: #ff4d5e;
  --danger-soft: rgba(255, 77, 94, .12);
  --radius: 8px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif; letter-spacing: 0; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
svg { width: 18px; height: 18px; flex: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; white-space: nowrap; }
.brand .logo { width: 34px; height: 34px; }
.brand.small { font-size: 16px; }
.brand.small .logo { width: 28px; height: 28px; }

/* Buttons */
.round { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--panel-3); color: var(--text); transition: background .15s, transform .1s; }
.round:hover { background: #30313b; }
.round:active { transform: scale(.96); }
.round.off { background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1px rgba(255,77,94,.35); }
.round.off:hover { background: rgba(255,77,94,.2); }
.round.on { background: var(--accent); color: var(--accent-ink); }
.round.raised { background: var(--warn); color: #2b1c00; }
.round.ghost { background: transparent; color: var(--muted); }
.round.ghost:hover { background: var(--panel-3); color: var(--text); }
.round.danger { background: var(--danger); color: #fff; width: 56px; }
.round.danger:hover { background: #ff6574; }
.icon-btn { width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); flex: none; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn.boxed { width: 42px; height: 42px; border: 1px solid var(--line-2); background: var(--panel-2); }
.icon-btn.ok { color: var(--accent); }
.icon-btn.ok:hover { background: var(--accent-soft); }
.icon-btn.bad:hover { color: var(--danger); background: var(--danger-soft); }
.text-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line-2); white-space: nowrap; font-weight: 600; font-size: 13px; }
.text-btn:hover { background: var(--panel-3); }
.text-btn.accent { background: var(--accent-soft); border-color: rgba(46,230,166,.35); color: var(--accent); }
.text-btn.accent:hover { background: rgba(46,230,166,.2); }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 18px; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); font-weight: 700; transition: filter .15s; }
.primary:hover { filter: brightness(1.07); }
.primary:disabled { opacity: .6; cursor: default; }
.wide { width: 100%; }

/* Fields */
.field { display: grid; gap: 7px; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 600; }
input, select { height: 42px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--panel-2); outline: none; min-width: 0; width: 100%; transition: border-color .15s; }
input::placeholder { color: var(--faint); }
input:focus, select:focus { border-color: var(--accent); }
input:disabled { opacity: .6; }
.input-row { display: flex; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 28px; cursor: pointer; }
.check input { width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.segmented { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; gap: 3px; }
.segmented button { flex: 1; height: 32px; border-radius: 6px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; min-width: 0; }
.segmented button svg { width: 15px; height: 15px; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.warn { margin: 0; padding: 10px 12px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.warn.error { background: var(--danger-soft); color: #ff8a95; }

/* Lobby */
.lobby { min-height: 100%; display: flex; flex-direction: column; background: radial-gradient(1200px 600px at 20% -10%, rgba(46,230,166,.07), transparent 60%), var(--bg); }
.lobby-top { padding: 22px 32px; }
.lobby-inner { flex: 1; width: min(1080px, 100%); margin: 0 auto; padding: 8px 32px 48px; display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 48px; align-items: center; }
.lobby-preview { display: grid; gap: 16px; }
.preview-frame { position: relative; aspect-ratio: 16/9; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: grid; place-items: center; box-shadow: 0 30px 60px -30px rgba(0,0,0,.8); }
.preview-frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-tag { position: absolute; left: 14px; bottom: 14px; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 7px; background: rgba(8,8,10,.72); font-weight: 600; font-size: 13px; }
.preview-tag:has(span:empty) { display: none; }
.meter { position: absolute; right: 14px; bottom: 14px; width: 110px; height: 8px; border-radius: 4px; background: rgba(8,8,10,.72); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .08s; }
.preview-controls { display: flex; justify-content: center; gap: 10px; }
.lobby-form { display: grid; gap: 18px; }
.lobby-form h1 { margin: 0 0 4px; font-size: 26px; line-height: 1.2; }

/* Avatar */
.avatar { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 26px; color: #101113; transition: box-shadow .15s; }
.avatar.big { width: 104px; height: 104px; font-size: 38px; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; flex: none; }

/* Room */
.room { height: 100%; display: grid; grid-template-rows: 60px minmax(0, 1fr) 80px; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 16px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); min-width: 0; }
.top-sep { width: 1px; height: 26px; background: var(--line-2); flex: none; }
.room-name { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.room-title { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.room-meta { display: flex; align-items: center; gap: 6px; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 12px; background: var(--panel-3); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill svg { width: 14px; height: 14px; }
.pill.director { background: var(--warn-soft); color: var(--warn); }
.pill.tally { background: var(--danger); color: #fff; }
.pill.tally svg { animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
.top-actions { display: flex; align-items: center; gap: 8px; }
.clock { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; padding: 0 6px; }
.room-body { display: grid; grid-template-columns: minmax(0, 1fr) 348px; min-height: 0; }
.room-body.no-sidebar { grid-template-columns: minmax(0, 1fr); }
.room-body.no-sidebar .sidebar { display: none; }
.controls { display: flex; align-items: center; justify-content: center; padding: 0 16px; background: var(--bg); }
.dock { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 10px 30px -10px rgba(0,0,0,.6); }
.dock-sep { width: 1px; height: 28px; background: var(--line-2); }
.controls-group { display: flex; gap: 8px; }

/* Stage */
.stage { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 4px; min-height: 0; min-width: 0; }
.stage-main { flex: 1; min-height: 0; display: grid; gap: 10px; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.stage-strip { flex: none; height: 146px; display: flex; gap: 10px; overflow-x: auto; }
.stage-strip:empty { display: none; }
.stage-strip > :first-child { margin-left: auto; }
.stage-strip > :last-child { margin-right: auto; }
.stage-strip .tile { width: 236px; flex: none; }

.tile { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; min-height: 0; min-width: 0; transition: box-shadow .15s, border-color .15s; }
.tile::before { content: ""; position: absolute; inset: auto 0 0 0; height: 64px; background: linear-gradient(transparent, rgba(0,0,0,.55)); z-index: 1; pointer-events: none; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile.screen video, .tile.contain video { object-fit: contain; }
.tile.mirror video { transform: scaleX(-1); }
.tile.speaking { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 24px -4px rgba(46,230,166,.45); }
.tile .avatar { position: relative; }
.tile.speaking .avatar { box-shadow: 0 0 0 4px var(--bg-2), 0 0 0 7px var(--accent); }
.tile.on-air::after { content: "NA LIVE"; position: absolute; top: 10px; left: 10px; z-index: 2; padding: 3px 7px; border-radius: 5px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; }
.tile-label { position: absolute; left: 10px; bottom: 10px; z-index: 2; max-width: calc(100% - 20px); display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.tile-label .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-label svg { width: 15px; height: 15px; }
.tile-label .muted-ic { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: #fff; }
.tile-label .muted-ic svg { width: 13px; height: 13px; }
.tile-label .hand-ic { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--warn); color: #2b1c00; }
.tile-label .hand-ic svg { width: 13px; height: 13px; }
.tile-actions { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; gap: 4px; padding: 3px; border-radius: 9px; background: rgba(10,10,12,.72); opacity: 0; transition: opacity .15s; }
.tile:hover .tile-actions { opacity: 1; }
.tile-actions button { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; }
.tile-actions button:hover { background: rgba(255,255,255,.12); }
.tile-actions button.active { color: var(--danger); }
.tile-actions svg { width: 16px; height: 16px; }
.tile-status { position: absolute; top: 50%; left: 50%; transform: translate(-50%, 64px); color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Sidebar */
.sidebar { border-left: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 4px; margin: 12px 12px 4px; padding: 4px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.tab { position: relative; flex: 1; height: 34px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 13px; }
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel-3); color: var(--text); }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.panel { flex: 1; overflow-y: auto; padding: 8px 12px 16px; min-height: 0; }
#panel-chat { display: flex; flex-direction: column; padding: 0; }
.section-title { color: var(--faint); font-size: 11px; font-weight: 700; text-transform: uppercase; margin: 18px 6px 8px; }
.section-title:first-child { margin-top: 6px; }

.person { padding: 10px; border-radius: var(--radius); display: grid; gap: 9px; border: 1px solid transparent; transition: background .15s; }
.person:hover { background: var(--panel); border-color: var(--line); }
.person-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.person-name small { color: var(--faint); font-weight: 500; margin-left: 6px; }
.crown { display: inline-flex; margin-left: 5px; color: var(--warn); vertical-align: -2px; }
.crown svg { width: 14px; height: 14px; }
.person .avatar.speaking { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--accent); }
.status-icons { display: flex; gap: 6px; color: var(--muted); }
.status-icons svg { width: 16px; height: 16px; }
.status-icons .off { color: var(--danger); }
.status-icons .live { color: var(--accent); }
.status-icons .hand { color: var(--warn); }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.conn.connected { background: var(--accent); }
.conn.connecting, .conn.new { background: var(--warn); }
.conn.failed, .conn.disconnected { background: var(--danger); }
.person-actions { display: flex; margin-right: -4px; opacity: .55; transition: opacity .15s; }
.person:hover .person-actions { opacity: 1; }
.person-actions .icon-btn { width: 28px; height: 28px; }
.person-actions svg { width: 16px; height: 16px; }
.slider-row { display: flex; align-items: center; gap: 8px; color: var(--muted); padding-left: 44px; }
.slider-row svg { width: 16px; height: 16px; }
.slider-row input[type=range] { height: 18px; padding: 0; border: 0; background: none; accent-color: var(--accent); flex: 1; }
.slider-row .val { width: 38px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.person-toggles { display: flex; gap: 6px; padding-left: 44px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 14px; border: 1px solid var(--line-2); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip svg { width: 14px; height: 14px; }
.chip.active { border-color: rgba(46,230,166,.4); background: var(--accent-soft); color: var(--accent); }
.chip.danger { border-color: rgba(255,77,94,.4); background: var(--danger-soft); color: var(--danger); }
.knock { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; margin-bottom: 6px; border-radius: var(--radius); border: 1px solid rgba(255,181,71,.35); background: var(--warn-soft); }

.chat-list { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: grid; gap: 2px; }
.msg-head { display: flex; gap: 8px; align-items: baseline; }
.msg-head b { font-size: 13px; }
.msg-head time { color: var(--faint); font-size: 11px; }
.msg p { margin: 0; overflow-wrap: anywhere; color: #d9d9de; }
.chat-empty { margin: auto; color: var(--faint); }
.chat-form { display: flex; gap: 6px; padding: 12px; border-top: 1px solid var(--line); }

.live-group { display: grid; gap: 12px; padding: 14px; margin-bottom: 4px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.link-box { display: flex; gap: 6px; }
.link-box input { font-size: 12px; color: var(--muted); height: 36px; }
.link-box .icon-btn { height: 36px; }

/* Dialog */
.dialog { border: 1px solid var(--line-2); background: var(--panel); color: var(--text); border-radius: 12px; padding: 0; width: min(460px, calc(100% - 32px)); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
.dialog-body { display: grid; gap: 18px; padding: 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 17px; }

/* Waiting room */
.wait-box { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 4px 6px 4px 14px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel-2); }
.wait-text { flex: 1; min-width: 0; }
.spinner { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--panel-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.primary .spinner { border-color: rgba(6,36,24,.25); border-top-color: var(--accent-ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Output (OBS) */
body.is-output, body.is-output.bg-dark { background: #0b0b0d; }
body.is-output.bg-transparent { background: transparent; }
body.is-output.bg-green { background: #00ff00; }
.output { position: fixed; inset: 0; display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.output .tile { border: 0; background: #16171a; animation: tile-in .35s ease; }
.output .tile::before { display: none; }
.bg-transparent .output .tile, .bg-green .output .tile { background: rgba(22,23,26,.85); }
.output .tile-label { padding: 4px 8px; border-radius: 6px; background: rgba(10,10,12,.72); text-shadow: none; }
.output .stage-strip { height: 22%; }
.output .stage-strip .tile { width: auto; aspect-ratio: 16/9; }
.output .tile-actions, .output .hand-ic { display: none; }
.output.no-names .tile-label { display: none; }
.output.fill { padding: 0; }
.output.fill, .output.fill .stage-main, .output.fill .stage-strip { gap: 0; }
.output.fill .tile { border-radius: 0; }
.output .tile.speaking { box-shadow: none; }
.output.speakers .tile.speaking { box-shadow: inset 0 0 0 4px var(--accent); }
.output.square .tile { border-radius: 0; }
.output.contain .tile video { object-fit: contain; }
.output.vertical .stage-strip .tile { aspect-ratio: 9/16; }
@keyframes tile-in { from { opacity: 0; } }
.unlock { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.out-error { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: #c9c9ce; font-size: 16px; }

/* Toast + tooltip */
.toasts { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: 8px; z-index: 50; pointer-events: none; }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: 0 12px 30px rgba(0,0,0,.45); display: flex; gap: 8px; align-items: center; font-weight: 500; animation: pop .2s ease; }
.toast svg { color: var(--accent); width: 16px; height: 16px; }
.toast.error svg { color: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.tooltip { position: fixed; z-index: 60; padding: 5px 9px; border-radius: 6px; background: #000; border: 1px solid var(--line-2); color: #fff; font-size: 12px; pointer-events: none; white-space: nowrap; }

@media (max-width: 1100px) {
  .clock { display: none; }
}
@media (max-width: 900px) {
  .lobby-inner { grid-template-columns: 1fr; gap: 28px; padding: 0 20px 32px; }
  .lobby-top { padding: 18px 20px; }
  .room-body { grid-template-columns: 1fr; }
  .sidebar { position: fixed; right: 0; top: 60px; bottom: 80px; width: min(348px, 100%); z-index: 20; box-shadow: -20px 0 40px rgba(0,0,0,.5); }
  .room-body.no-sidebar .sidebar { display: none; }
  .text-btn .label { display: none; }
  .text-btn { padding: 0 10px; }
  .stage-strip { height: 110px; }
  .stage-strip .tile { width: 170px; }
  .top-sep, .brand.small span { display: none; }
}
@media (max-width: 560px) {
  .room-meta .pill:not(#peerCount) { display: none; }
  .dock { gap: 6px; padding: 6px; }
  .controls-group { gap: 4px; }
  .round { width: 40px; height: 40px; border-radius: 10px; }
  .round.danger { width: 46px; }
  .dock-sep { display: none; }
}

/* ---- Dashboard polish ---- */
.tile { background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--c, #000) 18%, transparent), transparent 62%), var(--panel); }
.invite-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; border: 1px dashed var(--line-2); background: var(--bg-2); }
.invite-tile::before { display: none; }
.invite-art { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.invite-art svg { width: 28px; height: 28px; }
.invite-title { font-weight: 700; font-size: 16px; }

/* Switch-style checkboxes */
.check { flex-direction: row-reverse; justify-content: space-between; gap: 12px; }
.check span { flex: 1; min-width: 0; }
.check input { appearance: none; -webkit-appearance: none; width: 34px; height: 20px; margin: 0; border-radius: 10px; background: var(--panel-3); border: 1px solid var(--line-2); position: relative; cursor: pointer; transition: background .15s, border-color .15s; }
.check input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #c7c8d0; transition: transform .15s, background .15s; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { transform: translateX(14px); background: var(--accent-ink); }

/* Program preview */
#panel-live { display: flex; flex-direction: column; gap: 10px; }
#panel-live[hidden] { display: none !important; }
.program-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 0; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.prog-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; text-transform: none; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.live { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); animation: blink 1.6s ease-in-out infinite; }
.program { position: relative; flex: none; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line-2); background: #0b0b0d; display: flex; flex-direction: column; gap: 3px; padding: 3px; }
.program.vertical { aspect-ratio: 9/16; max-height: 320px; align-self: center; }
.program.bg-green { background: #00ff00; }
.program.bg-transparent { background: repeating-conic-gradient(#1d1e24 0 25%, #15161b 0 50%) 0 0 / 14px 14px; }
.prog-main { flex: 1; min-height: 0; display: grid; gap: 3px; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.prog-strip { flex: none; height: 24%; display: flex; gap: 3px; justify-content: center; }
.prog-strip:empty { display: none; }
.prog-strip .ptile { aspect-ratio: 16/9; height: 100%; }
.ptile { position: relative; overflow: hidden; border-radius: 4px; background: #1a1b20; display: grid; place-items: center; min-width: 0; min-height: 0; }
.ptile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ptile.screen video, .program.contain .ptile video { object-fit: contain; }
.ptile.mirror video { transform: scaleX(-1); }
.ptile b { width: 30%; max-width: 40px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; color: #101113; font-size: 11px; }
.prog-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: 12px; }
.out-link input { font-size: 12px; color: var(--muted); height: 36px; }
.out-link .icon-btn { height: 36px; }

/* Layout cards */
.layout-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.layout-card { display: grid; gap: 7px; padding: 8px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--bg-2); color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; transition: border-color .15s, color .15s; }
.layout-card:hover { color: var(--text); border-color: var(--faint); }
.layout-card.active { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.lc-art { display: grid; gap: 3px; aspect-ratio: 16/10; }
.lc-art i { border-radius: 2px; background: var(--line-2); }
.layout-card.active .lc-art i { background: var(--accent); opacity: .85; }
.lc-auto { grid-template-columns: repeat(3, 1fr); grid-template-rows: 2.2fr 1fr; }
.lc-auto i:first-child { grid-column: 1 / -1; }
.lc-grid { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.lc-focus { grid-template-columns: 1fr; }
.lc-focus i:not(:first-child) { display: none; }

/* Collapsible sections */
.live-sec { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.live-sec summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; font-weight: 700; font-size: 13px; }
.live-sec summary::-webkit-details-marker { display: none; }
.live-sec summary span { flex: 1; }
.live-sec summary svg { width: 16px; height: 16px; color: var(--muted); }
.live-sec summary svg:last-child { transition: transform .15s; }
.live-sec[open] summary svg:last-child { transform: rotate(180deg); }
.live-sec[open] summary { border-bottom: 1px solid var(--line); }
.live-sec-body { display: grid; gap: 12px; padding: 14px; }
.live-sec-body > div { display: grid; gap: 12px; }
.layout-card { min-width: 0; }
.lc-art { width: 100%; min-width: 0; gap: 2px; }
.lc-auto { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* OBS output: the strip must always fit, never scroll */
.output .stage-strip { overflow: hidden; justify-content: center; flex-wrap: wrap; align-content: center; }
.output .stage-strip > :first-child, .output .stage-strip > :last-child { margin: 0; }
.output .stage-strip .tile { aspect-ratio: auto; height: var(--sh, 100%); width: var(--sw, auto); flex: none; }
.output .stage-strip .avatar { width: min(56px, 34%); height: auto; aspect-ratio: 1; font-size: 18px; transform: translateY(-10%); }

/* ---- Free layout ---- */
.output.free { padding: 0; }
.output.free .stage-main { display: block; position: relative; }
.output.free .tile { position: absolute; }
.program.free .prog-main { display: block; position: relative; }
.program.free { padding: 0; }
.program.free .ptile { position: absolute; border-radius: 3px; outline: 1px solid rgba(255,255,255,.08); }
.program .pname, .program .rz { display: none; }
.program.free .ptile { cursor: grab; touch-action: none; user-select: none; }
.program.free.dragging .ptile { cursor: grabbing; }
.program.free .pname { display: block; position: absolute; left: 4px; bottom: 4px; max-width: calc(100% - 8px); padding: 1px 5px; border-radius: 3px; background: rgba(8,8,10,.75); font-size: 10px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.program.free .ptile:hover { outline: 2px solid var(--accent); z-index: 998 !important; }
.program.free .rz { display: block; position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, var(--accent) 50%); opacity: 0; }
.program.free .ptile:hover .rz { opacity: 1; }
.program.big { position: fixed; z-index: 41; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(calc(100vw - 80px), calc((100vh - 160px) * 16 / 9)); max-height: none; box-shadow: 0 30px 80px rgba(0,0,0,.7); }
.program.big.vertical { width: auto; height: calc(100vh - 160px); }
.program.big .pname { font-size: 13px; padding: 3px 8px; left: 8px; bottom: 8px; }
.program.big .rz { width: 22px; height: 22px; }
.program.big .ptile b { font-size: 16px; max-width: 64px; }
.prog-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.7); backdrop-filter: blur(2px); }
.program-head .icon-btn { width: 28px; height: 28px; margin-left: 4px; }
.program-head .icon-btn svg { width: 15px; height: 15px; }
.program-head .prog-status { margin-left: auto; }
.layout-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.layout-card { padding: 7px 6px; }
.lc-free { position: relative; display: block; }
.lc-free i { position: absolute; }
.lc-free i:nth-child(1) { left: 0; top: 0; width: 62%; height: 62%; }
.lc-free i:nth-child(2) { right: 0; top: 18%; width: 34%; height: 34%; }
.lc-free i:nth-child(3) { left: 30%; bottom: 0; width: 34%; height: 34%; }
.lc-free i:nth-child(4) { display: none; }
.wide-btn { width: 100%; justify-content: center; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.preset { display: inline-flex; align-items: center; height: 30px; border-radius: 15px; border: 1px solid var(--line-2); background: var(--bg-2); overflow: hidden; }
.preset button { height: 100%; padding: 0 10px; font-size: 12px; font-weight: 600; white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.preset button:hover { background: var(--accent-soft); color: var(--accent); }
.preset .preset-x { padding: 0 8px 0 4px; color: var(--faint); }
.preset .preset-x:hover { color: var(--danger); background: var(--danger-soft); }
.preset .preset-x svg { width: 13px; height: 13px; }
.preset-empty { color: var(--faint); font-size: 12px; }

/* Confirm dialog */
.confirm-dialog { width: min(420px, calc(100% - 32px)); }
.confirm-dialog[open] { animation: dlg-in .16s ease; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.confirm-body { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px 16px; padding: 22px; }
.confirm-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.confirm-icon svg { width: 22px; height: 22px; }
.confirm-icon.warn { background: var(--warn-soft); color: var(--warn); }
.confirm-icon.danger { background: var(--danger-soft); color: var(--danger); }
.confirm-text h2 { margin: 2px 0 6px; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.confirm-text p { margin: 0; color: var(--muted); font-size: 13px; }
.confirm-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.confirm-actions .primary, .confirm-actions .text-btn { height: 40px; padding: 0 16px; }
.primary.warn { background: var(--warn); color: #2b1c00; }
.primary.danger { background: var(--danger); color: #fff; }

/* Free resize handles on every edge and corner */
.program.free .rz { display: block; position: absolute; opacity: 0; background: none; z-index: 2; }
.program.free .ptile:hover .rz { opacity: 1; }
.program.free .rz-n, .program.free .rz-s { left: 10px; right: 10px; height: 8px; cursor: ns-resize; }
.program.free .rz-e, .program.free .rz-w { top: 10px; bottom: 10px; width: 8px; cursor: ew-resize; }
.program.free .rz-n { top: 0; } .program.free .rz-s { bottom: 0; }
.program.free .rz-e { right: 0; } .program.free .rz-w { left: 0; }
.program.free .rz-ne, .program.free .rz-nw, .program.free .rz-se, .program.free .rz-sw { width: 12px; height: 12px; background: var(--accent); border-radius: 3px; }
.program.free .rz-nw { left: -1px; top: -1px; cursor: nwse-resize; }
.program.free .rz-se { right: -1px; bottom: -1px; cursor: nwse-resize; }
.program.free .rz-ne { right: -1px; top: -1px; cursor: nesw-resize; }
.program.free .rz-sw { left: -1px; bottom: -1px; cursor: nesw-resize; }
.program.free .rz-n::after, .program.free .rz-s::after, .program.free .rz-e::after, .program.free .rz-w::after { content: ""; position: absolute; background: var(--accent); border-radius: 2px; }
.program.free .rz-n::after, .program.free .rz-s::after { left: 50%; width: 22px; height: 4px; margin-left: -11px; top: 2px; }
.program.free .rz-e::after, .program.free .rz-w::after { top: 50%; height: 22px; width: 4px; margin-top: -11px; left: 2px; }
.program.big.free .rz-ne, .program.big.free .rz-nw, .program.big.free .rz-se, .program.big.free .rz-sw { width: 14px; height: 14px; }
.program.free .rz-n, .program.free .rz-s { width: auto; height: 8px; }
.program.free .rz-e, .program.free .rz-w { height: auto; width: 8px; }
.program.big.free .rz-n, .program.big.free .rz-s { height: 10px; }
.program.big.free .rz-e, .program.big.free .rz-w { width: 10px; }

/* Settings dialog */
.settings-dialog { width: min(520px, calc(100% - 32px)); max-height: calc(100vh - 48px); }
.settings-dialog[open] { animation: dlg-in .16s ease; }
.settings-dialog .dialog-body { gap: 14px; }
.set-sec { display: grid; gap: 14px; padding: 16px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.set-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; font-weight: 700; color: var(--text); }
.set-title svg { width: 16px; height: 16px; color: var(--accent); }
.settings-dialog select { background: var(--panel); }
.settings-dialog select:focus-visible { outline: none; }
.mic-test { display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line-2); }
.mic-test-ic { display: grid; place-items: center; color: var(--accent); }
.mic-test-ic.off { color: var(--danger); }
.mic-test-ic svg { width: 16px; height: 16px; }
.mic-bars { flex: 1; display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; height: 14px; }
.mic-bars i { border-radius: 2px; background: var(--panel-3); transition: background .06s; }
.mic-bars i.on { background: var(--accent); }
.mic-bars i.hot { background: var(--warn); }
.cam-row { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 14px; align-items: end; }
.cam-thumb { position: relative; aspect-ratio: 16/9; border-radius: 7px; overflow: hidden; background: var(--panel); border: 1px solid var(--line-2); display: grid; place-items: center; color: var(--faint); }
.cam-thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-thumb svg { width: 20px; height: 20px; }
@media (max-width: 480px) { .cam-row { grid-template-columns: 1fr; } }
.settings-dialog .dialog-body { gap: 12px; padding: 18px 20px 20px; }
.set-sec { gap: 10px; padding: 12px 14px 14px; }
.settings-dialog .field { gap: 6px; }
.settings-dialog select { height: 38px; }
.settings-dialog .segmented button { height: 30px; }
.mic-test { height: 32px; }
.cam-row { grid-template-columns: 104px minmax(0, 1fr); align-items: center; }
.segmented button.two-line { height: 44px; gap: 10px; }
.settings-dialog .segmented button.two-line { height: 44px; }
.two-line span { display: grid; text-align: left; line-height: 1.2; }
.two-line b { font-weight: 700; }
.two-line small { font-size: 11px; font-weight: 500; color: var(--faint); }
.two-line.active small { color: var(--muted); }

/* ---- Lobby v2 ---- */
.lobby-inner { width: min(1180px, 100%); grid-template-columns: minmax(0, 1.7fr) minmax(340px, 1fr); gap: 40px; }
.preview-frame { border-radius: 16px; }
.preview-frame .preview-controls { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 2; display: flex; gap: 8px; padding: 6px; border-radius: 16px; background: rgba(8,8,10,.6); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.06); }
.preview-frame .preview-controls .round { width: 42px; height: 42px; }
.round.glass { background: transparent; color: var(--text); }
.round.glass:hover { background: rgba(255,255,255,.1); }
.preview-tag { top: 14px; bottom: auto; }
.meter { right: auto; left: 14px; top: 46px; bottom: auto; width: 90px; height: 5px; }
.lobby-card { display: grid; gap: 16px; padding: 22px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 30px 60px -30px rgba(0,0,0,.8); }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.mode-tab { height: 38px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; color: var(--muted); font-weight: 700; font-size: 13px; white-space: nowrap; }
.mode-tab svg { width: 16px; height: 16px; }
.mode-tab:hover { color: var(--text); }
.mode-tab.active { background: var(--panel-3); color: var(--text); }
.input-wrap { position: relative; flex: 1; min-width: 0; }
.input-wrap input { padding-right: 132px; }
.room-status { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; }
.room-status svg { width: 14px; height: 14px; }
.room-status.ok { color: var(--accent); }
.room-status.bad { color: var(--danger); }
@media (max-width: 900px) { .lobby-inner { grid-template-columns: 1fr; } }

/* ---- Scene editor affordances ---- */
.program.free .ptile { outline: 1px dashed rgba(46,230,166,.55); outline-offset: -1px; }
.program.free .ptile.sel { outline: 2px solid var(--accent); z-index: 997 !important; }
.program.free .ptile.sel .rz { opacity: 1; }
.prog-edit { display: none; position: absolute; right: 8px; bottom: 8px; z-index: 999; height: 30px; padding: 0 12px; border-radius: 8px; align-items: center; gap: 6px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.prog-edit svg { width: 15px; height: 15px; }
.program.free:not(.big) .prog-edit { display: inline-flex; }
.program.free:not(.big) .ptile { pointer-events: none; }
.program.free:not(.big) { cursor: pointer; }
.prog-top, .prog-toolbar { display: none; }
.program.big.free ~ .prog-top { display: flex; position: fixed; z-index: 42; left: 50%; transform: translateX(-50%); top: 22px; width: min(calc(100vw - 80px), calc((100vh - 160px) * 16 / 9)); align-items: center; justify-content: space-between; }
.prog-top-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.prog-top-title svg { color: var(--accent); }
.program.big.free ~ .prog-toolbar { display: flex; position: fixed; z-index: 42; left: 50%; transform: translateX(-50%); bottom: 18px; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: 0 16px 40px rgba(0,0,0,.6); max-width: calc(100vw - 32px); overflow-x: auto; }
.prog-toolbar .icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.tool-sel { display: inline-flex; align-items: center; gap: 8px; padding: 0 8px; min-width: 150px; max-width: 220px; font-size: 13px; white-space: nowrap; overflow: hidden; }
.tool-sel b { overflow: hidden; text-overflow: ellipsis; }
.tool-sel svg { color: var(--accent); width: 16px; height: 16px; }
.tool-hint { color: var(--faint); }
.tool-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; flex: none; }
.program.big.free .prog-main { background-image: linear-gradient(rgba(255,255,255,.07), rgba(255,255,255,.07)), linear-gradient(rgba(255,255,255,.07), rgba(255,255,255,.07)); background-size: 1px 100%, 100% 1px; background-position: 50% 0, 0 50%; background-repeat: no-repeat; }
.program.big { top: calc(50% - 6px); }
.prog-edit { width: 30px; height: 30px; padding: 0; justify-content: center; border-radius: 8px; background: rgba(8,8,10,.72); color: var(--accent); border: 1px solid rgba(46,230,166,.45); box-shadow: none; right: 6px; bottom: 6px; }
.prog-edit:hover { background: var(--accent); color: var(--accent-ink); }
.prog-edit svg { width: 15px; height: 15px; }

/* Editing chrome only inside the big editor */
.program.free:not(.big) .ptile, .program.free:not(.big) .ptile.sel { outline: none; }
.program.free:not(.big) .rz, .program.free:not(.big) .ptile.sel .rz, .program.free:not(.big) .ptile:hover .rz { display: none; }

/* Desktop screen picker */
.picker-dialog { width: min(820px, calc(100% - 40px)); }
.picker-dialog[open] { animation: dlg-in .16s ease; }
#pickerTabs { width: 260px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; max-height: min(52vh, 440px); overflow-y: auto; padding: 2px; }
.pick { display: grid; gap: 8px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); text-align: left; transition: border-color .12s, background .12s; }
.pick:hover { border-color: var(--line-2); background: var(--panel-2); }
.pick.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.pick-thumb { aspect-ratio: 16/9; border-radius: 6px; overflow: hidden; background: #000; display: grid; place-items: center; }
.pick-thumb img { width: 100%; height: 100%; object-fit: contain; }
.pick-name { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 12px; font-weight: 600; }
.pick-name img, .pick-name svg { width: 16px; height: 16px; flex: none; }
.pick-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-empty { color: var(--faint); grid-column: 1 / -1; text-align: center; padding: 40px 0; margin: 0; }
.picker-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.picker-foot .confirm-actions { margin: 0; }
.picker-audio { flex-direction: row; gap: 10px; }
.picker-audio span { flex: none; }

/* Download link in the lobby header */
.lobby-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
a.text-btn { text-decoration: none; color: var(--text); }

/* Download link in the lobby header */
.lobby-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
a.text-btn { text-decoration: none; }
