:root {
  --navy: #0E3749;
  --terracota: #C96F4A;
  --terracota-canva: #D0753C;
  --terracota-claro: #E08A5F;
  --bege: #F4F1EC;
  --grafite: #3C3C3C;
  --border: #E2DCD1;
  --text-muted: #6B7280;
  --raio: 8px;
  --altura-controle: 38px;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bege);
  color: var(--navy);
}

.topo {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.topo h1 {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.1px;
  padding-bottom: 8px;
  border-bottom: 3px solid var(--terracota);
}

.topo h1 .topo-separador {
  color: var(--terracota);
  font-weight: 500;
}

.topo span {
  font-size: 12px;
  color: var(--text-muted);
}

.mobile-topbar {
  display: none;
}

.mobile-menu-btn {
  background: none;
  border: none;
  padding: 4px;
  margin: 0;
  cursor: pointer;
  color: var(--navy);
  display: flex;
  width: auto;
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

.painel-backdrop {
  display: none;
}

.layout {
  display: flex;
  min-height: calc(100vh - 68px);
}

.painel {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.bloco-posts {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 12px;
}

.posts-nome-input {
  display: block;
  width: 100%;
  height: var(--altura-controle);
  border: 1px solid var(--border);
  border-radius: var(--raio);
  padding: 0 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  background: var(--bege);
  margin-bottom: 8px;
}

.posts-nome-input:hover,
.posts-nome-input:focus {
  border-color: var(--terracota);
  outline: none;
  background: #fff;
}

.campo-modelo {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.posts-modelo-select {
  display: block;
  width: 100%;
  height: var(--altura-controle);
  border: 1px solid var(--border);
  border-radius: var(--raio);
  padding: 0 10px;
  font-family: inherit;
  font-size: 12px;
  color: var(--navy);
  background: #fff;
}

.campo-modelo .posts-modelo-select { margin-bottom: 0; flex: 1; min-width: 0; }

.btn-salvar-modelo {
  flex-shrink: 0;
  width: var(--altura-controle);
  height: var(--altura-controle);
  border: 1px solid var(--border);
  border-radius: var(--raio);
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-salvar-modelo:hover { border-color: var(--terracota); color: var(--terracota); }
.btn-salvar-modelo svg { width: 16px; height: 16px; }

.posts-secao-titulo {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin: 12px 0 6px;
}

.posts-lista {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--raio);
}

.posts-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
}

.posts-item:last-child { border-bottom: none; }
.posts-item:hover { background: var(--bege); }
.posts-item.ativo { background: #FBF0EB; }

.posts-item-info { flex: 1; min-width: 0; }
.posts-item-nome {
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.posts-item-data { color: var(--text-muted); font-size: 10px; }

.posts-item-excluir {
  background: none;
  border: none;
  color: var(--terracota);
  cursor: pointer;
  flex-shrink: 0;
  padding: 4px;
  display: inline-flex;
}

.posts-item-excluir svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
}

.posts-feedback {
  font-size: 11px;
  color: #3F8A63;
  margin-top: 8px;
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: opacity 0.2s;
}

.posts-feedback.mostrar {
  opacity: 1;
  height: auto;
}

.bloco-ia {
  border: 1px solid var(--terracota);
  background: #FBF0EB;
  border-radius: 10px;
  padding: 14px;
}

.bloco-ia label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}

.bloco-ia textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--raio);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  margin-bottom: 8px;
}

.bloco-ia .btn-principal {
  margin-top: 0;
}

.ia-status {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.ia-status.erro { color: #B14B3A; }
.ia-status.ok { color: #3F8A63; }
.ia-status.carregando { color: var(--text-muted); }

.abas {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.aba {
  flex: 1;
  min-height: var(--altura-controle);
  height: auto;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--raio);
  background: #fff;
  color: var(--navy);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.aba:hover { background: var(--bege); }

.aba.ativa {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.campo {
  margin-bottom: 14px;
}

.campo label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 4px;
}

.btn-remover-campo {
  border: none;
  background: none;
  padding: 0;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--terracota);
  cursor: pointer;
  text-transform: none;
}

.btn-remover-campo:hover { text-decoration: underline; }

.barra-cores {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.swatch-cor {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
}

.swatch-cor:hover { border-color: var(--terracota); transform: scale(1.08); }

.swatch-accent {
  background: linear-gradient(135deg, var(--terracota) 50%, var(--navy) 50%);
  color: #fff;
}

.swatch-remover {
  background: #fff;
  color: var(--text-muted);
}

.swatch-formato {
  width: 26px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  background: #fff;
  margin-right: 4px;
}

.swatch-formato:hover { border-color: var(--terracota); color: var(--terracota); }

.swatch-negrito { font-weight: 700; }

.campo input[type="text"],
.campo textarea,
.campo select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--raio);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}

.campo select { height: var(--altura-controle); }

.campo .ajuda {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.campo input[type="file"] {
  font-size: 12px;
}

.campo-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--navy);
  margin-bottom: 10px;
  cursor: pointer;
}

.btn {
  height: var(--altura-controle);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--raio);
  background: #fff;
  color: var(--navy);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
}

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

.btn:focus-visible,
.mobile-menu-btn:focus-visible,
.aba:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--terracota);
  outline-offset: 1px;
}

