:root {
  --bg:            #0B1020;
  --surface:       #131a2e;
  --surface-2:     #1a1a24;
  --border:        #2a2a38;
  --text:          #e6e6ef;
  --text-muted:    #94a3b8;
  --text-faint:    #64748b;
  --accent:        #8B5CF6;
  --accent-2:      #C084FC;
  --green:         #4ADE80;
  --red:           #F87171;
  --blue:          #60A5FA;
  --yellow:        #FBBF24;
  --radius-md:     12px;
  --radius-sm:     8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding-bottom: 32px;
}

.hidden { display: none !important; }

.screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 0 14px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.topbar h1 {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  flex: 1;
}

.btn-back {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  cursor: pointer;
}

.btn-icon-danger {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--red);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  cursor: pointer;
}

/* ── Lista de perfis (Início) ───────────────────────── */
.profile-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 90px;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s ease;
}
.profile-card:active { border-color: var(--accent); }

.profile-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.profile-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.profile-card-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.profile-card-badge.on {
  background: rgba(74, 222, 128, .15);
  color: var(--green);
}
.profile-card-badge.off {
  background: rgba(248, 113, 113, .15);
  color: var(--red);
}

.profile-card-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.profile-card-stats b { color: var(--text); }

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  margin-top: 60px;
}

.btn-fab {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 20px;
  max-width: 448px;
  margin: 0 auto;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 6px 20px rgba(139, 92, 246, .35);
  cursor: pointer;
}
.btn-fab-icon { font-size: 18px; line-height: 1; }

/* ── Formulário (Adicionar) ─────────────────────────── */
.form-pad { padding-bottom: 24px; }

.field-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin: 16px 0 6px;
}
.field-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
}
.field-textarea { resize: vertical; font-family: monospace; font-size: 12px; }
.field-input:focus { outline: none; border-color: var(--accent); }

.field-error {
  color: var(--red);
  font-size: 12px;
  margin: 10px 0 0;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 14px;
  font-weight: 800;
  margin-top: 20px;
  cursor: pointer;
}

/* ── Detalhe da live ─────────────────────────────────── */
.status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  transition: background .3s;
}
.status-dot.on { background: var(--green); box-shadow: 0 0 8px rgba(74,222,128,.6); }
.status-label { font-size: 12px; color: var(--text-muted); }

/* ── Barra lateral de ícones + painéis ─────────────────────────── */
.detail-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.icon-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
  position: sticky;
  top: 70px;
}
.rail-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  opacity: .7;
}
.rail-btn.active {
  background: rgba(139, 92, 246, .15);
  border-color: var(--accent);
  opacity: 1;
}
.detail-content {
  flex: 1;
  min-width: 0;
  padding-bottom: 24px;
}
.tool-panel {
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 18px;
}
.tool-panel .section-label { margin-top: 0; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.stat-card.accent-green { border-left-color: var(--green); }
.stat-label {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-value {
  display: block;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}
.stat-card.accent-green .stat-value { color: var(--green); }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease;
}
.toggle-row:active { border-color: var(--accent); }
.toggle-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: 0 0 auto;
}
.toggle-state {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.toggle-row input:checked ~ .toggle-state {
  color: var(--green);
}

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin: 18px 0 8px;
}

.cmd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.btn-cmd {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn-cmd:active { border-color: var(--accent); }
.btn-cmd-danger { color: var(--red); border-color: rgba(248,113,113,.3); }
.btn-cmd-full { width: 100%; padding: 13px 8px; margin-top: 4px; }
.program-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; font-size: 12px; }
.program-field select { max-width: 145px; }
.program-field input[type="range"] { flex: 1 1 auto; max-width: 160px; }
.program-field span span { color: var(--text-muted); font-weight: 400; }

/* Checkbox simples (sem indicador de estado remoto) — pra config local que
   só é aplicada na hora de conectar, igual ao Electron desktop (Espelhar/
   Ken Burns/Efeitos visuais do perfil). */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 2px;
  cursor: pointer;
}
.check-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

/* Cabeçalho de um grupo de config (min/max) — mesmo texto do Electron
   ("Brilho 90% – 110%"). */
.config-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  margin: 10px 0 2px;
}
.config-group-value { color: var(--text-muted); font-weight: 400; }

/* Mini switch (liga/desliga de cada efeito visual — Grão/Vinheta/Filtro) */
.switch-mini { position: relative; display: inline-block; width: 34px; height: 20px; cursor: pointer; }
.switch-mini input { opacity: 0; width: 0; height: 0; }
.switch-mini-track {
  position: absolute; inset: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background .15s ease;
}
.switch-mini-track::before {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  left: 2px; top: 2px;
  background: var(--text-faint);
  border-radius: 50%;
  transition: transform .15s ease, background .15s ease;
}
.switch-mini input:checked ~ .switch-mini-track { border-color: var(--accent); background: rgba(139, 92, 246, .15); }
.switch-mini input:checked ~ .switch-mini-track::before { transform: translateX(14px); background: var(--accent); }

/* Campos de intensidade de um efeito — apagados até o switch dele ligar
   (mesmo comportamento do Electron: dá pra ver mas não pra mexer). */
.config-fields-disabled { opacity: .4; pointer-events: none; }
.program-video-name, .program-prepare-state {
  padding: 8px 10px;
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 11px;
  color: var(--text-muted);
}
.program-preview-wrap { margin: 8px 0; }
.program-preview-wrap img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.program-preview-wrap span { display: block; margin-top: 4px; font-size: 10px; color: var(--text-faint); }

