/* ================= Tokens ================= */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #121826;
  --muted: #5d6779;
  --border: #dde2ec;
  --accent: #4361ee;
  --accent-hover: #3651d4;
  --accent-soft: rgba(67, 97, 238, 0.12);
  --accent-text: #ffffff;
  --danger: #e5484d;
  --danger-hover: #cc3a3f;
  --success: #2fb171;
  --warn: #f5a524;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08), 0 2px 6px rgba(16, 24, 40, 0.06);
  --radius: 14px;

  /* The meeting room is always dark, like a studio. */
  --m-bg: #0d111a;
  --m-surface: #151b27;
  --m-surface-2: #1d2433;
  --m-tile: #1a2130;
  --m-text: #eef1f7;
  --m-muted: #97a1b5;
  --m-border: #283044;
  --m-hover: #242c3d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d111a;
    --surface: #151b27;
    --surface-2: #1d2433;
    --text: #eef1f7;
    --muted: #97a1b5;
    --border: #283044;
    --accent: #5b7bff;
    --accent-hover: #6f8bff;
    --accent-soft: rgba(91, 123, 255, 0.16);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg: #0d111a;
  --surface: #151b27;
  --surface-2: #1d2433;
  --text: #eef1f7;
  --muted: #97a1b5;
  --border: #283044;
  --accent: #5b7bff;
  --accent-hover: #6f8bff;
  --accent-soft: rgba(91, 123, 255, 0.16);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* ================= Base ================= */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2 { letter-spacing: -0.02em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }
.ico { flex: none; display: block; }

