:root {
  --bg: #1c1c20;
  --bg-elevated: #242429;
  --bg-card: #28282e;
  --bg-card-hover: #2e2e36;
  --border: #38383f;
  --border-soft: #2c2c33;
  --text: #e3e3e6;
  --text-muted: #8f8f98;
  --text-faint: #65656d;
  --accent: #9d8cff;
  --accent-strong: #8170f0;
  --accent-soft: rgba(157, 140, 255, 0.16);
  --bg-glow-1: rgba(157, 140, 255, 0.06);
  --bg-glow-2: rgba(157, 140, 255, 0.04);
  --danger: #ff6b6b;
  --success: #4fd67a;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --radius-sm: 7px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
}

/* Color themes — each one tints the whole neutral bg/border scale toward
   its hue (not just the accent), so themes read as distinct moods rather
   than just a different button color. Text/danger/success/shadows stay
   fixed across themes for readability and semantic consistency. */
[data-theme="ocean"] {
  --bg: #121a22;
  --bg-elevated: #17222c;
  --bg-card: #1b2733;
  --bg-card-hover: #21303e;
  --border: #33495c;
  --border-soft: #223243;
  --accent: #5ab9f5;
  --accent-strong: #3ea3e6;
  --accent-soft: rgba(90, 185, 245, 0.2);
  --bg-glow-1: rgba(90, 185, 245, 0.12);
  --bg-glow-2: rgba(90, 185, 245, 0.07);
}

[data-theme="forest"] {
  --bg: #131a14;
  --bg-elevated: #182319;
  --bg-card: #1c281e;
  --bg-card-hover: #223225;
  --border: #3a5240;
  --border-soft: #24362a;
  --accent: #5fd68a;
  --accent-strong: #3fc073;
  --accent-soft: rgba(95, 214, 138, 0.2);
  --bg-glow-1: rgba(95, 214, 138, 0.11);
  --bg-glow-2: rgba(95, 214, 138, 0.065);
}

[data-theme="sunset"] {
  --bg: #1c1610;
  --bg-elevated: #251c14;
  --bg-card: #2b2117;
  --bg-card-hover: #33281b;
  --border: #4f3c26;
  --border-soft: #362819;
  --accent: #ffa759;
  --accent-strong: #f28f38;
  --accent-soft: rgba(255, 167, 89, 0.22);
  --bg-glow-1: rgba(255, 167, 89, 0.13);
  --bg-glow-2: rgba(255, 167, 89, 0.075);
}

[data-theme="rose"] {
  --bg: #1c1217;
  --bg-elevated: #25161d;
  --bg-card: #2b1922;
  --bg-card-hover: #331e29;
  --border: #4f2d3d;
  --border-soft: #361c27;
  --accent: #ff7ab3;
  --accent-strong: #f0599c;
  --accent-soft: rgba(255, 122, 179, 0.2);
  --bg-glow-1: rgba(255, 122, 179, 0.12);
  --bg-glow-2: rgba(255, 122, 179, 0.07);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 0%, var(--bg-glow-1), transparent 45%),
    radial-gradient(circle at 85% 20%, var(--bg-glow-2), transparent 40%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease;
}

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

/* ---------- App shell / left sidebar ---------- */

#app {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 56px;
  padding: 14px 0;
  gap: 4px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-soft);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-bottom: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.sidebar-brand:hover { background: var(--accent-soft); }
.sidebar-brand:active { transform: scale(0.92); }
.sidebar-brand svg { width: 24px; height: 24px; }

.sidebar-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-tab svg { width: 19px; height: 19px; }

.sidebar-tab:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.sidebar-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-spacer { flex: 1; }

.sidebar-tab-sep {
  width: 20px;
  height: 1px;
  background: var(--border-soft);
  margin: 3px 0 10px;
}

.sidebar-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--danger);
  color: #1c1c20;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--bg);
  animation: badge-in 0.25s cubic-bezier(0.22, 0.9, 0.32, 1.2) both;
}

