:root {
  --font-main: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow-postit: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 10px rgba(0, 0, 0, 0.08);
  --shadow-postit-hover: 0 2px 4px rgba(0, 0, 0, 0.08), 0 8px 18px rgba(0, 0, 0, 0.12);
  --shadow-postit-drag: 0 12px 28px rgba(0, 0, 0, 0.2);
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --link-color: #94a3b8;
  --link-hover: #ef4444;
  --transition-fast: 0.15s ease;
}

/* Paletas do mural */
body[data-theme="claro"]   { --bg-board-color: #fafafa; --bg-dot-color: #e3e3e3; --ui-bg: #ffffff; --ui-text: #2c2c2c; --ui-muted: #6b7280; --ui-border: #ececec; --ui-hover: rgba(0,0,0,0.05); }
body[data-theme="creme"]   { --bg-board-color: #faf7f2; --bg-dot-color: #e7dfd1; --ui-bg: #ffffff; --ui-text: #2c2723; --ui-muted: #7a7065; --ui-border: #eee7db; --ui-hover: rgba(0,0,0,0.05); }
body[data-theme="cinza"]   { --bg-board-color: #f1f3f5; --bg-dot-color: #d9dde2; --ui-bg: #ffffff; --ui-text: #25282c; --ui-muted: #6b7280; --ui-border: #e3e6ea; --ui-hover: rgba(0,0,0,0.05); }
body[data-theme="azulado"] { --bg-board-color: #f2f6fc; --bg-dot-color: #d6e0ef; --ui-bg: #ffffff; --ui-text: #1f2937; --ui-muted: #64748b; --ui-border: #e2e8f3; --ui-hover: rgba(37,99,235,0.06); }
body[data-theme="rosado"]  { --bg-board-color: #fcf4f6; --bg-dot-color: #efd9df; --ui-bg: #ffffff; --ui-text: #2d2226; --ui-muted: #7c6970; --ui-border: #f3e3e8; --ui-hover: rgba(219,39,119,0.06); }
body[data-theme="escuro"]  { --bg-board-color: #1e1e24; --bg-dot-color: #33333c; --ui-bg: #26262e; --ui-text: #f0f0f5; --ui-muted: #a1a1aa; --ui-border: #38383f; --ui-hover: rgba(255,255,255,0.07); --link-color: #71717a; }

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--ui-bg);
  color: var(--ui-text);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  user-select: none;
}

button, input, select, textarea {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(30, 30, 36, 0.92);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  animation: toastIn 0.2s ease;
}
.toast.toast-error { background: #dc2626; }
.toast.toast-success { background: #16a34a; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Barra superior */
#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background-color: var(--ui-bg);
  border-bottom: 1px solid var(--ui-border);
  z-index: 20;
  flex-wrap: wrap;
  gap: 10px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon { font-size: 1.3rem; }
.logo-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ui-muted);
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--ui-hover);
}
.sync-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
}
.sync-pill.offline .dot { background: #f59e0b; }
.sync-pill.syncing .dot { background: #3b82f6; animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.filter-bar {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--ui-hover);
}

.filter-chip {
  background: transparent;
  border: none;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--ui-muted);
  transition: all var(--transition-fast);
}
.filter-chip:hover { color: var(--ui-text); }
.filter-chip.active {
  background: var(--ui-bg);
  color: var(--ui-text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}
.btn-primary { background-color: var(--accent); color: #fff; }
.btn-primary:hover { background-color: var(--accent-hover); }
.btn-secondary { background-color: #f3f4f6; color: #374151; border-color: #e5e7eb; }
.btn-secondary:hover { background-color: #e5e7eb; }
.btn-ghost { background: transparent; color: rgba(0,0,0,0.6); }
.btn-ghost:hover { background: rgba(0,0,0,0.06); }
.btn-icon {
  background: transparent;
  color: var(--ui-text);
  padding: 7px 9px;
}
.btn-icon:hover { background: var(--ui-hover); }

/* Seletor de paleta */
.theme-picker { position: relative; }
.theme-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.14);
  padding: 6px;
  width: 240px;
  z-index: 50;
}
.theme-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.theme-custom {
  border-top: 1px solid var(--ui-border);
  margin-top: 6px;
  padding: 8px 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}
.theme-custom-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ui-muted);
}
.theme-custom label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.theme-custom .theme-custom-check { justify-content: flex-start; gap: 8px; }
body[data-theme="custom"] { --ui-bg: #ffffff; --ui-text: #2c2c2c; --ui-muted: #6b7280; --ui-border: #ececec; --ui-hover: rgba(0,0,0,0.05); }
.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ui-text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.theme-option:hover { background: var(--ui-hover); }
.theme-option.active { background: var(--ui-hover); outline: 2px solid var(--accent); outline-offset: -2px; }
.theme-swatch {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

/* Mural */
#board-container {
  flex: 1;
  position: relative;
  overflow: auto;
  background-color: var(--bg-board-color);
  background-image: radial-gradient(var(--bg-dot-color) 1px, transparent 1px);
  background-size: 24px 24px;
  touch-action: none;
  cursor: grab;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge legado */
}
#board-container::-webkit-scrollbar {
  display: none; /* Chrome/Edge/Safari */
}
#board-container.is-panning {
  cursor: grabbing;
}

#board {
  position: relative;
  width: 3200px;
  height: 3200px;
}

