:root {
  --bg: #0e0f13;
  --panel: #17191f;
  --panel2: #1f222a;
  --line: #2a2e38;
  --text: #e9ebf0;
  --muted: #8b91a0;
  --accent: #7c5cff;
  --accent2: #9b82ff;
  --green: #3ddc84;
  --red: #f0475b;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; outline: none; }
input:focus, select:focus { border-color: var(--accent); }
[hidden] { display: none !important; }

.primary { background: var(--accent); color: #fff; padding: 11px 18px; border-radius: 10px; font-weight: 600; }
.primary:hover { background: var(--accent2); }
.ghost { padding: 7px 12px; border-radius: 9px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px; }
.ghost:hover { border-color: var(--accent); }
.icon { width: 28px; height: 28px; border-radius: 8px; color: var(--muted); }
.icon:hover { background: var(--panel2); color: var(--text); }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; }
.err { color: var(--red); font-size: 13px; margin: 0; min-height: 1em; }
.pill { font-size: 12px; color: var(--muted); background: var(--panel2); padding: 2px 8px; border-radius: 99px; }

/* Entrada */
.lobby { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1000px 500px at 50% -10%, #2a1f5c55, transparent); }
.card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px; display: grid; gap: 14px; }
.card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.brand img { width: 30px; height: 30px; }
.sub { margin: -6px 0 4px; color: var(--muted); }

/* Sala */
.call { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; }
.room { display: flex; align-items: center; gap: 10px; }
.room img { width: 22px; height: 22px; }
.main { min-height: 0; display: flex; gap: 10px; padding: 0 12px; }
.stage { flex: 1; min-width: 0; min-height: 0; display: flex; gap: 10px; }
.featured { display: none; }
.tiles { flex: 1; min-height: 0; display: grid; gap: 10px; align-content: center; justify-content: center;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); overflow: auto; }

.stage.focus .featured { display: flex; flex: 1; min-width: 0; }
.stage.focus .featured .tile { flex: 1; aspect-ratio: auto; height: 100%; }
.stage.focus .tiles { flex: 0 0 240px; grid-template-columns: 1fr; align-content: start; }
.stage.focus .tiles .tile { aspect-ratio: 16/9; }

.tile { position: relative; background: var(--panel); border: 2px solid transparent; border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 16/9; display: grid; place-items: center; transition: border-color .12s; }
.tile.speaking { border-color: var(--green); }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.tile.person video { object-fit: cover; }
.tile.mirror video { transform: scaleX(-1); }
.tile .avatar { width: 30%; max-width: 110px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  font-size: clamp(20px, 4vw, 42px); font-weight: 700; color: #fff; }
.tile .label { position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px;
  background: #000a; padding: 4px 9px; border-radius: 8px; font-size: 13px; max-width: calc(100% - 16px); }
.tile .label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .label svg { width: 14px; height: 14px; flex: none; }
.tile .muted-ic { color: var(--red); }
.tile .stats { position: absolute; left: 8px; top: 8px; background: #000a; padding: 3px 8px; border-radius: 7px;
  font: 11.5px ui-monospace, monospace; color: #cfd3dc; white-space: pre; }
.tile .tools { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; align-items: center; opacity: 0; transition: opacity .15s; }
.tile:hover .tools, .tile:focus-within .tools { opacity: 1; }
.tile .tools button { background: #000b; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; }
.tile .tools button:hover { background: var(--accent); }
.tile .tools svg { width: 16px; height: 16px; }
.tile .tools input[type=range] { width: 90px; padding: 0; accent-color: var(--accent); background: none; border: 0; }
.tile .live { position: absolute; right: 8px; bottom: 8px; background: var(--red); color: #fff; font-size: 11px;
  font-weight: 700; padding: 2px 7px; border-radius: 6px; letter-spacing: .04em; }
.tile.screen { cursor: zoom-in; }
.stage.focus .featured .tile.screen { cursor: default; }
.tile:fullscreen { border-radius: 0; border: 0; }
.tile .play { position: absolute; inset: 0; background: #000a; color: #fff; font-weight: 600; }

/* Controles */
.controls { display: flex; justify-content: center; gap: 8px; padding: 12px; flex-wrap: wrap; }
.ctl { position: relative; display: grid; justify-items: center; gap: 3px; min-width: 64px; padding: 8px 10px;
  border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.ctl:hover { background: var(--panel2); }
.ctl .ic svg { width: 22px; height: 22px; display: block; }
.ctl .lb { font-size: 11.5px; color: var(--muted); }
.ctl.off { background: #3a1d24; border-color: #5a2632; }
.ctl.off .ic { color: var(--red); }
.ctl.accent .ic { color: var(--accent2); }
.ctl.on { background: var(--accent); border-color: var(--accent); }
.ctl.on .ic, .ctl.on .lb { color: #fff; }
.ctl.danger { background: var(--red); border-color: var(--red); }
.ctl.danger .lb { color: #fff; }
.badge { position: absolute; top: 5px; right: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

/* Chat */
.chat { width: 300px; flex: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.chathead { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-weight: 600;
  border-bottom: 1px solid var(--line); }
.chatlog { overflow-y: auto; padding: 10px 12px; display: grid; align-content: start; gap: 10px; }
.msg b { font-size: 13px; }
.msg time { color: var(--muted); font-size: 11px; margin-left: 6px; }
.msg p { margin: 2px 0 0; word-wrap: break-word; white-space: pre-wrap; }
.msg.sys { color: var(--muted); font-size: 12.5px; font-style: italic; }
.chatform { padding: 10px; border-top: 1px solid var(--line); }

/* Ajustes */
.settings { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px;
  width: min(440px, 92vw); padding: 22px; }
.settings::backdrop { background: #0009; }
.settings form { display: grid; gap: 14px; }
.settings h3 { margin: 0; }
.settings label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.settings label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.settings label.check input { width: auto; }
.settings .row { display: flex; justify-content: flex-end; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--panel2);
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 10; }

@media (max-width: 760px) {
  .stage.focus { flex-direction: column; }
  .stage.focus .tiles { flex: 0 0 auto; grid-template-columns: repeat(3, 1fr); }
  .chat { position: fixed; inset: 60px 10px 90px; width: auto; z-index: 5; }
  .ctl { min-width: 0; padding: 8px; }
  .ctl .lb { display: none; }
}
