:root {
  color-scheme: dark;
  --bg: #101214; --surface: #181b1f; --surface-2: #22262b; --surface-3: #2d3238; --line: #33383f;
  --text: #f1f2f3; --text-2: #b9bfc6; --text-3: #8f969e;
  --accent: #f5a524; --accent-ink: #1b1305; --danger: #e5484d; --danger-ink: #fff; --good: #46c172;
  --series-1: #3987e5; --series-2: #d95926; --grid: #2a2f35;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.brand { font-weight: 750; font-size: 20px; letter-spacing: -.02em; text-decoration: none; color: var(--text); }
.brand b { color: var(--accent); font-weight: inherit; }

.field { display: grid; gap: 6px; margin-bottom: 14px; color: var(--text-2); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], select {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 15px;
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-weight: 600; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.error { color: #ff9592; font-size: 14px; min-height: 20px; margin: 8px 0 0; }
.muted { color: var(--text-3); font-size: 13px; }

/* Páginas simples */
.center { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.narrow { width: 100%; max-width: 420px; }
.narrow .brand { display: block; margin-bottom: 18px; font-size: 26px; }
.narrow h1 { font-size: 18px; margin-bottom: 16px; }
.rooms { list-style: none; padding: 0; margin: 12px 0 0; }
.rooms li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
.stack { display: grid; gap: 16px; }

/* Lobby */
.lobby { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 28px; align-items: center; max-width: 1040px; margin: 0 auto; padding: 24px 16px; }
.preview { position: relative; aspect-ratio: 16/9; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; }
.preview video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-controls { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 10px; }
@media (max-width: 760px) { .lobby { grid-template-columns: minmax(0, 1fr); align-content: start; } }

/* Sala */
.room { height: 100dvh; display: grid; grid-template-rows: 52px minmax(0, 1fr) 72px; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.topbar .title { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--surface-2); border-radius: 999px; font-size: 13px; white-space: nowrap; }
.pill svg.i { width: 15px; height: 15px; }
.pill.warn { background: #3b2a08; color: #ffd27a; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; }
.layout.closed { grid-template-columns: minmax(0, 1fr); }
.main { display: flex; flex-direction: column; gap: 10px; padding: 10px; min-height: 0; min-width: 0; }

.stage { position: relative; flex: 1 1 62%; min-height: 0; background: #000; border-radius: var(--radius); overflow: hidden; }
.stage-layer { position: absolute; inset: 0; visibility: hidden; }
.stage-layer.on { visibility: visible; }
.stage-layer video { width: 100%; height: 100%; object-fit: contain; }
.stage-tabs { position: absolute; top: 10px; left: 10px; z-index: 4; display: flex; gap: 6px; flex-wrap: wrap; }
.stage-tabs button { border: 0; padding: 5px 10px; font-size: 13px; border-radius: 999px; background: rgba(0,0,0,.65); color: #fff; }
.stage-tabs button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* A live fica sob uma película: o player não recebe clique nem teclado. */
#yt-host, #yt-host iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; }
.yt-shield { position: absolute; inset: 0; z-index: 2; }
.yt-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; gap: 12px; align-items: center; padding: 10px 14px; background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; }
.yt-bar input[type=range] { width: 110px; accent-color: var(--accent); }
.yt-bar .spacer { flex: 1; }
.yt-bar button { background: none; border: 0; color: #fff; display: inline-flex; padding: 4px; }
.live-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.live-tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.yt-msg { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; text-align: center; padding: 24px; }

.grid-wrap { position: relative; flex: 1 1 38%; min-height: 0; display: flex; gap: 8px; align-items: stretch; }
.no-stage .grid-wrap { flex: 1 1 100%; }
.grid { flex: 1; min-width: 0; display: grid; gap: 8px; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.pager { align-self: center; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); }
.pager button { background: var(--surface-2); border: 0; border-radius: 8px; padding: 6px; display: inline-flex; }
.tile { position: relative; background: var(--surface); border-radius: 10px; overflow: hidden; display: grid; place-items: center; border: 2px solid transparent; min-height: 0; }
.tile.speaking { border-color: var(--accent); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile.local video { transform: scaleX(-1); }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: 22px; font-weight: 650; }
.avatar.small { width: 30px; height: 30px; font-size: 13px; flex: none; }
.tile-label { position: absolute; left: 6px; bottom: 6px; right: 6px; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.tile-label span { background: rgba(0,0,0,.6); padding: 2px 7px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-label svg.i { width: 15px; height: 15px; }
.tile-flag { background: rgba(0,0,0,.6); border-radius: 6px; padding: 3px; display: inline-flex; }
.tile-flag.off { color: #ff9592; }
.tile-flag.hand { color: var(--accent); }

.dock { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 12px; border-top: 1px solid var(--line); }
.dock .sep { width: 1px; height: 32px; background: var(--line); margin: 0 4px; }
.ctl { position: relative; width: 48px; height: 48px; border-radius: 12px; border: 0; background: var(--surface-2); display: inline-grid; place-items: center; }
.ctl:hover { background: var(--surface-3); }
.ctl.off { background: var(--danger); color: var(--danger-ink); }
.ctl.on { background: var(--accent); color: var(--accent-ink); }
.ctl.leave { width: 64px; background: var(--danger); color: var(--danger-ink); }
.ctl.locked { opacity: .55; }
.badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: grid; place-items: center; }

.side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--surface); }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; padding: 12px 6px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 600; font-size: 14px; }
.tabs button.on { color: var(--text); border-color: var(--accent); }
.tabs .close { display: none; flex: 0 0 44px; }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg-head { display: flex; gap: 6px; align-items: baseline; font-size: 13px; }
.msg-head b { overflow-wrap: anywhere; }
.msg-head time { color: var(--text-3); font-size: 12px; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; color: var(--text-2); }
.chip { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; }
.chip.organizador { background: #3b2a08; color: #ffd27a; }
.chip.admin { background: var(--accent); color: var(--accent-ink); }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; }
.people-tools { padding: 10px; border-bottom: 1px solid var(--line); }
.people { flex: 1; min-height: 0; overflow-y: auto; }
.person { border-bottom: 1px solid var(--line); }
.person-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; background: none; border: 0; text-align: left; }
.person-row:hover { background: var(--surface-2); }
.person-name { flex: 1; min-width: 0; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.person-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-flags { display: flex; gap: 5px; color: var(--text-3); }
.person-flags svg.i { width: 16px; height: 16px; }
.person-flags .live { color: var(--text); }
.person-flags .hand { color: var(--accent); }
.person-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 10px 48px; }

.controls { padding: 14px; overflow-y: auto; display: grid; gap: 18px; align-content: start; }
.controls h3 { font-size: 14px; margin-bottom: 8px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 14px; }
.switch input { width: 40px; height: 22px; accent-color: var(--accent); }

.toasts { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.audio-gate { position: fixed; top: 62px; left: 50%; transform: translateX(-50%); z-index: 40; }

@media (max-width: 860px) {
  .layout, .layout.closed { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 52px 0 72px 0; z-index: 20; border-left: 0; }
  .layout.closed .side { display: none; }
  .tabs .close { display: inline-flex; align-items: center; justify-content: center; }
  .dock { gap: 6px; }
  .ctl { width: 44px; height: 44px; }
  .ctl.leave { width: 52px; }
  .dock .sep { display: none; }
  .topbar .hide-sm { display: none; }
}

/* Painel admin */
.admin-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.admin-top nav { display: flex; gap: 4px; }
.admin-top nav button { background: none; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--text-2); font-weight: 600; }
.admin-top nav button.on { background: var(--surface-2); color: var(--text); }
.admin-top .spacer { flex: 1; }
.dash { max-width: 1160px; margin: 0 auto; padding: 20px 16px 48px; }
.dash-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; margin-bottom: 16px; }
.dash-head h1 { font-size: 22px; }
.dash-head select { width: auto; max-width: 100%; }
.sub { color: var(--text-2); margin: 2px 0 0; font-size: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile-stat .label { color: var(--text-2); font-size: 13px; }
.tile-stat .value { font-size: 34px; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile-stat .note { color: var(--text-3); font-size: 13px; }
.section { margin-top: 16px; }
.dash h2 { font-size: 16px; margin: 0 0 12px; }
.head-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.head-row a { color: var(--text-2); font-size: 13px; }
.head-links { display: flex; gap: 12px; }
#chart { position: relative; height: 240px; }
#flow { position: relative; height: 200px; }
#chart svg, #flow svg { display: block; width: 100%; height: 100%; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.chart-tip { position: absolute; pointer-events: none; display: none; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 9px; font-size: 13px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.35); z-index: 2; }
.empty { color: var(--text-3); padding: 40px 0; text-align: center; }
.even { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.bar-row { display: grid; grid-template-columns: 124px minmax(0, 1fr) 84px; gap: 10px; align-items: center; padding: 5px 0; font-size: 14px; }
.bar-track i { display: block; height: 10px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--series-1); }
.bar-row .v { text-align: right; font-variant-numeric: tabular-nums; }
.moment { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.moment:last-child { border-bottom: 0; }
.moment span { color: var(--text-2); }
.moment b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.hint { color: var(--text-3); font-size: 13px; margin: 8px 0 0; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 16px; margin-top: 16px; align-items: start; }
@media (max-width: 800px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.scroll { max-height: 520px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 14px; }
td.name { white-space: normal; overflow-wrap: anywhere; }
th { position: sticky; top: 0; background: var(--surface); font-size: 13px; color: var(--text-2); }
th button { all: unset; cursor: pointer; }
th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { text-align: right; }
td.in { color: var(--good); }
td.out { color: var(--text-3); }
.dash input[type=search] { margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end; }
.form-grid .field { margin: 0; }
