/* ═══════════════════════════════════════════════════════════════════
   Editor Avançado de E-mail - estilos do módulo isolado.

   Editor de blocos em tela cheia (estilo Substack), dark theme do
   ecossistema RR (preto + dourado, fonte Inter). Todas as classes têm
   prefixo `aee-` para não colidir com o resto do app (`em-`, `cb-`).

   Paleta de referência (espelho de style.css / campaign.css):
     bg base      #0a0a0b
     painel       #0d0d10 / #15151a
     painel alt   #1f1f24
     texto        #ededeb
     texto suave  rgba(237,237,235,0.55)
     dourado      #c9a24f
     bordas       rgba(255,255,255,0.06 - 0.10)
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Variáveis locais do editor ──────────────────────────────────── */
/* Os menus/diálogos flutuantes (.aee-insert-menu, .aee-format-bar,
   .aee-modal) sao anexados ao <body>, fora de .aee-root. Por isso as
   variaveis precisam ser declaradas neles tambem: custom properties so
   herdam de ancestrais, e .aee-root nao e ancestral desses overlays. */
.aee-root,
.aee-insert-menu,
.aee-format-bar,
.aee-modal {
  --aee-bg:        #0a0a0b;
  --aee-panel:     #15151a;
  --aee-panel-2:   #1f1f24;
  --aee-side:      #0d0d10;
  --aee-text:      #ededeb;
  --aee-text-mut:  rgba(237, 237, 235, 0.55);
  --aee-text-dim:  rgba(237, 237, 235, 0.38);
  --aee-gold:      #c9a24f;
  --aee-gold-soft: rgba(201, 162, 79, 0.12);
  --aee-border:    rgba(255, 255, 255, 0.08);
  --aee-border-2:  rgba(255, 255, 255, 0.12);
  --aee-danger:    #f4677b;
  --aee-ok:        #6fc784;
}
/* Tipografia base e cor de texto dos overlays anexados ao <body>. */
.aee-modal,
.aee-insert-menu,
.aee-format-bar {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--aee-text);
}
.aee-modal *,
.aee-insert-menu *,
.aee-format-bar * { box-sizing: border-box; }

/* ─── Overlay em tela cheia ───────────────────────────────────────── */
/* Cobre toda a viewport acima de tudo. Animação de entrada suave. */
.aee-root {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  background: var(--aee-bg);
  color: var(--aee-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  animation: aee-fade-in 0.18s ease;
}
@keyframes aee-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.aee-root * { box-sizing: border-box; }

/* ─── Barra superior ──────────────────────────────────────────────── */
.aee-topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: var(--aee-side);
  border-bottom: 1px solid var(--aee-border);
}
.aee-topbar-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.aee-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--aee-gold);
}
.aee-topbar-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.aee-topbar-spacer { flex: 1; }

/* Botões da barra superior */
.aee-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--aee-border-2);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(237, 237, 235, 0.85);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.aee-btn:hover:not(:disabled) {
  background: rgba(201, 162, 79, 0.08);
  border-color: rgba(201, 162, 79, 0.4);
  color: var(--aee-text);
}
.aee-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.aee-btn-primary {
  background: var(--aee-gold);
  border-color: var(--aee-gold);
  color: #0a0a0b;
}
.aee-btn-primary:hover:not(:disabled) {
  background: #d8b566;
  border-color: #d8b566;
  color: #0a0a0b;
}
.aee-btn-ghost {
  background: transparent;
  border-color: var(--aee-border);
  color: var(--aee-text-mut);
}
.aee-btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--aee-border-2);
  color: var(--aee-text);
}
.aee-btn-icon {
  padding: 8px;
  width: 34px;
  height: 34px;
  justify-content: center;
}

/* ─── Corpo: canvas central + painel lateral ──────────────────────── */
.aee-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Coluna central rolável onde ficam os blocos */
.aee-canvas {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px 20px 120px;
}
.aee-doc {
  max-width: 640px;
  margin: 0 auto;
}

