:root {
  --bg: #1e1f22;
  --panel: #2b2d31;
  --field: #383a40;
  --border: #3f4147;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --danger: #da373c;
  --stage: #111214;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2 { margin: 0; }
.muted { color: var(--muted); }

button, input, select {
  font: inherit;
  color: inherit;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--field);
  padding: 8px 12px;
}

button { cursor: pointer; font-weight: 600; white-space: nowrap; }
button:hover { filter: brightness(1.1); }
button.primary { background: var(--accent); border-color: transparent; }
button.primary:hover { background: var(--accent-hover); filter: none; }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------- esqueleto */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 52px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
.logo img { width: 24px; height: 24px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }

.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--danger);
}

.body { flex: 1; display: flex; flex-wrap: wrap; align-items: stretch; }

.stage-wrap { flex: 999 1 560px; padding: 16px; display: flex; min-width: 0; }
.stage {
  position: relative;
  flex: 1;
  min-height: 360px;
  border-radius: 12px;
  background: var(--stage);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.panel {
  flex: 1 1 280px;
  background: var(--panel);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.panel h2 { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.panel-section { display: grid; gap: 10px; }

/* ----------------------------------------------------------- estado vazio */

.empty { display: grid; justify-items: center; gap: 14px; padding: 32px 16px; text-align: center; max-width: 520px; }
.empty h1 { font-size: 24px; }
.empty p { margin: 0; }
.empty > .icon { width: 40px; height: 40px; color: var(--muted); }

.start { height: 60px; padding: 0 28px; font-size: 17px; display: inline-flex; align-items: center; gap: 10px; }

.steps {
  margin: 6px 0 0;
  padding: 14px 16px 14px 36px;
  background: var(--bg);
  border-radius: 8px;
  text-align: left;
  color: var(--muted);
  font-size: 14px;
}
.steps li + li { margin-top: 6px; }
.steps strong { color: var(--text); }

/* ----------------------------------------------------------------- vídeo */

.preview, .video { position: absolute; inset: 0; }
.preview[hidden] { display: none; }
.preview video, .video video { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--stage); }
.preview .label {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgb(0 0 0 / 0.6);
  font-size: 13px;
}

.overlay { position: relative; z-index: 1; }
.status-failed h1 { color: var(--danger); font-size: 18px; }

/* ----------------------------------------------------------------- painel */

.share { display: flex; gap: 8px; }
.share input { flex: 1; min-width: 0; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--bg); border-radius: 8px; padding: 10px 12px; color: var(--muted); font-size: 13px; }
.stat strong { display: block; font-size: 24px; color: var(--text); }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.people li { display: flex; align-items: center; gap: 10px; min-width: 0; }
.people .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .muted { font-size: 13px; }

.avatar {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
}

details.panel summary { cursor: pointer; list-style: none; }
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary h2::after { content: " ▾"; }
details.panel:not([open]) summary h2::after { content: " ▸"; }

/* ------------------------------------------------------- barra de controle */

.controls {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.pill {
  height: 44px;
  border-radius: 22px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pill.static { background: var(--bg); color: var(--muted); font-weight: 600; }
.pill.danger { background: var(--danger); border-color: transparent; }

/* -------------------------------------------------------- chip do apelido */

.nickname { display: flex; }
.chip { display: inline-flex; align-items: center; gap: 8px; border-radius: 18px; padding: 2px 12px 2px 2px; max-width: 220px; }
.chip .avatar { width: 28px; height: 28px; font-size: 13px; }
.chip .name { overflow: hidden; text-overflow: ellipsis; }
.chip .icon { width: 16px; height: 16px; color: var(--muted); }
/* O campo fica sempre focável (escondido sem display: none) e aparece no lugar
   do chip enquanto tem foco. */
.nickname input { position: absolute; width: 1px; opacity: 0; pointer-events: none; }
.nickname:has(input:focus) .chip { display: none; }
.nickname:has(input:focus) input { position: static; width: 200px; opacity: 1; pointer-events: auto; }

/* ---------------------------------------------------------------- celular */

@media (max-width: 640px) {
  .stage-wrap { padding: 8px; }
  .stage { min-height: 56vw; }
  .watch #audience-count { display: none; }
  .chip { max-width: 150px; }
}
