/* ============================================================== TEMAS ======
   Contrato: nenhuma regra abaixo escreve cor crua. Toda cor sai de um token,
   e os tokens vivem só neste bloco. É o que faz um tema novo ser um bloco de
   13 linhas em vez de uma caçada por hexadecimal no arquivo inteiro.

   Dois eixos independentes, os dois no <html>:
     data-tema  = controle | ouro | terminal | papel   (a paleta)
     data-modo  = escuro | claro                        (a luz)

   Os seletores são de ATRIBUTO, não `:root[...]`, de propósito: assim o mesmo
   bloco pinta uma amostra dentro do seletor de temas (uma div com data-tema
   próprio) sem duplicar nenhum hexadecimal no JavaScript.

   Especificidade: [data-tema] vale 1 atributo; [data-modo][data-tema] vale 2,
   então o claro sempre vence o escuro, independente da ordem.

   Os 13 primitivos de cada tema:
     bg panel panel-2 border text muted
     accent      — cor de preenchimento da marca (botão, borda acesa)
     accent-ink  — texto EM CIMA do accent (o tema amarelo precisa de tinta escura)
     accent-text — o accent como texto/link sobre o fundo (versão legível)
     accent-2    — secundária: hover do botão primário, etapas de follow-up
     green red yellow — estado: pronto, perigo, grifo/comentário
   ------------------------------------------------------------------------- */

/* --- 1. Controle · azul e violeta (a paleta original do dash) ------------- */
[data-tema="controle"] {
  --bg: #0f1117; --panel: #161922; --panel-2: #1d2230; --border: #262b3a;
  --text: #e6e8ee; --muted: #8b91a3;
  --accent: #4f8cff; --accent-ink: #ffffff; --accent-text: #6f9fff; --accent-2: #7c5cff;
  --green: #2ecc71; --red: #ff5470; --yellow: #ffc145;
}
[data-modo="claro"][data-tema="controle"] {
  --bg: #f5f7fb; --panel: #ffffff; --panel-2: #eef1f7; --border: #dce1ec;
  --text: #171a22; --muted: #646c80;
  --accent: #3574e8; --accent-ink: #ffffff; --accent-text: #2560cf; --accent-2: #6a45e6;
  --green: #109b68; --red: #d92b4b; --yellow: #c98a10;
}

/* --- 2. Ouro · grafite quente e amarelo ---------------------------------- */
/* O fundo é grafite, não preto: preto chapado com amarelo em cima vibra e
   cansa a vista numa tela em que se lê texto o dia inteiro. */
[data-tema="ouro"] {
  --bg: #1a1917; --panel: #232220; --panel-2: #2c2a27; --border: #3b3733;
  --text: #f2efe9; --muted: #a29b90;
  --accent: #f5c443; --accent-ink: #1a1917; --accent-text: #f5c443; --accent-2: #ffd977;
  --green: #4fbe85; --red: #f2695f; --yellow: #f5c443;
}
[data-modo="claro"][data-tema="ouro"] {
  --bg: #f8f5ee; --panel: #fffdf8; --panel-2: #f0ebdf; --border: #e2dac9;
  --text: #211f1a; --muted: #7a7264;
  --accent: #e0ac1f; --accent-ink: #211f1a; --accent-text: #8f6708; --accent-2: #f0c14b;
  --green: #12855f; --red: #c0392b; --yellow: #a9761a;
}

/* --- 3. Terminal · grafite frio e esmeralda ------------------------------ */
/* Família Supabase/Vercel: neutro quase preto com um verde só de acento. */
[data-tema="terminal"] {
  --bg: #181a19; --panel: #212423; --panel-2: #2a2e2c; --border: #353a37;
  --text: #e9ede9; --muted: #929c96;
  --accent: #3ecf8e; --accent-ink: #0c1310; --accent-text: #4fdb9c; --accent-2: #2bb5a0;
  --green: #7ad3a4; --red: #f26d6d; --yellow: #e5b95c;
}
[data-modo="claro"][data-tema="terminal"] {
  --bg: #f4f7f5; --panel: #ffffff; --panel-2: #eaf0ec; --border: #d7e1db;
  --text: #14201a; --muted: #5e6f66;
  --accent: #14a172; --accent-ink: #ffffff; --accent-text: #0d7f59; --accent-2: #0f8f8a;
  --green: #12996a; --red: #cf3b45; --yellow: #b08009;
}