/* ─── Painel lateral de ajustes ───────────────────────────────────── */
.aee-side {
  flex: 0 0 290px;
  background: var(--aee-side);
  border-left: 1px solid var(--aee-border);
  overflow-y: auto;
  padding: 22px 20px 60px;
}
.aee-side-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.aee-side-sub {
  margin: 0 0 20px;
  font-size: 11px;
  line-height: 16px;
  color: var(--aee-text-mut);
}
.aee-field { margin-bottom: 16px; }
.aee-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--aee-text-mut);
}
.aee-field input,
.aee-field select,
.aee-field textarea {
  width: 100%;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--aee-border);
  border-radius: 8px;
  color: var(--aee-text);
  font-family: inherit;
  font-size: 13px;
}
.aee-field textarea { resize: vertical; min-height: 60px; }
.aee-field input:focus,
.aee-field select:focus,
.aee-field textarea:focus {
  outline: none;
  border-color: rgba(201, 162, 79, 0.5);
}
.aee-field-hint {
  margin: 5px 0 0;
  font-size: 10px;
  line-height: 14px;
  color: var(--aee-text-dim);
}

/* ─── Bloco genérico ──────────────────────────────────────────────── */
.aee-block {
  position: relative;
  margin: 4px 0;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: border-color 0.12s, background 0.12s;
}
.aee-block:hover { border-color: var(--aee-border); }
.aee-block.is-selected {
  border-color: rgba(201, 162, 79, 0.45);
  background: rgba(201, 162, 79, 0.03);
}

/* ─── Alça de arrastar (estilo Notion) ───────────────────────────────
   Fica levemente para FORA da borda esquerda do bloco. O canvas tem
   padding lateral de 20px, então o `left` negativo cabe sem cortar.
   Aparece só no hover/seleção do bloco, com um fade-in discreto. */
.aee-drag-handle {
  position: absolute;
  top: 4px;
  left: -26px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 26px;
  border-radius: 6px;
  color: var(--aee-text-dim);
  cursor: grab;
  opacity: 0;
  transition: opacity 0.14s, color 0.12s, background 0.12s;
  z-index: 4;
  /* Evita o "ghost" de seleção de texto ao agarrar a alça. */
  user-select: none;
  -webkit-user-select: none;
}
.aee-block:hover > .aee-drag-handle,
.aee-block.is-selected > .aee-drag-handle { opacity: 1; }
.aee-drag-handle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--aee-text-mut);
}
.aee-drag-handle:active { cursor: grabbing; }
/* Enquanto qualquer bloco está sendo arrastado, o cursor é "grabbing"
   em toda a janela e o bloco de origem fica esmaecido. */
body.aee-block-dragging,
body.aee-block-dragging .aee-drag-handle { cursor: grabbing; }
.aee-block.aee-dragging { opacity: 0.4; }

/* Conteúdo editável de texto dentro do bloco */
.aee-block-content {
  padding: 6px 12px;
  outline: none;
  line-height: 1.55;
  /* Texto editável pode receber URLs ou palavras longas coladas: quebra
     dentro da palavra para não estourar a largura do canvas no celular. */
  overflow-wrap: break-word;
  word-break: break-word;
}
.aee-block-content:empty::before {
  content: attr(data-placeholder);
  color: var(--aee-text-dim);
}
/* Tipografia dos blocos de texto */
.aee-block-content.aee-h1 { font-size: 26px; font-weight: 800; line-height: 1.25; }
.aee-block-content.aee-h2 { font-size: 20px; font-weight: 700; line-height: 1.3; }
.aee-block-content.aee-p  { font-size: 15px; }
.aee-block-content.aee-quote {
  font-size: 16px;
  font-style: italic;
  border-left: 3px solid var(--aee-gold);
  padding-left: 16px;
  color: var(--aee-text-mut);
}
.aee-block-content a { color: var(--aee-gold); }
.aee-block-content strong { font-weight: 700; }

/* Lista editável */
.aee-list { padding: 6px 12px 6px 34px; margin: 0; }
.aee-list li {
  font-size: 15px;
  line-height: 1.55;
  margin: 3px 0;
  outline: none;
  /* Item editável pode receber URLs/palavras longas: quebra dentro da
     palavra para não estourar a largura do canvas. */
  overflow-wrap: break-word;
  word-break: break-word;
}
.aee-list li a { color: var(--aee-gold); }