.btn-principal {
  background: var(--terracota);
  color: #fff;
  border-color: var(--terracota);
  width: 100%;
}

.btn-principal:hover { background: #B15E3B; }

.area-editor {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.barra-undo {
  display: flex;
  gap: 6px;
}

.barra-undo .btn {
  width: 38px;
  padding: 0;
}

.barra-undo .btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.editor-principal {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.preview-ativo {
  flex: 1 1 480px;
  min-width: 320px;
}

.campos-ativo {
  flex: 1 1 320px;
  min-width: 280px;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.campos-secao {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--terracota);
  margin: 18px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.campos-ativo-titulo + .campos-secao,
#c-variar-ia + .campos-secao {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.campos-ativo-titulo {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.tira-miniaturas-wrap {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.tira-miniaturas {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  overflow-x: auto;
  padding: 4px 2px 10px;
}

#baixar-todos {
  width: auto;
  margin-top: 4px;
}

.miniatura {
  position: relative;
  flex-shrink: 0;
  width: 90px;
  aspect-ratio: 1080 / 1350;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  background: #efece4;
}

.miniatura canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.miniatura.ativa { border-color: var(--terracota); }
.miniatura:hover { border-color: var(--terracota-claro); }

.miniatura-numero {
  position: absolute;
  bottom: 4px;
  left: 5px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.miniatura-remover {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.miniatura-remover svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
}

.miniatura:hover .miniatura-remover { display: flex; }

.miniatura-duplicar {
  position: absolute;
  top: 2px;
  right: 24px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.miniatura-duplicar svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
}

.miniatura:hover .miniatura-duplicar { display: flex; }

.miniatura[draggable="true"] { cursor: grab; }

.miniatura-dragover { outline: 2px dashed var(--terracota); outline-offset: -2px; }

.miniatura-add {
  flex-shrink: 0;
  width: 90px;
  aspect-ratio: 1080 / 1350;
  border-radius: 6px;
  border: 2px dashed var(--border);
  background: #fff;
  color: var(--terracota);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.miniatura-add svg {
  width: 26px;
  height: 26px;
  stroke: currentColor;
}

.miniatura-add:hover { border-color: var(--terracota); background: var(--bege); }

.slide-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  padding: 12px;
  max-width: 520px;
}

.canvas-wrap {
  position: relative;
  max-height: 640px;
  overflow-y: auto;
  overflow-x: hidden; /* só liga (via JS) quando o zoom passa de 100% */
  border-radius: 4px;
  margin-bottom: 8px;
  background: #efece4;
  border: 1px solid var(--border);
}

.guia-alinhamento {
  position: absolute;
  background: #FF3B8D;
  z-index: 6;
  pointer-events: none;
  display: none;
}

.guia-v { width: 1px; }
.guia-h { height: 1px; }

.alca-redimensionar {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--terracota);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  cursor: ew-resize;
  z-index: 5;
  touch-action: none;
}

/* Área de toque maior que o quadradinho visual (16px vira ~32px de alvo) —
   dedo precisa de mais espaço que mouse pra acertar a alça. */
.alca-redimensionar::before {
  content: '';
  position: absolute;
  inset: -8px;
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
}

.slide-card canvas.canvas-arrastavel {
  cursor: move;
  touch-action: none;
}

.zoom-controles {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.zoom-controles button {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.zoom-controles button:hover { background: var(--bege); }

.slide-card .ajuda {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.campo-zoom {
  margin-bottom: 10px;
}

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

.slide-card .btn { width: 100%; margin-bottom: 6px; }

/* ---------- Responsivo (mobile) ---------- */

@media (max-width: 860px) {
  .topo { display: none; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 150;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--navy);
  }

  .layout {
    flex-direction: column;
    min-height: calc(100vh - 49px);
  }

  .painel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
  }

  .painel.aberto { transform: translateX(0); }

  .painel-backdrop.visivel {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 190;
  }

  .area-editor {
    padding: 16px;
  }

  .editor-principal {
    flex-direction: column;
  }

  .preview-ativo,
  .campos-ativo {
    width: 100%;
    max-width: 100%;
  }

  .canvas-wrap {
    max-height: 70vh;
  }

  .btn,
  .campo select,
  .aba {
    min-height: 44px;
  }
}
