/* ==========================================================================
   Nexos — Mapa de ideias (canvas infinito) · prefixo .cnv-
   Só variáveis de tokens.css. --inv = 1/zoom (mantém alças e rótulos no
   mesmo tamanho na tela, qualquer que seja o zoom).
   ========================================================================== */

.cnv-root { --inv: 1; position: relative; height: 100%; min-height: 0; overflow: hidden; user-select: none; -webkit-user-select: none; container-type: size; container-name: cnvroot; }
/* telas baixas (janela pequena, celular deitado): sem minimapa para não cobrir o mapa */
@container cnvroot (max-height: 480px) { .cnv-mini { display: none; } }
@container cnvroot (max-height: 600px) {
  .cnv-empty-wrap { place-items: start center; overflow-y: auto; padding-top: 68px; padding-bottom: 76px; }
  .cnv-empty-art { display: none; }
}

/* ---- Palco e mundo ---- */
.cnv-stage {
  position: absolute; inset: 0; overflow: hidden; outline: none;
  touch-action: none; -webkit-touch-callout: none;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dot) 1.15px, transparent 1.65px);
  background-size: 24px 24px;
  cursor: default;
  transition: box-shadow .15s;
}
.cnv-stage:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: -3px; border-radius: 0; }
.cnv-root[data-tool="hand"] .cnv-stage { cursor: grab; }
.cnv-root[data-tool="sticky"] .cnv-stage,
.cnv-root[data-tool="frame"] .cnv-stage,
.cnv-root[data-tool="connect"] .cnv-stage { cursor: crosshair; }
.cnv-root[data-tool="text"] .cnv-stage { cursor: text; }
.cnv-root.cnv-space .cnv-stage, .cnv-root.cnv-space .cnv-stage * { cursor: grab !important; }
.cnv-root.cnv-panning .cnv-stage, .cnv-root.cnv-panning .cnv-stage * { cursor: grabbing !important; }
.cnv-root.cnv-drop-on .cnv-stage { box-shadow: inset 0 0 0 3px var(--accent-ring); }

.cnv-world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }
.cnv-moving .cnv-world { will-change: transform; }
.cnv-frames, .cnv-nodes, .cnv-labels { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.cnv-svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }

/* ---- Nós (base) ---- */
.cnv-node { position: absolute; left: 0; top: 0; border-radius: var(--r-lg); outline: none; }
.cnv-k-item, .cnv-k-sticky, .cnv-k-text { cursor: grab; }
.cnv-node.is-dragging { cursor: grabbing; }
.cnv-node.is-new { animation: cnvPop .46s var(--spring) both; animation-delay: var(--d, 0ms); }
/* tempo real: nó mexido por outra pessoa desliza até a nova posição e brilha de leve */
.cnv-node.cnv-glide { transition: transform .38s var(--ease), width .38s var(--ease), height .38s var(--ease); }
.cnv-node.cnv-remote::after {
  content: ""; position: absolute; inset: calc(-4px * var(--inv, 1)); border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 calc(2px * var(--inv, 1)) color-mix(in srgb, var(--info) 60%, transparent);
  animation: cnvRemote 1.6s var(--ease) forwards;
}
@keyframes cnvRemote { 0%, 30% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cnv-node.cnv-glide { transition: none; } .cnv-node.cnv-remote::after { animation: none; opacity: 0; } }
.cnv-node.is-sel { outline: calc(2px * var(--inv)) solid var(--accent); outline-offset: calc(3px * var(--inv)); }
.cnv-node:focus-visible { outline: calc(2px * var(--inv)) solid var(--accent-ring); outline-offset: calc(3px * var(--inv)); border-radius: var(--r-lg); }
.cnv-node.is-sel:focus-visible { outline-color: var(--accent); }
.cnv-node.is-target { outline: calc(2.5px * var(--inv)) dashed var(--accent); outline-offset: calc(5px * var(--inv)); }
.cnv-node.is-source { outline: calc(2.5px * var(--inv)) solid var(--accent); outline-offset: calc(4px * var(--inv)); animation: cnvSource 1.3s ease-in-out infinite; }
.cnv-k-frame, .cnv-k-frame:focus-visible { border-radius: var(--r-xl); }
.cnv-k-frame.is-sel { outline-offset: calc(2px * var(--inv)); }