.links-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.link-line {
  stroke: var(--link-color);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke var(--transition-fast);
}
.link-temp {
  stroke: var(--accent);
  stroke-dasharray: 6 6;
}
.link-hit {
  stroke: transparent;
  stroke-width: 16;
  pointer-events: stroke;
  cursor: pointer;
}
.link:hover .link-line {
  stroke: var(--link-hover);
  stroke-width: 3;
}

.empty-hint {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--ui-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  pointer-events: none;
  padding: 0 16px;
  width: min(460px, 100%);
}
.empty-hint-icon { font-size: 2.4rem; margin-bottom: 6px; }
.empty-hint-sub { font-size: 0.9rem; margin-top: 4px; opacity: 0.85; }
.mini-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  vertical-align: middle;
}

/* Post-it */
.postit {
  position: absolute;
  width: 220px;
  min-height: 170px;
  padding: 12px 14px 10px;
  box-shadow: var(--shadow-postit);
  cursor: grab;
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  transition: box-shadow var(--transition-fast), opacity var(--transition-fast);
  touch-action: none;
  z-index: 1;
  color: #1f2328;
}
.postit.size-small { width: 170px; min-height: 130px; }
.postit.size-medium { width: 220px; min-height: 170px; }
.postit.size-large { width: 290px; min-height: 220px; }

.postit:hover {
  box-shadow: var(--shadow-postit-hover);
  z-index: 5;
}
.postit.is-dragging {
  cursor: grabbing;
  box-shadow: var(--shadow-postit-drag);
  z-index: 30;
}
.postit.is-resolved { opacity: 0.55; }
.postit.is-resolved .postit-body { text-decoration: line-through; text-decoration-color: rgba(0,0,0,0.3); }
.postit.is-secret { outline: 2px dashed rgba(0,0,0,0.25); outline-offset: -6px; }
.postit.link-target {
  box-shadow: 0 0 0 3px var(--accent), var(--shadow-postit-hover);
}

