/* Arriving from the homepage: its closing animation cross-fades into the workspace. */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

/* ============ Tokens ============ */
/* The palette of the OMYT homepage: warm paper, ink and soft floating cards. */
:root {
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --radius: 22px;

  --bg: #F9F8F5;
  --dot: #D9D9D0;
  --surface: #FFFFFF;
  --surface-2: #F1F1EC;
  --glass: rgba(255, 255, 255, .82);
  --hover: rgba(20, 21, 19, .05);
  --active: rgba(20, 21, 19, .085);
  --border: rgba(20, 21, 19, .09);
  --border-strong: rgba(20, 21, 19, .17);
  --text: #141513;
  --text-2: #5E6059;
  --text-3: #9A9B93;
  --accent: #171816;
  --on-accent: #FFFFFF;
  --danger: #E5484D;
  --warn: #C98A0B;
  --tip-bg: #171816;
  --tip-fg: #FFFFFF;
  --shadow-sm: 0 1px 2px rgba(20, 21, 19, .06), 0 1px 1px rgba(20, 21, 19, .04);
  --shadow-md: 0 18px 40px -22px rgba(20, 21, 19, .24), 0 2px 6px rgba(20, 21, 19, .05);
  --shadow-lg: 0 40px 80px -36px rgba(20, 21, 19, .32), 0 2px 10px rgba(20, 21, 19, .05);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121311;
  --dot: #272823;
  --surface: #1B1C19;
  --surface-2: #252622;
  --glass: rgba(27, 28, 25, .86);
  --hover: rgba(255, 255, 250, .06);
  --active: rgba(255, 255, 250, .095);
  --border: rgba(255, 255, 250, .08);
  --border-strong: rgba(255, 255, 250, .16);
  --text: #EFEEE8;
  --text-2: #A9AAA1;
  --text-3: #70716A;
  --accent: #EFEEE8;
  --on-accent: #141513;
  --danger: #FF6369;
  --warn: #F2B33D;
  --tip-bg: #34352F;
  --tip-fg: #F4F3EE;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 18px 40px -20px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-lg: 0 40px 80px -30px rgba(0, 0, 0, .7), 0 4px 14px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  /* free area between the side cards: toolbar, hints and toasts centre on it */
  --sbw: 248px; --pw: 372px;
  --li: calc(var(--sbw) + 24px); --ri: 0px;
  --mid: calc(var(--li) + (100vw - var(--li) - var(--ri)) / 2);
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s;
}
button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
input, textarea { font: inherit; color: inherit; }
body.sb-collapsed { --li: 0px; }
body.panel-open { --ri: calc(var(--pw) + 24px); }
/* keep the edge tooltips of the swatch/shape rows inside the panel */
.swatches > :last-child::after, .shapes > :last-child::after { left: auto; right: -4px; transform: translate(0, 4px); }
.swatches > :last-child:hover::after, .shapes > :last-child:hover::after { transform: none; }
.swatches > :first-child::after, .shapes > :first-child::after { left: -4px; transform: translate(0, 4px); }
.swatches > :first-child:hover::after, .shapes > :first-child:hover::after { transform: none; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ Buttons ============ */
.icon-btn {
  position: relative;
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  border-radius: 9px;
  color: var(--text-2);
  transition: background-color .15s, color .15s, transform .25s var(--spring);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { transform: scale(.88); background: var(--active); transition-duration: .08s; }
.icon-btn:disabled { opacity: .32; pointer-events: none; }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 7px; }
.icon-btn.sm svg.i { width: 15px; height: 15px; }

.btn {
  height: 34px; padding: 0 14px; border-radius: 10px;
  font-weight: 600; font-size: 13.5px;
  transition: background-color .15s, transform .25s var(--spring), box-shadow .15s;
}
.btn:active { transform: scale(.95); transition-duration: .08s; }
.btn.ghost { color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.primary:hover, .btn.danger:hover { box-shadow: 0 4px 14px color-mix(in srgb, currentColor 0%, rgba(0,0,0,.18)); filter: brightness(1.05); }

/* ============ Tooltips ============ */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; z-index: 1000;
  left: 50%; bottom: calc(100% + 8px);
  transform: translate(-50%, 4px);
  padding: 5px 9px; border-radius: 7px;
  background: var(--tip-bg); color: var(--tip-fg);
  font-size: 12px; font-weight: 500; line-height: 1.3; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .12s, transform .18s var(--ease);
  box-shadow: var(--shadow-md);
}
[data-tip]:hover::after { opacity: 1; transform: translate(-50%, 0); transition-delay: .5s; }
[data-tip]:active::after { opacity: 0; transition-delay: 0s; }
[data-tip-pos="bottom"]::after { bottom: auto; top: calc(100% + 8px); transform: translate(-50%, -4px); }
[data-tip-pos="right"]::after { bottom: auto; left: calc(100% + 8px); top: 50%; transform: translate(-4px, -50%); }
[data-tip-pos="right"]:hover::after { transform: translate(0, -50%); }
[data-tip-pos="left"]::after { bottom: auto; left: auto; right: calc(100% + 8px); top: 50%; transform: translate(4px, -50%); }
[data-tip-pos="left"]:hover::after { transform: translate(0, -50%); }

/* ============ Canvas ============ */
#canvas {
  position: fixed; inset: 0;
  overflow: hidden;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dot) 1.15px, transparent 1.45px);
  background-size: 24px 24px;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  transition: background-color .3s;
}
#canvas.panning, #canvas.panning * { cursor: grabbing !important; }
#canvas.dragging-node, #canvas.dragging-node * { cursor: grabbing !important; }
#world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }
#world.fade-in { animation: worldIn .45s var(--ease); }
@keyframes worldIn { from { opacity: 0; filter: blur(4px); } }
#edges { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
#nodeLayer { position: absolute; left: 0; top: 0; }

.edge {
  fill: none; stroke-width: 2.6; stroke-linecap: round; opacity: .62;
  transition: opacity .25s;
}
.edge.leaving { opacity: 0; }
.edge.hot { opacity: 1; }
#ghostLine {
  fill: none; stroke: var(--gc, var(--accent)); stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 2 7; opacity: 0; transition: opacity .15s;
}
#ghostLine.visible { opacity: .75; }