@keyframes badge-in {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.app-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(28, 28, 32, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}

.view-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.view-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.notebook-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-width: 0;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.notebook-chip:hover { color: var(--text); border-color: var(--border); }
.notebook-chip svg { width: 12px; height: 12px; flex-shrink: 0; transition: transform 0.15s ease; }
.notebook-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.notebook-switcher {
  position: relative;
}

.notebook-switcher.open .notebook-chip svg { transform: rotate(180deg); }
.notebook-switcher.open .notebook-chip { color: var(--text); border-color: var(--accent); }

.notebook-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  width: 240px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 6px;
  animation: dropdown-in 0.15s cubic-bezier(0.22, 0.9, 0.32, 1.1) both;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.notebook-dropdown-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.notebook-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 9px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.notebook-dropdown-item:hover { background: var(--bg-card-hover); }
.notebook-dropdown-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.notebook-dropdown-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notebook-dropdown-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0;
}

.notebook-dropdown-item.active svg { opacity: 1; }

.notebook-dropdown-manage {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 9px;
  border: none;
  border-top: 1px solid var(--border-soft);
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.notebook-dropdown-manage:hover { color: var(--accent); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  width: 150px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  color: var(--text-faint);
  transition: width 0.18s ease, border-color 0.18s ease;
}

.search-box:focus-within {
  width: 210px;
  border-color: var(--accent);
  color: var(--text-muted);
}

.search-box svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-size: 12.5px;
  color: var(--text);
}

.search-box input::placeholder { color: var(--text-faint); }

.search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  flex-shrink: 0;
}

.search-clear svg { width: 13px; height: 13px; }
.search-clear:hover { color: var(--text); }

.sort-select {
  -webkit-appearance: none;
  appearance: none;
  padding: 6px 24px 6px 10px;
  border-radius: 999px;
  background: var(--bg-elevated) url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2365656d" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3E%3Cpolyline points="6 9 12 15 18 9"/%3E%3C/svg%3E') no-repeat right 6px center / 13px 13px;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.sort-select:hover { color: var(--text); }
.sort-select:focus-visible { outline: none; border-color: var(--accent); color: var(--text); }

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 0 rgba(79, 214, 122, 0.5);
  transition: background 0.25s ease;
}

.status-dot.live {
  background: var(--success);
  animation: pulse 2.4s ease-out infinite;
}

.status-dot.offline {
  background: var(--danger);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 214, 122, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(79, 214, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 214, 122, 0); }
}

.note-count {
  font-size: 12.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.icon-btn svg { width: 17px; height: 17px; }

.icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.icon-btn:active { transform: scale(0.92); }

.icon-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn.spinning svg { animation: spin 0.6s linear; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.user-chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--border);
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #171719;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Layout ---------- */

main {
  position: relative;
}

.view[hidden] { display: none; }

.view:not([hidden]) {
  animation: view-in 0.22s cubic-bezier(0.22, 0.9, 0.32, 1.05) both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .view:not([hidden]) { animation: none; }
}

#pinboardView {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 80px;
}

/* ---------- Composer ---------- */

.composer {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px 12px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer-title {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 16px;
  font-weight: 700;
  padding: 4px 2px 10px;
  outline: none;
}

.composer-title::placeholder { color: var(--text-faint); font-weight: 600; }

.composer-body {
  width: 100%;
  border: none;
  background: transparent;
  resize: vertical;
  min-height: 56px;
  font-size: 14px;
  line-height: 1.6;
  padding: 6px 2px;
  outline: none;
  font-family: inherit;
}

.composer-body::placeholder { color: var(--text-faint); }

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
  margin-top: 6px;
}

.composer-hint {
  font-size: 11.5px;
  color: var(--text-faint);
}

.composer-edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  margin: 2px 2px 8px;
  background: var(--accent-soft);
  border: 1px solid rgba(157, 140, 255, 0.35);
  border-radius: var(--radius-sm);
  animation: pop-in 0.15s ease;
}