/* Barra de ações por bloco (canto superior direito, aparece no hover).
   Antes ficava em `top:-13px` mas a barra tem ~32px de altura, então
   13px ficavam pendurados PRA DENTRO do bloco, cobrindo o texto da
   primeira/segunda linha em paragrafos longos. Agora usa `bottom:100%`
   pra que o rodapé da barra se ancore exatamente no topo do bloco; com
   o margin-bottom de 4px a barra sobe inteira pra fora, sem importar
   a altura dela. */
.aee-block-tools {
  position: absolute;
  bottom: 100%;
  right: 6px;
  margin-bottom: 4px;
  display: none;
  gap: 2px;
  padding: 3px;
  background: var(--aee-panel-2);
  border: 1px solid var(--aee-border-2);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  z-index: 4;
}
.aee-block:hover > .aee-block-tools,
.aee-block.is-selected > .aee-block-tools { display: flex; }
.aee-block-tools button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--aee-text-mut);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.aee-block-tools button:hover { background: rgba(255, 255, 255, 0.08); color: var(--aee-text); }
.aee-block-tools button.aee-tool-del:hover { color: var(--aee-danger); }
.aee-block-tools button:disabled { opacity: 0.3; cursor: not-allowed; }

/* Controles "lápis" / "+" no canto do bloco (botão, linha de botões e
   imagem). Ficam no canto SUPERIOR ESQUERDO para não colidir com a barra
   de ações do bloco, que mora no canto superior direito. */
.aee-pencil-tools {
  position: absolute;
  top: -13px;
  left: 10px;
  display: none;
  gap: 2px;
  padding: 3px;
  background: var(--aee-panel-2);
  border: 1px solid var(--aee-border-2);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  z-index: 4;
}
/* O `>` nao e usado aqui de proposito: os controles "lápis" sao
   construidos dentro do miolo do bloco (ex: .aee-btnblock), entao sao
   NETOS de .aee-block, nao filhos diretos. */
.aee-block:hover .aee-pencil-tools,
.aee-block.is-selected .aee-pencil-tools { display: flex; }
.aee-pencil-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--aee-gold);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.aee-pencil-btn:hover { background: var(--aee-gold-soft); }
.aee-pencil-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  color: var(--aee-text-mut);
}
/* Em telas de toque o lápis fica sempre visível (sem hover confiável). */
@media (hover: none) {
  .aee-pencil-tools { display: flex; }
}

/* ─── Bloco de imagem ─────────────────────────────────────────────── */
.aee-img-wrap { padding: 10px 12px; text-align: center; }

/* Contêiner da imagem: ancora as alças de redimensionamento na borda
   real da imagem. inline-block para encolher junto com a imagem. */
.aee-img-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}
.aee-img-frame img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Alças de redimensionamento nos cantos inferiores da imagem.
   Aparecem ao passar o mouse no bloco (ou sempre, em telas de toque). */
.aee-img-handle {
  position: absolute;
  bottom: -7px;
  width: 16px;
  height: 16px;
  background: var(--aee-gold);
  border: 2px solid var(--aee-bg);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.12s, transform 0.12s;
  z-index: 5;
}
.aee-img-handle-left  { left: -7px;  cursor: nesw-resize; }
.aee-img-handle-right { right: -7px; cursor: nwse-resize; }
.aee-block:hover .aee-img-handle,
.aee-block.is-selected .aee-img-handle { opacity: 1; }
.aee-img-handle:hover { transform: scale(1.18); }
@media (hover: none) {
  .aee-img-handle { opacity: 0.85; }
}

/* Enquanto arrasta uma alça: cursor de resize global e sem seleção de
   texto acidental pela página. */
body.aee-resizing { cursor: nwse-resize; user-select: none; }
body.aee-resizing * { cursor: nwse-resize !important; }

.aee-img-empty {
  padding: 36px 16px;
  border: 1px dashed var(--aee-border-2);
  border-radius: 10px;
  color: var(--aee-text-mut);
  font-size: 13px;
}
.aee-img-empty button { margin-top: 10px; }
.aee-img-progress {
  margin: 10px auto 0;
  max-width: 260px;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}
