:root {
  --ink: #121212;
  --ink-3: #2a2a2a;
  --white: #ffffff;

  --yellow: #ffc83d;
  --orange: #ff6b2c;
  --pink: #ff8ad0;
  --teal: #1ec8b4;
  --lilac: #b9a2ff;
  --blue: #7fb2ff;
  --lime: #c8f169;

  --line: 2.5px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);

  --font-display: "Bricolage Grotesque", "DM Sans", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Theme tokens: light */
  color-scheme: light;
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-2: #f6f3ec;
  --text: #121212;
  --text-muted: #8c8a85;
  --stroke: #121212;
  --stroke-soft: #121212;
  --shadow: #121212;
  --btn-shadow: #121212;
  --node-shadow-tint: 0%;
  --divider: #121212;
  --grid-dot: rgba(18, 18, 18, .17);
  --hover-border: rgba(18, 18, 18, .15);
  --flow: #ffc83d;
  --primary-bg: #121212;
  --primary-text: #ffffff;
  --toast-bg: #121212;
  --toast-text: #ffffff;
  --sidebar-bg: #121212;
  --sidebar-border: transparent;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #16140c;
    --surface: #201c11;
    --surface-2: #17150d;
    --text: #f2efe8;
    --text-muted: #958e76;
    --stroke: #f2efe8;
    --stroke-soft: #3f3820;
    --shadow: #000000;
    --btn-shadow: #ffc83d;
    --node-shadow-tint: 100%;
    --divider: #2d2816;
    --grid-dot: rgba(255, 200, 61, .11);
    --hover-border: rgba(255, 200, 61, .18);
    --flow: #ff6b2c;
    --primary-bg: #f2efe8;
    --primary-text: #121212;
    --toast-bg: #f2efe8;
    --toast-text: #121212;
    --sidebar-bg: #0e0c06;
    --sidebar-border: #26210f;
    /* Chips (botões "fantasma" e redondos da topbar) eram creme fixo --
       ficavam brancos destoando do resto, que é todo escuro/amarelado
       neste tema. Viram amarelo com ícone/texto preto, como o resto da
       identidade escura. */
    --chip-bg: var(--yellow);
    --chip-icon: var(--ink);
    --chip-icon-accent: var(--ink);
    --pill-light-bg: var(--yellow);
    --pill-light-text: var(--ink);
  }
}

:root {
  --chip-bg: var(--surface);
  --chip-icon: var(--text);
  --chip-icon-accent: var(--orange);
  --pill-light-bg: var(--surface);
  --pill-light-text: var(--text);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16140c;
  --surface: #201c11;
  --surface-2: #17150d;
  --text: #f2efe8;
  --text-muted: #958e76;
  --stroke: #f2efe8;
  --stroke-soft: #3f3820;
  --shadow: #000000;
  --btn-shadow: #ffc83d;
  --node-shadow-tint: 100%;
  --divider: #2d2816;
  --grid-dot: rgba(255, 200, 61, .11);
  --hover-border: rgba(255, 200, 61, .18);
  --flow: #ff6b2c;
  --primary-bg: #f2efe8;
  --primary-text: #121212;
  --toast-bg: #f2efe8;
  --toast-text: #121212;
  --sidebar-bg: #0e0c06;
  --sidebar-border: #26210f;
  --chip-bg: var(--yellow);
  --chip-icon: var(--ink);
  --chip-icon-accent: var(--ink);
  --pill-light-bg: var(--yellow);
  --pill-light-text: var(--ink);
}

/* ---------- Temas extras (templates) ---------- */
:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #0c1220;
  --surface: #141c30;
  --surface-2: #101828;
  --text: #e8edf9;
  --text-muted: #8591b0;
  --stroke: #e8edf9;
  --stroke-soft: #26314d;
  --shadow: #000000;
  --btn-shadow: #7fb2ff;
  --node-shadow-tint: 100%;
  --divider: #202a44;
  --grid-dot: rgba(127, 178, 255, .13);
  --hover-border: rgba(127, 178, 255, .2);
  --flow: #7fb2ff;
  --primary-bg: #e8edf9;
  --primary-text: #0c1220;
  --toast-bg: #e8edf9;
  --toast-text: #0c1220;
  --sidebar-bg: #080d18;
  --sidebar-border: #1b2440;
  --chip-bg: #7fb2ff;
  --chip-icon: #0c1220;
  --chip-icon-accent: #0c1220;
  --pill-light-bg: #7fb2ff;
  --pill-light-text: #0c1220;
}

:root[data-theme="forest"] {
  color-scheme: dark;
  --bg: #0f1710;
  --surface: #182519;
  --surface-2: #131e15;
  --text: #eaf2ea;
  --text-muted: #87a08a;
  --stroke: #eaf2ea;
  --stroke-soft: #28391f;
  --shadow: #000000;
  --btn-shadow: #c8f169;
  --node-shadow-tint: 100%;
  --divider: #223321;
  --grid-dot: rgba(200, 241, 105, .12);
  --hover-border: rgba(200, 241, 105, .18);
  --flow: #c8f169;
  --primary-bg: #eaf2ea;
  --primary-text: #0f1710;
  --toast-bg: #eaf2ea;
  --toast-text: #0f1710;
  --sidebar-bg: #0a120b;
  --sidebar-border: #1c2c1b;
  --chip-bg: #c8f169;
  --chip-icon: #0f1710;
  --chip-icon-accent: #0f1710;
  --pill-light-bg: #c8f169;
  --pill-light-text: #0f1710;
}

