:root {
  --bg: #14122b;
  --bg-2: #1d1a3d;
  --panel: #252150;
  --panel-2: #2f2a63;
  --line: #3b3578;
  --text: #f4f2ff;
  --muted: #a9a3d6;
  --primary: #6c5cff;
  --primary-2: #8a7dff;
  --accent: #ffcf3f;
  --accent-ink: #2a2200;
  --danger: #ff5b6e;
  --ok: #3ddc97;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #3a2f8f 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 110%, #5b2a7a 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }

/* ---------- componentes ---------- */
.card {
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 18px;
  font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .3);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn:focus-visible, .icon-btn:focus-visible, .code-pill:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: var(--panel-2); color: var(--text); box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.btn-sm { padding: 8px 12px; font-size: 14px; }
.btn-block { width: 100%; padding: 14px; font-size: 17px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.field input, .field select {
  background: var(--bg); border: 2px solid var(--line); border-radius: 12px;
  padding: 12px 14px; outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus { border-color: var(--primary-2); }

.error { color: var(--danger); font-weight: 600; min-height: 1.2em; margin: 0; text-align: center; }
.warning { color: var(--accent); font-size: 14px; margin: 0; text-align: center; }

.logo-icon {
  display: inline-block; width: 1.1em; height: .8em; margin-right: .35em; vertical-align: -.05em;
  border-radius: .15em; background: var(--accent);
  box-shadow: 0 .18em 0 -.06em var(--accent);
}

/* ---------- home ---------- */
.home { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.home-card { width: min(440px, 100%); padding: 32px 28px; display: flex; flex-direction: column; gap: 18px; }
.logo { margin: 0; text-align: center; font-size: 44px; font-weight: 900; letter-spacing: -.02em; }
.tagline { margin: -8px 0 4px; text-align: center; color: var(--muted); line-height: 1.5; }
.home { grid-auto-flow: row; align-content: center; gap: 18px; }
.support { margin: 0; text-align: center; color: var(--muted); font-size: 15px; }
.support a {
  display: inline-block; margin-left: 4px; padding: 6px 12px; border-radius: 999px;
  color: var(--accent); font-weight: 700; text-decoration: none;
  background: rgba(255, 207, 63, .1); border: 2px solid rgba(255, 207, 63, .35);
  transition: background .15s, transform .08s;
}
.support a:hover { background: rgba(255, 207, 63, .2); }
.support a:active { transform: translateY(1px); }
.support a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.legal { width: min(720px, 100%); padding: 28px; line-height: 1.6; }
.legal h1 { margin-top: 0; }
.legal h2 { font-size: 18px; margin: 24px 0 8px; }
.legal a { color: var(--accent); }
.legal li { margin-bottom: 4px; }
.footer-links { margin: 0; text-align: center; font-size: 13px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }

.feedback-form textarea {
  background: var(--bg); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px;
  resize: vertical; outline: none; font: inherit; color: inherit;
}
.feedback-form textarea:focus { border-color: var(--primary-2); }
.rating { display: flex; justify-content: center; gap: 14px; }
.rating-btn {
  font-size: 34px; width: 72px; height: 72px; border-radius: 18px; cursor: pointer;
  background: var(--panel); border: 3px solid var(--line); transition: transform .08s, border-color .15s;
}
.rating-btn:hover { transform: translateY(-2px); }
.rating-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--panel-2); }
.rating-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hint-plain { margin: -6px 0 0; }
.join-row { display: flex; gap: 10px; align-items: flex-end; margin: 0; }
.join-row .grow { flex: 1; min-width: 0; }
#code-input { text-transform: uppercase; letter-spacing: .25em; font-weight: 800; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; text-transform: uppercase; }
.divider::before, .divider::after { content: ""; flex: 1; height: 2px; background: var(--line); border-radius: 2px; }

/* ---------- sala ---------- */
.room { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 16px; background: rgba(20, 18, 43, .75); backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--line);
}
.brand { font-weight: 900; font-size: 22px; }
.room-code { display: flex; align-items: center; gap: 10px; }
.room-label { color: var(--muted); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.code-pill {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px;
  padding: 6px 12px; font-size: 20px; letter-spacing: .2em; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .3);
}
.actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.room-body { flex: 1; min-height: 0; display: flex; }
.stage { flex: 1; min-width: 0; position: relative; padding: 16px; overflow: auto; }
.sidebar {
  width: 260px; flex-shrink: 0; padding: 16px; border-left: 2px solid var(--line);
  background: rgba(29, 26, 61, .6); overflow-y: auto;
}
.sidebar h2 { margin: 0 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.count { background: var(--panel-2); color: var(--text); border-radius: 999px; padding: 2px 9px; font-size: 13px; }

.peer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.peer {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--panel); border-radius: 12px; border: 2px solid transparent;
}
.peer.clickable { cursor: pointer; }
.peer.clickable:hover { border-color: var(--primary-2); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 900; color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25);
}
.peer-info { min-width: 0; display: flex; flex-direction: column; }
.peer-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-status { font-size: 12px; color: var(--muted); }
.peer-status.live { color: var(--ok); font-weight: 700; }

