:root {
  --bg: #0b0d12;
  --surface: #12151d;
  --surface-2: #1a1f2b;
  --surface-3: #232a39;
  --border: #2a3142;
  --text: #e9ecf3;
  --muted: #8f97ab;
  --accent: #4f7cff;
  --accent-soft: rgb(79 124 255 / 0.16);
  --danger: #ef4444;
  --danger-soft: rgb(239 68 68 / 0.16);
  --success: #22c55e;
  --warn: #f59e0b;
  --radius: 14px;
  --shadow: 0 18px 50px rgb(0 0 0 / 0.45);
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

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

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

/* ------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover {
  background: var(--surface-3);
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.btn.primary:hover {
  filter: brightness(1.08);
}
.btn.primary:disabled {
  opacity: 0.6;
  cursor: progress;
}
.btn.ghost {
  background: transparent;
}
.btn.big {
  height: 50px;
  font-size: 16px;
  border-radius: 12px;
}
.btn.small {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}
.btn.small .icon {
  width: 16px;
  height: 16px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.icon-btn.accent {
  background: var(--accent);
  color: #fff;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.chip .icon {
  width: 15px;
  height: 15px;
}
button.chip:hover {
  background: var(--surface-3);
}
.chip.warn {
  border-color: rgb(245 158 11 / 0.4);
  background: rgb(245 158 11 / 0.14);
  color: #fcd34d;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  background: rgb(0 0 0 / 0.55);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  backdrop-filter: blur(6px);
}

/* -------------------------------------------------------------- inputs */

.field {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.field > span,
.field > legend {
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.field > legend {
  margin-bottom: 6px;
}

input:not([type='checkbox']),
select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:not([type='checkbox']):focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select {
  appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 19px, calc(100% - 12px) 19px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
}

.input-group {
  display: flex;
  gap: 8px;
}
.input-group input {
  flex: 1;
  font-family: var(--mono);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}
.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background 0.15s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch-row input:checked + .switch {
  background: var(--accent);
}
.switch-row input:checked + .switch::after {
  transform: translateX(16px);
}
.switch-row input:focus-visible + .switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --------------------------------------------------------------- lobby */

.lobby {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgb(79 124 255 / 0.14), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgb(124 92 255 / 0.12), transparent 60%), var(--bg);
}
.lobby-wrap {
  width: min(1100px, 100%);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
}
.brand-name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.brand-tag {
  margin-left: 4px;
  color: var(--muted);
  font-size: 13px;
}

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.preview {
  display: grid;
  gap: 12px;
}
.preview-tile {
  width: 100%;
  aspect-ratio: 16 / 9;
}
.preview-controls {
  position: absolute;
  left: 50%;
  bottom: 14px;
  display: flex;
  gap: 12px;
  transform: translateX(-50%);
  z-index: 3;
}
.preview-meter {
  position: absolute;
  left: 14px;
  top: 14px;
  width: 6px;
  height: 46px;
  border-radius: 3px;
  background: rgb(0 0 0 / 0.45);
  overflow: hidden;
  z-index: 3;
}
.preview-meter span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: var(--success);
  transition: height 0.08s linear;
}
.device-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.select-wrap {
  position: relative;
  display: block;
  min-width: 0;
}
.select-wrap .icon {
  position: absolute;
  left: 12px;
  top: 12px;
  color: var(--muted);
  pointer-events: none;
  width: 18px;
  height: 18px;
}
.select-wrap select {
  padding-left: 38px;
  font-size: 14px;
}
.media-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: #fecaca;
  font-size: 14px;
}

.join-form {
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgb(18 21 29 / 0.85);
  backdrop-filter: blur(10px);
}
.join-form h1 {
  font-size: 26px;
  letter-spacing: -0.02em;
}
.join-form > p {
  margin: -6px 0 0;
  font-size: 14px;
}
.form-error {
  min-height: 1em;
  margin: -4px 0 0;
  color: #fca5a5;
  font-size: 14px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.q-chip {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
}
.q-chip:hover {
  background: var(--surface-3);
}
.q-chip[aria-checked='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #c7d5ff;
}

/* --------------------------------------------------------------- tiles */

.tile {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2);
  container-type: size;
  isolation: isolate;
  transition: box-shadow 0.15s;
}
.tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.tile.screen video {
  object-fit: contain;
}
.tile.mirror video {
  transform: scaleX(-1);
}
.tile.no-video video {
  opacity: 0;
}
.tile.speaking {
  box-shadow:
    inset 0 0 0 3px var(--accent),
    0 0 0 1px var(--accent);
}