.composer-edit-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.composer-edit-label svg { width: 13px; height: 13px; }

.link-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover { color: var(--text); }

#composer.editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--accent);
  color: #17151f;
}

.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:active { transform: scale(0.96); }

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn.pending {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.pending::after {
  content: '';
  width: 11px;
  height: 11px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  opacity: 0.75;
  animation: spin 0.6s linear infinite;
}

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
  font-size: 14px;
}

/* ---------- Board (masonry pinboard) ---------- */

.date-group {
  margin-bottom: 36px;
}

.date-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: capitalize;
}

.date-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

.board-grid {
  column-width: 280px;
  column-gap: 16px;
}

.note-card {
  position: relative;
  break-inside: avoid;
  margin: 0 0 16px;
  padding: 14px 16px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-top: 3px solid var(--pin-color, var(--accent));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.note-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.note-title {
  margin: 2px 62px 8px 0;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}

.note-bullets {
  margin: 0;
  padding: 0 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.note-bullets li {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.note-bullets li::marker {
  color: var(--accent);
}

.inline-tag {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  padding: 0 2px;
  margin: 0 -2px;
  transition: background 0.12s ease;
}

.inline-tag:hover {
  background: var(--accent-soft);
  text-decoration: underline;
}

.note-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  font-size: 11.5px;
  color: var(--text-faint);
}

.author-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 2px 4px 2px 2px;
  margin: -2px -4px -2px -2px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.author-btn:hover {
  background: var(--bg-elevated);
}

.author-btn:hover .author-name {
  color: var(--text);
}

.note-meta .avatar {
  width: 17px;
  height: 17px;
  font-size: 8.5px;
}

.note-meta .author-name {
  color: var(--text-muted);
  font-weight: 600;
  transition: color 0.12s ease;
}

.note-meta .dot-sep {
  opacity: 0.6;
}

.note-action-btn {
  position: absolute;
  top: 10px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.note-card:hover .note-action-btn,
.note-card:focus-within .note-action-btn { opacity: 1; transform: scale(1); }

.note-action-btn svg { width: 14px; height: 14px; }

.note-delete { right: 10px; }
.note-edit { right: 40px; }

.note-delete:hover {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
}

.note-edit:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.note-delete.confirm {
  opacity: 1;
  transform: scale(1);
  background: var(--danger);
  color: #1c1c20;
  animation: confirm-pulse 1s ease-in-out infinite;
}

@keyframes confirm-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(255, 107, 107, 0); }
}

/* Fly-in / pin animation for new notes */

.note-card.entering {
  animation: pin-in 0.55s cubic-bezier(0.22, 0.9, 0.32, 1.15) both;
}

@keyframes pin-in {
  0% { opacity: 0; transform: scale(0.5) translateY(-28px) rotate(-6deg); }
  55% { opacity: 1; transform: scale(1.035) translateY(0) rotate(1.5deg); }
  80% { transform: scale(0.99) translateY(0) rotate(-0.5deg); }
  100% { opacity: 1; transform: scale(1) translateY(0) rotate(0deg); }
}

.note-card.updated {
  animation: update-flash 0.9s ease-out;
}

@keyframes update-flash {
  0% { box-shadow: 0 0 0 0 var(--accent-soft); background: var(--bg-card-hover); }
  100% { box-shadow: 0 0 0 10px rgba(157, 140, 255, 0); background: var(--bg-card); }
}

/* Deliberate navigation target (double-click a mindmap point, jump from
   search) — more sustained/noticeable than the quiet .updated flash. */
.note-card.highlighted {
  animation: highlight-ring 2s ease-out;
}

@keyframes highlight-ring {
  0%, 40% { box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

.note-card.leaving {
  animation: pin-out 0.22s ease forwards;
  pointer-events: none;
}

@keyframes pin-out {
  to { opacity: 0; transform: scale(0.85) translateY(-8px) rotate(3deg); }
}

/* ---------- Mindmap ---------- */

.mindmap-view {
  height: calc(100vh - 67px);
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 28px 20px;
  user-select: none;
}

.mindmap-toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  flex-shrink: 0;
  height: fit-content;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.mindmap-toolbar-sep {
  width: 20px;
  height: 1px;
  background: var(--border-soft);
  margin: 3px 0;
}

.mindmap-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
}

.mindmap-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background-color: var(--bg-elevated);
  background-image: radial-gradient(circle, var(--border-soft) 1.2px, transparent 1.2px);
  background-size: 24px 24px;
  cursor: grab;
}

.mindmap-canvas.panning { cursor: grabbing; }

.mindmap-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  transform-origin: 0 0;
  will-change: transform;
}