/* A tela do LIVE Studio não é 16:9 (mais perto de 1.6:1) — usar o aspect-ratio
   fixo de cima faria letterbox e desalinharia o cálculo de onde o dedo tocou
   (offsetX/offsetY são relativos ao tamanho renderizado, não ao conteúdo real
   se sobrar barra vazia). Deixa a altura seguir a proporção real da imagem. */
#dup-screenshot-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: crosshair;
}

/* Botão de tela cheia — sempre visível sobre a imagem (fundo semi-
   transparente pra não sumir em cima de qualquer conteúdo). Não muda o
   elemento da imagem em si (#dup-screenshot-img continua o mesmo, mesmo
   listener de toque) — só o CONTAINER que muda de tamanho/posição, então o
   cálculo de fração (getBoundingClientRect) do toque continua correto
   automaticamente em qualquer um dos dois estados. */
.dup-screenshot-frame { position: relative; }
.dup-screenshot-fullscreen-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.dup-screenshot-fullscreen-btn:active { background: rgba(0, 0, 0, .8); }

/* Estado tela cheia — o FRAME (não a imagem) vira position:fixed cobrindo a
   tela toda; a imagem só ganha max-width/max-height:100% pra caber inteira
   sem cortar (object-fit:contain já evita distorcer). */
.dup-screenshot-frame.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  margin: 0;
}
.dup-screenshot-frame.is-fullscreen #dup-screenshot-img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border: none;
  border-radius: 0;
}
.dup-screenshot-frame.is-fullscreen .dup-screenshot-fullscreen-btn {
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
}
body.dup-screenshot-locked { overflow: hidden; }

/* Retrato + tela cheia: a captura (janela do LIVE Studio, bem "paisagem",
   ~1.6:1) sobra muito espaço preto num celular em pé — gira 90° pra
   aproveitar o lado comprido da tela. O TAMANHO em pixel (width/height) é
   calculado no JS (_layoutFullscreenScreenshot em app.js), não fixo aqui —
   precisa bater exatamente com o conteúdo visível (sem sobra dentro da
   própria caixa da imagem), senão o cálculo de toque erra o alvo. Só o
   necessário pro CSS aqui é a rotação em si. */
.dup-screenshot-frame.is-fullscreen.is-rotated #dup-screenshot-img {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: none;
  max-height: none;
  transform: translate(-50%, -50%) rotate(90deg);
  border: none;
  border-radius: 0;
}

/* Zoom livre (pinça) na tela cheia — camada SEPARADA em volta da imagem
   (não mexe no transform de rotação dela, que continua o de cima). Fora da
   tela cheia é "display:contents" (não existe como caixa própria, zero
   efeito no layout normal). Em tela cheia vira uma caixa do tamanho do
   frame inteiro (mesma caixa que a imagem usava antes pra se centralizar,
   girada ou não) — o zoom/pan (transform inline, via JS) é aplicado NELA,
   não na imagem. Como getBoundingClientRect() da imagem sempre reflete a
   composição de TODOS os transforms dos ancestrais, o cálculo de toque em
   app.js não precisa saber nada sobre zoom — ver notas de verificação lá. */
.dup-screenshot-zoom-wrap { display: contents; }
.dup-screenshot-frame.is-fullscreen .dup-screenshot-zoom-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.quick-reply-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.btn-quick-reply {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.btn-quick-reply:active { border-color: var(--accent); }

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.comment-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
  cursor: pointer;
}
.comment-item:active { border-color: var(--accent); }
.remote-reply-box { margin: 8px 0 14px; }
.remote-reply-box textarea { width: 100%; box-sizing: border-box; resize: vertical; }

.watch-add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 14px;
}
.watch-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.watch-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.watch-item.is-live { border-color: rgba(74, 222, 128, .4); }
.watch-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.watch-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.watch-item-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  flex: 0 0 auto;
}
.watch-item-badge.on {
  background: rgba(74, 222, 128, .15);
  color: var(--green);
}
.watch-item-badge.off {
  background: rgba(148, 163, 184, .15);
  color: var(--text-muted);
}
.watch-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.watch-item-actions .btn-cmd { flex: 1; padding: 8px; font-size: 11px; }
.watch-item-remove {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}
.watch-item-remove:active { border-color: var(--red); color: var(--red); }

.hint-small {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.sale-toast {
  position: fixed;
  z-index: 9999;
  top: 14px;
  left: 50%;
  width: min(420px, calc(100% - 28px));
  box-sizing: border-box;
  transform: translate(-50%, -130%);
  opacity: 0;
  padding: 14px 16px;
  border: 1px solid #4ade80;
  border-left: 5px solid #4ade80;
  border-radius: 12px;
  background: #101827;
  color: #fff;
  box-shadow: 0 12px 35px #000a;
  transition: transform .3s ease, opacity .3s ease;
}
.sale-toast.show { transform: translate(-50%, 0); opacity: 1; }
.sale-toast strong, .sale-toast span { display: block; }
.sale-toast strong { color: #4ade80; font-size: 15px; margin-bottom: 4px; }
.sale-toast span { font-size: 13px; }

.sale-toast.live-toast { border-color: var(--accent); border-left-color: var(--accent); }
.sale-toast.live-toast strong { color: var(--accent); }