/* ============ Nodes ============ */
.node { position: absolute; left: 0; top: 0; width: 0; height: 0; --s: 60px; }
.node-hit {
  position: absolute;
  width: var(--s); height: var(--s);
  left: calc(var(--s) / -2); top: calc(var(--s) / -2);
  cursor: pointer;
  transition: transform .4s var(--spring);
}
.node-svg {
  position: absolute; left: -10%; top: -10%; width: 120%; height: 120%;
  overflow: visible;
  filter: drop-shadow(0 6px 10px color-mix(in srgb, var(--c) 34%, transparent)); /* a soft shadow in the note's colour, under the orb */
  transition: filter .3s var(--ease);
}
.node .fill, .p-hero-shape .fill { fill: var(--c); transition: fill .3s; }
.node .poly.fill, .p-hero-shape .poly.fill { stroke: var(--c); stroke-width: 8; stroke-linejoin: round; transition: fill .3s, stroke .3s; }
/* the orb layers over the fill (orbMarkup in app.js): two tinted spots and a pale rim */
.orb { pointer-events: none; }
.orb-hot { stop-color: var(--c1, var(--c)); transition: stop-color .3s; }
.orb-warm { stop-color: var(--c2, var(--c)); transition: stop-color .3s; }
.orb.rim { fill: url(#orbRim); }
.node .halo {
  fill: none; stroke: var(--c); stroke-width: 3; stroke-linejoin: round;
  opacity: 0; transform: scale(1.02);
  transition: opacity .2s, transform .45s var(--spring);
}
.node:hover .node-hit { transform: scale(1.07); }
.node:hover .node-svg { filter: drop-shadow(0 10px 16px color-mix(in srgb, var(--c) 40%, transparent)); }
.node.pressed .node-hit { transform: scale(.93); transition-duration: .12s; }
.node.dragging .node-hit { transform: scale(1.12); }
.node.dragging .node-svg { filter: drop-shadow(0 16px 24px color-mix(in srgb, var(--c) 42%, transparent)); }
.node.dragging { z-index: 5; }
.node.selected .halo { opacity: .5; transform: scale(1.2); }
/* a dragged note pressing against this one */
.node.touching .node-hit { transform: scale(.95); transition-duration: .15s; }
.node.touching .halo { opacity: .45; transform: scale(1.22); stroke-dasharray: 5 6; }
.node.selected { z-index: 4; }

.node-label {
  position: absolute;
  top: calc(var(--s) / 2 + 10px); left: -100px; width: 200px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  pointer-events: none;
  transition: opacity .2s, transform .3s var(--ease);
}
.node-title {
  pointer-events: auto; cursor: pointer;
  max-width: 190px; padding: 2px 7px; border-radius: 7px;
  font-size: 13px; font-weight: 550; line-height: 1.32; text-align: center;
  color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
  transition: background-color .15s, box-shadow .15s, color .15s;
}
.node-title.empty { color: var(--text-3); font-weight: 450; }
.node.root .node-title { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.node.renaming .node-title {
  display: block; -webkit-line-clamp: unset;
  min-width: 70px; cursor: text;
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--c), var(--shadow-md);
  color: var(--text);
  user-select: text; -webkit-user-select: text;
}
.node.renaming .node-title.empty:empty::before { content: "Название…"; color: var(--text-3); }
.node-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.node-badges:empty { display: none; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px 2px 6px; border-radius: 999px;
  font-size: 11px; font-weight: 550; line-height: 1.4; white-space: nowrap;
  background: var(--surface); color: var(--text-2);
  box-shadow: 0 0 0 1px var(--border), var(--shadow-sm);
}
.badge svg.i { width: 11px; height: 11px; stroke-width: 2.2; }
.badge.tinted { color: var(--bc); background: color-mix(in srgb, var(--bc) 12%, var(--surface)); }
.badge.tag-badge { color: color-mix(in srgb, var(--bc) 85%, var(--text)); }
.badge.today { color: var(--warn); }

/* Done mark */
.node-mark {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; pointer-events: none;
  opacity: 0; transform: scale(.3) rotate(-20deg);
  transition: opacity .15s, transform .45s var(--spring);
}
.node-mark svg.i { width: 46%; height: 46%; stroke-width: 3.2; filter: drop-shadow(0 1px 2px rgba(0,0,0,.18)); }
.node.done .node-mark { opacity: 1; transform: none; }
.node.done .node-title { color: var(--text-2); text-decoration: line-through; text-decoration-color: var(--text-3); }
.node.done .node-svg { opacity: .8; }
.badge.overdue { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }

.node.is-new .node-hit { animation: nodeIn .55s var(--spring); }
.node.is-new .node-label { animation: labelIn .4s .08s var(--ease) both; }
@keyframes nodeIn { 0% { transform: scale(.15); } 100% { transform: scale(1); } }
@keyframes labelIn { from { opacity: 0; transform: translateY(-6px); } }
.node.leaving { pointer-events: none; }
.node.leaving .node-hit { animation: nodeOut .22s ease-in forwards; }
.node.leaving .node-label { opacity: 0; }
@keyframes nodeOut { to { transform: scale(0); opacity: 0; } }

.ripple {
  position: absolute; width: 60px; height: 60px; margin: -30px 0 0 -30px;
  border-radius: 50%; border: 2px solid var(--c);
  pointer-events: none;
  animation: ripple .6s var(--ease) forwards;
}
@keyframes ripple { from { transform: scale(.6); opacity: .55; } to { transform: scale(2.4); opacity: 0; } }

/* Ghost "+" */
#ghost { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.ghost-ring {
  position: absolute; width: 60px; height: 60px; left: -30px; top: -30px;
  border-radius: 50%;
  border: 2px dashed color-mix(in srgb, var(--gc, var(--accent)) 75%, transparent);
  background: color-mix(in srgb, var(--gc, var(--accent)) 11%, transparent);
  color: var(--gc, var(--accent));
  display: grid; place-items: center;
  opacity: 0; transform: scale(.35);
  transition: opacity .14s, transform .32s var(--spring), border-color .2s, background-color .2s;
}
.ghost-ring svg.i { width: 22px; height: 22px; stroke-width: 2.4; transition: transform .3s var(--spring); }
#ghost.visible .ghost-ring { opacity: 1; transform: scale(1); }
#ghost.visible .ghost-ring svg.i { animation: plusIn .35s var(--spring); }
#ghost.press .ghost-ring { transform: scale(.86); transition-duration: .08s; }
@keyframes plusIn { from { transform: rotate(-90deg) scale(.5); } }

/* ============ Floating cards ============ */
.card {
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

/* Sidebar */
#sidebar {
  position: fixed; left: 12px; top: 12px; bottom: 12px; width: var(--sbw);
  display: flex; flex-direction: column;
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  z-index: 20;
  transition: transform .42s var(--ease), opacity .3s, background-color .3s;
}
/* Width handles on the inner edges of the side cards */
.resizer {
  position: absolute; top: 18px; bottom: 18px; width: 14px; z-index: 5;
  cursor: col-resize; touch-action: none;
}
#sidebar .resizer { right: -8px; }
#panel .resizer { left: -8px; }
.resizer::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 44px;
  margin: -22px 0 0 -2px; border-radius: 4px;
  background: var(--border-strong);
  opacity: 0; transform: scaleY(.6);
  transition: opacity .15s, transform .35s var(--spring), background-color .15s, height .25s var(--spring);
}
.resizer:hover::after { opacity: 1; transform: none; }
.resizer.drag::after { opacity: 1; transform: scaleY(1.5); background: var(--accent); }
.resizer.will-close::after { background: var(--danger); }
/* while dragging: no lagging transitions, no text selection, one cursor everywhere */
body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
body.resizing #sidebar, body.resizing #panel, body.resizing #toolbar, body.resizing #hint,
body.resizing #toasts, body.resizing #filterPill { transition: none; }
#sidebar.will-close, #panel.will-close { opacity: .55; }
#sidebar.snap-back, #panel.snap-back { transition: width .45s var(--spring), transform .42s var(--ease), opacity .3s; }

body.sb-collapsed #sidebar { transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, #9AA5FF, #6C7BFF 60%, #5563E8);
  box-shadow: 0 3px 10px rgba(108, 123, 255, .45);
  position: relative;
}
.brand-mark::before, .brand-mark::after {
  content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: #22B8A0; right: -5px; top: -3px; box-shadow: 0 0 0 2px var(--surface);
}
.brand-mark::after { background: #F2B33D; right: auto; left: -4px; top: auto; bottom: -3px; }
.sb-title { padding: 10px 18px 6px; font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
#projectList { flex: 1; overflow-y: auto; padding: 0 8px; display: flex; flex-direction: column; gap: 2px; }
.project-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; border-radius: 10px;
  color: var(--text-2); font-size: 13.5px; text-align: left;
  transition: background-color .15s, color .15s, transform .25s var(--spring);
  animation: itemIn .3s var(--ease) both;
}
@keyframes itemIn { from { opacity: 0; transform: translateX(-8px); } }
/* folders in the project list (renderSidebar / moveProject in app.js) */
.folder-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 10px; border-radius: 10px;
  color: var(--text-2); font-size: 12.5px; font-weight: 650; letter-spacing: .01em;
  cursor: pointer; user-select: none;
  transition: background-color .15s, color .15s, box-shadow .15s;
  animation: itemIn .3s var(--ease) both;
}
.folder-item:hover { background: var(--hover); color: var(--text); }
.folder-item .f-caret { display: grid; place-items: center; width: 14px; flex: none; color: var(--text-3); transition: transform .25s var(--spring); transform: rotate(180deg); }
.folder-item .f-caret svg.i { width: 13px; height: 13px; }
.folder-item.collapsed .f-caret { transform: rotate(90deg); }
.folder-item .f-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-item .f-name[contenteditable="plaintext-only"] { white-space: normal; background: var(--surface); box-shadow: 0 0 0 2px var(--accent); border-radius: 5px; padding: 0 4px; margin: 0 -4px; cursor: text; user-select: text; }
.folder-item .p-count { font-size: 12px; font-weight: 400; color: var(--text-3); }
.folder-item.collapsed.has-active { color: var(--text); }
.folder-item.collapsed.has-active .f-name::after { content: " ·"; color: var(--text-3); }
.project-item.nested { padding-left: 30px; }
.project-item.dragging { opacity: .4; }
.project-item.drop-before { box-shadow: inset 0 2px 0 var(--text); }
.folder-item.drop-into { background: var(--active); box-shadow: inset 0 0 0 1.5px var(--text); color: var(--text); }
.project-item:hover { background: var(--hover); color: var(--text); }
.project-item:active { transform: scale(.97); transition-duration: .08s; }
.project-item.active { background: var(--active); color: var(--text); font-weight: 600; }
.project-item .p-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 20%, transparent); transition: background-color .3s; }
.project-item .p-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-item .p-name[contenteditable="plaintext-only"] { white-space: normal; overflow: visible; background: var(--surface); box-shadow: 0 0 0 2px var(--accent); border-radius: 5px; padding: 0 4px; margin: 0 -4px; cursor: text; user-select: text; }
.project-item .p-count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sb-new {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 8px 10px; padding: 9px 10px; border-radius: 10px;
  color: var(--text-2); font-size: 13.5px;
  border: 1px dashed var(--border-strong);
  transition: background-color .15s, color .15s, border-color .15s, transform .25s var(--spring);
}
.sb-new:hover { background: var(--hover); color: var(--text); border-color: var(--accent); }
.sb-new:active { transform: scale(.97); transition-duration: .08s; }
.sb-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 6px; padding: 10px; border-top: 1px solid var(--border); }
.sb-actions { display: flex; gap: 0; margin-left: auto; }
.sb-actions .icon-btn { width: 28px; } /* four buttons beside the theme switch in the default width */
.seg { position: relative; display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { position: relative; z-index: 1; width: 32px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--text-3); transition: color .2s, transform .25s var(--spring); }
.seg button svg.i { width: 15px; height: 15px; }
.seg button:hover { color: var(--text); }
.seg button:active { transform: scale(.88); }
.seg button.active { color: var(--text); }
.seg-thumb { position: absolute; top: 3px; left: 3px; width: 32px; height: 26px; border-radius: 7px; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .4s var(--spring); }

