:root {
  color-scheme: dark;
  --room: #0d1430;
  --room-glow: #1b2a66;
  --screen: #070b1d;
  --phosphor: #cfe0ff;
  --text: #edf0ff;
  --muted: #8c95bd;
  --line: rgba(200, 212, 255, 0.14);
  --glass: rgba(26, 36, 82, 0.58);
  --glass-strong: rgba(18, 26, 62, 0.78);
  --tally: #ff4438;
  --tally-soft: rgba(255, 68, 56, 0.18);

  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --r-lg: 28px;
  --r-md: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --osd: "Doto", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 400 1rem/1.5 var(--font);
  color: var(--text);
  background:
    radial-gradient(70% 55% at 50% 38%, var(--room-glow) 0%, transparent 70%),
    var(--room);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
svg { width: 1.25rem; height: 1.25rem; flex: none; }

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

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 3rem; padding: 0 1.4rem;
  border: 0; border-radius: 999px;
  font-weight: 600; letter-spacing: -0.005em;
  transition: transform 120ms ease-out, background-color 160ms ease, opacity 160ms ease;
}
.btn:active:not(:disabled) { transform: scale(0.96); transition-duration: 60ms; }
.btn:disabled { opacity: 0.38; cursor: default; }
.btn-primary { background: var(--text); color: var(--room); }
.btn-primary:hover:not(:disabled) { background: #fff; }
.btn-quiet { background: rgba(200, 212, 255, 0.1); color: var(--text); }
.btn-quiet:hover { background: rgba(200, 212, 255, 0.16); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 2.5rem; height: 2.5rem; border: 0; border-radius: 999px;
  background: transparent; color: var(--text);
  transition: transform 120ms ease-out, background-color 160ms ease;
}
.icon-btn:hover { background: rgba(200, 212, 255, 0.12); }
.icon-btn:active { transform: scale(0.92); transition-duration: 60ms; }
.icon-btn-lg { width: 3rem; height: 3rem; background: rgba(200, 212, 255, 0.08); }
.icon-btn-leave:hover { background: var(--tally-soft); color: #ffb3ad; }

/* ---------- Entrada ---------- */
.lobby {
  min-height: 100dvh; overflow-y: auto;
  display: grid; justify-items: center; align-content: center; gap: 2rem;
  padding: max(2rem, env(safe-area-inset-top)) 1rem max(2rem, env(safe-area-inset-bottom));
}
.lobby.leaving { opacity: 0; transition: opacity 260ms ease; pointer-events: none; }

.brand { text-align: center; max-width: 32rem; }
.brand h1 {
  margin: 0; font-size: clamp(2rem, 6vw, 2.75rem); line-height: 1.05;
  font-weight: 700; letter-spacing: -0.035em;
}
.brand p { margin: 0.5rem 0 0; color: var(--muted); font-size: 1.0625rem; letter-spacing: -0.01em; }

/* A telinha: o número do canal aparece nela */
.tv {
  position: relative; width: min(34rem, 100%); aspect-ratio: 16 / 10;
  border-radius: var(--r-lg); overflow: hidden;
  background: radial-gradient(80% 80% at 50% 45%, #10183a 0%, var(--screen) 100%);
  box-shadow:
    0 0 0 1px var(--line),
    0 0 0 10px rgba(10, 15, 38, 0.9),
    0 0 0 11px var(--line),
    0 40px 120px -20px rgba(80, 120, 255, 0.35),
    0 30px 60px -30px rgba(0, 0, 0, 0.8);
  display: grid; place-items: center; align-content: center; gap: 0.75rem;
  animation: power-on 900ms var(--ease-out) 120ms both;
  cursor: text;
}
@keyframes power-on {
  0%   { transform: scale(0.72, 0.006); filter: brightness(3); opacity: 0; }
  12%  { opacity: 1; }
  45%  { transform: scale(1, 0.012); filter: brightness(2.4); }
  100% { transform: scale(1, 1); filter: brightness(1); }
}
.tv-static {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated; opacity: 0.16; mix-blend-mode: screen;
  transition: opacity 500ms ease;
}
.tv.tuned .tv-static { opacity: 0.04; }
.tv-glass {
  position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px),
    radial-gradient(120% 70% at 30% 0%, rgba(255,255,255,0.08), transparent 55%);
}

.osd { position: relative; display: grid; justify-items: center; cursor: text; }
.osd-word {
  font: 700 clamp(1rem, 3.4vw, 1.375rem)/1 var(--osd);
  color: var(--phosphor); opacity: 0.7; letter-spacing: 0.04em;
}
.osd-digits {
  width: 4.6ch; padding: 0; border: 0; background: none; outline: none;
  text-align: center; caret-color: var(--tally);
  font: 900 clamp(4.5rem, 19vw, 8.5rem)/1 var(--osd);
  letter-spacing: 0.06em; color: var(--phosphor);
  text-shadow: 0 0 18px rgba(150, 190, 255, 0.55), 0 0 2px #fff;
}
.osd-digits::placeholder { color: var(--phosphor); opacity: 0.18; text-shadow: none; }
.tv:focus-within { box-shadow:
    0 0 0 1px rgba(207, 224, 255, 0.5),
    0 0 0 10px rgba(10, 15, 38, 0.9),
    0 0 0 11px var(--line),
    0 40px 120px -20px rgba(80, 120, 255, 0.45),
    0 30px 60px -30px rgba(0, 0, 0, 0.8); }
.tv .osd-digits:focus-visible { outline: none; }
.tv-hint {
  position: relative; margin: 0; padding: 0 1.25rem; text-align: center;
  color: var(--muted); font-size: 0.9375rem;
}
.tv.tuned .tv-hint { color: var(--phosphor); }

.controls { width: min(26rem, 100%); display: grid; gap: 1rem; }
.field { display: grid; gap: 0.375rem; }
.field span { font-size: 0.875rem; font-weight: 600; color: var(--muted); padding-left: 0.25rem; }
.field input {
  height: 3rem; padding: 0 1rem; border-radius: var(--r-md);
  border: 1px solid var(--line); background: rgba(10, 15, 38, 0.6);
  font-size: 1.0625rem; outline: none;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.field input::placeholder { color: rgba(140, 149, 189, 0.6); }
.field input:focus { border-color: rgba(207, 224, 255, 0.55); background: rgba(10, 15, 38, 0.85); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem; }
.error {
  margin: 0; padding: 0.75rem 1rem; border-radius: var(--r-md);
  background: var(--tally-soft); color: #ffcfcb; font-size: 0.9375rem;
}
.footnote { margin: 0; max-width: 26rem; text-align: center; color: var(--muted); font-size: 0.8125rem; opacity: 0.8; }

/* ---------- Sala ---------- */
.room {
  position: fixed; inset: 0;
  display: grid; grid-template-columns: 1fr auto; gap: 0.75rem;
  padding: 0.75rem;
  padding-bottom: calc(5.75rem + env(safe-area-inset-bottom));
  background: var(--room);
}

.stage {
  position: relative; min-width: 0; min-height: 0;
  border-radius: 22px; overflow: hidden;
  background: var(--screen);
  box-shadow: 0 0 0 1px var(--line);
}
.stage:fullscreen { border-radius: 0; }
.feature {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #000;
}
.stage.idle .feature { display: none; }
.stage.idle-cursor { cursor: none; }

.empty {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center;
  gap: 0.5rem; padding: 1.5rem; text-align: center;
  background: radial-gradient(70% 70% at 50% 45%, #10183a 0%, var(--screen) 100%);
}
.stage:not(.idle) .empty { display: none; }
.empty-digits {
  margin: 0 0 0.5rem; font: 900 clamp(3.5rem, 12vw, 7rem)/1 var(--osd);
  letter-spacing: 0.06em; color: var(--phosphor); opacity: 0.9;
  text-shadow: 0 0 18px rgba(150, 190, 255, 0.5);
}
.empty h2 { margin: 0; font-size: 1.375rem; line-height: 1.2; letter-spacing: -0.02em; font-weight: 650; }
.empty p:not(.empty-digits) { margin: 0 0 1rem; color: var(--muted); max-width: 30ch; }

.unmute {
  position: absolute; left: 50%; top: 1rem; translate: -50% 0;
  display: inline-flex; align-items: center; gap: 0.5rem;
  height: 2.75rem; padding: 0 1.1rem; border: 0; border-radius: 999px;
  background: var(--text); color: var(--room); font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

/* Material translúcido para a cromagem flutuante */
.glass, .stage-bar, .dock, .channel {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 0 1px var(--line), 0 16px 40px -12px rgba(0,0,0,0.6);
}

.stage-bar {
  position: absolute; left: 0.75rem; right: 0.75rem; bottom: 0.75rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.375rem 0.375rem 0.375rem 0.875rem; border-radius: 999px;
  transition: opacity 260ms ease, translate 360ms var(--ease-out);
}
.stage.idle-cursor .stage-bar { opacity: 0; translate: 0 0.5rem; pointer-events: none; }
.live-chip { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 0; font-weight: 600; letter-spacing: -0.01em; }
.live-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally {
  width: 0.625rem; height: 0.625rem; border-radius: 50%; flex: none;
  background: var(--tally); box-shadow: 0 0 0 4px var(--tally-soft), 0 0 12px var(--tally);
}
.stage-tools { display: flex; align-items: center; gap: 0.125rem; }
.volume { display: flex; align-items: center; }
.volume input {
  width: 6rem; accent-color: var(--phosphor);
}

.channel {
  position: fixed; left: calc(0.75rem + 0.75rem); top: calc(0.75rem + 0.75rem);
  display: inline-flex; align-items: baseline; gap: 0.5rem;
  padding: 0.4rem 0.9rem; border-radius: 999px; pointer-events: none;
  transition: opacity 260ms ease;
}
.room:has(.stage.idle-cursor) .channel { opacity: 0; }
.room:has(.stage.idle) .channel { display: none; }
.channel-word { font: 700 0.8125rem/1 var(--osd); color: var(--phosphor); opacity: 0.7; }
.channel-digits { font: 900 1.25rem/1 var(--osd); color: var(--phosphor); letter-spacing: 0.06em; }

/* Lista lateral de transmissões */
.strip {
  list-style: none; margin: 0; padding: 0;
  width: 15rem; display: flex; flex-direction: column; gap: 0.625rem;
  overflow-y: auto; scrollbar-width: none;
}
.strip:empty { display: none; }
.thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 10;
  padding: 0; border: 0; border-radius: var(--r-md); overflow: hidden;
  background: var(--screen); box-shadow: 0 0 0 1px var(--line);
  transition: transform 160ms ease-out, box-shadow 200ms ease;
  animation: materialize 420ms var(--ease-out) both;
}
.thumb:active { transform: scale(0.97); transition-duration: 60ms; }
.thumb[aria-current="true"] { box-shadow: 0 0 0 2px var(--phosphor); }
.thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-name {
  position: absolute; left: 0.5rem; bottom: 0.5rem; max-width: calc(100% - 1rem);
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.8125rem; font-weight: 600;
  background: rgba(7, 11, 29, 0.72); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thumb-name .tally { width: 0.45rem; height: 0.45rem; box-shadow: 0 0 6px var(--tally); }
@keyframes materialize {
  from { opacity: 0; transform: scale(0.94); filter: blur(8px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* Dock */
.dock {
  position: fixed; left: 50%; translate: -50% 0;
  bottom: calc(0.875rem + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem; border-radius: 999px;
  max-width: calc(100vw - 1.5rem);
}
.dock-share { min-height: 3rem; }
.dock-share.live { background: var(--tally); color: #fff; }
.dock-share.live:hover { background: #ff5a4f; }

/* Qualidade: botão no dock + painel que nasce dele */
.quality-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  height: 3rem; padding: 0 1rem 0 0.85rem; border: 0; border-radius: 999px;
  background: rgba(200, 212, 255, 0.08); color: var(--text);
  font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.005em;
  transition: transform 120ms ease-out, background-color 160ms ease;
}
.quality-btn:hover, .quality-btn[aria-expanded="true"] { background: rgba(200, 212, 255, 0.16); }
.quality-btn:active { transform: scale(0.95); transition-duration: 60ms; }

.quality {
  position: fixed; z-index: 5;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  width: min(21rem, calc(100vw - 1.5rem));
  padding: 1.1rem 1rem 1rem; border-radius: 24px;
  background: rgba(16, 23, 56, 0.86);
  -webkit-backdrop-filter: blur(32px) saturate(180%); backdrop-filter: blur(32px) saturate(180%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 0 1px var(--line), 0 30px 70px -20px rgba(0,0,0,0.75);
  opacity: 0; transform: translateY(10px) scale(0.92); filter: blur(6px);
  transition: opacity 200ms ease, transform 340ms var(--ease-out), filter 260ms ease;
  pointer-events: none;
}
.quality[data-open] { opacity: 1; transform: none; filter: none; pointer-events: auto; }
.quality-title { margin: 0 0.25rem 0.85rem; font-size: 1.0625rem; font-weight: 650; letter-spacing: -0.015em; }
.quality fieldset { margin: 0 0 0.9rem; padding: 0; border: 0; min-width: 0; }
.quality legend { padding: 0 0.25rem; margin-bottom: 0.4rem; font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.seg-note { margin: 0.45rem 0.25rem 0; font-size: 0.8125rem; line-height: 1.4; color: var(--muted); font-variant-numeric: tabular-nums; }
.btn-small { min-height: 2.25rem; padding: 0 0.9rem; font-size: 0.875rem; }
.audio-row { display: flex; align-items: center; gap: 0.75rem; }
.audio-row .seg-note { flex: 1; margin: 0 0.25rem; }
.audio-row .btn { flex: none; }
.audio-help { margin-top: 0.6rem; padding: 0.75rem; border-radius: 14px; background: rgba(200, 212, 255, 0.07); font-size: 0.8125rem; line-height: 1.45; }
.audio-help p { margin: 0 0 0.5rem; }
.audio-help pre {
  margin: 0 0 0.6rem; padding: 0.6rem 0.7rem; border-radius: 10px; background: rgba(5, 8, 22, 0.6);
  white-space: pre-wrap; word-break: break-all; font-size: 0.75rem; line-height: 1.5;
}
.quality-upload {
  margin: 0; padding: 0.7rem 0.8rem; border-radius: 14px;
  background: rgba(200, 212, 255, 0.07);
  font-size: 0.875rem; line-height: 1.4; font-variant-numeric: tabular-nums;
}

/* Controle segmentado: o marcador desliza até a opção escolhida */
.seg {
  --n: 2; --i: 0;
  position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 3px; border-radius: 13px; background: rgba(200, 212, 255, 0.08);
}
.seg-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 6px) / var(--n));
  border-radius: 10px; background: rgba(200, 212, 255, 0.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 2px 8px rgba(0,0,0,0.25);
  transform: translateX(calc(var(--i) * 100%));
  transition: transform 340ms var(--ease-out);
}
.seg label {
  position: relative; display: grid; place-items: center; height: 2.25rem;
  border-radius: 10px; cursor: pointer;
  font-size: 0.9375rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums;
  transition: color 200ms ease, transform 120ms ease-out;
}
.seg label:hover { color: var(--text); }
.seg label:active { transform: scale(0.94); transition-duration: 60ms; }
.seg label:has(input:checked) { color: var(--text); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--phosphor); outline-offset: -2px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }

.people { list-style: none; margin: 0; padding: 0 0.5rem 0 0.25rem; display: flex; }
.people li {
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.8125rem; font-weight: 700;
  color: #0d1430; margin-left: -0.5rem;
  box-shadow: 0 0 0 2px #1a2452;
  animation: materialize 360ms var(--ease-out) both;
}
.people li:first-child { margin-left: 0; }
.people li.sharing { box-shadow: 0 0 0 2px #1a2452, 0 0 0 4px var(--tally); }
.people li.more { background: rgba(200,212,255,0.16); color: var(--text); }

/* Fora do ar */
.offair {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 1rem;
  background: rgba(5, 8, 22, 0.6);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  animation: fade 240ms ease both;
}
.offair-card {
  width: min(24rem, 100%); padding: 1.75rem; border-radius: var(--r-lg); text-align: center;
  background: var(--glass-strong); box-shadow: 0 0 0 1px var(--line), 0 30px 80px rgba(0,0,0,0.6);
  animation: materialize 420ms var(--ease-out) both;
}
.offair-card h2 { margin: 0 0 0.5rem; font-size: 1.375rem; letter-spacing: -0.02em; }
.offair-card p { margin: 0 0 1.25rem; color: var(--muted); }
@keyframes fade { from { opacity: 0; } }

/* Avisos */
.toasts {
  position: fixed; top: 1rem; left: 50%; translate: -50% 0; z-index: 20;
  display: grid; gap: 0.5rem; justify-items: center; pointer-events: none;
}
.toast {
  padding: 0.6rem 1.1rem; border-radius: 999px; font-size: 0.9375rem; font-weight: 600;
  letter-spacing: -0.01em; white-space: nowrap;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(24px) saturate(170%); backdrop-filter: blur(24px) saturate(170%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 0 1px var(--line), 0 12px 30px rgba(0,0,0,0.5);
  animation: toast-in 380ms var(--ease-out) both;
}
.toast.out { animation: toast-out 240ms ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-120%) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-120%) scale(0.96); } }

/* ---------- Telas menores ---------- */
@media (max-width: 760px) {
  .room { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .strip { width: auto; flex-direction: row; overflow-x: auto; }
  .thumb { width: 8.5rem; flex: none; }
  .volume input { display: none; }
  .dock-share span { display: none; }
  .dock-share { width: 3rem; padding: 0; }
  .actions { grid-template-columns: 1fr; }
}

/* ---------- Acessibilidade ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .tv { animation: fade 300ms ease both !important; }
  .quality { transform: none !important; filter: none !important; transition: opacity 150ms ease !important; }
  .seg-thumb { transition: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .stage-bar, .dock, .channel, .toast, .offair-card, .quality { background: #18214a; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --line: rgba(220, 228, 255, 0.5); --muted: #b9c0e0; }
}