.tile-avatar {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4cqmin;
  padding: 12px;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, var(--surface-3), var(--surface-2));
  z-index: 1;
}
.tile.no-video .tile-avatar {
  display: flex;
}
.avatar {
  --hue: 220;
  display: grid;
  place-items: center;
  width: clamp(40px, 30cqmin, 128px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: hsl(var(--hue) 55% 42%);
  color: #fff;
  font-size: clamp(15px, 11cqmin, 46px);
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: none;
}
.tile.speaking .avatar {
  box-shadow: 0 0 0 4px rgb(79 124 255 / 0.55);
}
.tile-reason {
  max-width: 90%;
  color: var(--muted);
  font-size: clamp(11px, 4.4cqmin, 14px);
}
.tile-reason:empty {
  display: none;
}

.tile-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgb(11 13 18 / 0.55);
  font-size: 13px;
  font-weight: 600;
  z-index: 4;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgb(255 255 255 / 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.tile-bottom {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  z-index: 3;
  pointer-events: none;
}
.tile-name {
  overflow: hidden;
  padding: 3px 8px;
  border-radius: 7px;
  background: rgb(0 0 0 / 0.55);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}
.tile-mic {
  display: none;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--danger);
}
.tile-mic .icon {
  width: 15px;
  height: 15px;
}
.tile.muted .tile-mic {
  display: grid;
}
.tile-stats {
  margin-left: auto;
  overflow: hidden;
  padding: 3px 7px;
  border-radius: 7px;
  background: rgb(0 0 0 / 0.5);
  color: #cbd2e1;
  font: 11px/1.3 var(--mono);
  white-space: nowrap;
  text-overflow: ellipsis;
  backdrop-filter: blur(6px);
}
.tile-stats:empty {
  display: none;
}
@container (max-width: 280px) {
  .tile-stats,
  .tile-quality {
    display: none;
  }
  .tile-name {
    font-size: 12px;
  }
}

.tile-top {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 3;
  pointer-events: none;
}
.bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 22px;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgb(0 0 0 / 0.55);
}
.bars i {
  display: block;
  width: 3px;
  border-radius: 1px;
  background: rgb(255 255 255 / 0.25);
}
.bars i:nth-child(1) { height: 4px; }
.bars i:nth-child(2) { height: 7px; }
.bars i:nth-child(3) { height: 10px; }
.bars i:nth-child(4) { height: 13px; }
.bars[data-level='4'] i { background: var(--success); }
.bars[data-level='3'] i:nth-child(-n + 3) { background: var(--success); }
.bars[data-level='2'] i:nth-child(-n + 2) { background: var(--warn); }
.bars[data-level='1'] i:nth-child(1) { background: var(--danger); }

.tile-actions {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 5;
}
.tile:hover .tile-actions,
.tile:focus-within .tile-actions {
  opacity: 1;
}
.tile-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: rgb(0 0 0 / 0.55);
  backdrop-filter: blur(6px);
}
.tile-btn:hover {
  background: rgb(0 0 0 / 0.75);
}
.tile-btn .icon {
  width: 16px;
  height: 16px;
}
.tile.pinned .tile-btn:first-child {
  background: var(--accent);
}
.tile:fullscreen {
  border-radius: 0;
}
.tile:fullscreen video {
  object-fit: contain;
}

/* ---------------------------------------------------------------- call */