/* --- 4. Papel · neutro quente e terracota ------------------------------- */
/* Família Notion: o cinza é quente e a cor entra só onde precisa apontar. */
[data-tema="papel"] {
  --bg: #191715; --panel: #211e1b; --panel-2: #2a2724; --border: #393330;
  --text: #efe9e3; --muted: #a49a90;
  --accent: #e0714a; --accent-ink: #ffffff; --accent-text: #ef8a66; --accent-2: #c95c38;
  --green: #67b98a; --red: #e2565b; --yellow: #dfae5a;
}
[data-modo="claro"][data-tema="papel"] {
  --bg: #faf8f5; --panel: #ffffff; --panel-2: #f2eee8; --border: #e5ded4;
  --text: #1c1815; --muted: #746b60;
  --accent: #c4552c; --accent-ink: #ffffff; --accent-text: #a8451f; --accent-2: #a8451f;
  --green: #12855f; --red: #c0392b; --yellow: #a9761a;
}

/* --- Derivados: saem dos primitivos, iguais em todo tema ---------------- */
/* `color-mix` no lugar de rgba() fixo — é o que permite um tema novo não ter
   que redeclarar dezoito transparências do accent. */
:root {
  --accent-soft:  color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-ring:  color-mix(in srgb, var(--accent) 26%, transparent);
  --accent-faint: color-mix(in srgb, var(--accent) 6%, transparent);
  --green-soft:   color-mix(in srgb, var(--green) 10%, transparent);
  --green-ring:   color-mix(in srgb, var(--green) 45%, transparent);
  --mark:         color-mix(in srgb, var(--yellow) 26%, transparent);
  --mark-active:  color-mix(in srgb, var(--yellow) 55%, transparent);
  --border-hover: color-mix(in srgb, var(--border) 60%, var(--muted));
  --side-w: 216px;
}

/* Sombra, véu e tinta sobre verde dependem da LUZ, não da paleta: no claro a
   sombra preta de 50% que funciona no escuro vira uma mancha. */
[data-modo="escuro"] {
  color-scheme: dark;
  --shadow-1: 0 2px 8px rgba(0, 0, 0, .35);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, .5);
  --shadow-3: 0 24px 60px -20px rgba(0, 0, 0, .7);
  --veil: rgba(0, 0, 0, .6);
  --green-ink: var(--bg);
}
[data-modo="claro"] {
  color-scheme: light;
  --shadow-1: 0 1px 2px rgba(20, 24, 34, .07), 0 3px 10px rgba(20, 24, 34, .06);
  --shadow-2: 0 12px 32px rgba(20, 24, 34, .14);
  --shadow-3: 0 20px 50px -18px rgba(20, 24, 34, .22);
  --veil: rgba(24, 26, 34, .34);
  --green-ink: #ffffff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -------------------------------------------------------------- estrutura --- */
/* A lateral é `fixed` e o conteúdo ganha uma margem do tamanho dela. Assim quem
   rola é o <body> — o drawer, os toasts e o pop-up do quadro continuam se
   posicionando contra a viewport, como sempre fizeram. */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--side-w); z-index: 25;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--border);
  transition: width .16s ease, transform .16s ease;
}
.content { margin-left: var(--side-w); transition: margin-left .16s ease; min-width: 0; }
/* O estado da lateral fica no <html>, não no <body>: o script do <head> escreve
   ele antes do primeiro quadro, e assim a lateral não abre para depois recolher. */
[data-lateral="recolhida"] { --side-w: 66px; }

/* Logo: monograma (arquivo da marca, verde fixo) + a palavra em texto do tema.
   A palavra não sai do PNG de propósito — lá ela é branca e desapareceria nos
   temas claros. O verde do monograma é da marca e não acompanha o tema. */
.logo { display: flex; align-items: center; gap: 10px; padding: 16px; color: var(--text); overflow: hidden; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 38px; height: 38px; flex: 0 0 auto; display: block; }
.logo-words { font-size: 16.5px; font-weight: 650; letter-spacing: -.015em; white-space: nowrap; }
[data-lateral="recolhida"] .logo { padding: 16px 0; justify-content: center; }
[data-lateral="recolhida"] .logo-words { display: none; }

