/* ==========================================================================
   Palco Ensaio — Estúdio de Ensaio Teatral (Fase 1)
   Identidade Visual: Apple Liquid Glass (DESIGN_SYSTEM_PALCO.md)
   Tema inicial padrão: Escuro | Opção de Tema Claro para leitura sob luz forte
   ========================================================================== */

:root {
  --studio-bg: #0b0b0e;
  --studio-surface: #14141a;
  --studio-surface-2: #1e1e26;
  --studio-text: #f5f5f7;
  --studio-muted: #9ca3af;

  /* Apple Liquid Glass Design System Tokens */
  --glass-surface: rgba(24, 24, 30, 0.72);
  --glass-surface-strong: rgba(20, 20, 26, 0.94);
  --glass-pill-bg: rgba(255, 255, 255, 0.06);
  --glass-pill-hover: rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  --glass-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --glass-blur: blur(20px) saturate(165%);

  --primary: #eb8018;
  --primary-glow: rgba(235, 128, 24, 0.28);
  --primary-ink: #111111;

  /* Folha de Roteiro — Padrão Tema Escuro */
  --paper-bg: #14141a;
  --paper-text: #f3f4f6;
  --paper-muted: #9ca3af;
  --paper-border: rgba(255, 255, 255, 0.1);
  --my-line-bg: rgba(235, 128, 24, 0.13);
  --my-line-border: #eb8018;
  --tech-bg: rgba(56, 189, 248, 0.12);
  --tech-text: #7dd3fc;

  --script-font: 'Courier Prime', 'Courier New', Courier, monospace;
  color-scheme: dark;
  accent-color: var(--primary);
}

/* Tema Claro opcional (para ensaio sob luz forte) */
body.theme-light {
  --studio-bg: #eef0f4;
  --studio-surface: #ffffff;
  --studio-surface-2: #e5e7eb;
  --studio-text: #111827;
  --studio-muted: #4b5563;

  --glass-surface: rgba(255, 255, 255, 0.78);
  --glass-surface-strong: rgba(255, 255, 255, 0.96);
  --glass-pill-bg: rgba(17, 24, 39, 0.06);
  --glass-pill-hover: rgba(17, 24, 39, 0.12);
  --glass-border: rgba(17, 24, 39, 0.12);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  --glass-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);

  --paper-bg: #ffffff;
  --paper-text: #111827;
  --paper-muted: #4b5563;
  --paper-border: #e5e7eb;
  --my-line-bg: #fef3c7;
  --my-line-border: #d97706;
  --tech-bg: #e0f2fe;
  --tech-text: #0369a1;

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100dvh;
  background: var(--studio-bg);
  color: var(--studio-text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

button,
input {
  font: inherit;
  color: inherit;
}

/* ==========================================================================
   ZONA 1: BARRA SUPERIOR (Liquid Glass)
   ========================================================================== */
.topbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--glass-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight);
  flex-shrink: 0;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.brand-logo-img {
  height: 36px;
  width: auto;
  display: block;
}

.play-meta-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.play-title-label {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--studio-muted);
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 3px 9px;
  flex-shrink: 0;
}

.topbar__right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.topbar__island {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight);
}

/* Botões Padrão */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--studio-text);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.12s ease;
}

.btn--pill {
  border-radius: 999px;
}

.btn--icon-only {
  padding: 7px;
  width: 34px;
  height: 34px;
}

.btn:hover {
  background: var(--glass-pill-hover);
}

.btn--primary {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 0 18px var(--primary-glow);
}

.btn--primary:hover {
  background: #f5912e;
}

/* Dropdown Liquid Glass (sem vidro-sobre-vidro) */
.top-dropdown {
  position: relative;
}

.top-dropdown summary {
  list-style: none;
}

.top-dropdown summary::-webkit-details-marker {
  display: none;
}

.top-dropdown__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 245px;
  padding: 6px;
  border-radius: 18px;
  background: var(--glass-surface-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#dropdown-mode .top-dropdown__menu,
#dropdown-acts .top-dropdown__menu {
  right: auto;
  left: 0;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--studio-text);
}