/* ---- Cartão de item ---- */
.cnv-card {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 7px;
  padding: 12px 14px; border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s;
}
.cnv-k-item:not(.cnv-plain) .cnv-card { background: var(--c-bg); color: var(--c-ink); border-color: color-mix(in srgb, var(--c-s) 24%, transparent); }
.cnv-k-item:hover .cnv-card { box-shadow: var(--shadow); border-color: var(--border-2); }
.cnv-k-item:not(.cnv-plain):hover .cnv-card { border-color: color-mix(in srgb, var(--c-s) 48%, transparent); }
.cnv-node.is-dragging .cnv-card,
.cnv-node.is-dragging .cnv-sticky { box-shadow: var(--shadow-lg); transform: rotate(-.8deg) scale(1.02); }
.cnv-node.is-resizing .cnv-card { transition: none; }

.cnv-top { display: flex; align-items: center; gap: 5px; min-height: 16px; font-size: 11px; font-weight: 600; line-height: 1; color: var(--text-3); flex-shrink: 0; }
.cnv-k-item:not(.cnv-plain) .cnv-top { color: color-mix(in srgb, var(--c-ink) 68%, transparent); }
.cnv-top svg.lucide { width: 13px; height: 13px; }
.cnv-type { white-space: nowrap; }
.cnv-sp { flex: 1; min-width: 0; }
.cnv-lock { display: inline-flex; color: var(--accent); }
.cnv-tag {
  max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 3px 7px; border-radius: var(--r-full); font-size: 10.5px;
  background: color-mix(in srgb, var(--surface) 58%, transparent);
}
.cnv-plain .cnv-tag { background: var(--surface-3); }
.cnv-links { display: inline-flex; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }
.cnv-links svg.lucide { width: 12px; height: 12px; }

