/* Telas simultâneas: grade, destaque e faixa de miniaturas. */
#stage-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-shrink: 0; padding: 14px 20px 0; color: var(--text-muted); font-size: 13px;
}
.stage-summary { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stage-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.stage-layout { display: flex; padding: 3px; gap: 2px; border: 1px solid var(--divider); border-radius: 9px; background: var(--bg-panel); }
.stage-layout button { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); font: inherit; font-size: 12px; font-weight: 600; }
.stage-layout button:hover { color: var(--text-strong); background: var(--hover); }
.stage-layout button[aria-pressed="true"] { color: var(--text-strong); background: var(--hover-strong); }
.stage-layout button:disabled { opacity: .4; cursor: default; }
.stage-layout button:focus-visible, #stage .tile:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

#main #voice-view #stage {
  display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0;
  padding: 16px 20px 100px; overflow: auto;
}
#stage-primary {
  display: grid; gap: 12px; flex: 1; min-width: 0; min-height: 160px;
  grid-template-columns: repeat(var(--stage-columns, 2), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr); align-items: center; align-content: center;
}
#stage[data-layout="people"] #stage-primary { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
#stage[data-layout="focus"] #stage-primary { grid-template-columns: minmax(0, 1fr); }
#main #voice-view #stage-primary > .tile:not(:fullscreen, .immersive, .cinema) {
  min-width: 0; min-height: 0; width: 100%; height: auto; max-height: 100%; aspect-ratio: 16 / 9;
  grid-column: auto; border-radius: 12px;
}
#main #voice-view #stage[data-layout="focus"] #stage-primary > .tile:not(:fullscreen, .immersive, .cinema) { height: 100%; aspect-ratio: auto; }
#stage-primary > .tile.screen::after {
  content: 'AO VIVO'; position: absolute; top: 12px; left: 12px; padding: 3px 6px;
  border-radius: 4px; background: var(--red-dark); color: #fff; font-size: 10px; font-weight: 700;
  letter-spacing: .04em; pointer-events: none;
}
#stage-primary > .tile.screen:not(.immersive) .stream-health { top: 40px; }
#stage-primary > .tile .label { bottom: 12px; left: 12px; max-width: calc(100% - 24px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#stage-primary > .tile:hover .label, #stage-primary > .tile:focus-within .label { bottom: 52px; }
#stage-primary > .tile.focus { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--brand) 70%, transparent); }
#stage-strip { display: flex; gap: 10px; flex: 0 0 auto; min-width: 0; overflow-x: auto; padding: 3px 2px 8px; scrollbar-width: thin; }
#main #voice-view #stage-strip > .tile:not(:fullscreen, .immersive, .cinema) { display: flex; flex: 0 0 168px; width: 168px; height: 96px; min-height: 0; max-height: none; aspect-ratio: 16 / 9; border-radius: 8px; }
#stage-strip > .tile .avatar { width: 44px; height: 44px; font-size: 18px; }
#stage-strip > .tile .label { bottom: 6px; left: 6px; font-size: 11px; max-width: calc(100% - 12px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage-strip > .tile.screen video { object-fit: contain; }
#stage-strip > .tile .stats, #stage-strip > .tile .stream-health,
#stage-strip > .tile .tc-btn:not(.tc-pin), #stage-strip > .tile .tc-volume,
#stage-strip > .tile .paused-overlay > :not(.paused-title),
#stage-strip > .tile .watch-overlay > :not(.watch-btn) { display: none; }
#stage-strip > .tile .paused-title { font-size: 13px; }
#stage-strip > .tile .watch-btn { font-size: 11px; padding: 6px 8px; }
#stage-strip > .tile .tile-controls { top: 6px; bottom: auto; right: 6px; }
#stage-strip > .tile .tc-pin { width: 26px; height: 26px; }
#stage-strip > .tile:hover { box-shadow: inset 0 0 0 2px var(--interactive); }
#main #voice-view #stage .tile:fullscreen { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; border-radius: 0; }
#main #voice-view #stage .tile:is(.immersive, .cinema) { width: auto; height: auto; max-height: none; min-height: 0; aspect-ratio: auto; border-radius: 0; }