.dropdown-item:hover {
  background: var(--glass-pill-hover);
}

.dropdown-item.is-active {
  color: var(--primary);
  font-weight: 700;
}

.dropdown-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--studio-muted);
}

/* ==========================================================================
   ZONA 2: BARRINHA RÁPIDA (1 linha deslizável no mobile)
   ========================================================================== */
.quickbar {
  position: relative;
  z-index: 20;
  background: var(--glass-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  padding: 7px 14px;
  flex-shrink: 0;
}

.quickbar__scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quickbar__scroll::-webkit-scrollbar {
  display: none;
}

.quick-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.quick-pill:hover {
  background: var(--glass-pill-hover);
}

.quick-pill--accent {
  border-color: rgba(235, 128, 24, 0.45);
}

.quick-pill strong {
  color: var(--primary);
  font-weight: 700;
}

/* ==========================================================================
   ZONA 3: WORKSPACE (Folha do Roteiro + Gaveta Lateral)
   ========================================================================== */
.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}

.stage {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 18px 14px 48px;
}

.script-sheet {
  max-width: 780px;
  margin: 0 auto;
  background: var(--paper-bg);
  color: var(--paper-text);
  border: 1px solid var(--paper-border);
  border-radius: 18px;
  padding: 28px 24px 40px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.25);
}

.script-header {
  border-bottom: 1px solid var(--paper-border);
  padding-bottom: 18px;
  margin-bottom: 22px;
}

.script-header__title {
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 700;
  line-height: 1.2;
}

.script-header__subtitle {
  margin-top: 4px;
  font-size: 14px;
  color: var(--paper-muted);
}

.script-header__authors {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.script-header__synopsis {
  margin-top: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--paper-muted);
}

/* Linhas do Roteiro */
.script-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--script-font);
  font-size: 16px;
  line-height: 1.55;
}

.s-line--act {
  margin-top: 20px;
  margin-bottom: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--glass-pill-bg);
  border-left: 4px solid var(--primary);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.s-line--tech {
  align-self: flex-start;
  margin: 6px 0;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--tech-bg);
  color: var(--tech-text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 600;
}

.s-line--parenthetical {
  color: var(--paper-muted);
  font-style: italic;
  font-size: 14.5px;
  padding-left: 12px;
}

.speech-block {
  padding: 10px 14px;
  border-radius: 12px;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.speech-block.is-mine {
  background: var(--my-line-bg);
  border-left-color: var(--my-line-border);
}

.speech-block__char {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.speech-block.is-mine .speech-block__char {
  color: var(--primary);
}

.mine-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-ink);
  text-transform: none;
  letter-spacing: 0;
}

.speech-block__parenthetical {
  color: var(--paper-muted);
  font-style: italic;
  font-size: 14px;
  margin-bottom: 4px;
}

.speech-block__dialogue {
  white-space: pre-wrap;
}

.speech-start-btn {
  margin-left: auto;
  border: 1px solid var(--glass-border);
  background: var(--glass-pill-bg);
  color: var(--paper-muted);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  opacity: 0.78;
}

.speech-start-btn:hover {
  opacity: 1;
  color: var(--primary);
  border-color: var(--primary);
}

/* Gaveta Lateral (Configurações & Elenco) */
.studio-drawer {
  width: 360px;
  flex-shrink: 0;
  background: var(--glass-surface-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.studio-drawer[hidden] {
  display: none;
}

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
}

.drawer__title {
  font-size: 15px;
  font-weight: 700;
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drawer-card {
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 14px;
}

.drawer-card--muted {
  opacity: 0.78;
}

.drawer-card__title {
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 6px;
}

.drawer-card__hint {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--studio-muted);
  margin-bottom: 10px;
}

.cast-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cast-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
  cursor: pointer;
}

.cast-item.is-selected {
  border-color: var(--primary);
  background: rgba(235, 128, 24, 0.14);
}