.cnv-title {
  flex-shrink: 0; font-weight: 650; font-size: 14.5px; line-height: 1.32; letter-spacing: -.005em; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.cnv-emoji { margin-right: 5px; }
.cnv-title.is-done { text-decoration: line-through; opacity: .55; }
.cnv-ex {
  flex: 1; min-height: 0; overflow: hidden;
  font-size: 12.8px; line-height: 1.5; color: var(--text-2);
  -webkit-mask-image: linear-gradient(180deg, var(--text) 55%, transparent); mask-image: linear-gradient(180deg, var(--text) 55%, transparent);
}
.cnv-k-item:not(.cnv-plain) .cnv-ex { color: color-mix(in srgb, var(--c-ink) 80%, transparent); }

/* tarefa */
.cnv-task { display: flex; align-items: flex-start; gap: 9px; min-height: 0; }
.cnv-task .check { margin-top: 1px; }
.cnv-task .cnv-title { -webkit-line-clamp: 2; }
.cnv-k-item:not(.cnv-plain) .check:not(.on) { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.cnv-meta { display: flex; align-items: center; gap: 6px; margin-top: auto; min-width: 0; font-size: 12px; color: var(--text-2); }
.cnv-meta .chip { flex-shrink: 0; }
.cnv-doing { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }

/* lista */
.cnv-checks { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 1px; }
.cnv-ck {
  display: flex; align-items: center; gap: 8px; width: calc(100% + 8px); min-height: 24px;
  margin: 0 -4px; padding: 2px 4px; border-radius: 6px; text-align: left;
  font-size: 12.8px; color: inherit; cursor: pointer; transition: background var(--dur);
}
.cnv-ck:hover { background: var(--hover); }
.cnv-k-item:not(.cnv-plain) .cnv-ck:hover { background: color-mix(in srgb, var(--surface) 55%, transparent); }
.cnv-ck-box { width: 14px; height: 14px; flex-shrink: 0; border-radius: 4px; border: 1.6px solid currentColor; opacity: .6; display: grid; place-items: center; }
.cnv-ck.done { opacity: .55; }
.cnv-ck.done .truncate { text-decoration: line-through; }
.cnv-ck.done .cnv-ck-box { background: currentColor; opacity: .85; }
.cnv-ck.done .cnv-ck-box::after { content: ""; width: 3px; height: 6px; margin-top: -1px; border: solid var(--c-bg, var(--surface)); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); }
.cnv-more { padding-left: 22px; font-size: 11.5px; opacity: .7; }
.cnv-prog { display: flex; align-items: center; gap: 8px; margin-top: auto; flex-shrink: 0; font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.cnv-k-item:not(.cnv-plain) .cnv-prog .progress { background: color-mix(in srgb, var(--surface) 60%, transparent); }
.cnv-prog-goal .progress { height: 8px; }

/* link, evento, imagem */
.cnv-link {
  display: flex; align-items: center; gap: 7px; min-width: 0; margin-top: auto; flex-shrink: 0;
  padding: 7px 9px; border-radius: var(--r-sm); font-size: 12px;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.cnv-plain .cnv-link { background: var(--surface-3); color: var(--text-2); }
.cnv-link svg.lucide { width: 13px; height: 13px; flex-shrink: 0; }
.cnv-link .truncate { flex: 1; }
.cnv-event { display: flex; align-items: center; gap: 11px; flex: 1; min-height: 0; }
.cnv-event .cnv-title { -webkit-line-clamp: 2; font-size: 14px; }
.cnv-date {
  width: 42px; height: 46px; flex-shrink: 0; border-radius: var(--r-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.cnv-date span { font-size: 10px; font-weight: 750; text-transform: uppercase; color: var(--accent); }
.cnv-date b { font-size: 17px; color: var(--text); }
.cnv-sub { margin-top: 2px; font-size: 12px; color: var(--text-3); }
.cnv-image {
  flex: 1; min-height: 0; border-radius: var(--r-sm); display: grid; place-items: center; font-size: 44px;
  background: linear-gradient(135deg, var(--c-bg, var(--surface-3)), color-mix(in srgb, var(--c-s, var(--accent)) 30%, var(--surface)));
}

/* zoom semântico: abaixo de 50% os itens viram pílulas */
.cnv-pill { display: none; }
.cnv-far .cnv-k-item .cnv-card { display: none; }
.cnv-far .cnv-k-item .cnv-pill {
  position: absolute; inset: 0; overflow: hidden;
  display: flex; flex-direction: row; align-items: center; justify-content: center; text-align: left;
  gap: min(calc(5px * var(--inv)), 18px); padding: calc(4px * var(--inv)) calc(7px * var(--inv));
  border-radius: calc(var(--r-lg) * 2.4);
  background: var(--surface); color: var(--text);
  border: calc(1.5px * var(--inv)) solid var(--border-2); box-shadow: var(--shadow);
}
.cnv-far .cnv-k-item:not(.cnv-plain) .cnv-pill { background: var(--c-bg); color: var(--c-ink); border-color: color-mix(in srgb, var(--c-s) 55%, transparent); }
.cnv-far .cnv-k-item.cnv-tall .cnv-pill { flex-direction: column; text-align: center; }
.cnv-far .cnv-k-item:not(.cnv-tall) .cnv-pill-t { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.cnv-pill-e { flex-shrink: 0; font-size: min(calc(20px * var(--inv)), 70px); line-height: 1; }
.cnv-pill-i { display: inline-grid; place-items: center; color: inherit; opacity: .8; }
.cnv-pill-i svg.lucide { width: min(calc(20px * var(--inv)), 66px) !important; height: min(calc(20px * var(--inv)), 66px) !important; }
.cnv-pill-t {
  min-width: 0; max-width: 100%; font-weight: 700; font-size: min(calc(12.5px * var(--inv)), 42px); line-height: 1.15; overflow-wrap: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---- Nota adesiva ---- */
.cnv-sticky {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: 16px 16px 16px; border-radius: var(--r-xs) var(--r-xs) var(--r-lg) var(--r-xs);
  background: linear-gradient(172deg, color-mix(in srgb, var(--c-s) 16%, var(--c-bg)) 0%, var(--c-bg) 46%);
  color: var(--c-ink);
  box-shadow: var(--shadow-sm), 0 8px 18px -10px color-mix(in srgb, var(--c-s) 70%, transparent);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.cnv-sticky::before {
  content: ""; position: absolute; top: -7px; left: 50%; width: 46px; height: 15px; margin-left: -23px;
  border-radius: 3px; rotate: -3deg; pointer-events: none;
  background: color-mix(in srgb, var(--surface) 55%, transparent); box-shadow: var(--shadow-sm);
}
.cnv-k-sticky:hover .cnv-sticky { box-shadow: var(--shadow), 0 10px 22px -10px color-mix(in srgb, var(--c-s) 75%, transparent); }
.cnv-sticky-text {
  flex: 1; min-height: 0; overflow: hidden; outline: none; cursor: inherit;
  font-size: 15px; font-weight: 550; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}
.cnv-sticky-text:empty::before, .cnv-textbox:empty::before { content: attr(data-ph); opacity: .45; pointer-events: none; }
.cnv-far .cnv-sticky-text { font-size: min(calc(15px * var(--inv) * .7), 34px); line-height: 1.25; }

/* ---- Texto livre ---- */
.cnv-textbox {
  position: absolute; inset: 0; overflow: hidden; outline: none; cursor: inherit;
  padding: 4px 6px; border-radius: var(--r-sm);
  font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1.22; letter-spacing: -.015em;
  color: var(--text); white-space: pre-wrap; word-break: break-word;
  transition: background var(--dur), box-shadow var(--dur);
}
.cnv-k-text:not(.cnv-plain) .cnv-textbox { color: var(--c-ink); }
.cnv-k-text:hover .cnv-textbox { background: var(--hover); }
.cnv-k-text.is-editing .cnv-textbox { background: color-mix(in srgb, var(--surface) 72%, transparent); box-shadow: inset 0 0 0 1.5px var(--accent-ring); }

.is-editing .cnv-sticky-text, .is-editing .cnv-textbox, .is-editing .cnv-frame-title { cursor: text; user-select: text; -webkit-user-select: text; }

/* ---- Ilha (frame) ---- */
.cnv-frame {
  position: absolute; inset: 0; border-radius: var(--r-xl);
  background: color-mix(in srgb, var(--c-bg) 62%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--c-s) 26%, transparent);
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.cnv-k-frame.is-drop .cnv-frame {
  background: color-mix(in srgb, var(--c-bg) 92%, transparent); border-color: var(--c-s);
  box-shadow: 0 0 0 calc(4px * var(--inv)) color-mix(in srgb, var(--c-s) 22%, transparent);
}
.cnv-frame-head { position: absolute; left: 0; right: 0; top: 0; height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 14px; cursor: grab; min-width: 0; }
.cnv-frame-title {
  display: inline-block; max-width: 100%; min-width: 24px; padding: 5px 12px;
  border-radius: var(--r-full); outline: none;
  font-weight: 700; font-size: 15px; line-height: 1.3; color: var(--c-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--surface) 72%, transparent); box-shadow: var(--shadow-sm);
}
.cnv-k-frame.is-editing .cnv-frame-title { box-shadow: 0 0 0 2px var(--accent-ring); background: var(--surface); text-overflow: clip; }
.cnv-frame-count {
  flex-shrink: 0; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--r-full);
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--c-ink);
  background: color-mix(in srgb, var(--surface) 50%, transparent);
}
.cnv-frame-count:empty { display: none; }
.cnv-far .cnv-frame { background: color-mix(in srgb, var(--c-bg) 86%, transparent); border-width: calc(1.5px * var(--inv)); }
.cnv-far .cnv-frame-head { top: auto; right: auto; bottom: 100%; height: auto; padding: 0 0 calc(7px * var(--inv)) calc(4px * var(--inv)); }
.cnv-far .cnv-frame-title {
  max-width: none; padding: 0; background: none; box-shadow: none; color: var(--text);
  font-family: var(--font-display); font-weight: 650; font-size: min(calc(17px * var(--inv)), 66px);
}
.cnv-far .cnv-frame-count { display: none; }

/* ---- Bolinhas de conexão e alça de tamanho ---- */
.cnv-port {
  position: absolute; z-index: 3; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow-sm);
  opacity: 0; pointer-events: none; cursor: crosshair;
  transform: scale(calc(var(--inv) * .5));
  transition: opacity .15s, transform .2s var(--spring), background .15s;
}
.cnv-port::before { content: ""; position: absolute; inset: -9px; border-radius: 50%; }
.cnv-port-t { left: 50%; top: 0; }
.cnv-port-r { left: 100%; top: 50%; }
.cnv-port-b { left: 50%; top: 100%; }
.cnv-port-l { left: 0; top: 50%; }
.cnv-port:hover { background: var(--accent); }
@media (hover: hover) {
  .cnv-node:hover > .cnv-port { opacity: 1; pointer-events: auto; transform: scale(var(--inv)); }
}
@media (hover: none) {
  .cnv-node.is-sel > .cnv-port { opacity: 1; pointer-events: auto; transform: scale(calc(var(--inv) * 1.3)); }
}
.cnv-busy .cnv-port, .cnv-editing .cnv-port, .cnv-multi .cnv-port { opacity: 0 !important; pointer-events: none !important; }

.cnv-resize {
  position: absolute; z-index: 4; left: 100%; top: 100%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  display: none; border-radius: 4px; background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow-sm);
  cursor: nwse-resize; transform: scale(var(--inv));
}
.cnv-resize::before { content: ""; position: absolute; inset: -8px; }
.cnv-node.is-sel > .cnv-resize { display: block; }
.cnv-multi .cnv-resize, .cnv-editing .cnv-resize { display: none !important; }
@media (hover: none) { .cnv-resize { transform: scale(calc(var(--inv) * 1.4)); } }

/* ---- Fios ---- */
.cnv-ehit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.cnv-epath {
  fill: none; stroke: color-mix(in srgb, var(--text-3) 82%, transparent); stroke-width: 2; stroke-linecap: round;
  transition: stroke .15s, stroke-width .15s;
}
.cnv-edge:hover .cnv-epath { stroke: var(--text-2); }
.cnv-edge.by-claude .cnv-epath { stroke: color-mix(in srgb, var(--accent) 55%, var(--text-3)); }
.cnv-edge.is-sel .cnv-epath { stroke: var(--accent); stroke-width: 2.6; }
.cnv-edge.is-fresh .cnv-epath { stroke-dasharray: 1; stroke-dashoffset: 1; animation: cnvDraw .6s var(--ease) forwards; }
.cnv-arrow path { fill: color-mix(in srgb, var(--text-3) 82%, transparent); }
.cnv-arrow.sel path, .cnv-arrow.wire path { fill: var(--accent); }
.cnv-wire { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 6 6; animation: cnvDash .6s linear infinite; }
.cnv-far .cnv-epath { stroke-width: calc(1.5px * var(--inv)); }
.cnv-far .cnv-edge.is-sel .cnv-epath { stroke-width: calc(2.2px * var(--inv)); }
.cnv-far .cnv-ehit { stroke-width: calc(14px * var(--inv)); }
.cnv-far .cnv-wire { stroke-width: calc(2.2px * var(--inv)); }

.cnv-elabel {
  position: absolute; z-index: 2; width: max-content; max-width: 220px;
  transform: translate(-50%, -50%) scale(var(--inv));
  padding: 3px 10px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.cnv-elabel:hover { border-color: var(--border-2); color: var(--text); }
.cnv-elabel.is-sel { border-color: var(--accent); color: var(--accent-ink); }
.cnv-elabel.is-ph { border-style: dashed; background: var(--surface-2); color: var(--text-3); }
.cnv-far .cnv-elabel:not(.is-sel) { display: none; }
.cnv-label-input {
  position: absolute; z-index: 9; width: 190px; height: 32px; padding: 0 12px;
  transform: translate(-50%, -50%) scale(var(--inv));
  border-radius: var(--r-full); border: 1.5px solid var(--accent); outline: none;
  background: var(--surface); color: var(--text); text-align: center;
  font: 600 12.5px var(--font-ui); box-shadow: 0 0 0 3px var(--accent-ring), var(--shadow);
  user-select: text; -webkit-user-select: text;
}

/* ---- Sugestões do Claude: arestas-fantasma ---- */
.cnv-gpath {
  fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 7 7;
  animation: cnvDash 1s linear infinite, cnvBreath 1.9s ease-in-out infinite;
}
.cnv-far .cnv-gpath { stroke-width: calc(2.2px * var(--inv)); }
.cnv-glabel {
  position: absolute; z-index: 6; display: flex; align-items: center; gap: 6px; width: max-content; max-width: 300px;
  transform: translate(-50%, -50%) scale(var(--inv));
  padding: 4px 4px 4px 10px; border-radius: var(--r-full);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border: 1.5px dashed color-mix(in srgb, var(--accent) 62%, transparent);
  box-shadow: var(--shadow), 0 6px 18px color-mix(in srgb, var(--accent) 14%, transparent);
  font-size: 12px; font-weight: 600; color: var(--accent-ink); cursor: default;
}
.cnv-glabel.is-in { animation: cnvGIn .4s var(--spring) both; animation-delay: var(--d, 0ms); }
.cnv-glabel.is-existing { border-style: dotted; }
.cnv-gico { display: inline-grid; place-items: center; color: var(--accent); flex-shrink: 0; }
.cnv-gico svg.lucide { width: 13px; height: 13px; }
.cnv-gtxt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cnv-gok, .cnv-gno { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; display: inline-grid; place-items: center; transition: background var(--dur), color var(--dur), transform .15s var(--spring); }
.cnv-gok { background: var(--accent); color: var(--on-accent); }
.cnv-gok:hover { background: var(--accent-2); transform: scale(1.08); }
.cnv-gno { color: var(--text-2); }
.cnv-gno:hover { background: var(--hover); color: var(--text); }
.cnv-gok svg.lucide, .cnv-gno svg.lucide { width: 15px; height: 15px; }

/* ---- Seleção por retângulo / desenho de ilha ---- */
.cnv-marquee { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; border: 1.5px solid var(--accent); background: var(--accent-soft); border-radius: 4px; }
.cnv-marquee.is-frame { border-style: dashed; border-radius: var(--r-xl); background: color-mix(in srgb, var(--accent) 7%, transparent); }

/* ==========================================================================
   Camada de interface (vidro)
   ========================================================================== */
.cnv-ui { position: absolute; z-index: 8; touch-action: manipulation; }
.cnv-mob { display: none !important; }

.cnv-toolbar {
  top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; padding: 5px;
  border-radius: 16px; background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  animation: cnvBarIn .3s var(--ease);
}
.cnv-tbtn {
  position: relative; width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center; color: var(--text-2);
  transition: background var(--dur), color var(--dur), box-shadow var(--dur), transform .14s var(--spring);
}
.cnv-tbtn:hover { background: var(--hover); color: var(--text); }
.cnv-tbtn:active { transform: scale(.9); }
.cnv-tbtn.on { background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 12px var(--accent-ring); }
.cnv-tbtn svg.lucide { width: 19px; height: 19px; }
.cnv-tbtn.cnv-sparkle { color: var(--accent); }
.cnv-tbtn.cnv-sparkle.on { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent-ring); }
.cnv-tbtn.cnv-sparkle:not(.on):has(.cnv-badge:not([hidden])) svg { animation: cnvTwinkle 2.6s ease-in-out infinite; }
.cnv-tsep { width: 1px; height: 22px; margin: 0 4px; flex-shrink: 0; background: var(--border); }
.cnv-badge {
  position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center; border-radius: var(--r-full);
  background: var(--accent); color: var(--on-accent); font-size: 10px; font-weight: 750; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface);
}

.cnv-zoom {
  left: 16px; bottom: 16px; display: flex; align-items: center; gap: 1px; padding: 4px;
  border-radius: 13px; background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.cnv-zbtn {
  height: 32px; min-width: 32px; padding: 0 6px; border-radius: 9px;
  display: inline-grid; place-items: center; color: var(--text-2);
  font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums;
  transition: background var(--dur), color var(--dur);
}
.cnv-zbtn:hover { background: var(--hover); color: var(--text); }
.cnv-zbtn svg.lucide { width: 16px; height: 16px; }
.cnv-zval { min-width: 54px; }
.cnv-zsep { width: 1px; height: 18px; margin: 0 3px; background: var(--border); }

.cnv-mini {
  right: 92px; bottom: 18px; width: 196px; height: 124px; overflow: hidden; cursor: pointer;
  border-radius: 14px; background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: opacity .2s, box-shadow .2s;
}
.cnv-mini:hover { box-shadow: var(--shadow-lg); }
.cnv-mini canvas { display: block; width: 100%; height: 100%; }

.cnv-selbar {
  left: 0; top: 0; display: flex; align-items: center; gap: 2px; padding: 4px;
  border-radius: 13px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: cnvBarIn .18s var(--ease); transition: opacity .12s;
}
.cnv-busy .cnv-selbar { opacity: 0; pointer-events: none; }
.cnv-blank .cnv-mini { display: none; }
.cnv-sbtn {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; color: var(--text-2);
  transition: background var(--dur), color var(--dur), transform .12s var(--spring);
}
.cnv-sbtn:hover { background: var(--hover); color: var(--text); }
.cnv-sbtn:active { transform: scale(.92); }
.cnv-sbtn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.cnv-sbtn svg.lucide { width: 17px; height: 17px; }
.cnv-sdot { width: 18px; height: 18px; border-radius: 50%; background: var(--c-bg); box-shadow: inset 0 0 0 2.5px var(--c-s); }
.cnv-sdot-none { background: conic-gradient(var(--c-yellow-s), var(--c-peach-s), var(--c-pink-s), var(--c-lilac-s), var(--c-sky-s), var(--c-mint-s), var(--c-yellow-s)); box-shadow: inset 0 0 0 2px var(--surface); }
.cnv-ssep { width: 1px; height: 20px; margin: 0 3px; flex-shrink: 0; background: var(--border); }
.cnv-scount {
  min-width: 24px; height: 24px; padding: 0 7px; margin: 0 4px 0 2px; border-radius: var(--r-full);
  display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink);
  font-size: 12px; font-weight: 750;
}

.cnv-gbar {
  top: 72px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 5px 5px 5px 13px; white-space: nowrap;
  border-radius: var(--r-full); background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border: 1.5px dashed color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: var(--shadow);
  font-size: 13px; color: var(--text);
  animation: cnvBarIn .25s var(--ease);
}
.cnv-gbar-ico { display: inline-grid; place-items: center; color: var(--accent); }
.cnv-gbar .btn { border-radius: var(--r-full); }

.cnv-tip {
  left: 50%; bottom: 20px; transform: translateX(-50%); max-width: min(92%, 520px);
  padding: 8px 15px; border-radius: var(--r-full); pointer-events: none; text-align: center;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg);
  font-size: 12.8px; font-weight: 550; line-height: 1.35;
}
.cnv-tip.in { animation: cnvTipIn .28s var(--spring); }

/* ---- Estado vazio ---- */
.cnv-empty-wrap { position: absolute; inset: 0; z-index: 7; display: grid; place-items: center; padding: 16px; pointer-events: none; }
.cnv-empty {
  pointer-events: auto; width: min(460px, 100%);
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 28px 26px 22px; border-radius: var(--r-xl);
  background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: pop .38s var(--spring);
}
.cnv-empty-art { position: relative; width: 220px; height: 110px; margin-bottom: 2px; }
.cnv-ea-line { position: absolute; inset: 0; width: 100%; height: 100%; }
.cnv-ea-line path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 5 6; opacity: .7; animation: cnvDash 1.3s linear infinite; }
.cnv-ea {
  position: absolute; width: 58px; height: 58px; border-radius: 15px;
  display: grid; place-items: center; font-size: 28px;
  background: var(--c-bg); border: 1.5px solid color-mix(in srgb, var(--c-s) 35%, transparent); box-shadow: var(--shadow);
  animation: cnvFloat 4s ease-in-out infinite;
}
.cnv-ea1 { left: 12px; top: 44px; rotate: -7deg; }
.cnv-ea2 { left: 81px; top: 2px; rotate: 3deg; animation-delay: -1.3s; }
.cnv-ea3 { right: 12px; top: 40px; rotate: 8deg; animation-delay: -2.6s; }
.cnv-empty-title { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; color: var(--text); }
.cnv-empty-text { max-width: 340px; font-size: 13.8px; color: var(--text-2); }
.cnv-empty-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 8px; }
.cnv-empty-actions .btn { width: 100%; white-space: normal; text-align: center; min-height: 44px; height: auto; padding-top: 8px; padding-bottom: 8px; }
.cnv-empty-hint { display: flex; align-items: center; gap: 7px; margin-top: 6px; font-size: 12.5px; color: var(--text-3); }
.cnv-empty-hint svg.lucide { width: 15px; height: 15px; }