.aee-img-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--aee-gold);
  transition: width 0.2s ease;
}
.aee-img-error { margin-top: 8px; font-size: 12px; color: var(--aee-danger); }

/* ─── Bloco de botão (CTA) ────────────────────────────────────────── */
.aee-btnblock { padding: 14px 12px; text-align: center; }
.aee-btnblock-preview {
  /* inline-flex: alinha o icone do template ao lado do texto.
     padding/font-size espelham `oneButtonHtml` (14px 32px / 15px) para
     que o preview tenha o mesmo tamanho do botão do e-mail final.
     white-space:nowrap mantém o botão em uma linha só, igual ao e-mail:
     antes o editor quebrava a linha e o e-mail também, mas em pontos
     diferentes (canvas tem 640px, card do e-mail ~508px), e cada um
     ficava com largura distinta. Forçando nowrap nos dois lados o
     tamanho coincide. Se o rótulo for longo demais, fica claro no
     canvas que precisa encurtar. */
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: var(--aee-gold);
  color: #0a0a0b;
  font-weight: 700;
  font-size: 15px;
  border-radius: 8px;
  white-space: nowrap;
}
/* Logo de template (WhatsApp, YouTube...) no preview do canvas. */
.aee-btn-tpl-icon {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}
/* Glifo de seta do template "Download" no preview do canvas. */
.aee-btn-tpl-glyph {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

/* ─── Cor personalizada de botão + linha de botões ────────────────── */
.aee-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--aee-text-mut);
  cursor: pointer;
}
.aee-check input { width: auto; }
.aee-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.aee-color-row[hidden] { display: none; }
.aee-color-row span {
  font-size: 11px;
  color: var(--aee-text-mut);
}
.aee-color-row input[type="color"] {
  width: 42px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--aee-border-2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}
/* Bloco de cor travado: o template tem cor fixa, entao o checkbox e os
   seletores ficam esmaecidos e sem interacao. */
.aee-color-locked {
  opacity: 0.55;
}
.aee-color-locked .aee-check,
.aee-color-locked input[type="color"] {
  cursor: not-allowed;
}

/* ─── Bloco linha de botões (2 a 3 lado a lado) ───────────────────── */
.aee-btnrow-block { padding: 14px 12px; }
.aee-btnrow-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
/* Em linha de botões, libera o nowrap dos chips: com 2-3 botões lado a
   lado o card do e-mail é estreito demais para forçar uma linha só, e
   o nowrap fazia os botões grudarem. O CTA único continua nowrap. */
.aee-btnrow-preview .aee-btnblock-preview {
  white-space: normal;
}
.aee-btnrow-editors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.aee-btnrow-editor {
  flex: 1 1 200px;
  text-align: left;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--aee-border);
  border-radius: 9px;
}
.aee-btnrow-editor label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--aee-text-mut);
}
.aee-btnrow-editor input {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--aee-border-2);
  border-radius: 7px;
  color: var(--aee-text);
  font-family: inherit;
  font-size: 12px;
}
.aee-btnrow-editor input[type="color"] { width: 42px; padding: 2px; cursor: pointer; }
.aee-btnrow-editor input[type="checkbox"] { width: auto; }
.aee-btnrow-editor input:focus { outline: none; border-color: rgba(201, 162, 79, 0.5); }
.aee-btnrow-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.aee-btnrow-editor-head strong { font-size: 12px; color: var(--aee-text); }
.aee-btnrow-rm {
  display: inline-flex;
  padding: 4px;
  background: transparent;
  border: 1px solid var(--aee-border);
  border-radius: 6px;
  color: var(--aee-text-mut);
  cursor: pointer;
}
.aee-btnrow-rm:hover { color: var(--aee-danger); border-color: var(--aee-danger); }

/* ─── Bloco divisor ───────────────────────────────────────────────── */
.aee-divider-block { padding: 14px 12px; }
.aee-divider-block hr {
  border: none;
  border-top: 1px solid var(--aee-border-2);
  margin: 0;
}