/* O painel privado também mantém as outras transmissões acessíveis. */
#main.dm-call #stage-toolbar { padding: 8px 14px 0; }
#main.dm-call #voice-view #stage { padding: 10px 14px 74px; gap: 8px; }
#main.dm-call #stage-primary { min-height: 72px; gap: 8px; }
#main.dm-call #voice-view #stage-strip > .tile:not(:fullscreen, .immersive, .cinema) { flex-basis: 112px; width: 112px; height: 64px; }
#main.dm-call #stage-strip > .tile .avatar { width: 32px; height: 32px; font-size: 14px; }

@container (max-width: 560px) {
  #stage-toolbar { padding: 10px 12px 0; }
  #main #voice-view #stage { padding: 12px 12px 100px; gap: 10px; }
  #stage[data-layout="streams"] #stage-primary { grid-template-columns: minmax(0, 1fr); }
  #stage-primary { gap: 10px; }
  #main #voice-view #stage-strip > .tile:not(:fullscreen, .immersive, .cinema) { flex-basis: 132px; width: 132px; height: 76px; }
  #stage-primary > .tile .label { font-size: 12px; bottom: 52px; }
  #stage-primary > .tile .tc-pip { display: none; }
  #stage-primary > .tile .tc-btn { width: 30px; height: 30px; }
  #stage-primary > .tile .tile-controls { gap: 4px; }
  #stage-primary > .tile .stats { font-size: 9px; max-width: calc(100% - 90px); }
  #main.dm-call #voice-view #stage-strip > .tile:not(:fullscreen, .immersive, .cinema) { flex-basis: 112px; width: 112px; height: 64px; }
}
@container (max-width: 440px) {
  #main #voice-view #stage { padding-bottom: 148px; }
  #main.dm-call #voice-view #stage { padding-bottom: 68px; }
}