#sbOpen {
  position: fixed; left: 14px; top: 14px; z-index: 19;
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--glass); backdrop-filter: blur(20px);
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  opacity: 0; transform: scale(.7); pointer-events: none;
  transition: opacity .2s, transform .35s var(--spring), background-color .15s;
}
body.sb-collapsed #sbOpen { opacity: 1; transform: scale(1); pointer-events: auto; transition-delay: .12s; }
body.sb-collapsed #sbOpen:active { transform: scale(.88); transition-delay: 0s; }

/* Panel */
#panel {
  position: fixed; right: 12px; top: 12px; bottom: 12px; width: var(--pw);
  display: flex; flex-direction: column;
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 30;
  transform: translateX(calc(100% + 28px)); opacity: .4;
  transition: transform .45s var(--ease), opacity .3s;
}
#panel.open { transform: none; opacity: 1; }
#panel::before {
  content: ""; position: absolute; left: 18px; right: 18px; top: 0; height: 3px;
  border-radius: 0 0 4px 4px; background: var(--c, var(--accent)); opacity: .9;
  transition: background-color .3s;
}
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 0 20px; min-height: 48px; }
.panel-crumb { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; font-size: 12px; color: var(--text-3); overflow: hidden; white-space: nowrap; }
.panel-crumb button { padding: 3px 6px; margin: 0 -2px; border-radius: 6px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; transition: background-color .15s, color .15s; }
.panel-crumb button:hover { background: var(--hover); color: var(--text); }
.panel-crumb .sep { opacity: .6; display: inline-flex; }
.panel-crumb .sep svg.i { width: 12px; height: 12px; }
.panel-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; padding-bottom: 10px; }
.panel-scroll.swap { animation: swap .32s var(--ease); }
@keyframes swap { from { opacity: 0; transform: translateY(6px); } }
.p-hero { display: flex; align-items: flex-start; gap: 12px; padding: 10px 20px 6px; }
.p-hero-shape { width: 40px; height: 40px; flex: none; margin-top: 2px; overflow: visible; filter: drop-shadow(0 4px 8px color-mix(in srgb, var(--c) 34%, transparent)); }
.p-hero-shape.bump { animation: bump .45s var(--spring); }
@keyframes bump { 0% { transform: scale(.7) rotate(-8deg); } 100% { transform: none; } }
.p-title {
  flex: 1; min-width: 0; border: 0; background: transparent; resize: none; overflow: hidden;
  font-size: 21px; font-weight: 650; line-height: 1.3; letter-spacing: -.015em;
  padding: 6px 8px; margin: -2px -8px 0; border-radius: 9px;
  transition: background-color .15s;
}
.p-title:hover { background: var(--hover); }
.p-title:focus { background: transparent; }
.p-title::placeholder { color: var(--text-3); }
.p-group { padding: 12px 20px 4px; }
.p-group.grow { flex: 1; display: flex; flex-direction: column; }
.p-label { font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 9px; }

