:root {
  --bg: #0b0d12;
  --surface: #151823;
  --surface-2: #1c2030;
  --border: #262b3d;
  --text: #e7e9f0;
  --muted: #8b93a7;
  --accent: #7c6cff;
  --accent-soft: #7c6cff22;
  --danger: #ff5d6c;
  --ok: #3ddc97;
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(1000px 600px at 15% -10%, #7c6cff1f, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #3ddc9714, transparent 60%);
  background-attachment: fixed;
}

a { color: var(--accent); }

.mark {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-weight: 650;
  letter-spacing: -.02em;
}
.mark b { font-size: 1.05rem; }
.mark .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ── Écrans centrés (accueil, 404, pré-join) ───────────────────────────── */
.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 24px 60px #00000055;
}

.card h1 {
  margin: 1.4rem 0 .4rem;
  font-size: 1.5rem;
  letter-spacing: -.02em;
}

.card h1 + form { margin-top: 1.5rem; }

.card p.lede {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.55;
}

label {
  display: block;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: .5rem;
}

input[type=text] {
  width: 100%;
  padding: .8rem .9rem;
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  margin-top: 1.1rem;
  padding: .8rem 1rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.error + .btn { margin-top: .45rem; }

.hint {
  margin: 1.4rem 0 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.6;
}
.hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .1rem .35rem;
  color: var(--text);
}

.error {
  margin: .7rem 0 0;
  color: var(--danger);
  font-size: .85rem;
  min-height: 1.2em;
}

/* ── Salon ─────────────────────────────────────────────────────────────── */
.room { display: none; min-height: 100vh; flex-direction: column; }
.room.live { display: flex; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: #0e111980;
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .title { font-weight: 600; letter-spacing: -.01em; }
.topbar .count { color: var(--muted); font-size: .85rem; }
.topbar .spacer { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .7rem;
  font: inherit;
  font-size: .82rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.net-ok { color: var(--ok); cursor: default; }
.chip.net-bad { color: var(--danger); cursor: default; }

/* Le plateau : flex-wrap plutôt que grid, parce qu'une tuile unique doit
   rester à taille raisonnable au lieu de s'étirer sur toute la fenêtre.
   `min-height: 0` est indispensable — sans lui, un enfant flexible refuse de
   rétrécir sous sa taille de contenu et la barre de contrôles se fait pousser
   hors de l'écran. */
main.stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: .9rem;
  padding: 1.1rem;
}

.tile {
  position: relative;
  overflow: hidden;
  flex: 1 1 320px;
  max-width: min(100%, 720px);
  aspect-ratio: 16 / 9;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  transition: box-shadow .12s, border-color .12s;
}
.tile.speaking { border-color: var(--ok); box-shadow: 0 0 0 2px #3ddc9755; }
/* Un partage d'écran mérite plus de place qu'une webcam. */
.tile.screen { flex-basis: 640px; max-width: min(100%, 1100px); }

/* Sans vidéo, des pastilles compactes et centrées plutôt que de grands vides. */
main.stage.voice-only .tile { flex: 0 1 190px; aspect-ratio: 1; }

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
}
.tile.screen video { object-fit: contain; }
.tile video.mirror { transform: scaleX(-1); }

.avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  font-weight: 650;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), #4a3fd1);
  user-select: none;
}
.tile .label {
  position: absolute;
  left: .6rem; bottom: .6rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  max-width: calc(100% - 3.6rem);
  padding: .3rem .6rem;
  font-size: .8rem;
  background: #0b0d12cc;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.tile .label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .label .muted-icon { color: var(--danger); }
.tile .badge {
  position: absolute;
  right: .6rem; top: .6rem;
  padding: .22rem .5rem;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  background: #0b0d12cc;
  border-radius: 999px;
}

/* ── Volume par participant (local : n'affecte que mes oreilles) ───────── */
.vol { position: absolute; right: .6rem; bottom: .6rem; }

.vol-btn {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  color: var(--text);
  background: #0b0d12cc;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.vol-btn:hover { background: var(--surface-2); }
.vol-btn svg { width: 16px; height: 16px; }
/* Coupé ou amplifié : deux écarts à la normale, deux couleurs. */
.vol-btn.is-off { color: var(--danger); }
.vol-btn.is-boosted { color: var(--accent); }

.vol-pop {
  display: none;
  position: absolute;
  right: 0;
  bottom: 40px;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px #000a;
  white-space: nowrap;
}
.vol.open .vol-pop { display: flex; }
.vol-pop input[type=range] { width: 130px; accent-color: var(--accent); }
.vol-val {
  min-width: 3.4em;
  font-size: .75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.controls {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: .6rem;
  padding: .9rem;
  border-top: 1px solid var(--border);
  background: #0e1119cc;
  backdrop-filter: blur(8px);
}

.ctl {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.ctl:hover { background: #242a3d; }
.ctl svg { width: 22px; height: 22px; }
.ctl.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ctl.off { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctl.leave { background: #2a1620; border-color: #52232f; color: var(--danger); }
.ctl.leave:hover { background: var(--danger); color: #fff; }
.ctl:disabled { opacity: .45; cursor: not-allowed; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%) translateY(1rem);
  padding: .6rem 1rem;
  font-size: .85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.unlock {
  position: fixed;
  left: 50%;
  top: 4.5rem;
  transform: translateX(-50%);
  display: none;
  gap: .5rem;
  padding: .7rem 1.2rem;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 30px #0008;
  z-index: 30;
}
.unlock.show { display: block; }

#audio-sink { position: absolute; width: 0; height: 0; overflow: hidden; }