.mindmap-edges {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
}

.mindmap-nodes {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
}

.mindmap-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius);
}

/* Nodes — mini cards, so the point itself already shows what it is instead
   of needing a hover tooltip. */

.mindmap-node {
  position: absolute;
  width: 172px;
  padding: 8px 10px;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--node-color, var(--accent));
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  user-select: none;
  transition: transform 0.18s cubic-bezier(0.22, 0.9, 0.32, 1.1), box-shadow 0.18s ease, border-color 0.18s ease;
}

.mindmap-node.transition-pos {
  transition: left 0.4s cubic-bezier(0.22, 0.9, 0.32, 1.1), top 0.4s cubic-bezier(0.22, 0.9, 0.32, 1.1),
    transform 0.18s cubic-bezier(0.22, 0.9, 0.32, 1.1), box-shadow 0.18s ease, border-color 0.18s ease;
}

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

.mn-header .avatar {
  width: 18px;
  height: 18px;
  font-size: 8.5px;
  flex-shrink: 0;
}

.mn-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mn-time {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 10.5px;
  color: var(--text-faint);
}

.mn-title {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.mindmap-node:hover,
.mindmap-node:focus-visible {
  transform: translate(-50%, -50%) scale(1.03);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md);
  z-index: 6;
  outline: none;
}

.mindmap-node.dragging {
  cursor: grabbing;
  z-index: 10;
  transform: translate(-50%, -50%) scale(1.05);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md);
}

.mindmap-node.connect-target {
  transform: translate(-50%, -50%) scale(1.06);
  border-color: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft), var(--shadow-md);
}

.mindmap-node.connect-source {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent);
}

/* Connect tool active: every card is a click-and-drag connector, so make
   that obvious before the user even commits to a drag. */
.mindmap-canvas.tool-connect .mindmap-node {
  cursor: crosshair;
}

.mindmap-node.entering {
  animation: node-in 0.4s cubic-bezier(0.22, 0.9, 0.32, 1.15) both;
}

@keyframes node-in {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  55% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Edges */

.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
  cursor: pointer;
}

.edge-line {
  fill: none;
  stroke: var(--border);
  stroke-width: 2;
  pointer-events: none;
  transition: stroke 0.15s ease, stroke-width 0.15s ease;
}

.mindmap-edge:hover .edge-line {
  stroke: var(--accent);
  stroke-width: 2.5;
}

.edge-delete {
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.mindmap-edge:hover .edge-delete {
  opacity: 1;
  pointer-events: auto;
}

.edge-delete circle {
  fill: var(--danger);
}

.edge-delete:hover circle {
  fill: #ff8a8a;
}

.edge-delete line {
  stroke: #1c1c20;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.temp-edge {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 5;
  pointer-events: none;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: toast-in 0.25s cubic-bezier(0.22, 0.9, 0.32, 1.1) both;
}

.toast[hidden] { display: none; }

.toast.leaving {
  animation: toast-out 0.2s ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translate(-50%, 12px); }
}

.undo-btn {
  color: var(--accent);
  white-space: nowrap;
}

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  max-width: min(360px, 80vw);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  animation: toast-item-in 0.25s cubic-bezier(0.22, 0.9, 0.32, 1.1) both;
}