.call {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.call-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.room-info,
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.live-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgb(34 197 94 / 0.18);
}
.room-label {
  overflow: hidden;
  font-family: var(--mono);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.timer {
  color: var(--muted);
  font: 13px var(--mono);
  font-variant-numeric: tabular-nums;
}
.net-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font: 12px var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.net-chip > span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.net-chip .icon {
  width: 13px;
  height: 13px;
}
.net-up .icon {
  color: #93c5fd;
}
.net-down .icon {
  color: #86efac;
}
.net-used {
  padding-left: 10px;
  border-left: 1px solid var(--border);
  color: var(--muted);
}

.call-body {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.stage {
  position: relative;
  display: flex;
  flex: 1;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 0 12px;
}
.grid {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}
.grid > .tile {
  width: var(--tile-w, 320px);
  height: var(--tile-h, 180px);
}

/* 1:1 — the other person fills the stage, you float in the corner */
.stage[data-mode='duo'] .grid > .tile.local {
  position: absolute;
  right: 24px;
  bottom: 12px;
  width: clamp(120px, 22%, 260px);
  height: auto;
  aspect-ratio: 16 / 9;
  z-index: 6;
  box-shadow: var(--shadow);
  border: 1px solid rgb(255 255 255 / 0.08);
}

.stage[data-mode='duo'] .grid > .tile.local .tile-actions {
  display: none;
}

/* spotlight — pinned tile large, everyone else in a strip */
.spotlight {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
}
.spotlight > .tile {
  flex: 1;
  width: 100%;
  height: 100%;
}
.stage[data-mode='spotlight'] .grid {
  flex: 0 0 220px;
  flex-direction: column;
  flex-wrap: nowrap;
  align-content: stretch;
  justify-content: flex-start;
  overflow-y: auto;
  scrollbar-width: thin;
}
.stage[data-mode='spotlight'] .grid > .tile {
  flex: none;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.empty-card {
  position: absolute;
  left: 50%;
  bottom: 18px;
  display: grid;
  gap: 4px;
  justify-items: center;
  width: min(440px, calc(100% - 32px));
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgb(18 21 29 / 0.88);
  box-shadow: var(--shadow);
  text-align: center;
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
  z-index: 7;
}
.empty-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}
.empty-link code {
  flex: 1;
  overflow: hidden;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font: 12.5px var(--mono);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------ controls */

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 24px;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.controls-group {
  display: flex;
  gap: 8px;
}
.ctrl {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  min-width: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.ctrl:hover {
  background: var(--surface-3);
}
.ctrl[aria-pressed='false']#micBtn,
.ctrl[aria-pressed='false']#camBtn,
.ctrl.round[aria-pressed='false'] {
  border-color: transparent;
  background: var(--danger);
  color: #fff;
}
.ctrl[aria-pressed='true']#screenBtn,
.ctrl.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #c7d5ff;
}
.ctrl.danger {
  border-color: transparent;
  background: var(--danger);
  color: #fff;
}
.ctrl.danger:hover {
  filter: brightness(1.1);
}
.ctrl.round {
  width: 48px;
  padding: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.5);
  border-color: rgb(255 255 255 / 0.15);
  backdrop-filter: blur(6px);
}
.quality-btn .ctrl-label {
  font-family: var(--mono);
}
.badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--surface-2);
}

/* ------------------------------------------------------------- popover */

.popover {
  position: fixed;
  left: 50%;
  bottom: 84px;
  width: min(620px, calc(100vw - 24px));
  max-height: calc(100dvh - 160px);
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  z-index: 50;
  animation: pop-in 0.14s ease-out;
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}
.pop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.pop-head h2 {
  font-size: 18px;
}
.pop-head p {
  margin: 4px 0 0;
}
.q-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 14px;
}
.q-col h3 {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.q-col h3 .muted {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.q-list {
  display: grid;
  gap: 6px;
}
.q-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  text-align: left;
}
.q-item:hover {
  background: var(--surface-3);
}
.q-item[aria-checked='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.q-radio {
  width: 16px;
  height: 16px;
  border: 2px solid var(--muted);
  border-radius: 50%;
}
.q-item[aria-checked='true'] .q-radio {
  border: 5px solid var(--accent);
  background: #fff;
}
.q-name {
  display: grid;
  min-width: 0;
}
.q-name b {
  font-size: 14px;
}
.q-name span {
  color: var(--muted);
  font-size: 12.5px;
}
.q-cost {
  color: var(--muted);
  font: 12px var(--mono);
  text-align: right;
  white-space: nowrap;
}
.q-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font: 12.5px var(--mono);
  color: var(--muted);
}
.q-foot span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.q-foot b {
  color: var(--text);
  font-weight: 600;
}
.q-foot .icon {
  width: 14px;
  height: 14px;
}
#qNote {
  margin: 10px 0 0;
}
#qNote:empty {
  display: none;
}

/* ---------------------------------------------------------- side panel */