.swatches { display: grid; grid-template-columns: repeat(10, 26px); justify-content: space-between; gap: 9px 0; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--sw); color: var(--sw-ink, #fff);
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 16%, transparent);
  transition: transform .3s var(--spring), box-shadow .2s;
}
.swatch svg.i { width: 14px; height: 14px; stroke-width: 3; opacity: 0; transform: scale(.4); transition: opacity .15s, transform .3s var(--spring); }
.swatch:hover { transform: scale(1.14); }
.swatch:active { transform: scale(.88); transition-duration: .08s; }
.swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw); }
.swatch.active svg.i { opacity: 1; transform: none; }
.user-colors-label { margin-top: 18px; }
.user-color-slot { width: 26px; height: 26px; border-radius: 50%; border: 1px dashed var(--border); display: grid; place-items: center; color: var(--text-2); }
.user-color-slot:not(:disabled):hover { background: var(--hover); border-color: var(--accent); color: var(--accent); }
.user-color-slot:disabled { opacity: .4; cursor: default; }
.user-color-slot svg.i { width: 14px; height: 14px; }
.menu-user-colors { padding: 7px 12px 10px; grid-template-columns: repeat(10, 18px); gap: 7px; }
.swatch.temp { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 16%, transparent), 0 0 0 2px var(--surface), 0 0 0 4px var(--sw); outline: 1px dashed var(--text-3); outline-offset: 5px; }
.user-color-add { border-style: solid; }
.rgb-form .rgb-save { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.rgb-form .rgb-save input { width: 16px; height: 16px; accent-color: var(--accent); }
.menu-user-colors .swatch, .menu-user-colors .user-color-slot { width: 18px; height: 18px; }
.menu-user-colors .swatch svg.i { width: 10px; height: 10px; }
.rgb-form { display: grid; gap: 14px; margin-top: 18px; }
.rgb-form label { display: grid; gap: 6px; font-size: 12px; color: var(--text-2); }
.rgb-channels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.rgb-form input { width: 100%; min-width: 0; height: 38px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; }
.rgb-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.rgb-form input:invalid { border-color: var(--danger, #e45565); }
.rgb-form .rgb-picker { height: 62px; padding: 3px; cursor: pointer; }
.rgb-form .rgb-help { font-size: 12px; }
.rgb-form .modal-actions { margin-top: 2px; }
.rgb-apply:disabled { opacity: .45; cursor: default; }

.shapes { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.shape-btn {
  height: 42px; border-radius: 10px; background: var(--surface-2);
  display: grid; place-items: center;
  transition: background-color .15s, transform .3s var(--spring), box-shadow .2s;
}
.shape-btn svg { width: 22px; height: 22px; overflow: visible; }
.shape-btn .fill { fill: var(--text-3); transition: fill .2s; }
.shape-btn .poly.fill { stroke: var(--text-3); stroke-width: 8; stroke-linejoin: round; transition: fill .2s, stroke .2s; }
.shape-btn:hover { background: var(--active); }
.shape-btn:hover .fill { fill: var(--text-2); }
.shape-btn:hover .poly.fill { stroke: var(--text-2); }
.shape-btn:active { transform: scale(.9); transition-duration: .08s; }
.shape-btn.active { background: color-mix(in srgb, var(--c) 14%, transparent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 55%, transparent); }
.shape-btn.active .fill { fill: var(--c); }
.shape-btn.active .poly.fill { stroke: var(--c); }
.shape-btn.active svg { animation: bump .45s var(--spring); }

#pFields { display: flex; flex-direction: column; gap: 6px; }
#pFields:not(:empty) { margin-bottom: 8px; }
.field {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 10px; border-radius: 11px;
  background: var(--surface-2);
  transition: background-color .15s;
}
.field.enter { animation: fieldIn .38s var(--spring); }
@keyframes fieldIn { from { opacity: 0; transform: scale(.94) translateY(-4px); } }
.field.removing { animation: fieldOut .2s ease-in forwards; }
@keyframes fieldOut { to { opacity: 0; transform: scale(.94); height: 0; padding: 0; margin: -3px 0; } }
.field:hover { background: var(--active); }
.field-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); flex: none; }
.field-icon svg.i { width: 16px; height: 16px; }
.field-value { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 2px 4px; border-radius: 7px; }
.field-value .f-label { font-size: 11.5px; color: var(--text-3); }
.field-value .f-main { font-size: 13.5px; font-weight: 550; display: flex; align-items: center; gap: 8px; }
.field-value .f-main.placeholder { color: var(--text-3); font-weight: 450; }
.field .field-remove { opacity: 0; transition: opacity .15s, background-color .15s, transform .25s var(--spring); }
.field:hover .field-remove, .field-remove:focus-visible { opacity: 1; }
/* Block fields: header + body */
.field.block { flex-direction: column; align-items: stretch; gap: 8px; padding: 6px 6px 10px 10px; }
.field.block:hover { background: var(--surface-2); }
.field-head { display: flex; align-items: center; gap: 10px; }
.field-name { font-size: 13px; font-weight: 600; color: var(--text); }
.field-extra { margin-left: auto; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.field-body { padding-right: 4px; }

.fseg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.fseg-btn {
  height: 32px; padding: 0 6px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); color: var(--text-2);
  font-size: 12.5px; font-weight: 550; white-space: nowrap;
  box-shadow: 0 0 0 1px var(--border);
  transition: background-color .15s, color .15s, box-shadow .2s, transform .25s var(--spring);
}
.fseg-btn svg.i { width: 15px; height: 15px; color: var(--oc); }
.fseg-btn:hover { color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
.fseg-btn:active { transform: scale(.94); transition-duration: .08s; }
.fseg-btn.on {
  background: color-mix(in srgb, var(--oc) 15%, var(--surface));
  color: var(--oc); font-weight: 650;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--oc) 55%, transparent);
}
.fseg-btn.on svg.i { animation: bump .45s var(--spring); }

/* Checklist */
.cl-bar { height: 4px; border-radius: 4px; background: var(--active); overflow: hidden; margin: 0 0 8px; transition: opacity .2s; }
.cl-bar.empty { display: none; }
.cl-bar span { display: block; height: 100%; border-radius: 4px; background: var(--c); transition: width .45s var(--spring), background-color .3s; }
.cl-bar.complete span { background: #4CAF57; }
.cl-items { display: flex; flex-direction: column; }
.cl-item { display: flex; align-items: center; gap: 8px; padding: 1px 0; border-radius: 8px; }
.cl-item.enter { animation: fieldIn .32s var(--spring); }
.cl-item.leaving { animation: fieldOut .18s ease-in forwards; }
.cl-check {
  width: 20px; height: 20px; flex: none; border-radius: 6px;
  display: grid; place-items: center; color: #fff;
  box-shadow: inset 0 0 0 1.6px var(--border-strong);
  background: var(--surface);
  transition: background-color .15s, box-shadow .15s, transform .3s var(--spring);
}
.cl-check svg.i { width: 13px; height: 13px; stroke-width: 3; opacity: 0; transform: scale(.3); transition: opacity .12s, transform .35s var(--spring); }
.cl-check:hover { box-shadow: inset 0 0 0 1.6px var(--c); }
.cl-check:active { transform: scale(.82); transition-duration: .06s; }
.cl-item.done .cl-check { background: #4CAF57; box-shadow: none; }
.cl-item.done .cl-check svg.i { opacity: 1; transform: none; }
.cl-text {
  flex: 1; min-width: 0; height: 30px; border: 0; background: transparent;
  font-size: 13.5px; padding: 0 6px; border-radius: 7px;
  transition: color .2s, background-color .15s;
}
.cl-text:focus { background: var(--surface); box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--c) 50%, transparent); }
.cl-text::placeholder { color: var(--text-3); }
.cl-item.done .cl-text { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-3); }
.cl-del { opacity: 0; }
.cl-item:hover .cl-del { opacity: 1; }
.cl-add { display: flex; align-items: center; gap: 8px; color: var(--text-3); }
.cl-add > svg.i { width: 20px; height: 15px; flex: none; }
.cl-new { flex: 1; height: 30px; border: 0; background: transparent; font-size: 13.5px; padding: 0 6px; border-radius: 7px; transition: background-color .15s; }
.cl-new:hover { background: var(--hover); }
.cl-new:focus { background: var(--surface); box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--c) 50%, transparent); }
.cl-new::placeholder { color: var(--text-3); }

/* Tags */
.tags-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 36px; padding: 5px; border-radius: 10px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--border);
  cursor: text; transition: box-shadow .15s;
}
.tags-box:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 50%, transparent); }
.tag {
  display: inline-flex; align-items: center; gap: 2px;
  height: 25px; padding: 0 3px 0 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--t) 15%, transparent);
  color: color-mix(in srgb, var(--t) 80%, var(--text));
  font-size: 12.5px; font-weight: 600; cursor: default;
}
.tag.enter { animation: tagIn .35s var(--spring); }
.tag.leaving { animation: popOut .15s forwards; }
@keyframes tagIn { from { opacity: 0; transform: scale(.6); } }
.tag-x { width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center; opacity: .55; transition: opacity .15s, background-color .15s, transform .2s var(--spring); }
.tag-x svg.i { width: 11px; height: 11px; stroke-width: 2.6; }
.tag-x:hover { opacity: 1; background: color-mix(in srgb, var(--t) 22%, transparent); }
.tag-x:active { transform: scale(.8); }
.tag-input { flex: 1; min-width: 90px; height: 25px; border: 0; background: transparent; font-size: 13px; padding: 0 4px; }
.tag-input::placeholder { color: var(--text-3); }
.tag-suggest { display: none; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag-suggest.show { display: flex; animation: fieldIn .25s var(--ease); }
.tag-sug {
  height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 550; color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  transition: background-color .15s, color .15s, box-shadow .15s, transform .25s var(--spring);
}
.tag-sug:hover { color: var(--t); box-shadow: inset 0 0 0 1px var(--t); background: color-mix(in srgb, var(--t) 8%, transparent); }
.tag-sug:active { transform: scale(.92); }
.tag-sug.create { --t: var(--c); display: inline-flex; align-items: center; gap: 4px; color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.tag-sug.create svg.i { width: 13px; height: 13px; }
.tag-sug-empty { font-size: 12px; color: var(--text-3); padding: 2px 2px; }

/* Sidebar tag library */
.sb-title-row { display: flex; align-items: center; justify-content: space-between; padding-right: 10px; padding-top: 4px; }
#tagList { max-height: 32vh; overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 1px; }
.tag-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 9px; cursor: pointer;
  font-size: 13px; color: var(--text-2);
  transition: background-color .15s, color .15s, transform .25s var(--spring);
  animation: itemIn .3s var(--ease) both;
}
.tag-item:hover { background: var(--hover); color: var(--text); }
.tag-item:active { transform: scale(.97); transition-duration: .08s; }
.tag-item.active { background: color-mix(in srgb, var(--t) 16%, transparent); color: var(--text); font-weight: 600; }
.tag-item .t-dot { width: 8px; height: 8px; border-radius: 3px; background: var(--t); flex: none; transform: rotate(45deg); transition: background-color .3s, transform .3s var(--spring); }
.tag-item.active .t-dot { transform: rotate(45deg) scale(1.3); }
.tag-item .t-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-item .t-name::before { content: "#"; opacity: .45; margin-right: 1px; }
.tag-item .t-name[contenteditable="plaintext-only"] { white-space: normal; overflow: visible; background: var(--surface); box-shadow: 0 0 0 2px var(--t); border-radius: 5px; padding: 0 4px; margin: 0 -4px; cursor: text; user-select: text; }
.tag-item .t-count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sb-empty { padding: 4px 10px 8px; font-size: 12px; line-height: 1.45; color: var(--text-3); }

/* Filter by tag */
.node.dimmed { opacity: .16; filter: grayscale(.7); }
.node { transition: opacity .3s, filter .3s; }
.edge.dimmed { opacity: .1; }
#filterPill {
  position: fixed; top: 18px; left: var(--mid); z-index: 16;
  display: flex; align-items: center; gap: 9px;
  padding: 6px 6px 6px 14px; border-radius: 12px;
  background: var(--glass); backdrop-filter: blur(20px);
  border: 1px solid color-mix(in srgb, var(--t, var(--accent)) 40%, var(--border));
  box-shadow: var(--shadow-md);
  font-size: 13px; color: var(--text-2); white-space: nowrap;
  opacity: 0; pointer-events: none; transform: translate(-50%, -10px);
  transition: opacity .25s, transform .4s var(--spring), left .45s var(--ease);
}
#filterPill.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
#filterPill b { color: var(--t); font-weight: 650; }
.fp-dot { width: 9px; height: 9px; border-radius: 3px; transform: rotate(45deg); background: var(--t); }
.fp-x { position: relative; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; color: var(--text-3); transition: background-color .15s, color .15s, transform .25s var(--spring); }
.fp-x svg.i { width: 14px; height: 14px; }
.fp-x:hover { background: var(--hover); color: var(--text); }
.fp-x:active { transform: scale(.85); }