.toast-item::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-faint);
}

.toast-item.error { border-color: rgba(255, 107, 107, 0.35); }
.toast-item.error::before { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.18); }
.toast-item.success { border-color: rgba(79, 214, 122, 0.35); }
.toast-item.success::before { background: var(--success); box-shadow: 0 0 0 3px rgba(79, 214, 122, 0.18); }

.toast-item.leaving {
  animation: toast-item-out 0.2s ease both;
}

@keyframes toast-item-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-item-out {
  to { opacity: 0; transform: translateY(6px) scale(0.96); }
}

/* ---------- Login modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 12, 0.6);
  backdrop-filter: blur(3px);
}

.modal-overlay[hidden] { display: none; }

.modal {
  width: 320px;
  padding: 28px 26px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  text-align: center;
  animation: pop-in 0.2s ease;
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.modal p {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 14px;
  outline: none;
  margin-bottom: 14px;
  text-align: center;
}

.modal input:focus { border-color: var(--accent); }

.modal .btn { width: 100%; justify-content: center; }

.auth-modal { width: 340px; }

.auth-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
}

.auth-tab {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 7px 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.auth-tab:hover { color: var(--text); }

.auth-tab.active {
  background: var(--accent);
  color: #17151f;
}

.auth-error {
  margin: -4px 0 14px;
  padding: 8px 10px;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 12.5px;
  text-align: left;
}

/* ---------- Options view ---------- */

.options-panel {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 28px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.avatar-lg {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

.account-card-info {
  flex: 1;
  min-width: 0;
}

.account-card-info h2 {
  margin: 0 0 2px;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-muted {
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 400;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover { background: var(--bg-card-hover); }

.options-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.user-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
}

.user-list-item:hover { background: var(--bg-elevated); }

.user-list-name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
}

.user-list-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.user-list-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
}

.user-list-status.online {
  color: var(--success);
}

.user-list-status.online::before {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(79, 214, 122, 0.25);
}

.user-list-item .role-badge { margin-left: 2px; }

.role-select {
  -webkit-appearance: none;
  appearance: none;
  padding: 4px 22px 4px 9px;
  border-radius: 999px;
  background: var(--bg-elevated) url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2365656d" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3E%3Cpolyline points="6 9 12 15 18 9"/%3E%3C/svg%3E') no-repeat right 5px center / 11px 11px;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.role-select:hover { color: var(--text); border-color: var(--border); }
.role-select:disabled { opacity: 0.5; cursor: not-allowed; }

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--bg-elevated);
  color: var(--text-faint);
  border: 1px solid var(--border-soft);
}

