
  :root {
    --bg: #0d0d14;
    --bg2: #13131f;
    --bg3: #1a1a2e;
    --bg4: #20203a;
    --accent: #7c6af7;
    --accent2: #5a4fd4;
    --accent3: #9d8fff;
    --text: #e8e8f0;
    --text2: #9090b0;
    --text3: #6060a0;
    --border: #2a2a4a;
    --border2: #3a3a6a;
    --success: #4ade80;
    --danger: #f87171;
    --warn: #fbbf24;
    --node-bg: #1e1e35;
    --node-border: #4a4a8a;
    --link-color: #7c6af7;
    --radius: 10px;
    --radius-sm: 6px;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }

  /* ===== UTILS ===== */
  .hidden { display: none !important; }
  .btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius-sm);
    border: none; cursor: pointer; font-size: 14px; font-weight: 500;
    transition: all 0.15s;
  }
  .btn-primary { background: var(--accent); color: #fff; }
  .btn-primary:hover { background: var(--accent2); }
  .btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border2); }
  .btn-ghost:hover { background: var(--bg4); color: var(--text); }
  .btn-danger { background: #3a1a1a; color: var(--danger); border: 1px solid #5a2a2a; }
  .btn-danger:hover { background: #5a2a2a; }
  .btn-sm { padding: 5px 10px; font-size: 12px; }
  .btn-icon { padding: 6px; border-radius: var(--radius-sm); background: transparent; border: 1px solid var(--border); cursor: pointer; color: var(--text2); display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
  .btn-icon:hover { background: var(--bg4); color: var(--text); }
  .btn-icon.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  input, textarea, select {
    background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius-sm);
    color: var(--text); padding: 8px 12px; font-size: 14px; width: 100%;
    outline: none; transition: border 0.15s;
  }
  input:focus, textarea:focus, select:focus { border-color: var(--accent); }
  textarea { resize: vertical; min-height: 60px; }
  label { font-size: 12px; color: var(--text2); margin-bottom: 4px; display: block; }
  .form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
  .tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
  }
  .tag-purple { background: #2a1f5a; color: var(--accent3); }
  .tag-green { background: #0f3a1f; color: var(--success); }
  .tag-red { background: #3a0f0f; color: var(--danger); }
  .tag-yellow { background: #3a2a0f; color: var(--warn); }

  /* ===== STARS BG ===== */
  #stars { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

  /* ===== AUTH ===== */
  #auth-screen {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
  }
  .auth-card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 16px; padding: 32px; width: 380px;
    position: relative; z-index: 1;
  }
  .auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 6px; }
  .auth-logo svg { color: var(--accent); }
  .auth-logo span { font-size: 18px; font-weight: 700; }
  .auth-subtitle { text-align: center; color: var(--text2); font-size: 13px; margin-bottom: 24px; }
  .auth-tabs { display: flex; background: var(--bg3); border-radius: var(--radius-sm); padding: 3px; margin-bottom: 24px; }
  .auth-tab { flex: 1; text-align: center; padding: 8px; border-radius: 5px; cursor: pointer; font-size: 14px; color: var(--text2); transition: all 0.15s; }
  .auth-tab.active { background: var(--accent); color: #fff; }
  .auth-link { text-align: center; font-size: 12px; color: var(--text3); margin-top: 16px; }
  .auth-link a { color: var(--accent3); cursor: pointer; }
  .auth-link a:hover { text-decoration: underline; }
  .forgot { font-size: 12px; color: var(--accent3); cursor: pointer; }
  .forgot:hover { text-decoration: underline; }
  .remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); margin-bottom: 14px; }
  .remember input[type=checkbox] { width: auto; }

  /* ===== MAIN LAYOUT ===== */
  #app { display: flex; height: 100vh; position: relative; z-index: 1; }

  /* SIDEBAR */
  #sidebar {
    width: 200px; min-width: 200px;
    background: var(--bg2); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
  }
  .sidebar-logo { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .sidebar-logo svg { color: var(--accent); }
  .sidebar-logo span { font-weight: 700; font-size: 15px; }
  .sidebar-nav { flex: 1; padding: 8px; overflow-y: auto; }
  .nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 14px; color: var(--text2);
    transition: all 0.15s; position: relative;
  }
  .nav-item:hover { background: var(--bg3); color: var(--text); }
  .nav-item.active { background: var(--bg4); color: var(--accent3); }
  .nav-badge {
    margin-left: auto; background: var(--accent); color: #fff;
    font-size: 10px; padding: 1px 5px; border-radius: 10px;
  }
  .sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
  .user-info { display: flex; align-items: center; gap: 8px; }
  .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
  .user-name { font-size: 13px; font-weight: 500; }
  .user-role { font-size: 11px; color: var(--text3); }

  /* MAIN AREA */
  #main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

  /* TOP BAR */
  #topbar {
    height: 52px; background: var(--bg2); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px; padding: 0 16px;
  }
  .topbar-search { flex: 1; max-width: 380px; position: relative; }
  .topbar-search input { padding-left: 36px; }
  .topbar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); }
  .topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

  /* PAGES */
  .page { flex: 1; overflow-y: auto; padding: 24px; display: none; }
  .page.active { display: block; }

  /* HOME PAGE */
  .page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
  .page-title { font-size: 24px; font-weight: 700; }
  .page-subtitle { color: var(--text2); font-size: 14px; margin-bottom: 28px; }
  .stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
  .stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
  .stat-icon { color: var(--text3); margin-bottom: 8px; }
  .stat-value { font-size: 28px; font-weight: 700; }
  .stat-label { font-size: 12px; color: var(--text2); margin-top: 2px; }
  .section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .section-title { font-size: 16px; font-weight: 600; }
  .section-link { font-size: 12px; color: var(--accent3); cursor: pointer; }
  .section-link:hover { text-decoration: underline; }
  .boards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
  .board-card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; cursor: pointer;
    transition: all 0.15s; position: relative;
  }
  .board-card:hover { border-color: var(--border2); transform: translateY(-2px); }
  .board-preview { height: 100px; background: var(--bg3); position: relative; overflow: hidden; }
  .board-preview-empty { height: 100px; background: var(--bg3); display: flex; align-items: center; justify-content: center; color: var(--text3); }
  .board-preview svg.preview-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
  .board-info { padding: 12px; }
  .board-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
  .board-meta { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--text3); }
  .board-date { font-size: 11px; color: var(--text3); margin-top: 4px; }
  .board-menu { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity 0.15s; }
  .board-card:hover .board-menu { opacity: 1; }
  .templates-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .tpl-card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; cursor: pointer;
    transition: all 0.15s;
  }
  .tpl-card:hover { border-color: var(--accent); }
  .tpl-card.empty { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; min-height: 100px; border-style: dashed; }
  .tpl-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--bg4); display: flex; align-items: center; justify-content: center; color: var(--accent3); margin-bottom: 8px; }
  .tpl-tag { font-size: 10px; color: var(--text3); float: right; margin-top: -30px; }
  .tpl-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
  .tpl-desc { font-size: 12px; color: var(--text2); line-height: 1.4; }

  /* BOARD EDITOR */
  #board-editor {
    position: fixed; inset: 0; z-index: 200;
    display: flex; flex-direction: column;
    background: var(--bg);
  }
  #board-editor.hidden { display: none !important; }
  .editor-topbar {
    height: 46px; background: var(--bg2); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px; padding: 0 12px;
    flex-shrink: 0;
  }
  .editor-title { font-size: 14px; font-weight: 600; margin: 0 8px; }
  .editor-title-input {
    font-size: 14px; font-weight: 600; background: transparent; border: none;
    color: var(--text); padding: 4px 8px; border-radius: 4px;
    width: 200px;
  }
  .editor-title-input:focus { background: var(--bg3); outline: 1px solid var(--border2); }
  .editor-status { font-size: 11px; color: var(--text3); }
  .editor-meta { margin-left: 0; display: flex; align-items: center; gap: 8px; }

  .editor-body { flex: 1; display: flex; overflow: hidden; }
  .editor-tools {
    width: 50px; background: var(--bg2); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; align-items: center;
    padding: 8px 0; gap: 4px;
  }
  .tool-sep { width: 30px; height: 1px; background: var(--border); margin: 4px 0; }
  .canvas-wrap { flex: 1; position: relative; overflow: hidden; }
  #canvas { width: 100%; height: 100%; cursor: default; }
  .editor-panel {
    width: 260px; background: var(--bg2); border-left: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden;
  }
  .panel-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
  .panel-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
  .panel-section { margin-bottom: 18px; }
  .panel-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); margin-bottom: 10px; font-weight: 600; }

  /* NODE TYPES */
  .node-type-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .node-type-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 10px 6px; border-radius: var(--radius-sm); cursor: pointer;
    background: var(--bg3); border: 1px solid var(--border);
    font-size: 11px; color: var(--text2); transition: all 0.15s;
  }
  .node-type-btn:hover { background: var(--bg4); border-color: var(--accent); color: var(--text); }
  .node-type-btn svg { color: var(--accent3); }

  /* CANVAS NODES */
  .canvas-node {
    position: absolute; min-width: 140px; max-width: 360px;
    background: var(--node-bg); border: 1.5px solid var(--node-border);
    border-radius: var(--radius); cursor: move; user-select: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    transition: box-shadow 0.15s, border-color 0.15s;
    z-index: 6;
  }
  .canvas-node:hover { border-color: var(--accent3); box-shadow: 0 4px 24px rgba(124,106,247,0.2); }
  .canvas-node.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124,106,247,0.3); }
  .node-head {
    padding: 8px 10px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 6px;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .node-head-icon { width: 20px; height: 20px; flex-shrink: 0; }
  .node-head-title { font-size: 12px; font-weight: 700; color: var(--text); flex: 1; min-width: 0; word-break: break-word; }
  .node-head-type { font-size: 10px; color: var(--text3); }
  .node-body { padding: 8px 10px; max-height: 280px; overflow-y: auto; }
  .node-body > div { word-break: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
  .node-field { margin-bottom: 6px; }
  .node-field-label { font-size: 10px; color: var(--text3); margin-bottom: 2px; }
  .node-field-value { font-size: 12px; color: var(--text2); word-break: break-all; }
  .node-port {
    position: absolute; width: 10px; height: 10px;
    background: var(--bg); border: 2px solid var(--node-border);
    border-radius: 50%; cursor: crosshair;
    transition: all 0.15s;
  }
  .node-port:hover { background: var(--accent); border-color: var(--accent); transform: scale(1.4); }
  .node-port.port-right { right: -5px; top: 50%; transform: translateY(-50%); }
  .node-port.port-left { left: -5px; top: 50%; transform: translateY(-50%); }
  .node-port.port-top { top: -5px; left: 50%; transform: translateX(-50%); }
  .node-port.port-bottom { bottom: -5px; left: 50%; transform: translateX(-50%); }
  .node-port.port-right:hover { transform: translateY(-50%) scale(1.4); }
  .node-port.port-left:hover { transform: translateY(-50%) scale(1.4); }
  .node-port.port-top:hover { transform: translateX(-50%) scale(1.4); }
  .node-port.port-bottom:hover { transform: translateX(-50%) scale(1.4); }

  .node-delete { position: absolute; top: -10px; right: -10px; width: 22px; height: 22px; background: var(--danger); border: 2px solid var(--bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 13px; line-height: 1; color: #fff; z-index: 20; opacity: 0; pointer-events: none; transition: opacity .12s, transform .12s; }
  .canvas-node.selected .node-delete, .canvas-node:hover .node-delete { opacity: 1; pointer-events: auto; }
  .node-delete:hover { transform: scale(1.12); }

  /* NODE COLORS */
  .node-person .node-head { background: #1a1433; }
  .node-phone .node-head { background: #0d2a1a; }
  .node-email .node-head { background: #1a2a0d; }
  .node-ip .node-head { background: #1a1a0d; }
  .node-domain .node-head { background: #1a0d2a; }
  .node-account .node-head { background: #0d1a2a; }
  .node-location .node-head { background: #2a0d0d; }
  .node-note .node-head { background: #2a2a0d; }
  .node-company .node-head { background: #0d1a1a; }
  .node-crypto .node-head { background: #1a0d0d; }

  /* ARROW SVG overlay */
  #arrows-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
  .arrow-path { stroke: var(--accent3); stroke-width: 1.5; fill: none; marker-end: url(#arrowhead); }
  .arrow-path.selected-edge { stroke: var(--accent); stroke-width: 2.5; }
  .arrow-label { fill: var(--text2); font-size: 11px; }
  .arrow-hitbox { stroke: transparent; stroke-width: 12; fill: none; cursor: pointer; pointer-events: all; }

  /* CONTEXT MENU */
  #ctx-menu {
    position: fixed; z-index: 9999;
    background: var(--bg2); border: 1px solid var(--border2);
    border-radius: var(--radius-sm); padding: 4px;
    min-width: 160px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  }
  .ctx-item { padding: 7px 12px; font-size: 13px; cursor: pointer; border-radius: 4px; display: flex; align-items: center; gap: 8px; }
  .ctx-item:hover { background: var(--bg4); }
  .ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }
  .ctx-item.danger { color: var(--danger); }

  /* MODAL */
  .modal-overlay {
    position: fixed; inset: 0; z-index: 5000;
    background: rgba(0,0,0,0.7); display: flex;
    align-items: center; justify-content: center;
  }
  .modal {
    background: var(--bg2); border: 1px solid var(--border2);
    border-radius: 14px; padding: 24px; width: 440px; max-width: 95vw;
    max-height: 85vh; overflow-y: auto;
  }
  .modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
  .modal-title { font-size: 17px; font-weight: 700; }
  .modal-close { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 20px; line-height: 1; }
  .modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

  /* COOP SHARE */
  .share-link-box { background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 10px 12px; font-family: monospace; font-size: 12px; word-break: break-all; color: var(--accent3); margin-bottom: 12px; }
  .coop-users { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
  .coop-user { display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--bg3); border-radius: var(--radius-sm); }
  .coop-user .avatar { width: 28px; height: 28px; font-size: 11px; }
  .coop-user-name { font-size: 13px; }
  .coop-user-role { font-size: 11px; color: var(--text3); margin-left: auto; }
  .online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }

  /* NOTIFICATIONS */
  #notif-area { position: fixed; top: 16px; right: 16px; z-index: 9000; display: flex; flex-direction: column; gap: 8px; }
  .notif {
    background: var(--bg2); border: 1px solid var(--border2);
    border-radius: var(--radius-sm); padding: 12px 16px;
    font-size: 13px; min-width: 260px; max-width: 340px;
    display: flex; align-items: center; gap: 10px;
    animation: slideIn 0.2s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  }
  .notif-success { border-left: 3px solid var(--success); }
  .notif-error { border-left: 3px solid var(--danger); }
  .notif-info { border-left: 3px solid var(--accent); }
  @keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

  /* MINI TOOLTIP */
  [data-tip] { position: relative; }
  [data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute; left: 52px; top: 50%; transform: translateY(-50%);
    background: var(--bg4); border: 1px solid var(--border2);
    color: var(--text); font-size: 11px; padding: 3px 8px;
    border-radius: 4px; white-space: nowrap; z-index: 100; pointer-events: none;
  }

  /* GRID CANVAS BG */
  .canvas-wrap::before {
    content: '';
    position: absolute; inset: 0;
    background-image:
      linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 30px 30px;
    pointer-events: none;
  }

  /* MINI MAP */
  #mini-map {
    position: absolute; bottom: 16px; right: 16px;
    width: 160px; height: 100px; background: var(--bg2);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    overflow: hidden; z-index: 10;
  }

  /* ZOOM CONTROLS */
  .zoom-controls {
    position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 4px;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 20px; padding: 4px 8px; z-index: 10;
  }
  .zoom-val { font-size: 12px; color: var(--text2); min-width: 42px; text-align: center; }

  /* EDGE LABEL INPUT */
  .edge-label-wrap { position: absolute; z-index: 20; }
  .edge-label-input { width: 100px; font-size: 11px; padding: 3px 6px; }

  /* SCROLLBAR */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--accent); }

  /* RESPONSIVE CANVAS NODES */
  @media (max-width: 900px) {
    .boards-grid, .templates-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
  }

  /* ===== CURSOR GLOW ===== */
  #cursor-glow {
    position: fixed;
    top: 0; left: 0;
    width: 28px; height: 28px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent) 55%, transparent) 0%, color-mix(in srgb, var(--accent) 15%, transparent) 50%, transparent 70%);
    box-shadow: 0 0 8px 2px color-mix(in srgb, var(--accent) 25%, transparent);
    transition: width 0.15s, height 0.15s, background 0.3s, opacity 0.2s;
    will-change: transform;
    mix-blend-mode: screen;
  }
  #cursor-glow.big {
    width: 48px; height: 48px;
    background: radial-gradient(circle, rgba(124,106,247,0.4) 0%, rgba(124,106,247,0.1) 50%, transparent 70%);
  }

  /* ===== PARTICLE SPARKS ===== */
  .spark {
    position: fixed;
    width: 4px; height: 4px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    background: var(--accent);
    animation: sparkFly 0.6s ease-out forwards;
  }
  @keyframes sparkFly {
    0% { opacity: 1; transform: scale(1) translate(0,0); }
    100% { opacity: 0; transform: scale(0) translate(var(--dx), var(--dy)); }
  }

  .cursor-trail-particle {
    position: fixed;
    z-index: 9997;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation-delay: var(--trail-delay, 0ms);
    animation-fill-mode: forwards;
  }
  .trail-neon {
    height: 3px !important; width: 22px !important; border-radius: 999px;
    transform-origin: right center; box-shadow: 0 0 9px var(--trail-color), 0 0 18px var(--trail-color);
    animation: trailNeon var(--trail-life) ease-out forwards;
  }
  .trail-ice {
    border-radius: 1px; transform: translate(-50%,-50%) rotate(45deg);
    box-shadow: 0 0 7px var(--trail-color); animation: trailIce var(--trail-life) ease-out forwards;
  }
  .trail-fire {
    border-radius: 70% 30% 70% 30%;
    background: linear-gradient(to top, #ef4444, var(--trail-color), #fef08a) !important;
    box-shadow: 0 0 10px var(--trail-color); animation: trailFire var(--trail-life) ease-out forwards;
  }
  .trail-toxic {
    border: 2px solid var(--trail-color); background: color-mix(in srgb, var(--trail-color) 22%, transparent) !important;
    box-shadow: inset 0 0 6px var(--trail-color), 0 0 8px var(--trail-color);
    animation: trailToxic var(--trail-life) ease-out forwards;
  }
  .trail-comet {
    width: 34px !important; height: 4px !important; border-radius: 999px; transform-origin: right center;
    background: linear-gradient(90deg, transparent, #67e8f9, var(--trail-color)) !important;
    box-shadow: 5px 0 10px var(--trail-color); animation: trailComet var(--trail-life) linear forwards;
  }
  @keyframes trailNeon {
    0% { opacity:.9; transform: translate(-100%,-50%) rotate(var(--trail-angle)) scaleX(1); }
    100% { opacity:0; transform: translate(-100%,-50%) rotate(var(--trail-angle)) scaleX(.05); }
  }
  @keyframes trailIce {
    0% { opacity:1; transform: translate(-50%,-50%) rotate(45deg) scale(.5); }
    60% { opacity:.8; transform: translate(var(--trail-drift-x),var(--trail-drift-y)) rotate(170deg) scale(1); }
    100% { opacity:0; transform: translate(var(--trail-drift-x),var(--trail-drift-y)) rotate(260deg) scale(.15); }
  }
  @keyframes trailFire {
    0% { opacity:1; transform: translate(-50%,-20%) scale(.65) rotate(0); }
    100% { opacity:0; transform: translate(var(--trail-drift-x),var(--trail-drift-y)) scale(.1) rotate(35deg); }
  }
  @keyframes trailToxic {
    0% { opacity:.8; transform: translate(-50%,-50%) scale(.2); }
    65% { opacity:.65; }
    100% { opacity:0; transform: translate(var(--trail-drift-x),var(--trail-drift-y)) scale(2.1); }
  }
  @keyframes trailComet {
    0% { opacity:1; transform: translate(-100%,-50%) rotate(var(--trail-angle)) scaleX(1); }
    100% { opacity:0; transform: translate(-100%,-50%) rotate(var(--trail-angle)) scaleX(.15); }
  }

  /* ===== NODE APPEAR ANIMATION (disabled: re-render replayed it on every click) ===== */
  @keyframes nodeAppear {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
  }


  /* ===== EDGE GLOW ON HOVER ===== */
  .arrow-hitbox:hover + .arrow-path {
    filter: drop-shadow(0 0 4px var(--accent));
  }

  /* ===== PULSING DOT ON SELECTED NODE ===== */
  .canvas-node.selected::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    border: 2px solid var(--accent);
    animation: pulseRing 1.5s ease-out infinite;
    pointer-events: none;
  }
  @keyframes pulseRing {
    0%  { opacity: 0.8; transform: scale(1); }
    100%{ opacity: 0; transform: scale(1.08); }
  }

  /* ===== THEME PRESET BUTTONS ===== */
  .theme-preset-btn {
    display: flex; flex-direction: column; align-items: center;
    cursor: pointer; padding: 8px; border-radius: 8px;
    border: 2px solid var(--border);
    transition: all 0.15s;
    color: var(--text2); font-size: 11px;
  }
  .theme-preset-btn:hover { border-color: var(--accent3); background: var(--bg3); transform: translateY(-1px); }
  .theme-preset-btn.active { border-color: var(--accent); background: var(--bg4); color: var(--text); box-shadow: 0 0 0 1px var(--accent); }
  .theme-preview {
    width: 44px; height: 28px; border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; margin-bottom: 4px;
  }
  .trail-preset-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .trail-preset-btn {
    min-width: 0; padding: 8px 4px; border: 2px solid var(--border); border-radius: 7px;
    background: var(--bg2); color: var(--text2); cursor: pointer; font: inherit; font-size: 11px;
    display: flex; flex-direction: column; align-items: center; gap: 6px; transition: border-color .15s, background .15s;
  }
  .trail-preset-btn:hover { border-color: var(--accent3); background: var(--bg3); }
  .trail-preset-btn.active { border-color: var(--accent); background: var(--bg4); color: var(--text); }
  .trail-preset-btn span {
    display: block; width: var(--trail-dot); height: var(--trail-dot); border-radius: 50%;
    background: var(--trail-swatch); box-shadow: 0 0 10px var(--trail-swatch), 0 0 18px var(--trail-swatch);
  }
  .color-picker-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border-radius: 6px;
    background: var(--bg3); border: 1px solid var(--border);
    transition: border-color 0.15s;
  }
  .color-picker-row:hover { border-color: var(--border2); }
  .color-swatch {
    width: 28px; height: 22px; border-radius: 4px;
    border: 1px solid var(--border2); cursor: pointer; flex-shrink: 0;
    overflow: hidden; position: relative;
  }
  .color-swatch input[type=color] {
    position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px);
    opacity: 0; cursor: pointer; padding: 0; border: none;
  }

  /* ===== FLOATING PARTICLES CANVAS ===== */
  #particles-canvas {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 0;
  }

  /* ===== STAT CARD HOVER ANIMATION ===== */
  .stat-card {
    transition: transform 0.2s, box-shadow 0.2s;
  }
  .stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(124,106,247,0.15);
  }

  /* ===== SIDEBAR NAV ITEM ANIMATED ===== */
  .nav-item { transition: all 0.2s; }
  .nav-item.active { position: relative; }
  .nav-item.active::before {
    content: '';
    position: absolute; left: 0; top: 20%; height: 60%;
    width: 3px; border-radius: 0 3px 3px 0;
    background: var(--accent);
    animation: navSlide 0.2s ease;
  }
  @keyframes navSlide {
    from { opacity: 0; transform: scaleY(0); }
    to   { opacity: 1; transform: scaleY(1); }
  }

  /* ===== BOARD CARD ANIMATE ===== */
  .board-card { transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; }
  .board-card:hover { box-shadow: 0 8px 28px rgba(124,106,247,0.18); }

  /* ===== COLOR PICKER INPUT STYLE ===== */
  input[type=color] {
    -webkit-appearance: none;
    appearance: none;
    background: none;
  }
  input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
  input[type=color]::-webkit-color-swatch { border: none; border-radius: 3px; }

  /* ===== NOTIFICATION ANIMATION ===== */
  .notif { animation: slideIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

  /* ===== CONNECTING LINE PULSE ===== */
  #temp-edge { animation: dashMove 0.5s linear infinite; }
  @keyframes dashMove {
    from { stroke-dashoffset: 16; }
    to   { stroke-dashoffset: 0; }
  }

/* Image nodes */
.canvas-node.node-image { max-width: 320px; }
.node-body-image { padding: 6px !important; max-height: none !important; overflow: hidden; }
.node-body-image .node-img {
  display: block; width: 100%; max-width: 300px; max-height: 240px;
  object-fit: contain; border-radius: 8px; background: rgba(0,0,0,.25);
  user-select: none; -webkit-user-drag: none;
}
.node-img-caption {
  margin-top: 6px; font-size: 11px; color: var(--text2);
  word-break: break-word; overflow-wrap: anywhere;
}

/* Image resize handle + scope menu */
.node-resize {
  position: absolute; right: -10px; bottom: -10px; width: 22px; height: 22px;
  border-radius: 5px; background: var(--accent); border: 3px solid var(--bg);
  cursor: nwse-resize; opacity: 0; pointer-events: none; transition: opacity .15s, transform .12s; z-index: 20;
}
.node-resize::after { content: ''; position: absolute; right: 3px; bottom: 3px; width: 7px; height: 7px; border-right: 2px solid #fff; border-bottom: 2px solid #fff; }
.canvas-node:hover .node-resize, .canvas-node.selected .node-resize, .canvas-node.is-resizing .node-resize { opacity: 1; pointer-events: auto; }
.node-resize:hover { transform: scale(1.1); }
.node-resize-active, .node-resize-active * { cursor: nwse-resize !important; }
.node-image .node-img { max-width: none !important; max-height: none !important; height: auto; }
.img-scope-menu {
  position: fixed; z-index: 9999; min-width: 190px; padding: 8px;
  background: rgba(18,18,28,.98); border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 6px;
}
.img-scope-title { font-size: 11px; color: var(--text2); margin-bottom: 2px; }
.img-scope-btn {
  font-size: 12px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05); color: var(--text);
  text-align: left;
}
.img-scope-btn:hover { background: rgba(255,255,255,.1); }
.img-scope-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.img-scope-btn.ghost { color: var(--text3); }

/* ===== INTRO SPLASH ===== */
#noxel-splash {
  position: fixed; inset: 0; z-index: 99999; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 45%, #14122b 0%, #08080f 60%, #05050a 100%);
  animation: splashOut .7s ease 2.5s forwards;
}
#noxel-splash .splash-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 18px; }
#noxel-splash .splash-logo {
  width: 240px; max-width: 62vw; filter: drop-shadow(0 0 40px rgba(124,106,247,.55));
  animation: splashLogo 1.5s cubic-bezier(.16,1,.3,1) both;
}
#noxel-splash .splash-tag {
  font-size: 12px; letter-spacing: .42em; color: #8f8fc0; text-transform: uppercase;
  animation: splashTag 1s ease .8s both;
}
#noxel-splash .splash-ring {
  position: absolute; top: 50%; left: 50%; width: 320px; height: 320px; margin: -160px 0 0 -160px;
  border: 1px solid rgba(124,106,247,.35); border-radius: 50%;
  animation: splashRing 2.2s ease-out infinite;
}
@keyframes splashLogo { 0% { opacity:0; transform: scale(.82) translateY(14px); } 100% { opacity:1; transform: none; } }
@keyframes splashTag { 0% { opacity:0; letter-spacing:.15em; } 100% { opacity:.9; letter-spacing:.42em; } }
@keyframes splashRing { 0% { transform: scale(.55); opacity:.55; } 100% { transform: scale(1.35); opacity:0; } }
@keyframes splashBeam { 0% { opacity:0; transform: scaleX(.4); } 60% { opacity:.75; } 100% { opacity:.35; transform: scaleX(1); } }
@keyframes splashOut { to { opacity: 0; visibility: hidden; } }

/* ===== NODE RESIZE (both directions) ===== */
.canvas-node.has-size { min-width: 0 !important; max-width: none !important; display: flex; flex-direction: column; }
.canvas-node.has-size .node-body { flex: 1 1 auto; max-height: none !important; overflow: auto; min-height: 0; }
.canvas-node.has-size .node-body-image { display: flex; flex-direction: column; }
.canvas-node.has-size .node-img { width: 100%; height: 100%; max-width: none !important; max-height: none !important; object-fit: contain; }
.canvas-node.is-resizing { transition: none !important; }

/* ===== LIGHTHOUSE SPARKS TRAVELLING TO CURSOR ===== */
#noxel-splash { overflow: hidden; }
#noxel-splash .splash-sparks { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
#noxel-splash .spark {
  position: fixed; left: 0; top: 0; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.98) 0%, rgba(196,184,255,.85) 40%, rgba(124,106,247,0) 72%);
  box-shadow: 0 0 14px rgba(150,130,255,.9), 0 0 28px rgba(124,106,247,.5);
  pointer-events: none; will-change: transform, opacity;
}
#noxel-splash .splash-logo { position: relative; z-index: 2; }