.chip { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--hover); color: var(--text-2); }
.chip.today { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.chip.overdue { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); }

.add-field {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 10px; border-radius: 11px;
  border: 1px dashed var(--border-strong);
  color: var(--text-2); font-size: 13px;
  transition: background-color .15s, color .15s, border-color .15s, transform .25s var(--spring);
}
.add-field svg.i { width: 16px; height: 16px; }
.add-field:hover { color: var(--text); border-color: var(--c); background: color-mix(in srgb, var(--c) 6%, transparent); }
.add-field:active { transform: scale(.98); transition-duration: .08s; }

.p-body {
  flex: 1; width: 100%; min-height: 160px; resize: none;
  border: 0; border-radius: 12px; padding: 12px 14px;
  background: var(--surface-2);
  font-size: 14px; line-height: 1.6;
  transition: box-shadow .2s, background-color .2s;
}
.p-body { position: relative; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; outline: none; }

/* Markdown toolbar */
.p-label-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; margin-bottom: 7px; }
.p-label-row .p-label { margin-bottom: 0; }
.md-tools { display: flex; gap: 1px; }
.md-tool {
  position: relative; width: 25px; height: 25px; border-radius: 7px;
  display: grid; place-items: center;
  font-size: 13px; color: var(--text-3);
  transition: background-color .15s, color .15s, transform .25s var(--spring);
}
.md-tool svg.i { width: 15px; height: 15px; }
.md-tool:hover { background: var(--hover); color: var(--text); }
.md-tool:active { transform: scale(.85); transition-duration: .06s; }
.md-tools > :last-child::after { left: auto; right: 0; transform: translate(0, 4px); }
.md-tools > :last-child:hover::after { transform: none; }

/* Markdown preview: the marks (**, #, > …) stay in the text but are never shown */
.md-line { min-height: 1.6em; }
.md-mark { display: none; color: var(--text-3); font-weight: 400; font-style: normal; text-decoration: none; }
.md-h1, .md-h2, .md-h3 { font-weight: 700; letter-spacing: -.015em; line-height: 1.3; }
.md-h1 { font-size: 1.5em; margin: .35em 0 .1em; }
.md-h2 { font-size: 1.25em; margin: .3em 0 .05em; }
.md-h3 { font-size: 1.08em; margin: .2em 0 0; }
.md-line:first-child { margin-top: 0; }
strong.md-b { font-weight: 700; }
em.md-i { font-style: italic; }
.md-s { text-decoration: line-through; color: var(--text-2); }
mark.md-hl { background: color-mix(in srgb, #F2B33D 38%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
code.md-code, .md-codeline, .md-fence { font-family: "Cascadia Code", "Cascadia Mono", Consolas, monospace; font-size: .88em; }
code.md-code { background: var(--active); padding: 1px 5px; border-radius: 5px; }
.md-codeline, .md-fence { background: var(--active); padding: 0 10px; }
.md-fence { color: var(--text-3); }
.md-fence + .md-codeline, .md-line:not(.md-codeline):not(.md-fence) + .md-fence { border-radius: 8px 8px 0 0; }
.md-codeline + .md-fence { border-radius: 0 0 8px 8px; }
.md-quote { border-left: 3px solid color-mix(in srgb, var(--c) 55%, transparent); padding-left: 11px; color: var(--text-2); }
.md-num { color: color-mix(in srgb, var(--c) 80%, var(--text)); font-weight: 600; font-variant-numeric: tabular-nums; }
.md-bullet, .md-check {
  position: relative; display: inline-block; vertical-align: top;
  color: transparent; white-space: pre; overflow: hidden; user-select: none;
}
.md-bullet { width: 1.25em; }
.md-bullet::before {
  content: ""; position: absolute; left: .3em; top: .78em; width: 6px; height: 6px; margin-top: -3px;
  border-radius: 50%; background: var(--c);
}
.md-check { width: 1.75em; cursor: pointer; }
.md-check::before {
  content: ""; position: absolute; left: 1px; top: .8em; width: 16px; height: 16px; margin-top: -8px;
  border-radius: 5px; background: var(--surface); box-shadow: inset 0 0 0 1.6px var(--border-strong);
  transition: background-color .15s, box-shadow .15s, transform .3s var(--spring);
}
.md-check:hover::before { box-shadow: inset 0 0 0 1.6px var(--c); }
.md-check:active::before { transform: scale(.82); }
.md-check.on::before { background: #4CAF57; box-shadow: none; animation: bump .4s var(--spring); }
.md-check.on::after {
  content: ""; position: absolute; left: 7px; top: .8em; width: 4px; height: 8px; margin-top: -6px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.md-task.done .md-task-text { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--text-3); }
.md-hr { position: relative; }
.md-hr::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--border-strong); }
.lnk-raw { color: color-mix(in srgb, var(--c) 75%, var(--text)); text-decoration: underline dotted; text-underline-offset: 3px; }
.p-body.is-empty::before { content: attr(data-placeholder); position: absolute; left: 14px; right: 14px; top: 12px; color: var(--text-3); pointer-events: none; }
/* a code fence line holds only its hidden ``` mark: a thin cap of the code block */
.md-fence { min-height: .7em; }

/* the note full screen (mdFullscreen in app.js): the same editor on a wide calm page */
.modal.md-modal {
  width: min(940px, calc(100vw - 32px)); height: calc(100dvh - 48px); max-height: none;
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
}
.mdf-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 4px 28px; }
.mdf-title { flex: 1; min-width: 0; font-size: 20px; font-weight: 700; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mdf-tools { padding: 2px 22px 10px; border-bottom: 1px solid var(--border); }
.mdf-tools .md-tool { width: 32px; height: 32px; }
.mdf-page { flex: 1; overflow: auto; padding: 26px 28px 48px; }
.md-modal .p-body { max-width: 72ch; min-height: 100%; margin: 0 auto; padding: 0; background: transparent; font-size: 16px; line-height: 1.7; box-shadow: none; }
.md-modal .p-body.is-empty::before { left: 0; right: 0; top: 0; }
.lnk {
  color: color-mix(in srgb, var(--c) 75%, var(--text));
  font-weight: 550; text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--c) 45%, transparent);
  text-decoration-thickness: 1.5px; text-underline-offset: 3px;
  padding: 1px 3px; margin: 0 -1px; border-radius: 5px; cursor: pointer;
  transition: background-color .15s, text-decoration-color .15s;
}
.lnk::after { content: "↗"; font-size: .78em; margin-left: 2px; opacity: .6; text-decoration: none; display: inline-block; }
.lnk:hover { background: color-mix(in srgb, var(--c) 14%, transparent); text-decoration-color: var(--c); }

.linkbar {
  position: fixed; z-index: 90;
  display: flex; align-items: center; gap: 2px;
  padding: 4px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(4px) scale(.97); pointer-events: none;
  transition: opacity .14s, transform .25s var(--spring);
}
.linkbar.show { opacity: 1; transform: none; pointer-events: auto; }
.linkbar > svg.i { width: 16px; height: 16px; color: var(--text-3); margin: 0 4px 0 6px; }
.lb-url {
  display: flex; align-items: center; gap: 6px; max-width: 240px; height: 26px; padding: 0 8px; border-radius: 7px;
  font-size: 12.5px; color: var(--text-2); transition: background-color .15s, color .15s;
}
.lb-url span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-url svg.i { width: 14px; height: 14px; flex: none; }
.lb-url:hover { background: var(--hover); color: var(--text); }
.lb-sep { width: 1px; height: 16px; background: var(--border-strong); margin: 0 3px; }
.lb-input { width: 220px; height: 28px; border: 0; border-radius: 7px; padding: 0 8px; background: var(--surface-2); font-size: 13px; }
.lb-input:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent); }
.p-body:hover { background: var(--active); }
.p-body:focus { background: var(--surface-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent); }

