:root {
  --bg: #0f1115;
  --panel: #181b22;
  --line: #2a2f3a;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #7c5cff;
  --danger: #ff5c7a;
  --live: #ff3b3b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1 { margin: 0 0 4px; font-size: 26px; }
h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.stop { background: var(--danger); }

input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  margin: 6px 0 14px;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.card {
  max-width: 380px;
  margin: 12vh auto 0;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.card form button { width: 100%; }

#room { display: flex; flex-direction: column; height: 100%; }
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.actions { display: flex; gap: 8px; }

.layout { flex: 1; display: flex; min-height: 0; }
#stage {
  flex: 1;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
  align-content: start;
  overflow: auto;
}
#empty { grid-column: 1 / -1; text-align: center; margin-top: 15vh; }
aside { width: 220px; padding: 16px; border-left: 1px solid var(--line); overflow: auto; }
#people { list-style: none; margin: 0 0 16px; padding: 0; }
#people li { padding: 6px 0; display: flex; align-items: center; gap: 8px; }
.live {
  font-size: 11px;
  font-weight: 700;
  background: var(--live);
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
}

.tile {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 16 / 9;
}
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile .label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, .65);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
}
.tile .sound {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 10px;
  font-size: 13px;
  background: rgba(0, 0, 0, .65);
  border: 1px solid var(--line);
}
.tile .sound.off { background: var(--accent); border-color: transparent; }
/* Quando só há um vídeo, ele ocupa o palco inteiro */
#stage:has(.tile:only-of-type) { grid-template-columns: 1fr; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 8px;
}

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  aside { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  #stage { grid-template-columns: 1fr; }
  header { flex-wrap: wrap; }
}