:root[data-theme="rose"] {
  color-scheme: light;
  --bg: #fdf3f3;
  --surface: #ffffff;
  --surface-2: #fdf0ef;
  --text: #2a1414;
  --text-muted: #9a7d7d;
  --stroke: #2a1414;
  --stroke-soft: #2a1414;
  --shadow: #2a1414;
  --btn-shadow: #2a1414;
  --node-shadow-tint: 0%;
  --divider: #2a1414;
  --grid-dot: rgba(42, 20, 20, .15);
  --hover-border: rgba(42, 20, 20, .15);
  --flow: #ff6b2c;
  --primary-bg: #2a1414;
  --primary-text: #ffffff;
  --toast-bg: #2a1414;
  --toast-text: #ffffff;
  --sidebar-bg: #2a1414;
  --sidebar-border: transparent;
  --chip-bg: var(--surface);
  --chip-icon: var(--text);
  --chip-icon-accent: #ff8ad0;
  --pill-light-bg: var(--surface);
  --pill-light-text: var(--text);
}

/* Circular reveal when switching theme (View Transitions API). */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

#app {
  display: flex;
  height: 100vh;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: 248px;
  flex: 0 0 auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--white);
  overflow: hidden;
  transition: width .4s var(--ease);
  z-index: 30;
}
#sidebar.collapsed { width: 0; border-right-width: 0; }

.sidebar-inner {
  width: 248px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  overflow-y: auto;
  transition: opacity .25s var(--ease), transform .4s var(--ease);
}
#sidebar.collapsed .sidebar-inner {
  opacity: 0;
  transform: translateX(-28px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: -.03em;
  margin: 0 4px 30px;
  cursor: pointer;
  color: var(--white);
  text-decoration: none;
}
.logo-thin { font-weight: 600; color: var(--yellow); }
.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--yellow);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 17px;
  transform: rotate(-8deg);
  transition: transform .5s var(--spring);
}
.logo:hover .logo-mark { transform: rotate(10deg) scale(1.1); }

.side-section { margin-bottom: 28px; }
.side-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: none;
  padding: 0 6px;
  margin: 0 0 12px;
  cursor: pointer;
  color: inherit;
}
.side-section-head h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #9a9a9a;
  margin: 0;
}
.side-section-chevron {
  flex: none;
  color: #7a7a7a;
  transition: transform .25s var(--spring);
}
.side-section.collapsed .side-section-chevron { transform: rotate(-90deg); }
.side-section.collapsed .palette {
  display: none;
}

.palette {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  color: #e6e6e6;
  cursor: grab;
  user-select: none;
  transition: background .2s, color .2s, transform .3s var(--spring);
}
.palette-item:hover {
  background: var(--ink-3);
  color: var(--white);
  transform: translateX(4px);
}
.palette-item:active { cursor: grabbing; transform: scale(.97); }
.pal-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--c);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  flex: none;
  transition: transform .4s var(--spring);
}
.palette-item:hover .pal-icon { transform: rotate(-10deg) scale(1.1); }
.pal-icon.icon-svg svg, .node-icon.icon-svg svg { display: block; }
.pal-grip {
  margin-left: auto;
  color: #5a5a5a;
  font-size: 12px;
  letter-spacing: -2px;
  opacity: 0;
  transition: opacity .2s;
}
.palette-item:hover .pal-grip { opacity: 1; }

.zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--ink-3);
  border-radius: 999px;
  padding: 4px;
}
.zoom-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--white);
  font-size: 17px;
  cursor: pointer;
  transition: background .2s, transform .25s var(--spring);
}
.zoom-btn:hover { background: #3e3720; }
.zoom-btn:active { transform: scale(.85); }
#zoomLevel {
  font-size: 13px;
  font-weight: 600;
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #e6e6e6;
  cursor: pointer;
  padding-left: 4px;
}
.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: #3e3720;
  border-radius: 999px;
  transition: background .25s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: transform .35s var(--spring), background .25s;
}
.switch input:checked + .slider { background: var(--yellow); }
.switch input:checked + .slider::before { transform: translateX(18px); background: var(--ink); }
.switch input:focus-visible + .slider { outline: 2px solid var(--white); outline-offset: 2px; }

.hint {
  font-size: 12.5px;
  color: #9a9a9a;
  line-height: 1.55;
  margin: 12px 4px 0;
}
.hint code {
  background: var(--ink-3);
  color: #e6e6e6;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 11px;
}

.sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  color: #7a7a7a;
  line-height: 2;
  padding: 0 6px;
}
.sidebar-footer kbd {
  font-family: inherit;
  font-size: 11px;
  background: var(--ink-3);
  color: #cfcfcf;
  border-radius: 6px;
  padding: 2px 7px;
  margin-right: 4px;
}

/* ---------- Content / Topbar ---------- */
#content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#topbar {
  height: 70px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  background: var(--bg);
  border-bottom: var(--line) solid var(--divider);
  z-index: 20;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.round-btn {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  border: none;
  background: var(--chip-bg);
  color: var(--chip-icon);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .3s var(--spring), filter .2s;
}
.round-btn:hover { transform: rotate(-6deg); filter: brightness(1.12); }
.round-btn:active { transform: scale(.92); }
.round-btn svg.spin-in { animation: spin-in .55s var(--spring); }
@keyframes spin-in {
  from { transform: rotate(-120deg) scale(.4); opacity: 0; }
}

.theme-picker { position: relative; }
.theme-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  color: var(--text);
  border: var(--line) solid var(--stroke);
  border-radius: 14px;
  box-shadow: 5px 5px 0 var(--btn-shadow);
  z-index: 100;
  transform-origin: top right;
}
.theme-menu.hidden { display: none; }
.theme-menu:not(.hidden) { animation: menu-in .25s var(--spring); }
.theme-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.theme-option:hover { background: var(--yellow); color: var(--ink); }
.theme-option.active { background: var(--surface-2); }
.theme-option.active::after {
  content: "✓";
  margin-left: auto;
  font-weight: 800;
}
.theme-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--stroke);
  flex: none;
}
.theme-swatch-system {
  display: grid;
  place-items: center;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text);
}