.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 10px 20px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.danger-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 8px;
  color: var(--danger); font-size: 13px; font-weight: 550;
  transition: background-color .15s, transform .25s var(--spring);
}
.danger-btn svg.i { width: 15px; height: 15px; }
.danger-btn:hover { background: color-mix(in srgb, var(--danger) 11%, transparent); }
.danger-btn:active { transform: scale(.93); transition-duration: .08s; }
.danger-btn[hidden] { display: none; }

/* ============ Toolbar / hint / toasts ============ */
#toolbar {
  position: fixed; left: var(--mid); bottom: 16px; transform: translateX(-50%);
  transition: left .45s var(--ease);
  display: flex; align-items: center; gap: 2px;
  padding: 5px; border-radius: 14px;
  background: var(--glass); backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  z-index: 15;
}
.tb-sep { width: 1px; height: 18px; background: var(--border-strong); margin: 0 4px; }
.zoom-label {
  position: relative; min-width: 54px; height: 32px; border-radius: 9px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums;
  transition: background-color .15s, color .15s, transform .25s var(--spring);
}
.zoom-label:hover { background: var(--hover); color: var(--text); }
.zoom-label:active { transform: scale(.92); }

#hint {
  position: fixed; left: var(--mid); top: 18px;
  transform: translate(-50%, -8px);
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px 9px 12px; border-radius: 12px;
  background: var(--glass); backdrop-filter: blur(20px);
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  color: var(--text-2); font-size: 13px; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .4s var(--spring), left .45s var(--ease);
  z-index: 14;
}
#hint.show { opacity: 1; transform: translate(-50%, 0); }
#hint .hint-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px dashed var(--accent); display: grid; place-items: center; color: var(--accent); animation: breathe 2.2s ease-in-out infinite; }
#hint .hint-dot svg.i { width: 13px; height: 13px; stroke-width: 2.6; }
@keyframes breathe { 50% { transform: scale(1.15); } }

#toasts { position: fixed; left: var(--mid); bottom: 74px; transition: left .45s var(--ease); transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 10px 9px 16px; border-radius: 12px;
  background: var(--tip-bg); color: var(--tip-fg);
  font-size: 13px; box-shadow: var(--shadow-lg);
  pointer-events: auto;
  opacity: 0; transform: translateY(12px) scale(.96);
  transition: opacity .2s, transform .4s var(--spring);
}
.toast.show { opacity: 1; transform: none; }
.toast.hide { opacity: 0; transform: translateY(6px) scale(.97); transition-duration: .18s; }
.toast:not(:has(.toast-btn)) { padding-right: 16px; }
.toast-btn { padding: 5px 10px; border-radius: 8px; font-weight: 650; color: #E4E0CF; transition: background-color .15s, transform .25s var(--spring); }
.toast-btn:hover { background: rgba(255,255,255,.1); }
.toast-btn:active { transform: scale(.92); }

/* ============ Menus / popovers ============ */
#overlay { position: fixed; inset: 0; pointer-events: none; z-index: 80; }
#overlay > * { pointer-events: auto; }
.menu, .popover {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  box-shadow: var(--shadow-lg);
  animation: popIn .2s var(--ease);
}
.menu { min-width: 216px; padding: 5px; }
@keyframes popIn { from { opacity: 0; transform: scale(.95) translateY(-4px); } }
.menu.closing, .popover.closing { animation: popOut .12s ease-in forwards; }
@keyframes popOut { to { opacity: 0; transform: scale(.97); } }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 10px; border-radius: 8px;
  font-size: 13px; text-align: left; color: var(--text);
  transition: background-color .1s, transform .2s var(--spring);
}
.menu-item svg.i { width: 16px; height: 16px; color: var(--text-2); }
.menu-item:hover { background: var(--hover); }
.menu-item:active { transform: scale(.97); }
.menu-item.danger, .menu-item.danger svg.i { color: var(--danger); }
.menu-item.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.menu-item:disabled { opacity: .4; pointer-events: none; }
.menu-item .kbd { margin-left: auto; padding-left: 16px; font-size: 11.5px; color: var(--text-3); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 6px; }
.menu-colors { display: flex; gap: 7px; padding: 7px 10px; }
.menu-colors .swatch { width: 18px; height: 18px; }
.menu-colors .swatch svg.i { width: 10px; height: 10px; }
.menu-colors .swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--sw); }