.postit-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(0,0,0,0.6);
}
.postit-author {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.author-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.postit-secret-tag {
  margin-left: auto;
  background: rgba(0,0,0,0.08);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
}

.postit-body {
  flex: 1;
  word-wrap: break-word;
  white-space: pre-wrap;
  line-height: 1.4;
  font-weight: 600;
}
.size-small .postit-body { font-size: 0.92rem; }
.size-medium .postit-body { font-size: 1.02rem; }
.size-large .postit-body { font-size: 1.18rem; }

.postit-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.postit-status {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(0,0,0,0.55);
  white-space: nowrap;
}
.postit-reactions {
  display: flex;
  gap: 3px;
}
.btn-react {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity var(--transition-fast);
}
.btn-react:hover { transform: scale(1.1); background: #fff; }
.btn-react.active { background: #fff; border-color: var(--accent); }
.btn-react.empty { opacity: 0; }
.postit:hover .btn-react.empty { opacity: 0.7; }

.postit-actions {
  position: absolute;
  top: -14px;
  right: 8px;
  display: flex;
  gap: 2px;
  background: var(--ui-bg);
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  padding: 2px 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  opacity: 0;
  transform: translateY(4px);
  transition: all var(--transition-fast);
  pointer-events: none;
}
.postit:hover .postit-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.btn-action-mini {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 3px 5px;
  border-radius: 999px;
}
.btn-action-mini:hover { background: var(--ui-hover); }

.link-handle {
  position: absolute;
  right: -11px;
  top: 50%;
  transform: translateY(-50%) scale(0.8);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 22px;
  text-align: center;
  cursor: crosshair;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  opacity: 0;
  transition: all var(--transition-fast);
  touch-action: none;
}
.postit:hover .link-handle,
body.is-linking .link-handle {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}
.link-handle:hover { transform: translateY(-50%) scale(1.15); }
body.is-linking, body.is-linking .postit { cursor: crosshair; }

/* Em telas de toque não existe hover: deixa ações e bolinha sempre visíveis */
@media (hover: none) {
  .postit-actions { opacity: 1; transform: none; pointer-events: auto; }
  .link-handle { opacity: 1; transform: translateY(-50%) scale(1); }
  .btn-react.empty { opacity: 0.7; }
}

/* Compositor (post-it sendo criado/editado no mural) */
.composer {
  position: absolute;
  width: 300px;
  padding: 14px;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.22);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #1f2328;
  animation: composerIn 0.15s ease-out;
  user-select: text;
}
@keyframes composerIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.composer textarea {
  width: 100%;
  border: none;
  background: rgba(255,255,255,0.45);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.4;
  color: inherit;
  resize: vertical;
}
.composer textarea:focus { outline: 2px solid rgba(0,0,0,0.2); }
.composer-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.1s;
}
.color-swatch.is-custom { border-radius: 5px; }
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border: 2px solid #1f2328; transform: scale(1.15); }
.composer.is-dark .color-swatch.selected { border-color: #fff; }

.composer-custom {
  display: flex;
  align-items: center;
  gap: 8px;
}
.custom-color-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.45);
  border-radius: 6px;
  padding: 3px 8px 3px 3px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.custom-color-btn input[type="color"],
.theme-custom input[type="color"] {
  width: 26px;
  height: 22px;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

/* Post-it em cor escura: texto claro */
.postit.is-dark, .composer.is-dark { color: #f5f5f7; }
.postit.is-dark .postit-header,
.postit.is-dark .postit-status,
.composer.is-dark .composer-tip,
.composer.is-dark .seg button { color: rgba(255,255,255,0.75); }
.postit.is-dark .postit-secret-tag { background: rgba(255,255,255,0.18); }
.postit.is-dark.is-secret { outline-color: rgba(255,255,255,0.4); }
.composer.is-dark textarea,
.composer.is-dark select,
.composer.is-dark .seg,
.composer.is-dark .custom-color-btn { background: rgba(255,255,255,0.14); }
.composer.is-dark .btn-ghost { color: rgba(255,255,255,0.8); }
.composer.is-dark select option { color: #1f2328; }
.composer.is-dark .secret-check input { accent-color: #fff; }

.composer-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.seg {
  display: inline-flex;
  background: rgba(255,255,255,0.45);
  border-radius: 6px;
  padding: 2px;
}
.seg button {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  color: rgba(0,0,0,0.6);
}
.seg button.active { background: #fff; color: #1f2328; box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.composer select {
  flex: 1;
  border: none;
  background: rgba(255,255,255,0.45);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
}
.secret-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
.secret-check input { width: 16px; height: 16px; accent-color: #1f2328; cursor: pointer; }
.secret-check input:disabled + span { opacity: 0.45; }
.composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.composer-tip {
  flex: 1;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(0,0,0,0.5);
}
.composer-actions .btn { padding: 6px 12px; font-size: 0.82rem; }

/* Modal de configurações */
.modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-content {
  background: #fff;
  color: #1e1e24;
  border-radius: 14px;
  width: 92%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  user-select: text;
}
.modal-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 800; }
.modal-body h3 { font-size: 0.95rem; margin-bottom: 6px; }
.btn-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #9ca3af;
  line-height: 1;
}
.btn-close:hover { color: #374151; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-actions {
  padding: 14px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
}
.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group label { font-size: 0.85rem; font-weight: 700; color: #374151; }
.form-group small { font-size: 0.75rem; color: #6b7280; }
.form-group input,
.form-group select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--accent); outline: none; }
.color-palette { display: flex; gap: 8px; }
.color-swatch-author {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.color-swatch-author.selected { border-color: #111827; transform: scale(1.1); }
.divider { margin: 16px 0; border: none; border-top: 1px solid #e5e7eb; }
.description-text { font-size: 0.85rem; color: #6b7280; margin-bottom: 12px; line-height: 1.45; }

@media (max-width: 720px) {
  #top-bar { padding: 8px 12px; }
  .filter-bar { order: 3; width: 100%; overflow-x: auto; }
  .filter-chip { white-space: nowrap; }
  .composer { width: min(300px, calc(100vw - 32px)); }
}