.cast-item__left {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.cast-item__left input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.cast-item__name {
  font-size: 13.5px;
  font-weight: 700;
}

.cast-item__desc {
  font-size: 12px;
  color: var(--studio-muted);
}

.cast-item__count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--studio-muted);
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-box {
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}

.stat-box__val {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.stat-box__lbl {
  font-size: 11px;
  color: var(--studio-muted);
}

/* ==========================================================================
   ZONA 4: RODAPÉ ENXUTO (1 linha)
   ========================================================================== */
.bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--studio-muted);
  background: var(--glass-surface);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
}

/* ==========================================================================
   MODAIS (<dialog>)
   ========================================================================== */
.palco-dialog {
  margin: auto;
  width: min(480px, calc(100vw - 20px));
  max-height: 85dvh;
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  background: var(--glass-surface-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  color: var(--studio-text);
  box-shadow: var(--glass-shadow);
  padding: 18px;
}

.palco-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.palco-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.palco-dialog__header h2 {
  font-size: 16px;
  font-weight: 700;
}

.palco-dialog__desc {
  font-size: 13px;
  color: var(--studio-muted);
  margin-bottom: 14px;
}

.palco-dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.library-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55dvh;
  overflow-y: auto;
}

.library-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
}

.library-item__info {
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.library-item__title {
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-item__meta {
  font-size: 11.5px;
  color: var(--studio-muted);
}

.btn--subtle {
  background: var(--glass-pill-bg);
  border-color: var(--glass-border);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding: 6px 0;
  cursor: pointer;
}

.toggle-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.range-field {
  margin-top: 10px;
}

.range-field__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 5px;
}

.range-field input[type="range"] {
  width: 100%;
  cursor: pointer;
}

.calib-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 6px;
}

.calib-meter {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
  overflow: hidden;
}

.calib-meter__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4ade80, var(--primary));
  transition: width 0.08s linear;
}

.segmented-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--studio-muted);
}

.seg-btn.is-active {
  background: var(--primary);
  color: var(--primary-ink);
}

.alert-box {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(235, 128, 24, 0.14);
  border: 1px solid rgba(235, 128, 24, 0.4);
  font-size: 12px;
  line-height: 1.45;
  margin-bottom: 10px;
}

.voice-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.voice-card {
  padding: 10px;
  border-radius: 12px;
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.voice-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.voice-card__name {
  font-size: 12.5px;
  font-weight: 700;
}

.voice-card select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 9px;
  border: 1px solid var(--glass-border);
  background: var(--studio-surface);
  color: var(--studio-text);
  font-size: 12px;
}

.voice-card__sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 11px;
  color: var(--studio-muted);
}

.voice-card__sliders input[type="range"] {
  width: 100%;
}

/* ==========================================================================
   TELA CAIXA PRETA (MODO ENSAIO FULLSCREEN)
   ========================================================================== */
.caixa-preta {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #070709;
  color: #f5f5f7;
  display: flex;
  flex-direction: column;
}

.caixa-preta[hidden] {
  display: none;
}

.cp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(20, 20, 26, 0.86);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-wrap: wrap;
}

.cp-topbar__left,
.cp-topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cp-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(235, 128, 24, 0.2);
  color: var(--primary);
  border: 1px solid rgba(235, 128, 24, 0.4);
}

.cp-act {
  font-size: 12.5px;
  color: #9ca3af;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-progress {
  font-size: 12px;
  font-weight: 600;
  color: #9ca3af;
}

.cp-btn-autoadvance.is-on,
#cp-btn-autoadvance.is-on {
  border-color: #4ade80;
  color: #4ade80;
}

.cp-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.cp-card {
  width: min(720px, 100%);
  background: #121218;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 24px 22px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cp-card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cp-role-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #d1d5db;
}

.cp-role-pill.is-mine {
  background: var(--primary);
  color: #111111;
}

.cp-role-pill.is-tech {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
}