/* Date picker */
.datepicker { width: 320px; padding: 12px; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-title { font-weight: 650; font-size: 14px; letter-spacing: -.01em; }
.dp-week, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.dp-mode { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; margin-bottom: 10px; border-radius: 10px; background: var(--surface-2); }
.dp-mode-thumb { position: absolute; top: 3px; left: 3px; width: calc(50% - 3px); height: calc(100% - 6px); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .4s var(--spring); }
.dp-mode button { position: relative; z-index: 1; height: 28px; display: flex; align-items: center; justify-content: center; gap: 6px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-3); transition: color .2s, transform .25s var(--spring); }
.dp-mode button svg.i { width: 14px; height: 14px; }
.dp-mode button.on { color: var(--text); }
.dp-mode button:active { transform: scale(.95); }
.dp-ends { display: none; align-items: center; gap: 4px; margin-bottom: 8px; }
.datepicker.is-range .dp-ends { display: flex; animation: fieldIn .3s var(--spring); }
.dp-arrow { color: var(--text-3); display: grid; }
.dp-arrow svg.i { width: 14px; height: 14px; }
.dp-end {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 6px 10px; border-radius: 9px; background: var(--surface-2); text-align: left;
  box-shadow: inset 0 0 0 1.5px transparent;
  transition: background-color .15s, box-shadow .2s, transform .25s var(--spring);
}
.dp-end span { font-size: 11px; color: var(--text-3); }
.dp-end b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dp-end:hover { background: var(--active); }
.dp-end:active { transform: scale(.96); }
.dp-end.on { background: color-mix(in srgb, var(--c, var(--accent)) 12%, var(--surface)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c, var(--accent)) 60%, transparent); }
.dp-day > span { position: relative; z-index: 1; }
.dp-day.in-range { background: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent); border-radius: 0; }
.datepicker.is-range .dp-day.range-start { border-radius: 10px 0 0 10px; }
.datepicker.is-range .dp-day.range-end { border-radius: 0 10px 10px 0; }
.datepicker.is-range .dp-day.range-start.range-end { border-radius: 10px; }
.dp-week span { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-3); padding: 4px 0; }
.dp-grid.slide-l { animation: slideL .28s var(--ease); }
.dp-grid.slide-r { animation: slideR .28s var(--ease); }
@keyframes slideL { from { opacity: 0; transform: translateX(14px); } }
@keyframes slideR { from { opacity: 0; transform: translateX(-14px); } }
.dp-day {
  position: relative; height: 36px; border-radius: 10px;
  font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text);
  transition: background-color .12s, color .12s, transform .25s var(--spring);
}
.dp-day:hover { background: var(--hover); }
.dp-day:active { transform: scale(.88); transition-duration: .06s; }
.dp-day.out { color: var(--text-3); }
.dp-day.weekend:not(.out):not(.selected) { color: var(--text-2); }
.dp-day.today::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--c, var(--accent)); }
.dp-day.selected { background: var(--c, var(--accent)); color: var(--on-accent); font-weight: 650; box-shadow: 0 4px 12px color-mix(in srgb, var(--c, var(--accent)) 45%, transparent); animation: daySel .35s var(--spring); }
.dp-day.selected::after { background: #fff; }
@keyframes daySel { from { transform: scale(.7); } }
.dp-time-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.dp-time-row > svg.i { color: var(--text-3); width: 16px; height: 16px; }
.dp-time-box { display: flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 9px; padding: 2px; }
.dp-time {
  width: 38px; height: 30px; border: 0; border-radius: 7px; background: transparent;
  text-align: center; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums;
  transition: background-color .12s, box-shadow .15s;
}
.dp-time:hover { background: var(--hover); }
.dp-time:focus { background: var(--surface); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c, var(--accent)) 55%, transparent); }
.dp-colon { font-weight: 700; color: var(--text-3); }
.dp-times { display: flex; gap: 4px; margin-left: auto; }
.dp-chip {
  padding: 5px 7px; border-radius: 7px; font-size: 11.5px; font-weight: 600; color: var(--text-2);
  font-variant-numeric: tabular-nums; background: var(--surface-2);
  transition: background-color .12s, color .12s, transform .25s var(--spring);
}
.dp-chip:hover { background: var(--active); color: var(--text); }
.dp-chip:active { transform: scale(.9); }
.dp-chip.on { background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent); color: var(--c, var(--accent)); }
.dp-quick { display: flex; gap: 6px; margin-top: 10px; }
.dp-quick .dp-chip { flex: 1; padding: 7px 0; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: rgba(10, 12, 18, .28); backdrop-filter: blur(3px);
  animation: fade .2s;
}
.modal-backdrop.closing { animation: fadeOut .16s forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.modal {
  width: min(420px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 22px 22px 16px;
  animation: modalIn .34s var(--spring);
}
.modal-backdrop.closing .modal { animation: popOut .14s forwards; }
@keyframes modalIn { from { opacity: 0; transform: scale(.92) translateY(8px); } }
.modal h3 { margin: 0 0 8px; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.modal p { margin: 0; color: var(--text-2); line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; margin-top: 14px; font-size: 13px; color: var(--text-2); align-items: center; }
.keys kbd {
  justify-self: start;
  font-family: inherit; font-size: 11.5px; font-weight: 600; color: var(--text);
  padding: 3px 7px; border-radius: 6px; background: var(--surface-2);
  box-shadow: inset 0 -1px 0 var(--border-strong); white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============ Selection, groups, layouts, tag drag ============ */
/* split button: layout + its chooser */
.split { display: inline-flex; align-items: center; }
.tb-more { width: 18px; margin-left: -3px; border-radius: 0 9px 9px 0; }
.tb-more svg.i { width: 14px; height: 14px; }

/* selection section of the toolbar */
.tb-sel { display: none; align-items: center; gap: 2px; }
.tb-sel.show { display: flex; animation: selIn .38s var(--spring); }
@keyframes selIn { from { opacity: 0; transform: translateX(-8px) scale(.96); } }
.sel-count { padding: 0 6px 0 2px; font-size: 12.5px; font-weight: 650; color: var(--accent); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* selection box */
.marquee {
  position: absolute; z-index: 3; pointer-events: none;
  border: 1.5px solid color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 6px;
  transition: background-color .15s, opacity .18s;
}
.marquee.has-hits { background: color-mix(in srgb, var(--accent) 13%, transparent); }
.marquee.leaving { opacity: 0; }

/* groups */
#groupLayer { position: absolute; left: 0; top: 0; }
.group {
  position: absolute; left: 0; top: 0; pointer-events: none;
  border-radius: 26px;
  background: color-mix(in srgb, var(--gc) 7%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--gc) 26%, transparent);
  transition: background-color .3s, box-shadow .3s, opacity .3s, scale .3s var(--spring);
}
.group.is-new { animation: groupIn .5s var(--spring); }
@keyframes groupIn { from { opacity: 0; scale: .94; } }
.group.leaving { opacity: 0; scale: .96; }
.group.pressed, .group.dragging { background: color-mix(in srgb, var(--gc) 11%, transparent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--gc) 45%, transparent); }
.group.dimmed { opacity: .25; }
.group.drop-target { background: color-mix(in srgb, var(--dt) 11%, transparent); box-shadow: inset 0 0 0 2px var(--dt); }
.group-head {
  position: absolute; left: 12px; top: 10px; max-width: calc(100% - 24px);
  display: flex; align-items: flex-start; gap: 8px;
  padding: 5px 7px 5px 10px; border-radius: 12px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--gc) 30%, transparent), var(--shadow-sm);
  font-size: 12.5px; font-weight: 600; line-height: 1.4;
  pointer-events: auto; cursor: grab;
  transition: box-shadow .2s, transform .3s var(--spring);
}
.group-head:hover { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--gc) 55%, transparent), var(--shadow-md); }
.group.pressed .group-head { transform: scale(.97); }
.group.dragging .group-head { cursor: grabbing; transform: scale(1.03); box-shadow: 0 0 0 1.5px var(--gc), var(--shadow-lg); }
.group-dot { flex: none; width: 8px; height: 8px; margin-top: 5px; border-radius: 3px; background: var(--gc); transform: rotate(45deg); }
.group-text { min-width: 40px; white-space: pre-wrap; overflow-wrap: anywhere; }
.group-text.empty { color: var(--text-3); font-weight: 500; }
.group.editing .group-head { cursor: default; box-shadow: 0 0 0 2px var(--gc), var(--shadow-md); }
.group.editing .group-text { cursor: text; outline: none; user-select: text; -webkit-user-select: text; min-width: 120px; }
.group-count { flex: none; margin-top: 1px; padding: 0 6px; border-radius: 999px; background: var(--hover); color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }

/* menus: titles, two-line items, the current choice */
.menu-title { padding: 6px 10px 4px; font-size: 11px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.mi-text { display: flex; flex-direction: column; line-height: 1.25; }
.mi-text small { font-size: 11.5px; color: var(--text-3); }
.menu-item.on { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.menu-item.on > svg.i { color: var(--accent); }
.mi-check { margin-left: auto; display: grid; color: var(--accent); }
.kbd + .mi-check { margin-left: 8px; }
.mi-check svg.i { width: 15px; height: 15px; stroke-width: 2.6; color: var(--accent); }

/* dragging a tag onto notes */
.tag-item { user-select: none; -webkit-user-select: none; touch-action: none; }
.tag-item.dragging { opacity: .45; }
body.tag-dragging, body.tag-dragging * { cursor: grabbing !important; user-select: none !important; }
.tag-ghost {
  position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none;
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--surface); color: var(--t);
  font-size: 13px; font-weight: 650; white-space: nowrap;
  box-shadow: 0 0 0 1.5px var(--t), var(--shadow-lg);
  animation: popIn .2s var(--ease);
  transition: scale .25s var(--spring);
}
.tag-ghost.over { scale: 1.08; }
.tg-to { max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); font-weight: 500; }
.tg-to:empty { display: none; }
.node.drop-target .node-hit { transform: scale(1.14); }
.node.drop-target .halo { stroke: var(--dt); opacity: .9; transform: scale(1.26); }
.node.tag-dropped .node-hit { animation: bump .45s var(--spring); }
#panel.drop-target { box-shadow: 0 0 0 2px var(--dt), var(--shadow-lg); }

/* ============ Re-linking ============ */
/* links become grabbable only in link mode (left Alt held) */
.edge-hit { fill: none; stroke: transparent; stroke-width: 16; stroke-linecap: round; pointer-events: none; }
body.link-edit .edge-hit { pointer-events: stroke; cursor: grab; }
.edge { transition: opacity .25s, stroke-width .2s; }
body.link-edit .edge { opacity: .85; }
.edge.hover, body.link-edit .edge.hover { opacity: 1; stroke-width: 4; }
.edge.detaching, body.link-edit .edge.detaching { opacity: .16; stroke-dasharray: 4 7; }

/* link mode: a handle in the middle of every link */
#linkHandles { position: absolute; left: 0; top: 0; }
.link-handle { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 6; }
.lh-btn {
  position: absolute; left: -14px; top: -14px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--c);
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--c) 65%, transparent), var(--shadow-md);
  cursor: grab;
  scale: var(--ik, 1);
  animation: lhIn .34s var(--spring) both;
  transition: scale .3s var(--spring), box-shadow .15s, opacity .15s;
}
.lh-btn svg.i { width: 15px; height: 15px; }
@keyframes lhIn { from { opacity: 0; scale: calc(var(--ik, 1) * .3); } }
.lh-btn:hover { scale: calc(var(--ik, 1) * 1.18); box-shadow: 0 0 0 2px var(--c), var(--shadow-lg); }
.lh-btn:active { scale: calc(var(--ik, 1) * .92); cursor: grabbing; }
.link-handle.active .lh-btn { opacity: 0; }
.link-handle.leaving .lh-btn { animation: lhOut .16s ease-in forwards; }
@keyframes lhOut { to { opacity: 0; scale: calc(var(--ik, 1) * .4); } }
/* in link mode notes and groups are inert: no grab cursors, no hover lift */
body.link-edit .node-hit, body.link-edit .node-title, body.link-edit .group-head { cursor: default; }
body.link-edit .node:hover:not(.link-target):not(.relinking) .node-hit { transform: none; }
body.link-edit #canvas { cursor: default; }