/* ---------- Estado de cada pessoa no bloco: quem fala, microfone, som, câmera e ao vivo ---------- */
.tile-badges { position: absolute; top: 10px; left: 10px; z-index: 2; display: flex; gap: 6px; pointer-events: none; }
.tile-badges:empty { display: none; }
.tb {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 999px;
  background: rgba(0, 0, 0, .62); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .04em;
  backdrop-filter: blur(6px); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); pointer-events: auto; animation: tb-in .18s ease-out;
}
.tb.off { padding: 0; width: 26px; background: color-mix(in srgb, var(--red) 88%, #000); }
.tb.live { background: var(--red); }
@keyframes tb-in { from { opacity: 0; transform: scale(.7); } }
#stage-strip > .tile .tile-badges { top: 6px; left: 6px; gap: 4px; }
#stage-strip > .tile .tb { height: 20px; min-width: 20px; font-size: 9px; padding: 0 5px; }
#stage-strip > .tile .tb.off { width: 20px; padding: 0; }
#stage-strip > .tile .tb .ico { width: 12px; height: 12px; }

.tile .label { gap: 6px; }
.tile .label-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .label .label-cam { display: inline-flex; }
.tile .label .label-cam .ico { color: #fff; opacity: .85; }
.live-pill {
  flex-shrink: 0; padding: 1px 6px; border-radius: 4px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: .05em; line-height: 16px;
}
.live-pill.paused { background: #4e5058; }

/* Barras de fala: aparecem ao lado do nome enquanto a pessoa fala (claro até com a câmera ligada). */
.speak-bars { display: none; align-items: flex-end; gap: 2px; height: 12px; flex-shrink: 0; }
.speak-bars i { display: block; width: 3px; height: 4px; border-radius: 2px; background: var(--green); animation: speak-bar .9s ease-in-out infinite; }
.speak-bars i:nth-child(2) { animation-delay: .15s; }
.speak-bars i:nth-child(3) { animation-delay: .3s; }
@keyframes speak-bar { 0%, 100% { height: 4px; } 50% { height: 12px; } }
.tile.speaking .speak-bars { display: inline-flex; }
.tile.speaking .label { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--green) 55%, transparent); }
/* Com a câmera ligada o anel verde fica mais grosso, para não sumir na imagem. */
.tile.cam-on.speaking { box-shadow: inset 0 0 0 4px var(--green), 0 0 26px color-mix(in srgb, var(--green) 30%, transparent); }
.tile.mic-off:not(.cam-on) .avatar { filter: saturate(.7); opacity: .9; }
@media (prefers-reduced-motion: reduce) { .speak-bars i { animation: none; height: 10px; } .tb { animation: none; } }

/* ---------- Prévia da câmera antes de ligar ---------- */
.campv-overlay { z-index: 60; }
.campv-card {
  width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; display: grid; gap: 14px; padding: 22px;
  border: 1px solid var(--divider); border-radius: 18px; background: var(--bg-main); box-shadow: 0 24px 80px rgba(0, 0, 0, .55); animation: pop .15s ease-out;
}
.campv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.campv-head h2 { margin: 0; font-size: 21px; color: var(--text-strong); }
.campv-head p { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }
.campv-close { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--interactive); }
.campv-close:hover { background: var(--hover); color: var(--text-strong); }
.campv-stage { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #0b0b0d; display: grid; place-items: center; }
.campv-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.campv-status { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px; text-align: center; color: rgba(255, 255, 255, .75); font-size: 14px; }
.campv-status strong { color: #fff; font-size: 15px; }
.campv-status.error .ico { color: var(--red); }
.campv-spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .18); border-top-color: #fff; animation: lb-spin .8s linear infinite; }
.campv-status.error .campv-spinner { display: none; }
.campv-badge {
  position: absolute; left: 12px; top: 12px; z-index: 1; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; font-weight: 600; backdrop-filter: blur(6px);
}
.campv-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 30%, transparent); }
.campv-device { display: flex; align-items: center; gap: 10px; color: var(--interactive); }
.campv-select { flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid var(--divider); border-radius: 8px; background: var(--bg-rail); color: var(--text); font: inherit; font-size: 14px; }
.campv-always { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 13px; cursor: pointer; }
.campv-always input { width: 16px; height: 16px; accent-color: var(--brand); }
.campv-card .confirm-actions { margin-top: 0; }
.campv-card .btn-primary { display: inline-flex; align-items: center; gap: 8px; }
.campv-card .btn-primary:disabled { opacity: .5; }
@media (max-width: 600px) { .campv-card { padding: 16px; } }
.campv-status.error ~ .campv-badge { display: none; }
/* No palco a tela já tem o selo AO VIVO no canto; o do nome fica para as miniaturas (e o PAUSADO). */
#stage-primary > .tile.screen .live-pill:not(.paused) { display: none; }

/* No toque o quadro só mostra o botão de fixar (canto inferior direito): o nome fica embaixo à esquerda,
   longe do avatar e do ícone de mudo, e termina em reticências antes do botão. */
html.touch #stage-primary > .tile:not(.screen) .label { bottom: 10px; left: 10px; max-width: calc(100% - 64px); font-size: 12px; }
/* O avatar acompanha a altura do quadro e sobe um pouco, deixando a faixa de baixo livre para o nome
   (em 360dp os quadros ficam bem mais baixos). */
html.touch #stage-primary > .tile:not(.screen) { container-type: size; }
html.touch #stage-primary > .tile:not(.screen) > .avatar {
  --av: min(64px, calc(100cqh - 50px)); width: var(--av); height: var(--av); font-size: calc(var(--av) * .38); margin-bottom: 26px;
}