.cp-speaker {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.cp-parenthetical {
  font-size: 14.5px;
  font-style: italic;
  color: #9ca3af;
}

.cp-cue-box {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid rgba(255, 255, 255, 0.25);
}

.cp-cue-box__speaker {
  font-size: 11.5px;
  font-weight: 700;
  color: #9ca3af;
  margin-bottom: 3px;
}

.cp-cue-box__text {
  font-size: 14.5px;
  color: #d1d5db;
}

.cp-dialogue {
  font-family: var(--script-font);
  font-size: clamp(19px, 3vw, 26px);
  line-height: 1.5;
  white-space: pre-wrap;
}

.cp-dialogue.is-hidden-cue {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  color: #9ca3af;
  font-style: italic;
}

.cp-silence {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cp-silence__label {
  font-size: 12px;
  color: #9ca3af;
  font-weight: 600;
}

.cp-silence__track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.cp-silence__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #4ade80);
  transition: width 0.06s linear;
}

.cp-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: rgba(20, 20, 26, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.cp-btn-sec {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.cp-btn-branco {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(248, 113, 113, 0.55);
  color: #fca5a5;
  padding: 12px 18px;
  font-size: 14px;
}

.cp-btn-next {
  padding: 12px 20px;
  font-size: 14px;
}

/* ==========================================================================
   FASE 3: EDIÇÃO RÁPIDA, SELEÇÃO DE TRECHO ANIMADA & NOTAS DE DIREÇÃO
   ========================================================================== */
.quick-pill.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(235, 128, 24, 0.14);
}

.script-lines {
  position: relative;
}

body.is-editing .speech-block__dialogue,
body.is-editing .speech-block__parenthetical,
body.is-editing .s-line--parenthetical {
  outline: 1px dashed rgba(235, 128, 24, 0.45);
  border-radius: 8px;
  padding: 4px 6px;
  cursor: text;
}

body.is-editing .speech-block__dialogue:focus,
body.is-editing .speech-block__parenthetical:focus,
body.is-editing .s-line--parenthetical:focus {
  outline: 2px solid var(--primary);
  background: rgba(235, 128, 24, 0.08);
}

/* Destaque do trecho selecionado (adaptado ao tema claro e escuro) */
.is-in-selection {
  background: rgba(56, 189, 248, 0.14) !important;
  box-shadow: inset 3px 0 0 #38bdf8;
  border-radius: 10px;
}

body.theme-light .is-in-selection {
  background: #fef9c3 !important;
  box-shadow: inset 3px 0 0 #eab308;
}

/* Duas linhas horizontais com animação center-out */
@keyframes lineCenterOut {
  from {
    transform: scaleX(0);
    opacity: 0.4;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

.range-line {
  position: absolute;
  left: -8px;
  right: -8px;
  height: 4px;
  z-index: 15;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.range-line[hidden] {
  display: none;
}

.range-line__bar {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
  transform-origin: center;
}

.range-line.is-animating .range-line__bar {
  animation: lineCenterOut 0.28s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.range-handle {
  position: relative;
  z-index: 2;
  pointer-events: auto;
  touch-action: none;
  border: 1px solid var(--primary);
  background: var(--studio-surface);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: ns-resize;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* Notas de direção por fala */
.speech-note-btn {
  border: 1px solid var(--glass-border);
  background: var(--glass-pill-bg);
  color: var(--paper-muted);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.speech-note-btn.has-note {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(235, 128, 24, 0.14);
}

.speech-block__note {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(235, 128, 24, 0.1);
  border-left: 2px solid var(--primary);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12px;
  color: var(--paper-muted);
}

.cp-note {
  font-size: 13px;
  color: var(--primary);
  background: rgba(235, 128, 24, 0.12);
  border-left: 3px solid var(--primary);
  padding: 6px 10px;
  border-radius: 8px;
}

.note-textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--studio-surface);
  color: var(--studio-text);
  padding: 10px 12px;
  font-size: 13.5px;
  line-height: 1.45;
  resize: vertical;
}

/* ==========================================================================
   FASE 4: GRAVAÇÃO MP3, VOZ DA DIREÇÃO & ESTÚDIO OFFLINE
   ========================================================================== */
.speech-actions-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.audio-chip-btn {
  border: 1px solid var(--glass-border);
  background: var(--glass-pill-bg);
  color: var(--paper-muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.audio-chip-btn:hover {
  color: var(--paper-text);
  border-color: var(--primary);
}

.audio-chip-btn.has-audio {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.45);
  background: rgba(74, 222, 128, 0.12);
}

.audio-chip-btn.has-director {
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.12);
}

.recording-bar {
  position: fixed;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  z-index: 85;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  width: min(560px, calc(100vw - 20px));
  border-radius: 18px;
  background: var(--glass-surface-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(239, 68, 68, 0.55);
  box-shadow: var(--glass-shadow);
  flex-wrap: wrap;
}

.recording-bar[hidden] {
  display: none;
}

.recording-bar__info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.recording-bar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  animation: recPulse 1s infinite;
  flex-shrink: 0;
}

.studio-preview-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

/* ==========================================================================
   FASE 5: AVISO DE TEXTO EXTERNO & REVISÃO DE MESCLAGEM .PE
   ========================================================================== */
.external-banner {
  max-width: 780px;
  margin: 0 auto 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(235, 128, 24, 0.14);
  border: 1px solid rgba(235, 128, 24, 0.42);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  line-height: 1.45;
}

.external-banner[hidden] {
  display: none;
}

.dialog-input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--studio-surface);
  color: var(--studio-text);
  padding: 8px 12px;
  font-size: 13.5px;
  margin-bottom: 10px;
}

.merge-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
  font-size: 12.5px;
}

.merge-item__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.merge-item select {
  width: 100%;
  padding: 6px 8px;
  border-radius: 9px;
  border: 1px solid var(--glass-border);
  background: var(--studio-surface);
  color: var(--studio-text);
  font-size: 12px;
}

/* ==========================================================================
   FASE 6: SALA DE ENSAIO & CHAT P2P
   ========================================================================== */
.room-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  margin-left: 4px;
}

.room-join-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.room-members {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.room-member-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
}

.room-chat-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 240px;
}

.room-chat-box {
  flex: 1;
  min-height: 160px;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.chat-msg,
.chat-pe-card {
  padding: 8px 11px;
  border-radius: 12px;
  background: var(--glass-pill-bg);
  border: 1px solid var(--glass-border);
  font-size: 12.5px;
  align-self: flex-start;
  max-width: 92%;
}

.chat-msg.is-self,
.chat-pe-card.is-self {
  align-self: flex-end;
  border-color: rgba(235, 128, 24, 0.45);
  background: rgba(235, 128, 24, 0.12);
}

.chat-msg__meta {
  font-size: 10.5px;
  color: var(--studio-muted);
  margin-bottom: 3px;
}

.chat-pe-card__title {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

.room-chat-form {
  display: flex;
  gap: 6px;
  align-items: center;
}

#room-btn-voice.is-active {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #fca5a5;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 42px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--glass-surface-strong);
  border: 1px solid var(--glass-border);
  color: var(--studio-text);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--glass-shadow);
  z-index: 90;
  max-width: calc(100vw - 24px);
  text-align: center;
}

/* ==========================================================================
   RESPONSIVIDADE MULTI-TELA & ACESSIBILIDADE
   ========================================================================== */
@media (max-width: 1024px) {
  .studio-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(380px, 100vw);
    z-index: 50;
  }
}

@media (max-width: 720px) {
  .hide-on-xs {
    display: none;
  }

  .topbar {
    padding: 7px 10px;
  }

  .brand-logo-img {
    height: 26px;
  }

  .quickbar {
    padding: 6px 10px;
  }

  .stage {
    padding: 10px 8px 36px;
  }

  .script-sheet {
    padding: 18px 14px 28px;
    border-radius: 14px;
  }

  .palco-dialog {
    left: 10px;
    right: 10px;
    width: calc(100vw - 20px);
  }
}

@media (min-width: 1601px) {
  .script-sheet {
    max-width: 900px;
  }
  .script-lines {
    font-size: 17.5px;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar,
  .quickbar,
  .top-dropdown__menu,
  .studio-drawer,
  .palco-dialog,
  .toast {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--studio-surface);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