.side-panel {
  display: flex;
  flex-direction: column;
  flex: 0 0 340px;
  min-height: 0;
  margin-right: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 10px 12px;
  border-bottom: 1px solid var(--border);
}
.tabs {
  display: flex;
  gap: 4px;
}
.tab {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.tab:hover {
  color: var(--text);
}
.tab[aria-selected='true'] {
  background: var(--surface-3);
  color: var(--text);
}
.panel {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}
.panel.active {
  display: flex;
}

.chat-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
}
.chat-empty {
  margin: auto;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.chat-msg {
  display: grid;
  gap: 3px;
  max-width: 88%;
}
.chat-msg.mine {
  align-self: flex-end;
  justify-items: end;
}
.chat-meta {
  color: var(--muted);
  font-size: 12px;
}
.chat-meta b {
  color: var(--text);
  font-weight: 600;
}
.chat-text {
  padding: 8px 11px;
  border-radius: 12px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.chat-msg.mine .chat-text {
  background: var(--accent);
  color: #fff;
}
.chat-msg.system {
  align-self: center;
  max-width: 100%;
  color: var(--muted);
  font-size: 12.5px;
}
.chat-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.chat-form .icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
}

.people-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
}
.person:hover {
  background: var(--surface-2);
}
.person .avatar {
  width: 36px;
  font-size: 13px;
}
.person-info {
  display: grid;
  flex: 1;
  min-width: 0;
}
.person-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.person-sub {
  color: var(--muted);
  font: 11.5px var(--mono);
}
.person-icons {
  display: flex;
  gap: 4px;
  color: var(--muted);
}
.person-icons .icon {
  width: 17px;
  height: 17px;
}
.person-icons .off {
  color: var(--danger);
}

.stat-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.stat-card b {
  font: 600 17px var(--mono);
  font-variant-numeric: tabular-nums;
}
.stats-peers {
  display: grid;
  gap: 10px;
}
.stats-peer {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.stats-peer h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 14px;
}
.stats-peer dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 12.5px;
}
.stats-peer dt {
  color: var(--muted);
}
.stats-peer dd {
  margin: 0;
  font-family: var(--mono);
  text-align: right;
  overflow-wrap: anywhere;
}

/* -------------------------------------------------------------- dialog */

.dialog {
  width: min(440px, calc(100vw - 24px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.dialog::backdrop {
  background: rgb(0 0 0 / 0.55);
  backdrop-filter: blur(2px);
}
.dialog-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

/* -------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  top: 14px;
  left: 50%;
  display: grid;
  gap: 8px;
  justify-items: center;
  width: min(420px, calc(100vw - 24px));
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
}
.toast {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toast-in 0.18s ease-out;
}
.toast.error {
  border-color: rgb(239 68 68 / 0.5);
  background: #2a1416;
}
.toast.leaving {
  opacity: 0;
  transition: opacity 0.25s;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.audio-unlock {
  position: fixed;
  left: 50%;
  top: 60px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  z-index: 90;
}

/* ---------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .ctrl-label {
    display: none;
  }
  .quality-btn .ctrl-label,
  #peopleCount {
    display: inline;
  }
  .ctrl {
    padding: 0 12px;
  }
}

@media (max-width: 860px) {
  .lobby-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .lobby {
    place-items: start center;
  }
  .side-panel {
    position: fixed;
    inset: 0;
    margin: 0;
    border-radius: 0;
    border: 0;
    z-index: 60;
    padding-top: env(safe-area-inset-top);
  }
}

@media (max-width: 720px) {
  .stage {
    padding: 0 8px;
  }
  .stage[data-mode='spotlight'] {
    flex-direction: column;
  }
  .stage[data-mode='spotlight'] .grid {
    flex: 0 0 96px;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .stage[data-mode='spotlight'] .grid > .tile {
    width: auto;
    height: 100%;
  }
  .stage[data-mode='duo'] .grid > .tile.local {
    right: 16px;
    width: 30%;
    max-width: 150px;
    aspect-ratio: 3 / 4;
  }
  .net-chip .net-used,
  .timer,
  #copyLinkBtn span {
    display: none;
  }
  .controls {
    gap: 8px;
    padding: 10px 8px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .controls-group {
    gap: 6px;
  }
  .ctrl {
    height: 44px;
    min-width: 44px;
    padding: 0 10px;
    border-radius: 12px;
  }
  /* still reachable through the Chat panel's tabs */
  #statsBtn,
  #peopleBtn {
    display: none;
  }
  .popover {
    bottom: 76px;
  }
  .tile-stats {
    display: none;
  }
  .tile-actions {
    opacity: 1;
  }
}

@media (max-width: 420px) {
  .brand-tag {
    display: none;
  }
  .join-form {
    padding: 18px;
  }
  .device-row {
    grid-template-columns: 1fr;
  }
  .ctrl {
    height: 42px;
    min-width: 42px;
    padding: 0 8px;
  }
  .net-chip {
    gap: 6px;
    padding: 0 8px;
  }
}

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