:root {
  --bg: #1e1f22;
  --panel: #2b2d31;
  --panel2: #313338;
  --line: #3f4147;
  --text: #f2f3f5;
  --muted: #a6a9b0;
  --accent: #5865f2;
  --accent2: #4752c4;
  --green: #23a55a;
  --red: #da373c;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 8px; padding: 9px 14px; background: var(--panel2); }
button:hover { filter: brightness(1.15); }
select, input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.primary { background: var(--accent); font-weight: 600; }
.ghost { background: transparent; color: var(--muted); padding: 6px 8px; }
.ghost:hover { color: var(--text); }

/* Lobby */
.lobby { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--panel); padding: 28px; border-radius: 14px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 40px #0006; }
.card h1 { margin: 0; font-size: 26px; }
.card .sub { margin: -8px 0 6px; color: var(--muted); }
.card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.card label input, .card label select { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text); font-size: 14px; }
.error { color: #ff7b7f; margin: 0; min-height: 1em; }

/* Call layout */
.call { display: grid; grid-template-columns: 260px 1fr; height: 100%; }
.sidebar { background: var(--panel); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid #0003; }
.room-head { display: flex; justify-content: space-between; align-items: center; padding: 14px; border-bottom: 1px solid #0003; }
.room-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.room-name { font-weight: 700; font-size: 16px; word-break: break-all; }
.section-title { padding: 14px 14px 6px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.participants { list-style: none; margin: 0; padding: 0 8px; }
.participant { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; border-radius: 8px; }
.participant:hover { background: var(--panel2); }
.p-row { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: var(--accent2); flex: none; box-shadow: 0 0 0 2px transparent; transition: box-shadow .1s; }
.avatar.speaking { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--green); }
.p-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-icons { color: var(--muted); font-size: 12px; white-space: nowrap; }
.p-status { font-size: 11px; color: var(--muted); }
.vol { width: 100%; accent-color: var(--accent); }

.chat-log { flex: 1; overflow-y: auto; padding: 0 14px; min-height: 60px; }
.chat-msg { margin: 6px 0; word-wrap: break-word; }
.chat-msg b { color: #c9cdfb; }
.chat-form { padding: 10px; }
.chat-form input { width: 100%; }

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #111214; }
.screens { flex: 1; display: grid; gap: 8px; padding: 8px; min-height: 0;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); grid-auto-rows: 1fr; }
.screens.focus { grid-template-columns: 1fr; }
.screens.focus .tile:not(.focused) { display: none; }
.empty { grid-column: 1 / -1; display: grid; place-items: center; text-align: center; color: var(--muted); }
.tile { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; min-height: 0; }
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.tile-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; align-items: center;
  padding: 8px 10px; background: linear-gradient(transparent, #000c); opacity: 0; transition: opacity .15s; }
.tile:hover .tile-bar, .tile.local .tile-bar { opacity: 1; }
.tile-name { font-weight: 600; flex: 0 1 auto; min-width: 40px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-stats { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: #cfd2d8; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile-bar button { padding: 5px 9px; background: #ffffff22; font-size: 12px; }
.tile-bar input[type=range] { width: 90px; accent-color: var(--accent); }
.live { position: absolute; top: 8px; left: 8px; background: var(--red); font-size: 11px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px; }

.controls { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 12px; background: var(--bg); border-top: 1px solid #0006; }
.group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ctrl { padding: 10px 14px; font-weight: 600; }
.ctrl.off { background: var(--red); }
.ctrl.share { background: var(--green); }
.ctrl.share.on { background: var(--red); }
.danger { background: var(--red); }

/* Picker (desktop app) */
.picker { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 10; padding: 16px; }
.picker-box { background: var(--panel); border-radius: 14px; width: min(900px, 100%); max-height: 90vh; display: flex; flex-direction: column; padding: 18px; gap: 12px; }
.picker-head { display: flex; justify-content: space-between; align-items: center; }
.picker-head h2 { margin: 0; font-size: 18px; }
.picker-tabs { display: flex; gap: 6px; }
.tab.active { background: var(--accent); }
.picker-audio { color: var(--muted); display: flex; gap: 8px; align-items: center; }
.picker-grid { overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.source { background: var(--panel2); padding: 8px; border-radius: 8px; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.source img { width: 100%; aspect-ratio: 16/9; object-fit: contain; background: #000; border-radius: 4px; }
.source span { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: #000d; padding: 10px 16px; border-radius: 8px; z-index: 20; }

@media (max-width: 760px) {
  .call { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { max-height: 40vh; }
  .screens { grid-template-columns: 1fr; }
}

.opt { text-transform: none; font-weight: 400; }
.stage { position: relative; }
.net-banner { background: #f0b232; color: #111; font-weight: 600; padding: 8px 12px; text-align: center; }
.p-status { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--green); flex: none; }
.dot.mid { background: #f0b232; }
.dot.bad { background: var(--red); }
.settings-box { max-width: 560px; gap: 16px; overflow-y: auto; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.field select, .field b { color: var(--text); }
.field small { color: var(--muted); }
.field input[type=range] { width: 100%; accent-color: var(--accent); }
.inline { display: flex; gap: 8px; align-items: center; }
.checks { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); }
.checks label { display: flex; gap: 6px; align-items: center; }
.meter { position: relative; height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.level { height: 100%; width: 0; background: #6d6f78; transition: width .05s linear; }
.level.open { background: var(--green); }
.gate-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; }

.app-link { color: #9aa4ff; font-size: 13px; text-align: center; }
.app-info { color: var(--muted); font-size: 12px; text-align: center; }
.link { background: none; padding: 0; color: #9aa4ff; text-decoration: underline; font-size: 12px; }