/* Navegação vertical. As classes `.tabs`/`.tab` continuam as mesmas porque o
   app.js liga a view pelo `data-view` — mudou o desenho, não o contrato. */
.tabs { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; overflow-y: auto; flex: 1; }
.tab {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; user-select: none;
  white-space: nowrap; overflow: hidden; border-left: 2px solid transparent;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: var(--text); background: var(--accent-soft); border-left-color: var(--accent); font-weight: 600; }
.tab .ti { flex: 0 0 18px; text-align: center; font-size: 14px; }
[data-lateral="recolhida"] .tab { justify-content: center; padding: 10px 0; border-left: none; }
[data-lateral="recolhida"] .tab .tl { display: none; }

.side-foot { border-top: 1px solid var(--border); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.side-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  background: transparent; border: none; border-radius: 8px; color: var(--muted);
  font-size: 13px; text-align: left; white-space: nowrap; overflow: hidden;
}
.side-btn:hover { background: var(--panel-2); color: var(--text); }
.side-btn .ti { flex: 0 0 18px; text-align: center; font-size: 14px; }
.side-user { display: flex; align-items: center; gap: 8px; padding: 2px 10px 4px; overflow: hidden; }
.side-user .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-lateral="recolhida"] .side-btn { justify-content: center; padding: 10px 0; }
[data-lateral="recolhida"] .side-btn .tl { display: none; }
/* Recolhida esconde o NOME de quem está logado, nunca o "Sair": sumir com a
   saída é o tipo de economia de espaço que faz a pessoa procurar por minutos. */
[data-lateral="recolhida"] .side-user { justify-content: center; padding: 2px 0 4px; }
[data-lateral="recolhida"] .side-user .who { display: none; }

.topbar { display: flex; gap: 10px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 12px; }

/* Botão só de ícone: ☰ da lateral e 🌙/☀️ do modo. */
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--muted); font-size: 15px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--border); }

/* Véu da lateral: só existe na tela estreita, onde a lateral entra por cima. */
.side-veil { position: fixed; inset: 0; background: var(--veil); z-index: 24; display: none; }
[data-lateral="aberta"] .side-veil { display: block; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-2); }
  [data-lateral="aberta"] .sidebar { transform: none; }
  /* Na tela estreita a lateral flutua: o conteúdo não perde largura por causa
     dela, e o estado "recolhido" do desktop não vale aqui. */
  .content, [data-lateral="recolhida"] .content { margin-left: 0; }
  /* "recolhida" pode chegar aqui pela memória de uma sessão no desktop; na tela
     estreita a lateral abre inteira ou não abre, então o estado é desfeito. */
  [data-lateral="recolhida"] .sidebar { --side-w: 216px; width: 216px; }
  [data-lateral="recolhida"] .logo-words, [data-lateral="recolhida"] .tab .tl,
  [data-lateral="recolhida"] .side-btn .tl, [data-lateral="recolhida"] .side-user .who { display: revert; }
  [data-lateral="recolhida"] .logo { padding: 16px; justify-content: flex-start; }
  [data-lateral="recolhida"] .tab, [data-lateral="recolhida"] .side-btn { justify-content: flex-start; padding: 9px 10px; }
  [data-lateral="recolhida"] .side-user { justify-content: flex-start; padding: 2px 10px 4px; }
  [data-lateral="recolhida"] .tab { border-left: 2px solid transparent; }
  [data-lateral="recolhida"] .tab.active { border-left-color: var(--accent); }
}

/* ------------------------------------------------------------ controles --- */
select, input, textarea, button { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 13px; font-family: inherit; }
textarea { width: 100%; resize: vertical; line-height: 1.55; }
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { cursor: pointer; transition: background .15s; }
button:hover { background: var(--border); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }
button.ghost { background: transparent; }
button.danger { color: var(--red); }
button:disabled { opacity: .5; cursor: not-allowed; }

/* Botão ocupado: o rótulo vira "…ando" e ganha um anel girando. O disabled já
   bloqueia o clique repetido; o anel é o que conta que algo está acontecendo. */
button.busy { opacity: 1; cursor: progress; }
.spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: 7px;
  vertical-align: -1px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .sidebar, .content { transition: none; }
}
button.sm { padding: 5px 9px; font-size: 12px; }