/* ─── Bloco espaçador ─────────────────────────────────────────────── */
.aee-spacer-block {
  margin: 4px 12px;
  border: 1px dashed var(--aee-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--aee-text-dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ─── Bloco "Espaço" (espaçador fixo de uma linha) ────────────────────
   Faixa tracejada discreta: a altura espelha a altura real do espaço no
   e-mail. Sem configuração; serve só para o usuário ver/selecionar o
   bloco. O `box-sizing` global garante que a borda não estoure a altura. */
.aee-space-block {
  margin: 4px 12px;
  border: 1px dashed var(--aee-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--aee-text-dim);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  user-select: none;
}

/* ─── Bloco "Badge" (pill/etiqueta destacada no corpo do e-mail) ──────
   O canvas mostra a pill já pintada com a cor de destaque do tema, fiel
   ao e-mail final. O alinhamento (text-align) posiciona a pill; o lápis
   no canto abre o modal de edição. */
.aee-badge-block {
  position: relative;
  padding: 10px 12px;
}
.aee-badge-pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  user-select: none;
  /* Texto de badge longo não pode estourar a largura do bloco: limita à
     largura útil e quebra dentro da palavra. */
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* Badge sem texto: a pill mostra o rótulo "Badge" esmaecido, só no
   editor (no e-mail final um badge vazio não é renderizado). */
.aee-badge-pill.is-empty { opacity: 0.5; }

/* ─── Seletor de mídia da galeria (modal do bloco "Mídia") ─────────────
   Grade simples de cards: cada card é um botão com o thumbnail e o nome
   da mídia. Alimentada por GET /api/email-marketing/media. */
.aee-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-top: 14px;
  /* Galeria grande não pode estourar a altura do modal. */
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 2px;
}
.aee-gallery-grid[hidden] { display: none; }
.aee-gallery-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--aee-border);
  border-radius: 9px;
  color: var(--aee-text-mut);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.aee-gallery-item:hover {
  border-color: rgba(201, 162, 79, 0.5);
  background: var(--aee-gold-soft);
  color: var(--aee-text);
}
.aee-gallery-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  overflow: hidden;
}
.aee-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Thumbnail que não carregou: esconde a <img> quebrada. O fundo cinza
   do contêiner já serve de placeholder discreto. */
.aee-gallery-thumb.is-broken img { display: none; }
.aee-gallery-name {
  font-size: 10px;
  line-height: 13px;
  text-align: center;
  /* Nome longo não pode empurrar a largura do card. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Selo "FIXO" no topo direito do thumb pra itens da galeria fixa
   (Renan / Rafael / RR Engenharia). Diferencia da midia do usuario. */
.aee-gallery-tag {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(201, 162, 79, 0.95);
  color: #1a1a18;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-radius: 3px;
  pointer-events: none;
}
.aee-gallery-item.is-preset {
  border-color: rgba(201, 162, 79, 0.35);
}

/* ─── Botão "+" inserir bloco (entre blocos) ──────────────────────── */
.aee-inserter {
  position: relative;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.aee-inserter-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: transparent;
  transition: background 0.12s;
}
.aee-inserter:hover .aee-inserter-line { background: rgba(201, 162, 79, 0.3); }
.aee-inserter-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: var(--aee-panel-2);
  border: 1px solid var(--aee-border-2);
  border-radius: 50%;
  color: var(--aee-text-mut);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s, transform 0.12s;
}
.aee-inserter:hover .aee-inserter-btn { opacity: 1; }
.aee-inserter-btn:hover {
  background: var(--aee-gold);
  color: #0a0a0b;
  transform: scale(1.12);
}
/* Em telas de toque o botão fica sempre visível (sem hover confiável) */
@media (hover: none) {
  .aee-inserter-btn { opacity: 0.7; }
}

/* ─── Indicador de drop (reordenação por arrastar) ────────────────────
   Quando um bloco está sendo arrastado, o inseridor da posição-alvo
   ganha a classe `aee-drop-active`: a linha vira uma barra dourada
   visível e um ponto marca o ponto exato de inserção. */