.board-name {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text);
  background: transparent;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 4px 10px;
  min-width: 0;
  width: 320px;
  transition: border-color .2s, background .2s;
}
.board-name:hover { border-color: var(--hover-border); }
.board-name:focus { border-color: var(--stroke); background: var(--surface); outline: none; }

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--stroke);
  white-space: nowrap;
}
.save-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background .2s;
}
.save-status.saved::before { background: var(--teal); }
.save-status.saving::before { background: var(--orange); animation: pulse .9s ease-in-out infinite; }
.save-status.error::before { background: #e11d48; }

@keyframes pulse {
  50% { transform: scale(1.6); opacity: .5; }
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: none;
  transition: background .2s;
}
#btnOnline.active .online-dot { background: var(--teal); animation: pulse 1.4s ease-in-out infinite; }

.presence-list {
  display: inline-flex;
  align-items: center;
}
.presence-list.hidden { display: none; }
.presence-avatar {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
  border: 2px solid var(--bg);
  margin-left: -8px;
  cursor: default;
  transition: transform .15s var(--spring), z-index 0s;
}
.presence-avatar:first-child { margin-left: 0; }
.presence-avatar:hover { transform: translateY(-3px) scale(1.08); z-index: 5; }

/* Avatar "+N" quando a sala tem mais gente do que cabe na topbar. */
.presence-avatar-more {
  background: var(--ink);
  color: var(--bg);
  font-size: 10px;
}

/* Tooltip com o nome, mostrado no hover em vez de depender do title nativo
   do navegador (lento e sem o visual do resto do app). */
.presence-avatar-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s var(--spring);
}
.presence-avatar-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink);
}
.presence-avatar:hover .presence-avatar-tip { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Cursores remotos (modo online) ---------- */
.remote-cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 90;
  pointer-events: none;
  transition: transform .08s linear;
  will-change: transform;
}
.remote-cursor-dot {
  width: 14px;
  height: 14px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(0,0,0,.25);
}
.remote-cursor-label {
  position: absolute;
  top: 16px;
  left: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  border: 2px solid var(--ink);
}

/* ---------- Modal: Modo online ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, .45);
  display: grid;
  place-items: center;
}
.modal-backdrop.hidden { display: none; }
.modal {
  position: relative;
  width: 100%;
  max-width: 380px;
  margin: 16px;
  padding: 26px;
  background: var(--surface);
  color: var(--text);
  border: var(--line) solid var(--stroke);
  border-radius: 18px;
  box-shadow: 7px 7px 0 var(--btn-shadow);
  animation: menu-in .25s var(--spring);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 0 0 4px;
}
.modal-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 18px;
  line-height: 1.5;
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
.modal-choice {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 2px solid var(--stroke-soft);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, transform .15s var(--spring);
}
.modal-choice-btn:hover { border-color: var(--stroke); transform: translate(-1px, -1px); }
.modal-choice-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--yellow);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 800;
}
.modal-choice-text { display: flex; flex-direction: column; gap: 2px; }
.modal-choice-text strong { font-size: 14px; }
.modal-choice-text small { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

.modal-field {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-field.hidden { display: none; }

.btn-modal-ghost {
  flex: none;
  padding: 10px 16px;
  border-radius: 10px;
  border: 2px solid var(--stroke-soft);
  background: transparent;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-modal-ghost:hover { border-color: var(--stroke); }

/* ---------- Modal: ajuste de foto (avatar circular) ---------- */
.modal-avatar-crop { max-width: 360px; text-align: center; }
.avatar-crop-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 16px 16px;
  touch-action: none;
  cursor: grab;
}
.avatar-crop-stage:active { cursor: grabbing; }
.avatar-crop-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.avatar-crop-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .45);
  pointer-events: none;
}
.avatar-crop-zoom {
  width: 100%;
  margin: 16px 0 4px;
  accent-color: var(--yellow);
}
.avatar-crop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* ---------- Modal: dúvidas frequentes ---------- */
.modal-help { max-width: 480px; max-height: 82vh; overflow-y: auto; }
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  border: 2px solid var(--stroke-soft);
  border-radius: 14px;
  background: var(--surface-2);
  overflow: hidden;
}
.faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.faq-chevron { flex: none; transition: transform .2s var(--spring); color: var(--text-muted); }
.faq-item.open .faq-chevron { transform: rotate(180deg); color: var(--text); }
.faq-answer {
  display: none;
  padding: 0 16px 16px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
}
.faq-item.open .faq-answer { display: block; animation: calendar-panel-in .18s var(--ease); }
.faq-answer p { margin: 0 0 10px; }
.faq-steps { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.faq-steps li::marker { font-weight: 800; color: var(--text); }
.faq-steps strong { color: var(--text); }
.faq-code {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin: 0 0 10px;
  background: var(--ink);
  border-radius: 10px;
  overflow-x: auto;
}
.faq-code code {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11.5px;
  color: #f2efe8;
  white-space: pre-wrap;
  word-break: break-word;
}
.faq-code-prompt code { white-space: pre-wrap; }
.faq-copy-btn {
  flex: none;
  align-self: flex-start;
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  background: var(--yellow);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: filter .15s, transform .15s var(--spring);
}
.faq-copy-btn:hover { filter: brightness(1.08); }
.faq-copy-btn:active { transform: scale(.94); }
.faq-copy-btn.copied { background: var(--teal); }
.faq-note { font-size: 12.5px; }
.modal-field input {
  width: 100%;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
}
.modal-field input:focus { border-color: var(--stroke); }
.modal-field-input { display: flex; gap: 8px; }
.modal-field-input input { flex: 1; min-width: 0; }
.btn-modal-confirm {
  flex: none;
  padding: 10px 16px;
  border-radius: 10px;
  border: 2px solid var(--stroke);
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-modal-confirm:hover { filter: brightness(1.08); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .25s var(--spring), filter .2s, background .2s, color .2s;
}
.pill-light {
  background: var(--pill-light-bg);
  color: var(--pill-light-text);
}
.pill-light:hover { filter: brightness(1.12); }
.pill-dark {
  background: var(--primary-bg);
  color: var(--primary-text);
}
.pill-dark:hover { filter: brightness(1.12); }
.pill-dark svg { transition: transform .3s var(--spring); }
.pill-dark:hover svg { transform: translateX(3px); }
.pill-light:active, .pill-dark:active { transform: scale(.96); }
.pill-ghost {
  background: var(--chip-bg);
  border-color: var(--chip-bg);
  color: var(--chip-icon);
}
.pill-ghost:hover { background: var(--chip-icon-accent); border-color: var(--chip-icon-accent); color: var(--chip-bg); }

/* ---------- Canvas ---------- */
#canvasWrapper {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--grid-dot) 1.4px, transparent 1.7px);
  background-size: 24px 24px;
  transition: box-shadow .25s;
  /* Pan/pinch do quadro são tratados via Pointer Events no JS -- sem isso
     o navegador tenta fazer scroll/zoom nativo da página com o dedo e
     disputa com o nosso próprio gesto. */
  touch-action: none;
}
#canvasWrapper.panning { cursor: grabbing; }
#canvasWrapper.drop-active { box-shadow: inset 0 0 0 4px var(--yellow); }
#canvasWrapper.animate-zoom {
  transition: background-position .32s var(--ease), background-size .32s var(--ease);
}
#canvasWrapper.animate-zoom #canvas { transition: transform .32s var(--ease); }

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 6000px;
  height: 4000px;
  transform-origin: 0 0;
  will-change: transform;
}

#connectionsLayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

/* Must not intercept clicks meant for the canvas (pan) or connections. */
#nodesLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#emptyHint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
#emptyHint.hidden { opacity: 0; transform: scale(.96); }
.empty-card { text-align: center; }
.empty-title {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text);
}
.empty-sub {
  margin-top: 6px;
  font-size: 15px;
  color: var(--text-muted);
}

/* ---------- Nodes ---------- */
.node {
  --node-shadow: color-mix(in srgb, var(--node-color) var(--node-shadow-tint), var(--shadow));
  position: absolute;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background: var(--surface);
  color: var(--text);
  border: var(--line) solid var(--stroke);
  border-radius: 18px;
  box-shadow: 5px 5px 0 var(--node-shadow);
  user-select: none;
  cursor: grab;
  outline: 3px solid transparent;
  outline-offset: 4px;
  transition: box-shadow .22s var(--ease), transform .35s var(--spring), outline-color .2s;
  touch-action: none;
}
/* Ao aplicar um board remoto (modo online), left/top/width/height passam a
   animar também -- sem isso, uma mudança feita pelo colaborador (mover,
   redimensionar) simplesmente "pulava" pro lugar novo em vez de deslizar.
   Fora do modo remoto-aplicando isso não entra em jogo: o arraste local já
   atualiza left/top a cada frame do pointermove, então não há salto a
   suavizar. */
.node.remote-move {
  transition: box-shadow .22s var(--ease), transform .35s var(--spring), outline-color .2s,
    left .32s var(--spring), top .32s var(--spring), width .32s var(--spring), height .32s var(--spring);
}
/* O efeito de "levantar" só reage ao hover fora da área de conteúdo
   interativo (.node-body) -- senão rolar um preview ou mexer num input
   dispara a animação do card inteiro toda hora. */
.node:hover:not(:has(.node-body:hover)) { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--node-shadow); }
.node.selected { outline-color: var(--orange); }
.node.dragging {
  cursor: grabbing;
  z-index: 50;
  transform: rotate(-1.5deg) scale(1.03);
  box-shadow: 12px 12px 0 var(--node-shadow);
  transition: box-shadow .2s var(--ease), transform .25s var(--spring);
}
#canvasWrapper.connecting .node:hover { outline-color: var(--yellow); }

.node-enter { animation: node-pop .55s var(--spring) both; animation-delay: var(--delay, 0ms); }
@keyframes node-pop {
  0%   { opacity: 0; transform: scale(.6) rotate(-6deg); }
  60%  { opacity: 1; transform: scale(1.04) rotate(1deg); }
  100% { opacity: 1; transform: none; }
}
.node-leaving { animation: node-out .2s var(--ease) forwards; pointer-events: none; }
@keyframes node-out {
  to { opacity: 0; transform: scale(.7) rotate(4deg); }
}

.node-header {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--node-color);
  border-bottom: var(--line) solid var(--stroke);
  border-radius: 15.5px 15.5px 0 0;
}
.node-icon {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  background: var(--ink);
  color: var(--node-color);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  transition: transform .4s var(--spring);
}
.node:hover .node-icon { transform: rotate(-10deg); }
.node-icon.has-avatar {
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 0 2px var(--node-color), 0 0 0 3px var(--ink);
  cursor: pointer;
}
.node-icon.avatar-pickable { cursor: pointer; }
.node-title {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 2px 4px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.015em;
  outline: none;
  transition: background .2s;
}
.node-title:focus { background: rgba(255, 255, 255, .55); }

.node-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 10px;
  padding: 12px;
  overflow-y: auto;
  /* O scroll funciona normalmente, só a barra fica invisível -- menos
     ruído visual no card sem perder a rolagem. */
  scrollbar-width: none;
  /* Permite rolagem vertical nativa por toque dentro do card, mesmo com
     .node tendo touch-action:none pra não disputar o pan do quadro. */
  touch-action: pan-y;
}
.node-body::-webkit-scrollbar { display: none; }
.node-tag {
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border: 2px solid var(--stroke-soft);
  border-radius: 999px;
}
.node-body textarea {
  width: 100%;
  min-height: 54px;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.45;
  padding: 8px 10px;
  resize: vertical;
  outline: none;
  transition: box-shadow .2s var(--ease), border-color .2s;
}
.node-body textarea::placeholder { color: var(--text-muted); }
.node-body textarea:focus { box-shadow: 3px 3px 0 var(--node-color); border-color: var(--stroke); }
.node-metric-value {
  width: 100%;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -.03em;
  text-align: center;
  padding: 6px 8px;
  outline: none;
  transition: box-shadow .2s var(--ease), border-color .2s;
}
.node-metric-value:focus { box-shadow: 3px 3px 0 var(--node-color); border-color: var(--stroke); }