/* Link com cara de botão. Serve para o que precisa MESMO ser um <a> — abrir o
   briefing preenchido numa aba nova, por exemplo, onde um <button> perderia o
   "abrir em nova aba" do clique do meio e do menu de contexto. */
.button-ish { display: inline-block; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; font-size: 13px; }
.button-ish:hover { background: var(--border); text-decoration: none; }
/* .field vale para <label> e para <div>: alguns campos são só de leitura e não
   têm controle nenhum para o label apontar. */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field > input, .field > select, .field > textarea { width: 100%; }

/* Campo travado: tem a caixa de um input para alinhar com os vizinhos, mas sem
   cursor de edição — mostra o dado, não pede o dado. */
.locked-field { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --------------------------------------------------------------- layout --- */
.page { padding: 20px; max-width: 1500px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 12px; }
.empty { color: var(--muted); padding: 40px 20px; text-align: center; border: 1px dashed var(--border); border-radius: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.card.clickable { cursor: pointer; transition: border-color .15s, transform .15s; }
.card.clickable:hover { border-color: var(--accent); transform: translateY(-1px); }
.card h3 { margin: 0 0 4px; font-size: 15px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 8px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }
.pill.on { color: var(--green); border-color: var(--green-ring); }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); margin: 2px 4px 2px 0; }

/* -------------------------------------------------------------- tabelas --- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; padding: 10px 12px; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--accent-faint); }
td.actions { white-space: nowrap; text-align: right; }
td [contenteditable] { min-width: 60px; display: block; outline: none; border-radius: 4px; padding: 2px 4px; }
td [contenteditable]:focus { background: var(--panel-2); outline: 1px solid var(--accent); }

/* Checkboxes de status do mini-dash */
.stage { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; user-select: none; width: 62px; }
.stage input { display: none; }
.stage .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-size: 11px; color: transparent; transition: all .15s; }
.stage input:checked + .dot { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.stage .lbl { font-size: 10px; color: var(--muted); }
.stage input:checked ~ .lbl { color: var(--text); }
.stages { display: flex; gap: 2px; }

/* --------------------------------------------------------- pastas COPY --- */
/* Flex, e não grid de colunas iguais, por causa do separador antes do "Desenho":
   num grid auto-fill ele ocuparia uma célula inteira de 150px. O `flex: 1 1 150px`
   das pastas reproduz o comportamento do grid que estava aqui antes. */
.folders { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.folder { flex: 1 1 150px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; cursor: pointer; transition: all .15s; }
.folder:hover { border-color: var(--accent); }
.folder.active { border-color: var(--accent); background: var(--panel-2); }
.folder .icon { font-size: 20px; }
.folder .name { font-weight: 600; margin-top: 6px; }
.folder .count { color: var(--muted); font-size: 12px; }

/* O desenho não é pasta de copy: separador antes dele e borda tracejada. */
.folder-sep { flex: 0 0 1px; align-self: stretch; background: var(--border); margin: 4px 6px; }
.folder.map { border-style: dashed; }
.folder.map.active { border-style: solid; border-color: var(--accent-2); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-2) 25%, transparent); }

/* ------------------------------------------------- desenho do funil (mapa) */
.map-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.map-stamp { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* Toggle "este funil está no ar": pastilha com bolinha, verde quando ligado. */
.running-toggle {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 12px 5px 10px; color: var(--muted); font-size: 12px; font-weight: 600;
}
.running-toggle .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.running-toggle:hover:not(:disabled) { border-color: var(--accent); }
.running-toggle.on { color: var(--green); border-color: var(--green-ring); background: var(--green-soft); }
.running-toggle.on .dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.running-toggle:disabled { cursor: default; opacity: .7; }
.tag.no-ar { color: var(--green); border-color: var(--green-ring); }

/* Ferramenta de texto armada: o botão fica aceso e o quadro vira mira. */
.tool.armed { color: var(--accent-text); border-color: var(--accent); background: var(--accent-soft); }
.map-canvas.armed, .map-canvas.armed .map-inner { cursor: crosshair; }

/* Tela cheia por classe: ver toggleMapFull() — a Fullscreen API esconderia o
   drawer da copy e os toasts, que são filhos do <body>. */
.map-wrap.full {
  position: fixed; inset: 0; z-index: 30; background: var(--bg);
  padding: 14px 18px; display: flex; flex-direction: column;
}
.map-wrap.full .map-area { flex: 1; min-height: 0; }
.map-wrap.full .map-canvas,
.map-wrap.full .map-panel { height: auto; max-height: none; align-self: stretch; }

.map-area { display: flex; gap: 14px; align-items: stretch; }
.map-canvas {
  flex: 1; min-width: 0; height: 62vh; min-height: 380px; overflow: auto;
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel);
  /* A grade dá referência de alinhamento sem precisar de régua nem de snap. */
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 22px 22px;
  cursor: grab;
}
.map-canvas.panning { cursor: grabbing; user-select: none; }
.map-inner { position: relative; }
.map-inner.linking { cursor: crosshair; }
.map-edges { position: absolute; inset: 0; pointer-events: none; }
.map-empty { position: absolute; left: 24px; top: 24px; max-width: 420px; color: var(--muted); font-size: 13px; line-height: 1.6; }

