:root {
  --bg: #101114;
  --panel: #1a1c21;
  --tile: #23262d;
  --line: #2f333b;
  --ink: #f4f5f7;
  --ink-2: #b8bcc6;
  --ink-3: #8a8f9b;
  --brand: #2f6fed;
  --brand-2: #4a83f5;
  --danger: #e5484d;
  --ok: #3dd68c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
h1 { font-family: Nunito, -apple-system, sans-serif; font-weight: 800; font-size: 26px; line-height: 1.15; margin: 0; }

/* lobby */
.lobby { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.card.center { text-align: center; align-items: center; }
.studio { margin: 0; color: var(--brand-2); font-weight: 700; font-size: 13px; letter-spacing: .02em; }
.muted { margin: 0; color: var(--ink-2); }
.fine { margin: 0; color: var(--ink-3); font-size: 12px; text-align: center; }
.error { margin: 0; color: var(--danger); font-size: 14px; }
.preview { position: relative; aspect-ratio: 16 / 10; background: var(--tile); border-radius: 14px; overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); }
.preview-controls { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.field input { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); padding: 0 12px; font: inherit; }
.field input:focus { outline: none; border-color: var(--brand); }
.primary { height: 46px; border-radius: 12px; background: var(--brand); font-weight: 700; padding: 0 20px; }
.primary:hover { background: var(--brand-2); }
.primary:disabled { opacity: .6; cursor: default; }

.host-wait { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: rgba(255,255,255,.06); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
#hostWaitText { flex: 1; min-width: 0; }
.spinner { width: 14px; height: 14px; border-radius: 99px; border: 2px solid var(--ink-3); border-top-color: transparent; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { background: none; color: var(--brand-2); font-weight: 700; padding: 0; }

/* round toggle buttons */
.round { width: 48px; height: 48px; border-radius: 999px; background: rgba(255,255,255,.12); display: grid; place-items: center; }
.round:hover { background: rgba(255,255,255,.2); }
.round.off { background: var(--danger); }
.round svg { width: 22px; height: 22px; }

/* call */
.call { height: 100%; display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.dot { width: 8px; height: 8px; border-radius: 99px; background: var(--danger); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.call-title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 13px; }
.grid { position: relative; flex: 1; min-height: 0; display: grid; gap: 10px; padding: 10px; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.tile { position: relative; background: var(--tile); border-radius: 16px; overflow: hidden; display: grid; place-items: center; outline: 3px solid transparent; transition: outline-color .15s; }
.tile.speaking { outline-color: var(--brand); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile video.mirror { transform: scaleX(-1); }
/* a shared screen: the stage, whole; the people in a strip under it */
/* the call's middle: the people's grid; while someone presents, the stage with the people in a column beside it */
.body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.stage { position: relative; flex: 1; min-width: 0; min-height: 0; margin: 10px 0 10px 10px; background: #000; border-radius: 16px; overflow: hidden; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }

.call.presenting .body { flex-direction: row; }
.call.presenting .grid { flex: 0 0 260px; grid-template-columns: 1fr; grid-auto-flow: row; grid-auto-rows: 160px; align-content: start; overflow-y: auto; }
.call.presenting .avatar { width: 48px; height: 48px; font-size: 18px; }
.avatar { width: 84px; height: 84px; border-radius: 999px; background: #3a3f4a; display: grid; place-items: center; font-weight: 800; font-size: 28px; }
.label { position: absolute; left: 10px; bottom: 10px; background: rgba(0,0,0,.55); border-radius: 999px; padding: 4px 10px; font-size: 13px; display: flex; gap: 6px; align-items: center; max-width: calc(100% - 20px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.badge { background: var(--brand); border-radius: 6px; padding: 0 6px; font-size: 11px; font-weight: 700; }
.muted-icon { color: var(--danger); font-size: 12px; }
.controls { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.leave { height: 48px; border-radius: 999px; padding: 0 22px; background: var(--danger); font-weight: 700; }
.waiting { position: absolute; top: 22px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.6); color: var(--ink-2); border-radius: 999px; padding: 6px 14px; font-size: 13px; white-space: nowrap; }

/* after .label: the stage's sits at the top */
.stage .label { top: 12px; bottom: auto; z-index: 1; }
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr !important; }
  /* a phone: the screen on top, the people in a strip under it */
  .call.presenting .body { flex-direction: column; }
  .stage { margin: 10px 10px 0; }
  .call.presenting .avatar { width: 36px; height: 36px; font-size: 14px; margin-bottom: 22px; }
  .call.presenting .grid { flex: 0 0 110px; grid-template-columns: none !important; grid-auto-flow: column; grid-auto-columns: 140px; grid-auto-rows: 100%; overflow-x: auto; overflow-y: hidden; }
  h1 { font-size: 22px; }
}