.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ================= Buttons and fields ================= */
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.link { background: none; border: 0; padding: 4px 6px; color: var(--accent); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 13px 20px; font-size: 16px; }
.btn:disabled { opacity: 0.6; cursor: progress; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.primary { background: var(--accent); color: var(--accent-text); }
.icon-btn.primary:hover { background: var(--accent-hover); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field > span { display: inline-flex; align-items: center; gap: 6px; }
.field.compact { font-weight: 500; font-size: 12px; }
input, select {
  width: 100%; padding: 10px 12px; font: inherit; font-weight: 400; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
select { appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23889' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; text-overflow: ellipsis; }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input-row { display: flex; gap: 8px; align-items: center; }
.error { color: var(--danger); min-height: 1.3em; font-size: 14px; margin: 8px 0 0; }

.switch { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 36px; height: 20px; padding: 0; border-radius: 20px; background: var(--border); border: 0; position: relative; flex: none; cursor: pointer; transition: background 0.15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

.avatar {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 24px; color: #fff; background: var(--accent); flex: none; user-select: none;
}
.avatar.xl { width: 96px; height: 96px; font-size: 38px; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }

/* ================= Lobby ================= */
.lobby-top { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.lobby {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 48px;
  align-items: center; max-width: 1180px; width: 100%; margin: 0 auto; padding: 8px 24px 48px;
}
.preview {
  position: relative; aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden;
  background: #0d111a; box-shadow: var(--shadow);
}
.preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.mirror { transform: scaleX(-1); }
.preview-off { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: #c9d1e0; font-size: 14px; }
.preview-meter { position: absolute; left: 16px; top: 16px; width: 6px; height: 56px; border-radius: 4px; background: rgba(255,255,255,.18); overflow: hidden; }
.preview-meter span { position: absolute; bottom: 0; left: 0; right: 0; height: 0; background: var(--success); transition: height 0.08s; }
.preview-controls { position: absolute; left: 0; right: 0; bottom: 16px; display: flex; justify-content: center; gap: 14px; }
.round-btn {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.35); background: rgba(13,17,26,.45); color: #fff; backdrop-filter: blur(6px);
  transition: background 0.15s;
}
.round-btn:hover { background: rgba(13,17,26,.7); }
.round-btn[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); }
.devices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }

.join-col h1 { font-size: 34px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 24px; }
.join-col .field { margin-bottom: 16px; }
#join-btn { width: 100%; margin-top: 6px; }
.feature-list { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.feature-list li { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 5px 10px; border-radius: 999px; }

/* ================= Waiting room ================= */
#waiting { align-items: center; justify-content: center; padding: 16px; }
.waiting-card { text-align: center; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 40px 32px; box-shadow: var(--shadow); }
.waiting-card h2 { margin: 18px 0 6px; }
.spinner { width: 44px; height: 44px; margin: 0 auto; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= Meeting ================= */
#meeting {
  height: 100vh; height: 100dvh; background: var(--m-bg); color: var(--m-text);
  --bg: var(--m-bg); --surface: var(--m-surface); --surface-2: var(--m-surface-2); --text: var(--m-text);
  --muted: var(--m-muted); --border: var(--m-border);
}
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; min-height: 56px; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.room-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--m-surface-2); color: var(--m-muted); white-space: nowrap; }
.pill.rec { background: rgba(229,72,77,.16); color: #ff7b80; }
.pill.rec .ico { animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.count { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--m-muted); white-space: nowrap; }
.topbar .icon-btn:hover, .topbar .btn.ghost:hover { background: var(--m-hover); }

.meeting-body { flex: 1; display: flex; min-height: 0; gap: 12px; padding: 0 12px; }
.stage { flex: 1; position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; }

/* Gallery */
.grid { flex: 1; min-height: 0; display: flex; flex-wrap: wrap; gap: var(--gap, 10px); align-content: center; justify-content: center; overflow: hidden; }
.grid > .tile { width: var(--tw, 100%); height: var(--th, 100%); flex: none; margin: 0; aspect-ratio: auto; }
.filmstrip { display: none; }
.filmstrip > .tile { margin: 0; }
.filmstrip > .tile:first-child { margin-left: auto; }
.filmstrip > .tile:last-child { margin-right: auto; }
.filmstrip:empty { display: none !important; }

/* Speaker view (also used while the whiteboard is open) */
.stage.speaker .filmstrip, .stage.boarding .filmstrip { display: flex; gap: 10px; overflow-x: auto; flex: none; height: 120px; padding-bottom: 2px; }
.stage.speaker .filmstrip .tile, .stage.boarding .filmstrip .tile { width: 200px; flex: none; }
.stage.boarding .grid { display: none; }

.tile {
  position: relative; border-radius: 14px; overflow: hidden; background: var(--m-tile);
  display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0;
  aspect-ratio: 16 / 9; max-height: 100%; width: 100%; margin: auto;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 3px solid transparent; pointer-events: none; transition: border-color 0.15s; }
.tile.speaking::after { border-color: var(--success); }
.tile.hand::after { border-color: var(--warn); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--m-tile); }
.tile video.contain { object-fit: contain; background: #000; }
.tile .avatar { position: absolute; width: 22%; max-width: 96px; min-width: 44px; height: auto; aspect-ratio: 1; font-size: clamp(16px, 3vw, 36px); }
.tile .avatar.hidden { display: none; }
.tile .label {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px);
  display: inline-flex; align-items: center; gap: 6px; background: rgba(8,11,18,.66);
  color: #fff; padding: 4px 9px; border-radius: 8px; font-size: 13px; backdrop-filter: blur(4px);
}
.tile .label .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .label .mic-ind { color: #ff7b80; display: none; }
.tile.muted .label .mic-ind { display: block; }
.tile .badges { position: absolute; left: 8px; top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.tile .badge { display: inline-flex; align-items: center; gap: 5px; background: rgba(8,11,18,.66); color: #fff; padding: 3px 8px; border-radius: 8px; font-size: 12px; backdrop-filter: blur(4px); }
.tile .badge.hand { background: var(--warn); color: #1b1300; }
.tile .net { position: absolute; right: 8px; bottom: 8px; display: flex; align-items: flex-end; gap: 2px; height: 14px; padding: 3px 5px; box-sizing: content-box; background: rgba(8,11,18,.55); border-radius: 6px; }
.tile .net i { width: 3px; background: rgba(255,255,255,.3); border-radius: 1px; }
.tile .net i:nth-child(1) { height: 5px; } .tile .net i:nth-child(2) { height: 9px; } .tile .net i:nth-child(3) { height: 14px; }
.tile .net[data-q="3"] i { background: var(--success); }
.tile .net[data-q="2"] i:nth-child(-n+2) { background: var(--warn); }
.tile .net[data-q="1"] i:nth-child(1) { background: var(--danger); }
.tile-menu { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.tile:hover .tile-menu, .tile:focus-within .tile-menu { opacity: 1; }
.tile-menu button { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: rgba(8,11,18,.66); color: #fff; }
.tile-menu button:hover { background: rgba(8,11,18,.9); }
.tile.pinned .tile-menu [data-act="pin"] { background: var(--accent); }
.tile-react { position: absolute; inset: 0; display: grid; place-items: center; font-size: 64px; pointer-events: none; animation: pop 1.6s ease-out forwards; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 15% { transform: scale(1.1); opacity: 1; } 70% { opacity: 1; } 100% { transform: scale(1) translateY(-20px); opacity: 0; } }

/* Whiteboard */
.board-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.board-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; background: var(--m-surface); border: 1px solid var(--m-border); border-radius: 12px; padding: 6px 8px; }
.tool-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 0; background: transparent; color: var(--m-text); }
.tool-btn:hover { background: var(--m-hover); }
.tool-btn.active { background: var(--accent); color: #fff; }
.sep { width: 1px; height: 22px; background: var(--m-border); margin: 0 4px; }
.swatches { display: flex; gap: 4px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; padding: 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.swatch.active { border-color: #fff; }
#board-size { width: 90px; padding: 0; accent-color: var(--accent); background: none; border: 0; }
.board-surface { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; container-type: size; }
.board-surface canvas {
  aspect-ratio: 16 / 9; width: min(100cqw, 100cqh * 16 / 9); height: auto; max-height: 100%;
  background: #fff; border-radius: 12px; touch-action: none; cursor: crosshair; display: block;
}

/* Captions and reactions */
.captions { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(760px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 4px; pointer-events: none; z-index: 5; }
.caption-line { background: rgba(0,0,0,.78); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 17px; line-height: 1.35; }
.caption-line b { color: #a9bcff; font-weight: 600; margin-right: 6px; }
.reactions-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 6; }
.float-react { position: absolute; bottom: 10px; display: flex; flex-direction: column; align-items: center; animation: floatUp 3.2s ease-out forwards; }
.float-react .e { font-size: 38px; line-height: 1; }
.float-react .n { font-size: 11px; background: rgba(0,0,0,.6); color: #fff; padding: 1px 6px; border-radius: 6px; margin-top: 2px; white-space: nowrap; }
@keyframes floatUp { 0% { transform: translateY(0) scale(.6); opacity: 0; } 10% { opacity: 1; transform: translateY(-20px) scale(1); } 100% { transform: translateY(-60vh) translateX(var(--drift, 0)); opacity: 0; } }

/* Side panel */
.panel { width: 340px; flex: none; display: flex; flex-direction: column; background: var(--m-surface); border: 1px solid var(--m-border); border-radius: 14px; min-height: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 10px; border-bottom: 1px solid var(--m-border); }
.tabs { display: flex; gap: 2px; background: var(--m-bg); padding: 3px; border-radius: 10px; }
.tab { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--m-muted); }
.tab[aria-selected="true"] { background: var(--m-surface-2); color: var(--m-text); }
.pane { display: none; flex: 1; min-height: 0; flex-direction: column; padding: 12px; gap: 10px; overflow-y: auto; }
.pane.active { display: flex; }
.section-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--m-muted); margin-top: 6px; }
.section-title .btn { margin-left: auto; text-transform: none; letter-spacing: 0; }
.host-tools { display: flex; flex-direction: column; gap: 10px; padding: 10px; background: var(--m-bg); border-radius: 10px; }
.host-tools .btn { align-self: flex-start; }
.people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.person { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; }
.person:hover { background: var(--m-hover); }
.person .who { flex: 1; min-width: 0; }
.person .who .nm { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.person .who .role { font-size: 12px; color: var(--m-muted); }
.person .st { display: flex; gap: 6px; color: var(--m-muted); }
.person .st .off { color: #ff7b80; }
.person .acts { display: flex; gap: 2px; }
.person .acts button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--m-muted); }
.person .acts button:hover { background: var(--m-surface-2); color: var(--m-text); }
.person .acts .ok { color: var(--success); }

.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.msg .who { font-size: 12px; color: var(--m-muted); margin-bottom: 2px; }
.msg .who b { color: var(--m-text); font-weight: 600; }
.msg .text { white-space: pre-wrap; word-break: break-word; background: var(--m-surface-2); padding: 8px 11px; border-radius: 4px 12px 12px 12px; display: inline-block; max-width: 100%; font-size: 14px; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg.mine .text { background: var(--accent); color: #fff; border-radius: 12px 4px 12px 12px; text-align: left; }
.msg.private .text { box-shadow: inset 0 0 0 1px var(--warn); }
.chat-form { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--m-border); padding-top: 10px; }
.to-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--m-muted); }
.to-row select { padding: 5px 30px 5px 9px; font-size: 13px; width: auto; max-width: 100%; }
.pane[data-pane="chat"] { overflow: hidden; }

.poll-card { background: var(--m-bg); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.poll-card h3 { margin: 0; font-size: 15px; }
.poll-opt { position: relative; text-align: left; border: 1px solid var(--m-border); background: var(--m-surface); border-radius: 10px; padding: 9px 12px; overflow: hidden; display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.poll-opt:hover:not(:disabled) { border-color: var(--accent); }
.poll-opt:disabled { cursor: default; }
.poll-opt .bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); width: 0; transition: width .3s; }
.poll-opt.mine { border-color: var(--accent); }
.poll-opt span { position: relative; }
.poll-meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--m-muted); }
.poll-form { display: flex; flex-direction: column; gap: 8px; }
.poll-form #poll-opts { display: flex; flex-direction: column; gap: 6px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }

/* Control bar */
.controlbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 10px 16px 12px; }
.cb-center { display: flex; gap: 6px; justify-content: center; }
.cb-right { display: flex; gap: 6px; justify-content: flex-end; }
.ctrl {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 64px; padding: 8px 8px 6px; border: 0; border-radius: 12px;
  background: transparent; color: var(--m-text); transition: background 0.15s;
}
.ctrl .ico-slot { display: grid; place-items: center; width: 40px; height: 32px; border-radius: 10px; background: var(--m-surface-2); transition: background 0.15s; }
.ctrl:hover .ico-slot { background: var(--m-hover); }
.ctrl .lbl { font-size: 11px; color: var(--m-muted); white-space: nowrap; }
.ctrl[aria-pressed="true"] .ico-slot { background: var(--accent); color: #fff; }
#mic[aria-pressed="true"] .ico-slot, #cam[aria-pressed="true"] .ico-slot { background: var(--danger); }
#rec-btn[aria-pressed="true"] .ico-slot { background: var(--danger); }
#hand[aria-pressed="true"] .ico-slot { background: var(--warn); color: #1b1300; }
.ctrl.danger .ico-slot { background: var(--danger); color: #fff; width: 56px; }
.ctrl.danger:hover .ico-slot { background: var(--danger-hover); }
.ctrl.active .ico-slot { background: var(--accent-soft); color: #a9bcff; }
.dot-badge { position: absolute; top: 4px; right: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); border: 2px solid var(--m-bg); display: none; }
.ctrl.unread .dot-badge, #people-badge:not(.hidden) { display: block; }
#people-badge { background: var(--warn); }

.popover-wrap { position: relative; }
.popover { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--m-surface-2); border: 1px solid var(--m-border); border-radius: 14px; padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.45); z-index: 20; }
.popover.up-right { left: auto; right: 0; transform: none; min-width: 210px; }
#react-pop { display: flex; gap: 2px; }
#react-pop.hidden { display: none; }
.react-opt { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; font-size: 26px; line-height: 1; transition: transform .1s, background .1s; }
.react-opt:hover { background: var(--m-hover); transform: scale(1.12); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 9px 12px; border-radius: 9px; text-align: left; font-size: 14px; }
.menu-item:hover { background: var(--m-hover); }
.menu-item.danger { color: #ff7b80; }

/* Dialog */
.dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 20px; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(5,8,14,.55); backdrop-filter: blur(2px); }
.dialog form { display: flex; flex-direction: column; gap: 14px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-foot { display: flex; justify-content: flex-end; }
#meeting ~ .dialog { --bg: var(--m-bg); }

/* Toasts */
.toasts { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: #20283a; color: #fff; padding: 10px 14px; border-radius: 12px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: toastIn .2s ease-out; max-width: 100%; }
.toast .acts { display: flex; gap: 6px; }
.toast .btn.sm { padding: 5px 10px; }
.toast .btn.ghost { color: #fff; border-color: rgba(255,255,255,.25); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* ================= Responsive ================= */
@media (max-width: 1100px) {
  .ctrl { min-width: 52px; }
  .ctrl .lbl { display: none; }
  .ctrl .ico-slot { width: 44px; height: 40px; }
  .dot-badge { right: 4px; }
}
@media (max-width: 900px) {
  .lobby { grid-template-columns: 1fr; gap: 24px; padding-top: 0; }
  .join-col h1 { font-size: 26px; }
  .panel { position: absolute; right: 8px; top: 64px; bottom: 76px; width: min(360px, calc(100% - 16px)); z-index: 30; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
  #invite { display: none; }
  .controlbar { grid-template-columns: 1fr; }
  .cb-left { display: none; }
  .cb-center, .cb-right { justify-content: center; }
  .controlbar { display: flex; flex-wrap: wrap; justify-content: center; }
}
@media (max-width: 600px) {
  .lobby-top { padding: 12px 16px; }
  .lobby { padding: 0 16px 32px; }
  .devices { grid-template-columns: 1fr; }
  .feature-list { display: none; }
  .topbar { padding: 8px 12px; }
  .topbar-left .pill:not(.rec) { display: none; }
  .meeting-body { padding: 0 6px; }
  .grid { gap: 6px; }
  .controlbar { padding: 8px 16px 10px; gap: 6px; }
  .ctrl { min-width: 0; padding: 2px; }
  .ctrl .ico-slot { width: 38px; height: 38px; }
  .ctrl.danger .ico-slot { width: 48px; }
  .cb-center, .cb-right { gap: 2px; flex-wrap: wrap; }
  .board-toolbar { gap: 2px; padding: 4px; }
  #board-size { width: 60px; }
  .stage.speaker .filmstrip .tile, .stage.boarding .filmstrip .tile { width: 140px; }
  .stage.speaker .filmstrip, .stage.boarding .filmstrip { height: 84px; }
  .toasts { bottom: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ================= Accounts, home and sharing ================= */
.logo { color: inherit; text-decoration: none; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.auth-area { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.user-btn:hover { background: var(--surface-2); }
.user-btn .nm { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.user-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); z-index: 40; }
.user-menu .who { padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-menu .who b { display: block; }
.user-menu .who span { font-size: 13px; color: var(--muted); word-break: break-all; }
.user-menu .menu-item:hover { background: var(--surface-2); }
.hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.center { text-align: center; }
input[readonly] { background: var(--surface-2); color: var(--muted); }

.notice { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; border: 1px solid var(--border); background: var(--surface); border-left: 4px solid var(--warn); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; }
.notice.error-note { border-left-color: var(--danger); }

.meeting-info { margin-bottom: 18px; }
.meeting-info h1 { font-size: 30px; margin: 4px 0 4px; word-break: break-word; }
.meeting-info .sub { margin-bottom: 10px; }
.mi-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.live { background: rgba(47, 177, 113, .14); color: var(--success); }
.chip.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

/* Home */
#home { min-height: 100vh; }
.home { width: 100%; max-width: 1080px; margin: 0 auto; padding: 8px 24px 64px; display: flex; flex-direction: column; gap: 36px; }
.home-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); gap: 32px; align-items: center; padding-top: 24px; }
.home-hero h1 { font-size: 36px; margin: 0 0 8px; }
.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-join { grid-column: 1 / -1; }
/* Quiet link between regular meetings and direct calls. */
.alt-link { display: inline-flex; align-items: center; gap: 8px; margin: -12px 0 20px; font-size: 14px; color: var(--muted); text-decoration: none; }
.alt-link strong { color: var(--accent); font-weight: 600; }
.alt-link:hover strong, .alt-link:focus-visible strong { text-decoration: underline; }
.alt-link svg { flex: none; }
.home-alt { grid-column: 1 / -1; margin: 4px 0 0; }
.home-section h2 { font-size: 18px; margin: 0 0 12px; }
.meeting-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.meeting-card { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; min-width: 0; }
.meeting-card h3 { margin: 0; font-size: 16px; word-break: break-word; }
.meeting-card .owner { font-size: 13px; color: var(--muted); margin-top: -6px; }
.meeting-card .link { font-size: 13px; color: var(--muted); font-family: ui-monospace, "Cascadia Code", Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meeting-card .acts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: auto; }
.meeting-card .acts .spacer { flex: 1; }
.meeting-card .icon-btn { width: 34px; height: 34px; border: 1px solid var(--border); }
.meeting-card .icon-btn.danger:hover { color: var(--danger); }
.empty { border: 1px dashed var(--border); border-radius: 14px; padding: 22px; color: var(--muted); font-size: 14px; text-align: center; grid-column: 1 / -1; }

/* Dialog extras */
.dialog.wide { width: min(520px, calc(100vw - 32px)); }
.dialog-body { display: flex; flex-direction: column; gap: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 10px; }
.seg-btn { border: 0; background: transparent; padding: 8px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg-btn[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.radio-group { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.radio-group legend { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.radio { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio input { width: auto; margin: 3px 0 0; accent-color: var(--accent); }
.radio b { display: block; font-size: 14px; }
.radio small { color: var(--muted); font-size: 12px; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; }
.share-row a { color: inherit; text-decoration: none; }
.invite-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; }
.invite-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.invite-list li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.invite-list li button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.invite-list li button:hover { color: var(--danger); }
.dialog .section-title { color: var(--muted); }

/* People list: account check */
.person .verified { color: var(--success); display: inline-flex; vertical-align: -3px; margin-left: 4px; }

@media (max-width: 900px) {
  .home-hero { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .home { padding: 0 16px 40px; gap: 28px; }
  .home-hero h1 { font-size: 28px; }
  .home-actions { grid-template-columns: 1fr; }
  .meeting-list { grid-template-columns: 1fr; }
  .user-btn .nm { display: none; }
  .user-btn { padding: 4px; }
}
.dialog form.input-row { flex-direction: row; gap: 8px; }
#sh-error:empty { display: none; }
