:root {
  --bg: #111214;
  --panel: #1a1b1e;
  --panel-2: #232428;
  --line: #2e3035;
  --text: #ececf1;
  --muted: #9b9ca3;
  --accent: #5865f2;
  --accent-2: #4752c4;
  --live: #ed4245;
  --ok: #3ba55d;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--live); margin: 12px 0 0; }
.link { color: var(--muted); font-size: 13px; }
.link:hover { color: var(--text); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; }
.brand.small { font-size: 17px; }
.logo { width: 26px; height: 18px; border-radius: 4px; background: var(--accent); position: relative; }
.logo::after { content: ""; position: absolute; left: 7px; right: 7px; bottom: -5px; height: 3px; border-radius: 2px; background: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 600;
  background: var(--panel-2); color: var(--text); cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.big { width: 100%; padding: 13px; margin-top: 8px; }
.btn.discord { background: #5865f2; color: #fff; }
.btn.discord:hover { background: #4752c4; }
.btn.discord svg { width: 22px; height: 22px; }
.btn.small-btn { padding: 7px 12px; font-size: 13px; white-space: nowrap; }
.small { font-size: 13px; margin: 0; }
.create { display: grid; gap: 10px; }
.me-card { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.me-card .avatar { width: 40px; height: 40px; }

/* Entrada */
.gate { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; display: grid; gap: 14px;
}
.card form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.waiting { display: grid; justify-items: center; text-align: center; gap: 10px; }
.pulse { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(88,101,242,.6); } 100% { box-shadow: 0 0 0 18px rgba(88,101,242,0); } }

/* App */
.app {
  height: 100%;
  display: grid;
  grid-template: "top top" auto "stage side" 1fr "ctl side" auto / 1fr 300px;
}
.top {
  grid-area: top; display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.room-label { flex: 1; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; flex: none; }

.stage-wrap { grid-area: stage; position: relative; min-height: 0; padding: 12px; overflow: auto; }
.stage { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-content: center; min-height: 100%; }
.stage.one { grid-template-columns: 1fr; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 16px; pointer-events: none; }
.empty p { margin: 4px 0; }
.unmute { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); z-index: 5; box-shadow: 0 6px 24px rgba(0,0,0,.4); }

.tile { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--line); }
.tile video.main { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.tile video.pip {
  position: absolute; right: 12px; bottom: 12px; width: 24%; min-width: 110px; aspect-ratio: 4 / 3;
  object-fit: cover; border-radius: 8px; border: 2px solid rgba(255,255,255,.15); background: #000;
}
.tile.cam-only video.main { object-fit: cover; }
.tile .label {
  position: absolute; left: 10px; top: 10px; display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.6); padding: 4px 10px 4px 4px; border-radius: 999px; font-size: 13px;
}
.tile .label .avatar { width: 22px; height: 22px; }
.tile .label .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); margin-left: 6px; }
.tile .tools { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.tile:hover .tools, .tile:focus-within .tools { opacity: 1; }
.tile .tools button, .tile .tools input {
  background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 8px; padding: 6px 9px; cursor: pointer; font: inherit; font-size: 13px;
}
.tile .tools input[type=range] { width: 90px; padding: 6px; accent-color: var(--accent); }
.tile .status { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; pointer-events: none; }
.tile:fullscreen { border-radius: 0; border: 0; }

.side { grid-area: side; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; padding: 12px; }
.side h3 { margin: 4px 4px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.badge { background: var(--panel-2); border-radius: 999px; padding: 0 8px; font-size: 11px; color: var(--text); }
.members { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 2px; max-height: 35%; overflow: auto; }
.members li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; }
.members li:hover { background: var(--panel-2); }
.members .initial { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.members .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-tag { background: var(--live); color: #fff; font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 4px; letter-spacing: .04em; }

.chat { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px; min-height: 120px; }
.msg { font-size: 14px; word-wrap: break-word; }
.msg b { color: #b5bcff; margin-right: 6px; }
.msg.mine b { color: var(--ok); }
.msg.sys { color: var(--muted); font-size: 12px; font-style: italic; }
.chat-form input { width: 100%; margin-top: 8px; }

.controls {
  grid-area: ctl; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px;
  padding: 12px; border-top: 1px solid var(--line); background: var(--panel);
}
.ctl {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); border-radius: 10px; padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
.ctl svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ctl:hover { border-color: #3d4047; }
.ctl.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ctl.select { padding: 0; gap: 0; }
.ctl.select select { border: 0; background: transparent; padding: 10px 12px; font-weight: 600; }

@media (max-width: 820px) {
  .app { grid-template: "top" auto "stage" minmax(50vh, auto) "ctl" auto "side" auto / 1fr; height: auto; min-height: 100%; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .chat { max-height: 40vh; }
  .ctl span { display: none; }
  .tile .tools { opacity: 1; }
  .top { padding: 10px 16px; }
}