.aee-inserter.aee-drop-active {
  height: 14px;
}
.aee-inserter.aee-drop-active .aee-inserter-line {
  height: 3px;
  border-radius: 2px;
  background: var(--aee-gold);
  box-shadow: 0 0 8px rgba(201, 162, 79, 0.6);
}
.aee-inserter.aee-drop-active::before {
  content: '';
  position: absolute;
  left: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--aee-gold);
  box-shadow: 0 0 8px rgba(201, 162, 79, 0.6);
}

/* ─── Menu de inserção de bloco ───────────────────────────────────── */
.aee-insert-menu {
  position: fixed;
  z-index: 9300;
  width: 220px;
  padding: 6px;
  background: var(--aee-panel-2);
  border: 1px solid var(--aee-border-2);
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
}
.aee-insert-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--aee-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.aee-insert-menu button:hover { background: var(--aee-gold-soft); }
.aee-insert-menu button svg { flex: 0 0 auto; color: var(--aee-gold); }

/* ─── Barra flutuante de formatação de texto ──────────────────────── */
.aee-format-bar {
  position: fixed;
  z-index: 9400;
  display: none;
  gap: 2px;
  padding: 4px;
  background: var(--aee-panel-2);
  border: 1px solid var(--aee-border-2);
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.aee-format-bar.is-visible { display: flex; }
.aee-format-bar button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--aee-text-mut);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.aee-format-bar button:hover { background: rgba(255, 255, 255, 0.08); color: var(--aee-text); }
.aee-format-bar button.is-active { background: var(--aee-gold-soft); color: var(--aee-gold); }
/* O atributo `hidden` precisa vencer o `display:flex` da regra dos
   botões da barra. Usado pelo botão "Converter o link em botão", que
   só aparece quando o cursor está dentro de um link. */
.aee-format-bar button[hidden] { display: none; }
/* "Converter o link em botão": destacado em dourado para o usuário
   perceber que é uma ação contextual diferente das de formatação. */
.aee-format-bar button.aee-fmt-link2btn { color: var(--aee-gold); }
.aee-format-bar button.aee-fmt-link2btn:hover { background: var(--aee-gold-soft); }
.aee-format-bar .aee-format-sep {
  width: 1px;
  margin: 4px 3px;
  background: var(--aee-border-2);
}

/* ─── Diálogos modais (vídeo->GIF, botão CTA, link) ───────────────── */
.aee-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 5, 7, 0.78);
  animation: aee-fade-in 0.14s ease;
}
.aee-modal-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  background: var(--aee-panel);
  border: 1px solid var(--aee-border-2);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}
/* Botão "X" de fechar no canto do card (modais de edição). */
.aee-modal-x {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--aee-border);
  border-radius: 7px;
  color: var(--aee-text-mut);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.aee-modal-x:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--aee-border-2);
  color: var(--aee-text);
}
.aee-modal-title {
  margin: 0 36px 4px 0;
  font-size: 17px;
  font-weight: 800;
}
.aee-modal-sub {
  margin: 0 36px 18px 0;
  font-size: 12px;
  line-height: 17px;
  color: var(--aee-text-mut);
}
/* Corpo do modal de edição: container dos campos. */
.aee-modal-body { margin: 0; }
/* Dentro de um modal de edição, a lista de cartões de botão fica em
   coluna (o modal e estreito demais para 3 cartões lado a lado). */
.aee-modal-body .aee-btnrow-editors {
  flex-direction: column;
  margin-top: 4px;
}
.aee-modal-body .aee-btnrow-editor { flex: 1 1 auto; }
.aee-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.aee-modal-status {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 17px;
  min-height: 17px;
}
.aee-modal-status[data-state="error"] { color: var(--aee-danger); }
.aee-modal-status[data-state="ok"]    { color: var(--aee-ok); }

/* Barra de progresso da conversão de vídeo */
.aee-conv-progress {
  margin-top: 14px;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}
.aee-conv-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--aee-gold);
  transition: width 0.25s ease;
}

/* Tabelinha de cálculo de aceleração no diálogo de vídeo */
.aee-conv-info {
  margin-top: 12px;
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--aee-border);
  border-radius: 9px;
  font-size: 12px;
  line-height: 19px;
  color: var(--aee-text-mut);
}
.aee-conv-info strong { color: var(--aee-gold); }