.edge { pointer-events: auto; cursor: pointer; }
.edge .hit { fill: none; stroke: transparent; stroke-width: 16px; }
.edge .line { fill: none; stroke: var(--muted); stroke-width: 1.6px; }
.edge:hover .line { stroke: var(--text); }
.edge.sel .line { stroke: var(--accent); stroke-width: 2.2px; }
.edge .lbl { fill: var(--text); font-size: 11px; }
.edge .lbl-bg { fill: var(--panel-2); stroke: var(--border); }
.edge-temp { fill: none; stroke: var(--accent); stroke-width: 1.8px; stroke-dasharray: 5 4; }

.map-node {
  position: absolute; width: 190px; background: var(--panel-2);
  border: 1px solid var(--border); border-left: 3px solid var(--muted);
  border-radius: 8px; padding: 9px 10px; cursor: grab; user-select: none;
  font-size: 12px; box-shadow: var(--shadow-1);
}
.map-node:hover { border-color: var(--accent); }
.map-node.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring), var(--shadow-1); }
.map-node.dragging { cursor: grabbing; opacity: .9; }
.mn-head { display: flex; gap: 6px; align-items: baseline; }
.mn-icon { font-size: 14px; }
.mn-label { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.mn-kind { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.mn-notes { color: var(--muted); font-size: 11px; margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mn-copies { display: flex; flex-direction: column; gap: 3px; margin-top: 7px; }
.mn-copies.vazio { color: var(--muted); font-size: 10px; font-style: italic; }
.mn-chip {
  display: flex; gap: 4px; align-items: center; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: 4px;
  padding: 3px 5px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mn-chip:hover { border-color: var(--accent); color: var(--accent-text); }
.mn-chip.on { border-color: var(--green-ring); }
.mn-chip .ci { flex: 0 0 auto; }

/* Botão de destino: o endereço fica só no title, nunca na caixa. */
.mn-go {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 7px;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
  border-radius: 5px; padding: 4px 8px; font-size: 11px; font-weight: 600;
}
.mn-go:hover { filter: brightness(1.12); text-decoration: none; }

/* ------------------------------------------------- texto solto no quadro --- */
.map-text {
  position: absolute; max-width: 460px; min-width: 40px; border-radius: 6px;
  padding: 4px 7px; color: var(--text); line-height: 1.35; cursor: grab;
  border: 1px dashed transparent;
}
.map-text:hover { border-color: var(--border); }
.map-text.sel { border-color: var(--accent); border-style: solid; cursor: text; }
.map-text.dragging { cursor: grabbing; opacity: .9; }
/* Texto com cor de fundo escolhida: as opções do seletor são todas escuras e
   ficam salvas no banco, então a tinta é clara mesmo no tema claro — senão o
   texto desapareceria dentro do próprio destaque. */
.map-text:not(.transparente) { color: #f2f3f7; }
.mt-body { outline: none; white-space: pre-wrap; overflow-wrap: anywhere; min-width: 30px; min-height: 1.2em; }
/* Texto recém-criado é uma caixa vazia — sem a dica, some no quadro. */
.mt-body:empty::before { content: attr(data-placeholder); color: var(--muted); font-style: italic; }
.map-text:not(.transparente) .mt-body:empty::before { color: rgba(242, 243, 247, .6); }

.cor-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.cor { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; padding: 0; }
.cor.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
/* Xadrez: é como se mostra "sem cor" sem escrever "sem cor". */
.cor.transp {
  background-color: var(--panel);
  background-image:
    linear-gradient(45deg, var(--border) 25%, transparent 25%, transparent 75%, var(--border) 75%),
    linear-gradient(45deg, var(--border) 25%, transparent 25%, transparent 75%, var(--border) 75%);
  background-size: 10px 10px;
  background-position: 0 0, 5px 5px;
}

/* A bolinha de ligar fica na borda direita, meio da caixa. */
.mn-port {
  position: absolute; right: -7px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--muted); cursor: crosshair;
}
.mn-port:hover { border-color: var(--accent); background: var(--accent); }

/* Cor da borda esquerda por grupo de etapa: entrada, destino, venda,
   acompanhamento e marco. É o que deixa o funil legível de relance. */
.kind-trafego, .kind-organico, .kind-lista { border-left-color: var(--yellow); }
.kind-pagina, .kind-vsl, .kind-webinar, .kind-formulario { border-left-color: var(--accent); }
.kind-checkout, .kind-upsell, .kind-downsell, .kind-obrigado { border-left-color: var(--green); }
.kind-email, .kind-whatsapp, .kind-call { border-left-color: var(--accent-2); }
.kind-compra { border-left-color: var(--green); }
.kind-decisao { border-left-color: var(--red); }
.kind-nota { border-left-color: var(--muted); border-style: dashed; }

.map-panel {
  flex: 0 0 288px; align-self: stretch; overflow-y: auto; max-height: 62vh;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
}
.map-panel h3 { margin: 0 0 8px; font-size: 14px; }
.map-panel .field { margin-bottom: 8px; }
.map-help { padding-left: 16px; line-height: 1.7; }
.map-help li { margin-bottom: 2px; }
.mp-block { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
.mp-title { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.mp-list { display: flex; flex-direction: column; gap: 4px; }
.mp-copy { display: flex; gap: 6px; align-items: center; font-size: 12px; }
.mp-copy a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; margin-bottom: 12px; }
.kind-opt {
  display: flex; gap: 5px; align-items: center; font-size: 12px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 7px 8px;
}
.kind-opt:hover { border-color: var(--accent); }
.kind-opt.sel { border-color: var(--accent); background: var(--accent-soft); }

/* Pop-up de resumo da copy. `fixed` porque o canvas tem overflow: auto — dentro
   dele, o pop-up seria cortado na borda. */
.map-tip {
  position: fixed; z-index: 45; display: none; width: 320px;
  background: var(--panel-2); border: 1px solid var(--accent); border-radius: 8px;
  padding: 10px 12px; font-size: 12px; box-shadow: var(--shadow-2);
}
.map-tip.open { display: block; }
.tp-head { font-weight: 600; margin-bottom: 4px; }
.tp-angle { color: var(--muted); font-style: italic; margin-bottom: 6px; }
.tp-stages { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 7px; }
.tp-stage { font-size: 10px; padding: 2px 6px; border-radius: 20px; background: var(--panel); border: 1px solid var(--border); color: var(--muted); }
.tp-stage.on { color: var(--green); border-color: var(--green-ring); }
.tp-preview {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.5;
  background: var(--bg); border: 1px solid var(--border); border-radius: 5px; padding: 7px 8px;
  max-height: 92px; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere;
}
.tp-preview.vazio { font-style: italic; color: var(--muted); font-family: inherit; }
.tp-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: 10px; margin-top: 7px; }
.tp-hint { color: var(--accent-text); font-size: 10px; margin-top: 6px; }

@media (max-width: 900px) {
  .map-area { flex-direction: column; }
  .map-panel { flex: 1 1 auto; max-height: none; }
}

/* --------------------------------------------------------------- drawer --- */
.drawer-backdrop { position: fixed; inset: 0; background: var(--veil); z-index: 40; display: none; }
.drawer-backdrop.open { display: block; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(820px, 100%); background: var(--bg); border-left: 1px solid var(--border); z-index: 41; transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--panel); }
.drawer header h2 { margin: 0; font-size: 15px; flex: 1; }
.drawer .body { padding: 18px; overflow-y: auto; flex: 1; }
.drawer footer { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--panel); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* ------------------------------------------------- editor + comentários --- */
.editor-area { display: flex; gap: 14px; align-items: flex-start; }
.editor-wrap { position: relative; flex: 1; min-width: 0; background: var(--panel-2); border-radius: 6px; }

/* O grifo é uma camada atrás do textarea com o MESMO texto e a MESMA métrica.
   Qualquer diferença de fonte, padding, borda ou entrelinha desalinha o grifo
   do texto — por isso as duas regras abaixo andam juntas e devem mudar juntas. */
.editor, .highlight-layer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; line-height: 1.55; letter-spacing: normal;
  padding: 8px 10px; border: 1px solid transparent; border-radius: 6px;
  white-space: pre-wrap; overflow-wrap: break-word;
}
.editor { position: relative; z-index: 1; width: 100%; min-height: 55vh; display: block; background: transparent; border-color: var(--border); }
.highlight-layer {
  position: absolute; inset: 0; overflow: hidden;
  color: transparent;          /* o texto de verdade é o do textarea, aqui só o fundo importa */
  pointer-events: none;        /* o clique é sempre do textarea, para o cursor cair onde a pessoa clicou */
}
.highlight-layer mark { background: var(--mark); color: transparent; border-radius: 2px; }
.highlight-layer mark.active { background: var(--mark-active); }

.comments-col { width: 268px; flex: none; max-height: 60vh; overflow-y: auto; }
.comment-card { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--yellow); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: pointer; }
.comment-card.active { border-color: var(--accent); border-left-color: var(--accent); }
.comment-card.resolved { border-left-color: var(--border); opacity: .7; }
.comment-card.composer { cursor: default; border-left-color: var(--accent); }
.comment-card .quote { font-size: 11px; color: var(--muted); border-left: 2px solid var(--border); padding-left: 7px; margin-bottom: 6px; font-style: italic; }
.comment-card .quote.orphan { color: var(--red); border-left-color: var(--red); font-style: normal; }
.comment-card .text { font-size: 12.5px; white-space: pre-wrap; overflow-wrap: break-word; margin-top: 4px; }
.comment-card .reply { margin-top: 8px; padding-left: 9px; border-left: 2px solid var(--border); }
.reply-box { margin-top: 8px; }
.resolved-block { margin-top: 10px; }
.resolved-block summary { cursor: pointer; padding: 4px 0; }

/* Links de referência da copy */
.links-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.link-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 20px; padding: 3px 4px 3px 10px; font-size: 12px; max-width: 320px; }
.link-chip a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-chip .link-del { background: none; border: none; color: var(--muted); padding: 0 6px; font-size: 15px; line-height: 1; }
.link-chip .link-del:hover { color: var(--red); background: none; }