/* ---- Soltar arquivos/textos ---- */
.cnv-drop {
  position: absolute; inset: 10px; z-index: 9; display: grid; place-items: center; pointer-events: none;
  border-radius: var(--r-xl); border: 2px dashed var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent);
  opacity: 0; transition: opacity .15s;
}
.cnv-dropping .cnv-drop { opacity: 1; }
.cnv-drop-card {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: var(--r-full);
  background: var(--surface); box-shadow: var(--shadow-lg); color: var(--accent-ink); font-weight: 650; font-size: 14px;
}

/* ---- Popover "Adicionar ao mapa" ---- */
.cnv-addpop { width: 336px; max-width: calc(100vw - 16px); padding: 8px; }
.cnv-add { display: flex; flex-direction: column; gap: 6px; }
.cnv-add-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 4px 6px 2px; font-size: 13.5px; }
.cnv-add-head span { font-size: 11.5px; color: var(--text-3); }
.cnv-add-search {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 11px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.cnv-add-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.cnv-add-search input { font-size: 13.5px; color: var(--text); }
.cnv-add-search input::-webkit-search-cancel-button { display: none; }
.cnv-add-list { display: flex; flex-direction: column; gap: 1px; max-height: 300px; overflow-y: auto; margin: 0 -2px; padding: 0 2px; overscroll-behavior: contain; }
.cnv-add-row {
  display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 5px 8px;
  border-radius: 9px; text-align: left; cursor: grab; touch-action: pan-y;
  transition: background var(--dur);
}
.cnv-add-row:hover, .cnv-add-row:focus-visible { background: var(--hover); }
.cnv-add-ic {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center; font-size: 15px;
  background: var(--c-bg, var(--surface-3)); color: var(--c-ink, var(--text-2));
}
.cnv-add-ic svg.lucide { width: 15px; height: 15px; }
.cnv-add-t { flex: 1; font-size: 13.5px; font-weight: 550; }
.cnv-add-type { flex-shrink: 0; font-size: 11px; color: var(--text-3); }
.cnv-add-empty { padding: 18px 10px; text-align: center; font-size: 13px; color: var(--text-3); }
.cnv-add-foot { display: flex; flex-direction: column; gap: 4px; padding-top: 6px; border-top: 1px solid var(--border); }
.cnv-add-foot .btn { justify-content: flex-start; }
.cnv-add-ghost {
  position: fixed; left: 0; top: 0; z-index: var(--z-drag); pointer-events: none;
  display: flex; align-items: center; gap: 8px; max-width: 240px; padding: 6px 12px 6px 6px;
  border-radius: var(--r-full); background: var(--surface); border: 1.5px solid var(--accent); box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 600; rotate: -2deg;
}

/* ---- Dicas ---- */
.cnv-help { width: 300px; display: flex; flex-direction: column; gap: 7px; }
.cnv-help-title { display: flex; align-items: center; gap: 8px; padding: 2px 2px 6px; font-weight: 700; font-size: 13.5px; color: var(--accent-ink); }
.cnv-help-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.8px; color: var(--text-2); }
.cnv-help-row .kbd { white-space: nowrap; }