/* ---------- Link widget ---------- */
.link-widget {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.link-url-input {
  width: 100%;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12.5px;
  padding: 7px 9px;
  outline: none;
  transition: box-shadow .2s var(--ease), border-color .2s;
}
.link-url-input::placeholder { color: var(--text-muted); }
.link-url-input:focus { box-shadow: 3px 3px 0 var(--node-color); border-color: var(--stroke); }
.link-url-input.hidden { display: none; }

/* O próprio setStatusText reescreve a className a cada poll, então a
   visibilidade no modo compacto depende do pai (.is-compact), não de uma
   classe "hidden" no elemento -- essa classe seria apagada no próximo poll. */
.link-widget.is-compact .link-status { display: none; }

.link-widget.is-compact .link-stats { margin-top: 2px; }
.link-widget.is-compact .link-stat-value { font-size: 19px; }
/* No card compacto o rótulo some de vista por padrão (CSS "font-size: 0")
   mas usa o texto curto salvo em data-short-label via ::after -- mais
   legível que o rótulo completo original, que não cabia bem nesse espaço. */
.link-widget.is-compact .link-stat-label {
  font-size: 0;
}
.link-widget.is-compact .link-stat-label::after {
  content: attr(data-short-label);
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .03em;
  color: var(--text);
  opacity: .75;
}

.link-detect-btn {
  width: 100%;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 9px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.link-detect-btn:hover { background: var(--yellow); color: var(--ink); border-color: var(--stroke); }
.link-detect-btn:disabled { opacity: .6; cursor: default; }
.link-detect-btn.hidden { display: none; }

.link-shorten-btn {
  width: 100%;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 9px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.link-shorten-btn:hover { background: var(--teal); color: var(--white); border-color: var(--stroke); }
.link-shorten-btn:disabled { opacity: .6; cursor: default; }

.link-original-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-original-hint.hidden { display: none; }

.link-pages-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  padding: 8px;
}
.link-pages-preview.hidden { display: none; }
.link-pages-empty {
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 4px 2px;
}
.link-pages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}
.link-pages-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-radius: 7px;
  cursor: pointer;
}
.link-pages-item:hover { background: var(--surface); }
.link-pages-item input[type="checkbox"] { flex: none; }
.link-pages-item-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.link-pages-item-url {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-pages-item-meta {
  font-size: 10.5px;
  color: var(--text-muted);
}
.link-pages-actions {
  display: flex;
  gap: 6px;
}
.link-pages-confirm,
.link-pages-cancel {
  flex: 1;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  padding: 7px;
  cursor: pointer;
  border: 2px solid var(--stroke-soft);
}
.link-pages-confirm { background: var(--orange); color: var(--white); border-color: var(--stroke); }
.link-pages-cancel { background: var(--surface); color: var(--text); }
.link-pages-cancel:hover { background: var(--surface-2); }

.link-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 14px;
}
.link-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: none;
}
.link-status.ok { color: var(--teal); }
.link-status.ok::before { background: var(--teal); }
.link-status.warn { color: #b8860b; }
.link-status.warn::before { background: var(--yellow); }
.link-status.error { color: #e11d48; }
.link-status.error::before { background: #e11d48; }
.link-status.loading::before { background: var(--orange); animation: pulse .9s ease-in-out infinite; }

.link-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.link-stat {
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  padding: 6px 4px;
  text-align: center;
}
.link-stat-value {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
}
.link-stat-label {
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Checkout widget ---------- */
.checkout-widget {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.checkout-input-row {
  display: flex;
  gap: 6px;
}
.checkout-currency {
  flex: none;
  width: 68px;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 4px;
  outline: none;
}
.checkout-value-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12.5px;
  padding: 7px 9px;
  outline: none;
  transition: box-shadow .2s var(--ease), border-color .2s;
}
.checkout-value-input:focus { box-shadow: 3px 3px 0 var(--node-color); border-color: var(--stroke); }
.checkout-display {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  text-align: center;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 12px;
  padding: 10px;
}

/* ---------- Action (checklist) widget ---------- */
.action-widget {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.action-progress {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.action-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.action-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
}
.action-item input[type="checkbox"] { flex: none; }
.action-item-text {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12.5px;
  padding: 3px 2px;
  outline: none;
  border-radius: 6px;
}
.action-item-text:focus { background: var(--surface-2); }
.action-item.done .action-item-text { color: var(--text-muted); text-decoration: line-through; }
.action-item-remove {
  flex: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.action-item:hover .action-item-remove { opacity: 1; }
.action-item-remove:hover { color: #e11d48; }
.action-add-row {
  display: flex;
  gap: 6px;
}
.action-add-input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  padding: 6px 9px;
  outline: none;
}
.action-add-input:focus { border-color: var(--stroke); }
.action-add-btn {
  flex: none;
  width: 30px;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.action-add-btn:hover { background: var(--yellow); color: var(--ink); border-color: var(--stroke); }

/* ---------- E-mail widget ---------- */
.email-widget {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.email-subject-input {
  width: 100%;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12.5px;
  padding: 7px 9px;
  outline: none;
  transition: box-shadow .2s var(--ease), border-color .2s;
}
.email-subject-input::placeholder { color: var(--text-muted); }
.email-subject-input:focus { box-shadow: 3px 3px 0 var(--node-color); border-color: var(--stroke); }
.email-rates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.email-rate-cell {
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  padding: 6px 8px;
  text-align: center;
}
.email-rate-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  outline: none;
}
.email-rate-label {
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Rede social widget ---------- */
.social-widget {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.social-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.social-stat-cell {
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  padding: 6px 8px;
  text-align: center;
}
.social-stat-cell input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  outline: none;
}
.social-stat-label {
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Widget de imagem ---------- */
.image-widget {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.image-preview {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  border: 2px dashed var(--stroke-soft);
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
}
/* Com imagem anexada, o preview ocupa toda a área restante do corpo do
   widget (até a borda colorida do node), sem a moldura tracejada de
   placeholder -- essa só faz sentido antes de ter imagem nenhuma. */
.image-preview.has-image {
  flex: 1;
  margin: -12px;
  width: calc(100% + 24px);
  border: none;
  border-radius: 0 0 15.5px 15.5px;
}
.image-preview-img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-preview-img.visible { display: block; }
.image-placeholder {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  padding: 10px;
}
.image-placeholder.hidden { display: none; }

/* ---------- Widget de Texto ---------- */
.text-widget {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 6px;
}
.text-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.text-font-select,
.text-effect-select {
  flex: 1 1 auto;
  min-width: 64px;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 4px;
}
.text-size-group,
.text-style-group {
  display: flex;
  flex: none;
  gap: 2px;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 8px;
  padding: 2px;
}
.text-size-btn,
.text-style-btn {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s;
}
.text-style-btn:nth-child(2) { font-style: italic; }
.text-style-btn:nth-child(3) { text-decoration: underline; }
.text-size-btn:hover,
.text-style-btn:hover { background: var(--surface-3, rgba(0,0,0,.06)); }
.text-size-btn.active,
.text-style-btn.active { background: var(--yellow); color: var(--ink); }
.text-color-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.text-color-swatch {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--stroke);
  background: var(--sw);
  padding: 0;
  cursor: pointer;
  transition: transform .15s var(--spring);
}
.text-color-swatch:hover { transform: scale(1.15); }
.text-color-swatch.active { outline: 2px solid var(--node-color); outline-offset: 2px; }
.text-color-custom {
  width: 22px;
  height: 22px;
  flex: none;
  padding: 0;
  border: 2px solid var(--stroke-soft);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  overflow: hidden;
}
.text-color-custom::-webkit-color-swatch-wrapper { padding: 0; }
.text-color-custom::-webkit-color-swatch { border: none; border-radius: 50%; }
.text-widget-content {
  flex: 1;
  min-height: 60px;
  width: 100%;
  resize: vertical;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 6px 4px;
  line-height: 1.3;
  transition: border-color .15s;
}
/* Sem caixa visível em repouso -- o texto fica "solto" no card, como um
   título/elemento decorativo. Só ganha um contorno tracejado sutil ao focar
   (editando) ou passar o mouse, pra sinalizar que é editável sem poluir o
   visual do resto do tempo. */
.text-widget-content:hover { border-color: var(--stroke-soft); }
.text-widget-content:focus { border-color: var(--stroke); outline: none; border-style: dashed; }
.text-widget-content.fx-shadow { text-shadow: 3px 3px 0 color-mix(in srgb, var(--text-fx-color) 35%, transparent); }
.text-widget-content.fx-outline {
  -webkit-text-stroke: 1.2px var(--ink);
  paint-order: stroke fill;
}
.text-widget-content.fx-highlight {
  background: color-mix(in srgb, var(--text-fx-color) 18%, transparent);
  box-decoration-break: clone;
}

/* ---------- Widget de calendário ---------- */
.calendar-widget {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
}
.calendar-nav-btn {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.calendar-nav-btn:hover { background: var(--yellow); color: var(--ink); }
.calendar-label {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 800;
  text-align: center;
  flex: 1;
}
.calendar-today-btn {
  flex: none;
  height: 22px;
  padding: 0 8px;
  border-radius: 7px;
  border: 2px solid var(--stroke-soft);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .02em;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.calendar-today-btn:hover { background: var(--node-color); color: var(--ink); border-color: var(--stroke); }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.calendar-weekday {
  font-size: 9px;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted);
  padding: 2px 0;
}
.calendar-day {
  position: relative;
  aspect-ratio: 1;
  border: none;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.calendar-day:hover { background: var(--hover-border); }
.calendar-day.marked { background: var(--node-color); color: var(--ink); font-weight: 800; }
/* Dia com tarefas vinculadas: badge pequeno no canto em vez de um ponto
   embaixo do número (que de perto parecia sujeira/erro de render). */
.calendar-day.has-links::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--node-color);
  box-shadow: 0 0 0 1.5px var(--surface-2);
}
.calendar-day.marked.has-links::after { background: var(--ink); box-shadow: 0 0 0 1.5px var(--node-color); }
.calendar-day.expanded { box-shadow: inset 0 0 0 2px var(--node-color); }
.calendar-day.expanded.marked { box-shadow: inset 0 0 0 2px var(--ink); }
/* Dia de hoje: contorno fino sempre visível, mesmo sem marcação -- ajuda a
   se situar no mês sem precisar contar os dias. */
.calendar-day.today { outline: 1.5px solid var(--node-color); outline-offset: -1.5px; }
.calendar-day.today.marked { outline-color: var(--ink); }

/* Painel das tarefas do dia expandido -- aparece inline na grade (abaixo
   da linha daquele dia), ocupando as 7 colunas inteiras. */
.calendar-day-panel {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  margin: 2px 0;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-radius: 10px;
  animation: calendar-panel-in .18s var(--ease);
}
@keyframes calendar-panel-in {
  from { opacity: 0; transform: translateY(-4px); }
}
.calendar-link-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: background .15s;
}
.calendar-link-item:hover { background: var(--hover-border); }
.calendar-link-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--ink);
}
.calendar-link-title {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-link-remove {
  flex: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.calendar-link-remove:hover { color: #e11d48; }

/* ---------- Widget de coluna ---------- */
.column-widget {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.column-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.column-empty {
  flex: 1;
  min-height: 60px;
  display: grid;
  place-items: center;
  border: 2px dashed var(--stroke-soft);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 11.5px;
  text-align: center;
  padding: 12px;
}
.column-empty.hidden { display: none; }
.column-item {
  border-radius: 10px;
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
  border-left: 4px solid var(--item-color, var(--node-color));
  overflow: hidden;
  transition: border-color .15s;
}
.column-item.open { border-color: var(--item-color, var(--node-color)); }
.column-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  cursor: pointer;
}
/* Seta que indica expansível -- gira quando o item está aberto, deixando
   claro (sem precisar de texto) que há conteúdo escondido ali dentro. */
.column-item-caret {
  flex: none;
  width: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  transition: transform .2s var(--spring);
}
.column-item.open .column-item-caret { transform: rotate(90deg); color: var(--item-color, var(--node-color)); }
.column-item-icon {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--item-color, var(--node-color));
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
}
.column-item-icon.icon-svg svg { display: block; width: 11px; height: 11px; }
.column-item-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.column-item-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
}
.column-item-btn {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.column-item-btn:hover:not(:disabled) { background: var(--hover-border); color: var(--text); }
.column-item-btn:disabled { opacity: .3; cursor: default; }
.column-item-remove:hover:not(:disabled) { color: #e11d48; }

/* Painel expandido -- mostra o widget real (preview/imagem/checklist/etc.)
   em miniatura dentro da coluna, no lugar de só um título. Os controles
   próprios do widget continuam funcionando (input, clique) sem disparar o
   drag/seleção do item da coluna por baixo. */
.column-item-panel {
  padding: 0 8px 10px;
  animation: calendar-panel-in .18s var(--ease);
}
.column-item-panel .node-tag { display: none; }
/* .image-preview.has-image normalmente sangra pra fora do padding do node
   (margin negativa) pra encostar na borda colorida do card -- dentro do
   mini-painel da coluna isso vazaria por cima do cantinho arredondado, então
   é neutralizado aqui. */
.column-item-panel .image-preview { aspect-ratio: 16/9; }
.column-item-panel .image-preview.has-image {
  margin: 0;
  width: 100%;
  border-radius: 8px;
}
.column-item-panel .link-widget,
.column-item-panel .calendar-widget,
.column-item-panel .column-widget { gap: 6px; }

/* ---------- Ports ---------- */
.port {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: var(--line) solid var(--stroke);
  cursor: crosshair;
  z-index: 5;
  transform: translateY(-50%);
  transition: transform .3s var(--spring), background .2s;
  touch-action: none;
}
.port.out { right: -10px; }
.port.in { left: -10px; }
.port.top, .port.bottom {
  top: auto;
  left: 50%;
  transform: translateX(-50%);
}
.port.top { top: -10px; }
.port.bottom { bottom: -10px; top: auto; }
.port:hover { background: var(--yellow); transform: translateY(-50%) scale(1.35); }
.port.top:hover, .port.bottom:hover { transform: translateX(-50%) scale(1.35); }
#canvasWrapper.connecting .port.in,
#canvasWrapper.connecting .port.top,
#canvasWrapper.connecting .port.bottom {
  background: var(--yellow);
  animation: port-pulse 1s ease-in-out infinite;
}
@keyframes port-pulse {
  50% { box-shadow: 0 0 0 6px rgba(255, 200, 61, .45); }
}

/* ---------- Resize handle ---------- */
.resize-handle {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 20px;
  height: 20px;
  cursor: nwse-resize;
  z-index: 6;
  opacity: 0;
  transition: opacity .2s;
  touch-action: none;
}
.node:hover .resize-handle,
.node.resizing .resize-handle { opacity: 1; }
.resize-handle::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 9px;
  height: 9px;
  border-right: 3px solid var(--stroke);
  border-bottom: 3px solid var(--stroke);
  border-radius: 0 0 4px 0;
}
.node.resizing { transition: none; }

/* ---------- Widget de rede social em modo bolinha ---------- */
.node-social-bubble {
  border-radius: 50%;
  padding: 0;
  overflow: visible;
}
.node-social-bubble .node-header {
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--node-color);
  display: grid;
  place-items: center;
}
.node-social-bubble .node-header .node-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  margin: 0;
}
.node-social-bubble .node-header .node-icon.has-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px var(--ink);
}
.node-social-bubble .node-title { display: none; }
.social-bubble-name {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 140px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: var(--line) solid var(--stroke-soft);
  border-radius: 999px;
  padding: 3px 10px;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-social-bubble.popover-open { z-index: 60; }
/* As 4 portas de conexão só aparecem no hover (ou enquanto conectando) --
   a bolinha é pequena e ficam poluindo o círculo se sempre visíveis, ao
   contrário dos cards normais, que têm espaço de sobra nas bordas. */
.node-social-bubble .port { opacity: 0; transition: opacity .15s, transform .3s var(--spring), background .2s; }
.node-social-bubble:hover .port,
.node-social-bubble.popover-open .port,
#canvasWrapper.connecting .node-social-bubble .port { opacity: 1; }
.social-popover {
  position: absolute;
  top: calc(100% + 34px);
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  background: var(--surface);
  border: var(--line) solid var(--stroke);
  border-radius: 16px;
  box-shadow: 6px 6px 0 var(--btn-shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: default;
  z-index: 61;
  animation: menu-in .2s var(--spring);
}
.social-popover .node-title {
  display: block;
  border: var(--line) solid var(--stroke-soft);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 14px;
}
.social-popover .node-body { padding: 0; }

/* ---------- Widget de Texto "nu" (sem card visível) ---------- */
.node-bare-text {
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
  padding: 2px;
  min-width: 40px;
  min-height: 24px;
}
.node-bare-text:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); border-radius: 8px; }
.node-bare-text.popover-open { z-index: 60; background: transparent; }
.bare-text-display {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.3;
}
/* Mesma lógica da bolinha social: portas só aparecem no hover, enquanto
   conectando, ou com o popover de edição aberto. */
.node-bare-text .port { opacity: 0; transition: opacity .15s, transform .3s var(--spring), background .2s; }
.node-bare-text:hover .port,
.node-bare-text.popover-open .port,
#canvasWrapper.connecting .node-bare-text .port { opacity: 1; }
.text-popover {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  width: 260px;
  background: var(--surface);
  border: var(--line) solid var(--stroke);
  border-radius: 16px;
  box-shadow: 6px 6px 0 var(--btn-shadow);
  padding: 12px;
  cursor: default;
  z-index: 61;
  animation: menu-in .2s var(--spring);
}
.text-popover .node-body { padding: 0; gap: 6px; }
.text-popover .text-widget-content {
  background: var(--surface-2);
  border: 2px solid var(--stroke-soft);
}
.text-popover .text-widget-content:hover { border-color: var(--stroke-soft); }
.text-popover .text-widget-content:focus { border-color: var(--stroke); border-style: solid; }

/* ---------- Connections ---------- */
.conn { cursor: pointer; }
.conn-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
  pointer-events: stroke;
}
.conn-line {
  fill: none;
  stroke: var(--stroke);
  stroke-width: 3.5;
  pointer-events: none;
  transition: stroke .2s;
}
.conn-flow {
  fill: none;
  stroke: var(--flow);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1 14;
  pointer-events: none;
  animation: flow 1s linear infinite;
}
.conn:hover .conn-line { stroke: var(--orange); }
.conn-arrow { fill: var(--stroke); }
.conn-temp {
  fill: none;
  stroke: var(--stroke);
  stroke-width: 2.5;
  stroke-dasharray: 6 6;
  pointer-events: none;
  animation: flow-temp .6s linear infinite;
}
@keyframes flow { to { stroke-dashoffset: -15; } }
@keyframes flow-temp { to { stroke-dashoffset: -12; } }

.snap-guide {
  stroke: var(--orange);
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
  pointer-events: none;
}

/* ---------- Context menu ---------- */
/* ---------- Hidden (kept functional, not shown) ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Marquee selection ---------- */
.marquee {
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 0;
  border: 2px dashed var(--yellow);
  background: color-mix(in srgb, var(--yellow) 12%, transparent);
  border-radius: 4px;
  pointer-events: none;
  z-index: 40;
  display: none;
}
.marquee.active { display: block; }

#canvasWrapper.space-pan { cursor: grab; }
#canvasWrapper.space-pan.panning { cursor: grabbing; }

.context-menu {
  position: fixed;
  min-width: 190px;
  padding: 6px;
  background: var(--surface);
  color: var(--text);
  border: var(--line) solid var(--stroke);
  border-radius: 14px;
  box-shadow: 5px 5px 0 var(--btn-shadow);
  z-index: 100;
  transform-origin: top left;
}
.context-menu:not(.hidden) { animation: menu-in .25s var(--spring); }
.context-menu.hidden { display: none; }
@keyframes menu-in {
  from { opacity: 0; transform: scale(.85); }
}
.ctx-item {
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ctx-item:hover { background: var(--yellow); color: var(--ink); }
.ctx-item.danger:hover { background: var(--orange); color: var(--white); }

.ctx-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px 6px;
}
.ctx-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--stroke);
  cursor: pointer;
  transition: transform .15s var(--spring);
  padding: 0;
}
.ctx-swatch:hover { transform: scale(1.15); }

.ctx-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 10px 8px;
}
.ctx-icon-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: var(--line) solid var(--stroke);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  transition: background .15s, transform .15s var(--spring);
}
.ctx-icon-btn:hover { background: var(--yellow); color: var(--ink); transform: scale(1.1); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 4px 4px 0 var(--yellow);
  opacity: 0;
  transform: translate(-50%, 24px);
  pointer-events: none;
  z-index: 200;
  transition: opacity .3s var(--ease), transform .45s var(--spring);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #3c3520; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 760px) {
  .save-status, .pill-ghost { display: none; }
  .board-name { width: 160px; font-size: 18px; }

  /* Sidebar passa a flutuar por cima do quadro em vez de empurrar o
     layout -- reaproveita o mesmo #sidebar.collapsed já usado no desktop
     para abrir/fechar, só inverte o padrão (começa fechada no celular,
     já que a preferência salva vem do uso no desktop). */
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: 0;
    box-shadow: none;
  }
  #sidebar:not(.collapsed) {
    width: 240px;
    box-shadow: 4px 0 0 var(--shadow);
  }
  #sidebar.collapsed { width: 0; border-right-width: 0; }
  .sidebar-inner { width: 240px; }

  #sidebarBackdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, .35);
  }
  #sidebar:not(.collapsed) ~ #sidebarBackdrop,
  #sidebarBackdrop.show {
    display: block;
  }

  #content { width: 100%; }

  #topbar {
    height: auto;
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 10px 12px;
  }
  .topbar-left, .topbar-right {
    flex-wrap: wrap;
    gap: 8px;
  }
  .board-name { width: auto; flex: 1 1 120px; }

  .pill { padding: 8px 12px; font-size: 12.5px; }
  .pill svg { width: 13px; height: 13px; }

  .round-btn { width: 38px; height: 38px; }

  /* Nodes do board ficam largos o bastante pra ler sem precisar de zoom
     manual, mas sem travar nada do desktop (regra só existe aqui dentro). */
  .node { min-width: 220px; max-width: calc(100vw - 32px); }

  /* :hover não existe em touch -- a alça de resize precisa ficar visível
     o tempo todo pra dar pra usar com o dedo. */
  .resize-handle { opacity: 1; width: 26px; height: 26px; }

  /* Painel de zoom (escondido no desktop, dentro de .visually-hidden)
     aparece como overlay no canto do quadro, pra zoom/encaixar funcionarem
     sem depender só de pinça. */
  .zoom-controls.visually-hidden {
    position: fixed;
    width: auto; height: auto;
    margin: 0;
    padding: 4px;
    overflow: visible;
    clip: auto;
    white-space: normal;
    right: 14px;
    bottom: 14px;
    z-index: 45;
    background: var(--ink-3);
    pointer-events: auto;
  }
}

@media (max-width: 480px) {
  .topbar-right .pill span,
  #btnExport { font-size: 12px; }
  .board-name { flex-basis: 100px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