.empty-state {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  padding: 24px; color: var(--muted); pointer-events: none;
}
.empty-state h2 { color: var(--text); margin: 16px 0 6px; }
.empty-state strong { color: var(--accent); letter-spacing: .15em; }
.empty-icon {
  width: 96px; height: 64px; margin: 0 auto; border-radius: 12px;
  border: 5px solid var(--line); position: relative;
}
.empty-icon::after {
  content: ""; position: absolute; left: 50%; bottom: -18px; transform: translateX(-50%);
  width: 34px; height: 8px; border-radius: 4px; background: var(--line);
}

/* grade de telas */
.grid {
  --cols: 1;
  display: grid; gap: 12px; align-content: start;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
}
.grid.has-focus { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid.has-focus .tile.focused { grid-column: 1 / -1; order: -1; aspect-ratio: auto; height: calc(100vh - 230px); min-height: 240px; }

.tile {
  position: relative; margin: 0; aspect-ratio: 16 / 9; background: #000;
  border-radius: var(--radius); overflow: hidden; border: 2px solid var(--line);
}
.tile.local { border-color: var(--accent); }
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.tile:fullscreen { border: 0; border-radius: 0; }
.tile-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px;
  padding: 24px 10px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .75));
  opacity: 1; transition: opacity .2s;
}
.tile:not(:hover) .tile-actions { opacity: 0; }
.tile-name { font-weight: 700; text-shadow: 0 1px 2px #000; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; transition: opacity .2s; }
.icon-btn {
  width: 32px; height: 32px; border: 0; border-radius: 8px; background: rgba(255, 255, 255, .14);
  cursor: pointer; font-size: 15px; display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(255, 255, 255, .28); }
.volume { width: 80px; accent-color: var(--accent); }
.tile-warning {
  position: absolute; top: 10px; left: 10px; right: 10px; width: fit-content; max-width: calc(100% - 20px);
  padding: 6px 12px; border-radius: 10px; background: rgba(20, 18, 43, .85);
  border: 2px solid var(--accent); color: var(--accent);
  font-size: 13px; font-weight: 700; line-height: 1.35; pointer-events: none;
}
.unmute-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: 8px 14px; font-weight: 800; cursor: pointer; box-shadow: var(--shadow);
}

.banner {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
  background: var(--danger); color: #fff; font-weight: 700; padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 20;
}

/* ---------- diálogo ---------- */
.dialog { width: min(520px, calc(100% - 32px)); padding: 0; color: var(--text); }
.dialog::backdrop { background: rgba(8, 6, 25, .7); backdrop-filter: blur(3px); }
.dialog form { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.dialog h2 { margin: 0; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.5; }
.steps strong { color: var(--text); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.hint { margin: -8px 0 0 30px; font-size: 13px; color: var(--muted); line-height: 1.4; }
.estimate {
  margin: -6px 0 0; padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.4;
  background: var(--panel); color: var(--muted); border-left: 4px solid var(--line);
}
.estimate.ok { border-left-color: var(--ok); color: var(--text); }
.estimate.warn { border-left-color: var(--accent); color: var(--accent); }
.tips {
  margin: 0; padding: 10px 12px 10px 28px; border-radius: 10px; background: var(--bg);
  font-size: 13px; line-height: 1.45; color: var(--muted); display: flex; flex-direction: column; gap: 4px;
}
.tips strong { color: var(--text); }
.toast { max-width: min(560px, calc(100vw - 32px)); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; align-items: center; }
.toast {
  background: var(--panel-2); border: 2px solid var(--line); padding: 10px 16px; border-radius: 12px;
  box-shadow: var(--shadow); font-weight: 600; animation: toast-in .2s ease;
}
.toast.error { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- responsivo ---------- */
@media (max-width: 860px) {
  .room-body { flex-direction: column; }
  .sidebar { width: auto; border-left: 0; border-top: 2px solid var(--line); max-height: 30vh; }
  .actions { margin-left: 0; width: 100%; }
  .actions .btn { flex: 1; }
  .grid { --cols: 1 !important; }
  .grid.has-focus .tile.focused { height: auto; aspect-ratio: 16 / 9; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