/* ==========================================================================
   Celular: barra compacta embaixo, sem minimapa
   ========================================================================== */
@media (max-width: 760px) {
  .cnv-desk { display: none !important; }
  .cnv-mob { display: grid !important; }
  .cnv-toolbar { top: auto; bottom: 12px; padding: 4px; gap: 2px; border-radius: 18px; max-width: calc(100% - 24px); }
  .cnv-tbtn { width: 44px; height: 44px; border-radius: 13px; }
  .cnv-tbtn svg.lucide { width: 21px; height: 21px; }
  .cnv-zoom { left: auto; right: 10px; top: 10px; bottom: auto; padding: 3px; border-radius: 14px; }
  .cnv-zbtn { height: 40px; min-width: 40px; }
  .cnv-zval { min-width: 52px; }
  .cnv-mini { display: none; }
  .cnv-gbar { top: 60px; left: 10px; right: 10px; transform: none; justify-content: space-between; gap: 6px; padding: 4px 4px 4px 12px; font-size: 12.5px; }
  .cnv-gbar-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .cnv-gbar .btn { height: 40px; }
  .cnv-gbar .btn-icon { width: 40px; }
  .cnv-tip { bottom: 78px; max-width: calc(100% - 32px); font-size: 12.5px; }
  .cnv-sbtn { width: 40px; height: 40px; }
  .cnv-gok, .cnv-gno { width: 40px; height: 40px; }
  .cnv-glabel { max-width: 270px; padding-left: 12px; }
  .cnv-empty { padding: 22px 18px 18px; gap: 8px; }
  .cnv-empty-art { transform: scale(.85); margin: -8px 0 -8px; }
  .cnv-addpop { width: calc(100vw - 16px); }
  .cnv-add-list { max-height: 42vh; }
}

/* ==========================================================================
   Animações
   ========================================================================== */
@keyframes cnvPop { from { opacity: 0; scale: .82; } to { opacity: 1; scale: 1; } }
@keyframes cnvDraw { to { stroke-dashoffset: 0; } }
@keyframes cnvDash { to { stroke-dashoffset: -14; } }
@keyframes cnvBreath { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes cnvGIn { from { opacity: 0; scale: .7; } to { opacity: 1; scale: 1; } }
@keyframes cnvBarIn { from { opacity: 0; translate: 0 5px; } to { opacity: 1; translate: 0 0; } }
@keyframes cnvTipIn { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
@keyframes cnvFloat { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }
@keyframes cnvTwinkle { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.14) rotate(8deg); } }
@keyframes cnvSource { 0%, 100% { outline-color: var(--accent); } 50% { outline-color: var(--accent-ring); } }