/* Painel de log da conversão de vídeo: diagnóstico dentro da janela */
.aee-conv-log {
  display: block;
  max-height: 168px;
  overflow-y: auto;
  margin: 12px 0 0;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--aee-border-2);
  border-radius: 8px;
  color: var(--aee-text-mut);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.aee-conv-log[hidden] { display: none; }

/* ─── Recursos de IA: bloco no painel lateral ─────────────────────── */
/* Bloco "Inteligência artificial" no topo do painel de ajustes, com os
   botões "Criar com IA" e "Ajustar com IA". */
.aee-ai-section {
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--aee-border);
}
.aee-ai-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Os botões de IA ocupam a largura do painel e têm um leve realce
   dourado para se destacarem dos campos de ajuste comuns. */
.aee-ai-btn {
  width: 100%;
  justify-content: center;
  padding: 10px 14px;
  background: var(--aee-gold-soft);
  border-color: rgba(201, 162, 79, 0.32);
  color: var(--aee-text);
}
.aee-ai-btn:hover:not(:disabled) {
  background: rgba(201, 162, 79, 0.2);
  border-color: rgba(201, 162, 79, 0.5);
}

/* ─── Recursos de IA: estados dentro dos modais ───────────────────── */
/* Bloco de carregando dos modais de IA: spinner + texto. */
.aee-ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--aee-border);
  border-radius: 9px;
  font-size: 12px;
  color: var(--aee-text-mut);
}
.aee-ai-loading[hidden] { display: none; }

/* Spinner circular giratório. */
.aee-ai-spinner {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(201, 162, 79, 0.25);
  border-top-color: var(--aee-gold);
  border-radius: 50%;
  animation: aee-spin 0.7s linear infinite;
}
@keyframes aee-spin {
  to { transform: rotate(360deg); }
}

/* Aviso de "versão melhorada pronta" no modal Ajustar com IA. */
.aee-ai-result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--aee-gold-soft);
  border: 1px solid rgba(201, 162, 79, 0.32);
  border-radius: 9px;
  font-size: 12px;
  line-height: 17px;
  color: var(--aee-text);
}
.aee-ai-result[hidden] { display: none; }
.aee-ai-result svg {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--aee-gold);
}
.aee-modal-actions[hidden] { display: none; }

/* ─── Toast de feedback ───────────────────────────────────────────── */
.aee-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 9600;
  padding: 11px 20px;
  background: var(--aee-panel-2);
  border: 1px solid var(--aee-border-2);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.aee-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.aee-toast[data-kind="error"] { border-color: rgba(244, 103, 123, 0.5); color: var(--aee-danger); }
.aee-toast[data-kind="ok"]    { border-color: rgba(111, 199, 132, 0.5); color: var(--aee-ok); }

/* ─── Estado vazio do documento ───────────────────────────────────── */
.aee-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--aee-text-mut);
}
.aee-empty p { font-size: 14px; margin: 0 0 16px; }

/* ─── Botão de fechar do painel lateral (mobile) ──────────────────── */
.aee-side-toggle { display: none; }

/* ─── Responsivo: mobile (<= 760px) ───────────────────────────────── */
@media (max-width: 760px) {
  .aee-topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .aee-topbar-title { font-size: 14px; }
  .aee-btn { padding: 8px 12px; font-size: 11px; }

  .aee-canvas { padding: 18px 10px 120px; }

  /* O painel lateral vira uma gaveta deslizante por cima do canvas */
  .aee-side {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 85%;
    max-width: 320px;
    flex: none;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    z-index: 30;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6);
  }
  .aee-root.aee-side-open .aee-side { transform: translateX(0); }
  .aee-side-toggle { display: inline-flex; }

  .aee-block-content.aee-h1 { font-size: 22px; }
  .aee-block-content.aee-h2 { font-size: 18px; }
  .aee-insert-menu { width: 200px; }

  /* O canvas tem só 10px de padding lateral no mobile: a alça `left:-26px`
     seria cortada. Puxamos a alça para dentro do bloco e mantemos ela
     sempre visível (sem hover confiável em toque). */
  .aee-drag-handle { left: 0; opacity: 0.45; }
}