/* the rubber line while re-linking */
#relinkLine {
  fill: none; stroke: var(--lc, var(--accent)); stroke-width: 2.6; stroke-linecap: round;
  stroke-dasharray: 7 7; opacity: 0; pointer-events: none;
  transition: opacity .15s, stroke .15s;
  animation: ants .6s linear infinite;
}
@keyframes ants { to { stroke-dashoffset: -14; } }
#relinkDot { fill: var(--surface); stroke: var(--lc, var(--accent)); stroke-width: 2.5; opacity: 0; pointer-events: none; transition: opacity .15s, stroke .15s; }
#relinkLine.show { opacity: .95; }
#relinkDot.show { opacity: 1; }
#canvas.relink-mode, #canvas.relink-mode * { cursor: crosshair !important; }
#canvas.relink-bad, #canvas.relink-bad * { cursor: not-allowed !important; }
.node.relinking .node-hit { transform: scale(1.06); }
.node.link-target .node-hit { transform: scale(1.16); }
.node.link-target .halo { opacity: .95; transform: scale(1.3); stroke-dasharray: none; animation: linkPulse 1s ease-in-out infinite; }
@keyframes linkPulse { 50% { opacity: .45; } }
.node.link-bad .halo { stroke: var(--danger); opacity: .9; transform: scale(1.24); stroke-dasharray: 4 5; }
.node.link-same .halo { opacity: .4; transform: scale(1.2); stroke-dasharray: 3 5; }
.node.link-shake .node-hit { animation: linkShake .36s ease-in-out; }
@keyframes linkShake { 20%, 60% { translate: -5px 0; } 40%, 80% { translate: 5px 0; } }

/* mode hint at the top while re-linking */
#modeHint {
  position: fixed; top: 18px; left: var(--mid); z-index: 17;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 15px 8px 11px; border-radius: 12px;
  background: var(--tip-bg); color: var(--tip-fg);
  font-size: 13px; white-space: nowrap; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transform: translate(-50%, -10px);
  transition: opacity .2s, transform .4s var(--spring), left .45s var(--ease);
}
#modeHint.show { opacity: 1; transform: translate(-50%, 0); }
#modeHint b { font-weight: 650; color: #A9B2FF; }
.mh-icon { display: grid; color: #A9B2FF; }
.mh-icon svg.i { width: 16px; height: 16px; }

/* ============ Creation polish ============ */
/* under a just-created note while it is being named */
.rename-hint {
  display: flex; align-items: center; gap: 5px; margin-top: 2px;
  padding: 3px 8px; border-radius: 8px;
  background: var(--tip-bg); color: var(--tip-fg);
  font-size: 11px; white-space: nowrap; pointer-events: none;
  box-shadow: var(--shadow-md);
  animation: labelIn .3s .15s var(--ease) both;
}
.rename-hint kbd { font-family: inherit; font-size: 10.5px; font-weight: 600; line-height: 1; padding: 2px 5px; border-radius: 4px; background: rgba(255,255,255,.14); color: inherit; }
.rename-hint span { opacity: .5; }
/* the "+" slid to the nearest free spot: a calmer ring so it reads as "placed for you" */
#ghost.nudged .ghost-ring { border-style: solid; border-color: color-mix(in srgb, var(--gc, var(--accent)) 45%, transparent); }

/* ============ Shortcuts window ============ */
.modal.help-modal {
  width: min(920px, calc(100vw - 40px)); max-height: calc(100vh - 60px);
  padding: 0; display: flex; flex-direction: column; overflow: hidden;
}
.help-head {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 16px 14px 24px; border-bottom: 1px solid var(--border);
}
.help-head h3 { margin: 0; flex: none; font-size: 18px; }
.help-search {
  flex: 1; display: flex; align-items: center; gap: 8px; max-width: 360px; margin-left: auto;
  height: 34px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); color: var(--text-3);
  transition: box-shadow .15s;
}
.help-search:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent); }
.help-search svg.i { width: 16px; height: 16px; }
.help-search input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 13.5px; color: var(--text); outline: none; }
.help-body {
  overflow-y: auto; padding: 18px 20px 22px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; align-items: start;
}
.help-sec {
  padding: 12px 14px 6px; border-radius: 14px; background: var(--surface-2);
  animation: fieldIn .35s var(--ease) both;
}
.help-sec h4 {
  display: flex; align-items: center; gap: 8px; margin: 0 0 6px;
  font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em;
}
.help-sec h4 svg.i { width: 15px; height: 15px; color: var(--accent); }
.help-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 8px 0; border-top: 1px solid var(--border);
}
.help-sec h4 + .help-row { border-top: 0; }
.help-label { font-size: 13.5px; color: var(--text); line-height: 1.35; }
.help-ways { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 5px; text-align: right; }
.help-ways em { font-style: normal; font-size: 11px; color: var(--text-3); padding: 0 2px; }
.hw-keys { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.hw-keys i { font-style: normal; font-size: 11px; color: var(--text-3); }
.hw-keys kbd {
  min-width: 24px; height: 24px; padding: 0 7px; border-radius: 7px;
  display: inline-grid; place-items: center;
  font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1; color: var(--text);
  background: var(--surface); box-shadow: 0 0 0 1px var(--border-strong), 0 2px 0 var(--border-strong);
}
.hw-mouse {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 999px;
  font-size: 12px; color: var(--text-2); background: var(--surface); box-shadow: 0 0 0 1px var(--border);
}
.hw-mouse svg.i { width: 13px; height: 13px; color: var(--text-3); }
.hw-md {
  padding: 3px 7px; border-radius: 6px; font: 12px/1.2 "Cascadia Code", Consolas, monospace;
  color: var(--text); background: var(--surface); box-shadow: 0 0 0 1px var(--border);
}
.help-empty { display: none; grid-column: 1 / -1; padding: 30px 0; text-align: center; color: var(--text-3); }
.help-empty.show { display: block; }
.help-row[hidden], .help-sec[hidden] { display: none; }

/* ============ Account & sync ============ */
.acc-btn { position: relative; }
.acc-btn .acc-letter { display: none; }
/* signed in: a letter avatar instead of the person icon */
.acc-btn[data-state]:not([data-state=""]) svg.i { display: none; }
.acc-btn[data-state]:not([data-state=""]) .acc-letter {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-size: 11.5px; font-weight: 700;
}
.acc-badge {
  position: absolute; right: 4px; bottom: 4px; width: 9px; height: 9px; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface); background: transparent; transition: background-color .3s;
}
.acc-btn[data-state="ok"] .acc-badge { background: #4CAF57; }
.acc-btn[data-state="syncing"] .acc-badge { background: var(--warn); animation: accPulse 1s ease-in-out infinite; }
.acc-btn[data-state="warn"] .acc-badge { background: var(--warn); }
.acc-btn[data-state="bad"] .acc-badge { background: var(--danger); }
@keyframes accPulse { 50% { opacity: .35; } }

.modal.acc-modal { width: min(400px, calc(100vw - 32px)); }
.acc { display: flex; flex-direction: column; }
.acc p { margin: 0 0 14px; font-size: 13.5px; }
.acc-avatar {
  width: 52px; height: 52px; border-radius: 50%; margin: 2px auto 10px;
  display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-size: 22px; font-weight: 700;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
}
.acc:not(.acc-form) h3 { text-align: center; margin-bottom: 2px; }
.acc-server { text-align: center; color: var(--text-3); font-size: 12px !important; }
.acc-status {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; color: var(--text-2);
}
.acc-status small { flex-basis: 100%; color: var(--text-3); }
.acc-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.acc-dot[data-state="ok"] { background: #4CAF57; }
.acc-dot[data-state="syncing"], .acc-dot[data-state="warn"] { background: var(--warn); }
.acc-dot[data-state="bad"] { background: var(--danger); }
.acc-form label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.acc-form input {
  height: 38px; padding: 0 12px; border: 0; border-radius: 10px;
  background: var(--surface-2); font-size: 14px; font-weight: 400; color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border); transition: box-shadow .15s;
}
.acc-form input:focus { outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.acc-more { margin: -2px 0 8px; font-size: 12.5px; color: var(--text-3); }
.acc-more summary { cursor: pointer; width: max-content; padding: 2px 0; }
.acc-more[open] summary { margin-bottom: 8px; }
.acc-error { min-height: 18px; font-size: 13px; color: var(--danger); }
.acc-form.busy { opacity: .6; pointer-events: none; }
.acc-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12.5px; }
.acc-links a, .acc-legal a { color: var(--text-2); }
.acc-link { padding: 0; border: 0; background: none; font: inherit; color: var(--text-3); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.acc-link.danger { color: var(--danger); }
.acc p.acc-legal { margin: 12px 0 0; font-size: 12px; color: var(--text-3); text-align: center; }
.acc-delete ul { margin: -6px 0 14px; padding-left: 20px; font-size: 13.5px; line-height: 1.5; }
