:root {
  --bg: #11141b;
  --surface: #1a1f2b;
  --surface-2: #232a39;
  --line: #2c3447;
  --text: #eceff6;
  --muted: #8d96ab;
  --action: #6aa8ff;
  --action-ink: #08111f;
  --live: #ffb84a;
  --danger: #ff7a7a;
  --radius: 14px;
  --font: "Avenir Next", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

h1, h2, p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

/* ---------- Botões e campos ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--action); color: var(--action-ink); }
.btn-primary:hover:not(:disabled) { background: #8dbcff; }
.btn-primary[data-sharing="true"] { background: var(--live); color: #231600; }
.btn-primary[data-sharing="true"]:hover:not(:disabled) { background: #ffca74; }
.btn-quiet { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-quiet:hover { color: var(--text); border-color: var(--muted); }

input[type="text"], input[type="password"], select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
}
input::placeholder { color: #626b80; }

label { display: block; font-size: 0.9rem; color: var(--muted); margin: 1rem 0 0.35rem; }

.error { color: var(--danger); font-size: 0.92rem; margin-top: 0.9rem; }

/* ---------- Entrada ---------- */
.join {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.join-card {
  width: min(100%, 25rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 2rem 1.75rem 1.75rem;
}
.join-card h1 { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }
.join-sub { color: var(--muted); margin-top: 0.4rem; }
.join-card .btn { width: 100%; margin-top: 1.5rem; }

/* ---------- Sala ---------- */
.room {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; min-width: 0; }
.topbar h2 { font-size: 1.1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status {
  font-size: 0.82rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  white-space: nowrap;
}
.status[data-state="live"] { color: #b9e6c4; border-color: #2f5a3c; }
.status[data-state="warn"] { color: var(--live); border-color: #6b4f1d; }

.people {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
  min-width: 0;
}
.people li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.85rem;
  max-width: 11rem;
}
.people li span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people li[data-sharing="true"]::before {
  content: "";
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  background: var(--live);
  flex: none;
}

.audio-banner {
  margin: 0.8rem 1.1rem 0;
  padding: 0.65rem 0.9rem;
  background: #3a2c10;
  color: #ffd998;
  border: 1px solid #6b4f1d;
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

/* ---------- Palco ---------- */
.stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.1rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
  align-content: start;
}

.empty {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  text-align: center;
  max-width: 28rem;
  padding: 18vh 1rem 0;
}
.empty-title { font-size: 1.25rem; font-weight: 650; }
.empty-sub { color: var(--muted); margin-top: 0.5rem; }
.stage:has(.tile) .empty { display: none; }

.tile {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.tile[data-focus="true"] { grid-column: 1 / -1; }

.frame {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 17rem);
  max-height: calc(100dvh - 17rem);
  min-height: 12rem;
  cursor: pointer;
}
.frame video { width: 100%; height: 100%; object-fit: contain; display: block; }

.tile-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.8rem;
  font-size: 0.92rem;
}
.tile-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-name::before {
  content: "";
  display: inline-block;
  width: 0.5rem; height: 0.5rem;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--live);
  vertical-align: 0.05em;
}
.tile-tools { display: flex; align-items: center; gap: 0.5rem; }
.tile-tools input[type="range"] { width: 6rem; accent-color: var(--action); }
.tool {
  appearance: none;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.25rem 0.6rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.tool:hover { border-color: var(--muted); }

/* ---------- Rodapé de controles ---------- */
.dock {
  border-top: 1px solid var(--line);
  padding: 0.9rem 1.1rem 1.1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.8rem 1.5rem;
  align-items: center;
}
.dock-main { display: flex; gap: 0.6rem; }
.dock-options { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem 1.4rem; }
.field { display: flex; align-items: center; gap: 0.6rem; margin: 0; }
.field select { width: auto; padding: 0.45rem 0.6rem; }
.check { display: flex; align-items: center; gap: 0.5rem; margin: 0; color: var(--text); }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--action); }

.tips, .note { grid-column: 1 / -1; font-size: 0.88rem; color: var(--muted); }
.tips summary { cursor: pointer; width: fit-content; }
.tips ul { margin: 0.5rem 0 0; padding-left: 1.2rem; max-width: 60ch; }
.tips li + li { margin-top: 0.3rem; }

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .people { justify-content: flex-start; }
  .dock { grid-template-columns: 1fr; }
  .tile-tools input[type="range"] { width: 4.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
