:root {
  --bg: #0e0f13;
  --panel: #16181f;
  --panel-2: #1e212b;
  --line: #2a2e3a;
  --text: #e8eaf0;
  --muted: #8b90a0;
  --accent: #6c7bff;
  --accent-hover: #8290ff;
  --live: #ff4d5e;
  --ok: #3ddc97;
}

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

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 15px;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-primary svg { width: 20px; height: 20px; }
.btn-primary.live { background: var(--live); }

/* entrada */
.join {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
}
.join-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.join-card h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.join-sub { margin: -8px 0 6px; color: var(--muted); }
.join-card label { display: flex; flex-direction: column; gap: 6px; }
.join-card label span { font-size: 13px; color: var(--muted); }
.join-card input {
  height: 44px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.join-card input:focus { border-color: var(--accent); }
.join-error { margin: 0; color: var(--live); font-size: 14px; }

/* app */
.app { height: 100%; display: flex; }

.sidebar {
  width: 250px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
}
.status { font-size: 12px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.bad { color: var(--live); }
.sidebar-label {
  padding: 14px 16px 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.people { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; }
.person { padding: 8px; border-radius: 10px; }
.person:hover { background: var(--panel-2); }
.person-row { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-2);
  border: 2px solid transparent;
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
}
.person.speaking .avatar { border-color: var(--ok); }
.person-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-muted { width: 16px; height: 16px; flex: none; color: var(--live); }
.badge-live {
  flex: none;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--live);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
}
.person input[type=range] { width: 100%; margin: 8px 0 0; display: none; }
.person:hover input[type=range] { display: block; }

input[type=range] { accent-color: var(--accent); height: 4px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 10px;
  padding: 10px;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
}
.stage[data-count="2"], .stage[data-count="3"] { grid-template-columns: 1fr 1fr; }
.stage.has-focus { grid-template-columns: 1fr 240px; }
.stage.has-focus .tile.focused { grid-column: 1; grid-row: 1 / span 2; }
.stage.has-focus .tile:not(.focused) { grid-column: 2; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
}
.empty p { margin: 0; }

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 12px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .8));
  opacity: 0;
  transition: opacity .15s;
}
.tile:hover .tile-bar { opacity: 1; }
.tile-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-stats { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tile-bar .spacer { flex: 1; }
.tile-bar input[type=range] { width: 90px; }
.tile-btn {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, .12);
}
.tile-btn:hover { background: rgba(255, 255, 255, .22); }
.tile-btn svg { width: 16px; height: 16px; }

/* barra de controles */
.bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.ctl {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}
.ctl:hover { border-color: var(--muted); }
.ctl svg { width: 20px; height: 20px; }
.ctl .off { display: none; }
.ctl.is-off { color: var(--live); border-color: var(--live); }
.ctl.is-off .on { display: none; }
.ctl.is-off .off { display: block; }
.ctl.danger:hover { color: var(--live); border-color: var(--live); }

.share { display: flex; align-items: center; gap: 8px; margin: 0 8px; }
.share select {
  height: 44px;
  padding: 0 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  z-index: 10;
}

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; max-height: 30%; border-right: 0; border-bottom: 1px solid var(--line); }
  .stage, .stage[data-count="2"], .stage[data-count="3"], .stage.has-focus { grid-template-columns: 1fr; }
  .stage.has-focus .tile.focused, .stage.has-focus .tile:not(.focused) { grid-column: 1; grid-row: auto; }
  .bar { flex-wrap: wrap; }
  .share { margin: 0; }
  #shareLabel { display: none; }
}