.role-badge.role-admin { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.role-badge.role-coadmin { background: rgba(95, 214, 138, 0.14); color: var(--success); border-color: transparent; }
.role-badge.role-editor { color: var(--text-muted); }
.role-badge.role-viewer { color: var(--text-faint); }

/* ---------- Options: theme + storage settings ---------- */

.section-hint {
  margin: -6px 0 12px;
  line-height: 1.5;
}

.theme-swatches {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  color: var(--text-faint);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}

.theme-swatch-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px var(--border-soft) inset;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.theme-swatch:hover .theme-swatch-dot { transform: scale(1.08); }

.theme-swatch.active .theme-swatch-dot {
  border-color: var(--bg);
  box-shadow: 0 0 0 2px var(--swatch-color, var(--accent));
}

.theme-swatch.active { color: var(--text); }

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.path-display {
  flex: 1;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  color: var(--text-muted);
  word-break: break-all;
}

.settings-row input[type="text"] {
  flex: 1;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}

.settings-row input[type="text"]:focus { border-color: var(--accent); }

.settings-note {
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.5;
  margin: 0;
}

.view-intro {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 4px;
}

/* ---------- Trash & audit log ---------- */

.trash-list, .audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trash-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.trash-item-info { flex: 1; min-width: 0; }

.trash-item-title {
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trash-item-meta {
  font-size: 11.5px;
  color: var(--text-faint);
}

.trash-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.audit-item {
  display: flex;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

.audit-item-time {
  flex-shrink: 0;
  width: 84px;
  color: var(--text-faint);
  font-size: 11.5px;
  padding-top: 1px;
}

.audit-item-text { flex: 1; color: var(--text); line-height: 1.5; }
.audit-item-text b { color: var(--text); font-weight: 700; }

/* ---------- Inbox ---------- */

.inbox-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  animation: notebook-card-in 0.3s cubic-bezier(0.22, 0.9, 0.32, 1.05) both;
}

.inbox-item.unread { border-left-color: var(--accent); }
.inbox-item.resolved { opacity: 0.55; }

.inbox-item-info { flex: 1; min-width: 0; }

.inbox-item-title {
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 3px;
}

.inbox-item-meta {
  font-size: 11.5px;
  color: var(--text-faint);
}

.inbox-item-status {
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
  flex-shrink: 0;
}

.inbox-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ---------- Notebook manager ---------- */

.notebook-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notebook-card {
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  animation: notebook-card-in 0.3s cubic-bezier(0.22, 0.9, 0.32, 1.05) both;
}

@keyframes notebook-card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.notebook-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.notebook-card-name {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notebook-card-meta {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
}

.notebook-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.notebook-card.member-only { cursor: pointer; transition: background 0.15s ease; }
.notebook-card.member-only:hover { background: var(--bg-card-hover); }

.notebook-card-body-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s cubic-bezier(0.22, 0.9, 0.32, 1.05);
}

.notebook-card-body-wrap.open { grid-template-rows: 1fr; }

.notebook-card-body {
  overflow: hidden;
  min-height: 0;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transition: opacity 0.2s ease 0.05s;
}

.notebook-card-body-wrap.open .notebook-card-body { opacity: 1; }

.notebook-card-manage-btn svg {
  transition: transform 0.2s ease;
}

.notebook-card-manage-btn.open svg {
  transform: rotate(180deg);
}

.notebook-card-body label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.invite-link-row {
  display: flex;
  gap: 6px;
}

.invite-link-row input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--text-muted);
}

.whitelist-row {
  display: flex;
  gap: 6px;
}

.whitelist-row input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  outline: none;
}

.whitelist-row input:focus { border-color: var(--accent); }

.member-mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.member-mini-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 2px;
  font-size: 12.5px;
}

.member-mini-item .member-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn-sm:hover { background: var(--bg-elevated); color: var(--danger); }
.icon-btn-sm svg { width: 13px; height: 13px; }

/* ---------- Read-only (Zuschauer) ---------- */

.composer.readonly-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}

[data-role="viewer"] #composer { display: none; }
[data-role="viewer"] #toolConnectBtn { display: none; }
[data-role="viewer"] .mindmap-node { cursor: default; }
[data-role="viewer"] .mindmap-canvas.tool-connect .mindmap-node { cursor: default; }

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .app-sidebar { width: 48px; padding: 10px 0; }
  .sidebar-tab { width: 34px; height: 34px; }
  .topbar { padding: 12px 16px; }
  .note-count { display: none; }
  .sort-select { display: none; }
  #pinboardView { padding: 18px 16px 60px; }
  .board-grid { column-width: 100%; }
  .user-name { max-width: 70px; }
  .mindmap-view { padding: 10px 12px 14px; gap: 10px; }
  .search-box { width: 92px; }
  .search-box:focus-within { width: 140px; }
  .options-panel { padding: 18px 16px 60px; }
  .settings-row { flex-wrap: wrap; }
  .trash-item { flex-wrap: wrap; }
  .inbox-item { flex-wrap: wrap; }
  .audit-item { flex-direction: column; gap: 4px; }
  .audit-item-time { width: auto; }
}