/* Numa tela estreita a coluna de comentários vai para baixo do texto: espremer
   os dois lado a lado deixaria os dois ruins. */
@media (max-width: 900px) {
  .editor-area { flex-direction: column; }
  .comments-col { width: 100%; max-height: none; }
}

/* --------------------------------------------------------------- modais --- */
.modal-backdrop { position: fixed; inset: 0; background: var(--veil); z-index: 50; display: none; place-items: center; padding: 20px; }
.modal-backdrop.open { display: grid; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; width: min(760px, 100%); max-height: 88vh; overflow-y: auto; padding: 20px; box-shadow: var(--shadow-2); }
.modal h2 { margin: 0 0 14px; font-size: 16px; }

/* ------------------------------------------------------------ aparência --- */
/* Cada cartão do seletor carrega o próprio data-tema/data-modo, então a amostra
   é pintada pelos MESMOS tokens do topo deste arquivo — nenhum hexadecimal do
   tema é repetido no JavaScript. */
.tema-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tema-opt {
  display: block; width: 100%; text-align: left; padding: 0; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
.tema-opt:hover { border-color: var(--accent); background: var(--panel); }
.tema-opt.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
/* A amostra herda os tokens do tema do cartão, não os da página. */
.tema-demo { background: var(--bg); border-bottom: 1px solid var(--border); padding: 10px; display: flex; gap: 8px; align-items: center; }
/* Bolinha no lugar do antigo "C": a amostra existe para mostrar o accent do
   tema, e desde que o logo virou monograma verde fixo, uma letra ali dava a
   entender que a marca mudaria de cor junto com o tema. */
.tema-demo .demo-c { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-text); flex: 0 0 auto; }
.tema-demo .demo-lines { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.tema-demo .demo-lines i { display: block; height: 6px; border-radius: 3px; background: var(--panel-2); }
.tema-demo .demo-lines i:first-child { width: 70%; background: var(--text); opacity: .75; }
.tema-demo .demo-btn { width: 26px; height: 16px; border-radius: 4px; background: var(--accent); }
.tema-nome { display: block; padding: 9px 11px; font-size: 13px; font-weight: 600; color: var(--text); }
.tema-nome small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Escolha do modo: dois botões colados, o ativo com o accent. */
.modo-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.modo-switch button { background: transparent; border: none; border-radius: 0; padding: 7px 14px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.modo-switch button:hover { background: var(--panel-2); color: var(--text); }
.modo-switch button.sel { background: var(--accent); color: var(--accent-ink); }

/* ------------------------------------------------------ envio de arquivo --- */
/* É um <label> com o input dentro: o clique em qualquer ponto da área abre o
   seletor sem uma linha de JavaScript, e o teclado continua chegando ao input. */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 26px 20px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border); border-radius: 12px; background: var(--panel-2);
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone input[type="file"] { display: none; }
.dropzone .dz-icon { font-size: 26px; line-height: 1; }
/* Arquivo por cima da área: a borda fecha e acende, para não haver dúvida de
   onde soltar. */
.dropzone.sobre { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.dropzone.lendo { cursor: progress; border-color: var(--accent); }
.dropzone.pronto { border-style: solid; border-color: var(--green-ring); background: var(--green-soft); }
.dz-estado { color: var(--accent-text); min-height: 16px; }
.dropzone.pronto .dz-estado { color: var(--green); }

/* ------------------------------------------ swipe files e referências --- */
/* As duas abas usam o mesmo cartão: capa em cima, dados embaixo. Só o que vai
   dentro do `.meta` muda — no swipe são título e tags, na referência são os
   campos da planilha, editáveis no lugar. */
.video-grid, .ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.video-card, .ref-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.ref-card { display: flex; flex-direction: column; }
.ref-card .meta { padding: 12px; display: flex; flex-direction: column; flex: 1; }
.ref-card h4 { margin: 0 0 10px; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }

/* Campo da planilha: rótulo pequeno em cima, valor editável embaixo. Duas linhas
   em vez de lado a lado porque o rótulo vem da planilha e pode ser longo. */
.ref-field { margin-bottom: 8px; }
.ref-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.ref-label a { font-size: 12px; letter-spacing: normal; }
.ref-value { font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; border-radius: 4px; padding: 2px 4px; margin-left: -4px; outline: none; }
.ref-value:hover { background: var(--panel-2); }
.ref-value:focus { background: var(--panel-2); outline: 1px solid var(--accent); }
/* Campo vazio precisa de um alvo de clique: sem o traço, a caixa tem altura zero. */
.ref-value.vazio:empty::before, .ref-card h4.vazio:empty::before { content: attr(data-placeholder); color: var(--muted); font-style: italic; }

/* Os campos em branco ficam guardados: uma planilha larga faria cada card virar
   uma coluna de traços, e o que interessa é o que está preenchido. */
.ref-vazios { margin: 2px 0 4px; }
.ref-vazios summary { cursor: pointer; font-size: 11px; color: var(--muted); padding: 3px 0; }
.ref-vazios summary:hover { color: var(--text); }
.ref-vazios[open] { border-left: 2px solid var(--border); padding-left: 8px; margin-top: 6px; }
/* A linha de ações cola no pé do card para os cartões da fileira terminarem
   alinhados, mesmo com quantidades diferentes de campo preenchido. */
.ref-card .meta > .row:last-child { margin-top: auto; padding-top: 10px; }
.video-frame { aspect-ratio: 16/9; background: #000; display: grid; place-items: center; }
.video-frame iframe, .video-frame video { width: 100%; height: 100%; border: 0; display: block; }
.video-frame.vertical { aspect-ratio: 9/16; max-height: 520px; }
.video-card .meta { padding: 12px; }
.video-card .meta h4 { margin: 0 0 6px; font-size: 14px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--border); padding: 11px 18px; border-radius: 8px; z-index: 100; box-shadow: var(--shadow-2); }
.toast.err { border-color: var(--red); color: var(--red); }
.toast.ok { border-color: var(--green); }

.breadcrumb { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.breadcrumb b { color: var(--text); }
