:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --dot: #d4d0c8;
  --surface: #ffffff;
  --surface-2: #f6f5f2;
  --surface-3: #ecebe6;
  --card: #ffffff;
  --text: #24242b;
  --muted: #6b6a73;
  --faint: #9b9aa3;
  --line: #e2e0da;
  --accent: #5457d6;
  --accent-soft: #e9e9fb;
  --on-accent: #ffffff;
  --shadow-s: 0 1px 2px rgba(30, 28, 40, .10), 0 1px 1px rgba(30, 28, 40, .05);
  --shadow-m: 0 2px 6px rgba(30, 28, 40, .08), 0 8px 24px rgba(30, 28, 40, .10);
  --danger: #c93b3b;
  --tool-on: #9747ff;
  --pen-body: #fff; --pen-collar: #f3f3f1; --pen-shade: #e6e6e3; --pen-edge: #c9c9c6;

  --st-plain: var(--card);
  --st-yellow: #ffe58a; --st-orange: #ffc98f; --st-red: #ffb3a7; --st-pink: #fbbbd9; --st-purple: #d8c6fb;
  --st-blue: #b4d7fb; --st-teal: #a7e6dc; --st-green: #c5eaa3; --st-gray: #e2e1dc;
  --st-text: #2a2820;

  --ink-ink: #24242b; --ink-red: #d93c3c; --ink-orange: #e5762a; --ink-yellow: #d9a406; --ink-pink: #d9458f;
  --ink-purple: #7c4ddb; --ink-blue: #2f74d6; --ink-teal: #0f9786; --ink-green: #3d9a3a; --ink-gray: #85848c;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, "Noto Color Emoji", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --pen-body: #56565e; --pen-collar: #6a6a72; --pen-shade: #4a4a52; --pen-edge: #3c3c44; --bg: #18181c; --dot: #2e2e35; --surface: #26262c; --surface-2: #2e2e35; --surface-3: #38383f; --card: #26262c;
    --text: #ececf0; --muted: #a5a5b0; --faint: #76767f; --line: #3a3a42;
    --accent: #8d90f5; --accent-soft: #33345c; --on-accent: #14142a;
    --shadow-s: 0 1px 2px rgba(0, 0, 0, .5); --shadow-m: 0 2px 6px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .45);
    --danger: #f07a7a;
    --st-yellow: #6d5a17; --st-orange: #744a1f; --st-red: #74352e; --st-pink: #6f3454; --st-purple: #4d3a7c;
    --st-blue: #27507c; --st-teal: #1c5f57; --st-green: #3f6324; --st-gray: #46464d;
    --st-text: #f6f4ea;
    --ink-ink: #ececf0; --ink-red: #f47c7c; --ink-orange: #f4a261; --ink-yellow: #f2cf4a; --ink-pink: #f28abf;
    --ink-purple: #b49af5; --ink-blue: #7db4f5; --ink-teal: #5fd4c3; --ink-green: #8ad27f; --ink-gray: #a2a2ab;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --pen-body: #56565e; --pen-collar: #6a6a72; --pen-shade: #4a4a52; --pen-edge: #3c3c44; --bg: #18181c; --dot: #2e2e35; --surface: #26262c; --surface-2: #2e2e35; --surface-3: #38383f; --card: #26262c;
  --text: #ececf0; --muted: #a5a5b0; --faint: #76767f; --line: #3a3a42;
  --accent: #8d90f5; --accent-soft: #33345c; --on-accent: #14142a;
  --shadow-s: 0 1px 2px rgba(0, 0, 0, .5); --shadow-m: 0 2px 6px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .45);
  --danger: #f07a7a;
  --st-yellow: #6d5a17; --st-orange: #744a1f; --st-red: #74352e; --st-pink: #6f3454; --st-purple: #4d3a7c;
  --st-blue: #27507c; --st-teal: #1c5f57; --st-green: #3f6324; --st-gray: #46464d;
  --st-text: #f6f4ea;
  --ink-ink: #ececf0; --ink-red: #f47c7c; --ink-orange: #f4a261; --ink-yellow: #f2cf4a; --ink-pink: #f28abf;
  --ink-purple: #b49af5; --ink-blue: #7db4f5; --ink-teal: #5fd4c3; --ink-green: #8ad27f; --ink-gray: #a2a2ab;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
html { cursor: var(--cur-default, default); }
a, select, input[type="checkbox"] { cursor: var(--cur-pointer, pointer); }
input:not([type]), input[type="text"], input[type="search"], input[type="url"], input[type="number"], textarea { cursor: var(--cur-text, text); }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: var(--cur-pointer, pointer); }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Canvas ---- */
#viewport {
  /* clip rather than hidden: a hidden box can still be scrolled by the browser. */
  position: fixed; inset: 0; overflow: clip; touch-action: none; user-select: none; outline: 0;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dot) 1.1px, transparent 1.2px);
}
#world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; --z: 1; }
#overlay { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#links { position: absolute; left: 0; top: 0; overflow: visible; z-index: 900000; pointer-events: none; }
#marquee { position: absolute; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 2px; z-index: 6; pointer-events: none; }
#drop-line { position: absolute; height: 3px; margin-top: -1px; border-radius: 3px; background: var(--accent); z-index: 7; pointer-events: none; }
.live-stroke { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; z-index: 900001; pointer-events: none; }

body[data-tool="hand"] #viewport { cursor: var(--cur-grab, grab); }
body.panning #viewport, body.panning * { cursor: var(--cur-grabbing, grabbing) !important; }
body.space-pan #viewport { cursor: var(--cur-grab, grab); }
body[data-tool="marker"] #viewport, body[data-tool="shapes"] #viewport, body[data-tool="stamp"] #viewport,
body[data-tool="sticky"] #viewport, body[data-tool="note"] #viewport, body[data-tool="todo"] #viewport,
body[data-tool="column"] #viewport, body[data-tool="section"] #viewport, body[data-tool="board"] #viewport { cursor: var(--cur-crosshair, crosshair); }
body[data-tool="text"] #viewport { cursor: var(--cur-text, text); }
body[data-tool="marker"][data-marker="eraser"] #viewport { cursor: cell; }
body:not([data-tool="select"]) .item, body:not([data-tool="select"]) .item * { cursor: inherit; }
body.dragging { cursor: var(--cur-grabbing, grabbing); }
body.dragging-task, body.dragging-task * { cursor: var(--cur-grabbing, grabbing) !important; }
body.dragging.duplicating, body.dragging.duplicating * { cursor: copy !important; }

/* ---- Cards ---- */
.item { position: absolute; border-radius: 10px; color: var(--text); }
/* Edge textures and surface styles: the card's background moves to a layer of its own, so its words stay crisp. */
body[data-texture] #world .item { --edge-active: var(--edge-filter); }
body[data-surface] #world .item { --surface-active: var(--surface-filter); }
body[data-surface] #world .item.tex-clear { --surface-active: ; }
body:is([data-texture], [data-surface]) #world .item.tex { background: transparent !important; box-shadow: none !important; isolation: isolate; overflow: visible; }
body:is([data-texture], [data-surface]) #world .item.tex::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--tex-bg); filter: var(--edge-active,) var(--surface-active,); pointer-events: none; }
body[data-texture] #world .item.has-stroke:not(.type-shape):not(.type-section)::after { filter: var(--edge-filter); }
body[data-texture] #world .type-image { overflow: visible; }
body[data-texture] #world .crop-frame:not(.has-crop) { overflow: visible; }
body[data-texture] #world .crop-frame > img, body[data-texture] #world .crop-frame > canvas { border-radius: 10px; filter: var(--edge-picture); }
body[data-texture] #world .link-shot.crop-frame > img { border-radius: 10px 10px 0 0; }
body[data-texture] #world .is-cropping .crop-frame > img, body[data-texture] #world .is-cropping .crop-frame > canvas { border-radius: 0; filter: none; }
body[data-texture] #world .color-swatch { filter: var(--edge-filter); }
body:is([data-texture], [data-surface]) #world .shape-art { overflow: visible; filter: var(--edge-active,) var(--surface-active,); }
.item.selected { outline: calc(2px / var(--z)) solid var(--accent); outline-offset: calc(1px / var(--z)); }
.item.drop-target { outline: calc(3px / var(--z)) solid var(--accent); outline-offset: calc(3px / var(--z)); }
.item.link-target { outline: calc(3px / var(--z)) solid var(--accent); outline-offset: calc(2px / var(--z)); }
.type-note, .type-todo, .type-link, .type-palette, .type-color, .type-board, .type-file { background: var(--card); }
.item.in-column { position: relative; left: auto; top: auto; width: auto; flex: none; }

.editable { outline: 0; min-height: 1.45em; word-break: break-word; cursor: inherit; }
.editable[contenteditable] { user-select: text; cursor: var(--cur-text, text); }
.editable:empty::before { content: attr(data-ph); color: var(--faint); pointer-events: none; }

.note-body { padding: 14px 16px; min-height: 64px; }
.text-body { padding: 4px 6px; font-size: 20px; line-height: 1.3; font-weight: 500; }
.note-body h1, .note-body h2, .note-body h3, .text-body h2 { font-size: 1.28em; line-height: 1.25; margin: .2em 0 .4em; font-weight: 650; }
.note-body ul, .note-body ol { margin: .3em 0; padding-left: 1.3em; }
.note-body p { margin: 0 0 .5em; }
.note-body a { color: var(--accent); }

.type-sticky { background: var(--st-yellow); color: var(--st-text); border-radius: 3px; box-shadow: var(--shadow-m); min-height: 80px; display: flex; }
.type-sticky.in-column { min-height: 90px; }
.sticky-body { padding: 16px; flex: 1; font-size: 15px; white-space: pre-wrap; }
.type-sticky .editable:empty::before { color: color-mix(in srgb, var(--st-text) 50%, transparent); }
.color-yellow.type-sticky { background: var(--st-yellow); } .color-orange.type-sticky { background: var(--st-orange); }
.color-red.type-sticky { background: var(--st-red); } .color-pink.type-sticky { background: var(--st-pink); }
.color-purple.type-sticky { background: var(--st-purple); } .color-blue.type-sticky { background: var(--st-blue); }
.color-teal.type-sticky { background: var(--st-teal); } .color-green.type-sticky { background: var(--st-green); }
.color-gray.type-sticky { background: var(--st-gray); } .color-plain.type-sticky { background: var(--st-plain); }

/* Shapes: an outline drawn to the card's real size, so strokes never stretch */
.type-shape { display: flex; align-items: center; justify-content: center; border-radius: 0; color: var(--st-text); }
.shape-art { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; stroke-linejoin: round; }
.shape-text { position: relative; max-width: 70%; min-width: 12px; padding: 4px; text-align: center; font-size: 15px; white-space: pre-wrap; }
.shape-triangle .shape-text { margin-top: 22%; }
.shape-triangleDown .shape-text { margin-bottom: 22%; }

/* A chosen fill and outline, which win over a card type's usual look */
.item.has-fill:not(.type-shape) { background: var(--fill) !important; }
.item.has-fill > :not(.col-body) { --text: var(--on-fill); --st-text: var(--on-fill); --muted: color-mix(in srgb, var(--on-fill) 68%, transparent); --faint: color-mix(in srgb, var(--on-fill) 48%, transparent); color: var(--on-fill); }
.item.fill-none:not(.type-shape) { background: transparent !important; box-shadow: none; }
.item.has-stroke:not(.type-shape):not(.type-section)::after { content: ""; position: absolute; inset: 0; border: var(--stroke-w) solid var(--stroke); border-radius: inherit; pointer-events: none; }
.item.has-stroke.type-section { border: var(--stroke-w) solid var(--stroke); }
.item.no-stroke.type-section { border-color: transparent; }
.item.no-stroke:not(.type-section):not(.type-shape) { box-shadow: none; }
.item.no-stroke.type-column { border-top-color: transparent; }

/* To-do */
.type-todo { padding: 8px 14px; }
.todo-title { font-weight: 650; font-size: 15px; margin-bottom: 2px; }
.todo-row { display: flex; align-items: flex-start; gap: 8px; padding: 3px 0; position: relative; }
.todo-check { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 5px; border: 1.5px solid var(--faint); display: grid; place-items: center; color: var(--on-accent); }
.todo-check:hover { border-color: var(--accent); }
.todo-grip { position: absolute; left: -14px; top: 5px; width: 14px; height: 16px; display: grid; place-items: center; color: var(--faint); opacity: 0; cursor: var(--cur-grab, grab); touch-action: none; }
.todo-row:hover .todo-grip, .todo-dragging .todo-grip { opacity: 1; }
.todo-grip:hover { color: var(--text); }
.todo-dragging { background: var(--surface-2); border-radius: 6px; opacity: .45; }
.todo-ghost { position: fixed; z-index: 40; pointer-events: none; transform-origin: 0 0; background: var(--card); color: var(--text); border-radius: 6px; box-shadow: var(--shadow-m); }
.todo-ghost .todo-grip { opacity: 1; }
.todo-row.done .todo-check { background: var(--accent); border-color: var(--accent); }
.todo-text { flex: 1; min-width: 0; white-space: pre-wrap; }
.todo-row.done .todo-text { color: var(--muted); text-decoration: line-through; }
.todo-del { opacity: 0; color: var(--faint); margin-top: 3px; }
.todo-row:hover .todo-del { opacity: 1; }
.todo-del:hover { color: var(--danger); }
.todo-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12.5px; }
.todo-add { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); padding: 2px 6px 2px 2px; border-radius: 6px; }
.todo-add:hover { color: var(--text); background: var(--surface-2); }

/* Image */
.type-image { overflow: hidden; }
.type-image img { display: block; width: 100%; height: auto; pointer-events: none; }
/* Only a picture that has not loaded gets a minimum height, as it would stretch one that has. */
.type-image img:not([src]) { min-height: 40px; background: var(--surface-2); }
.type-image canvas { display: block; width: 100%; height: auto; pointer-events: none; }
/* A picture's visible part. The whole picture is kept and moved around behind this. */
.crop-frame { position: relative; display: block; overflow: hidden; container-type: inline-size; }
.crop-frame.has-crop > img, .crop-frame.has-crop > canvas { position: absolute; left: var(--crop-l); top: var(--crop-t); width: var(--crop-w); max-width: none; height: auto; }
.item.is-cropping { overflow: visible !important; z-index: 99999 !important; box-shadow: none; transform: none !important; }
.is-cropping .crop-frame { overflow: visible; }
.media-actions { position: absolute; left: 8px; bottom: 8px; display: none; gap: 4px; pointer-events: none; }
body[data-tool="select"]:not(.dragging) .type-image:not(.is-locked):not(.is-cropping):hover .media-actions,
body[data-tool="select"]:not(.dragging) .type-link:not(.is-locked):not(.is-cropping):hover .media-actions { display: flex; }
.un-card .media-actions { display: none !important; }
.in-column .media-crop { display: none; }
/* Icons only, in the bottom left corner. A card too small for them has them in its bar instead. */
.media-btn { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border-radius: 13px; background: rgba(0, 0, 0, .72); color: #fff; pointer-events: auto; }
.media-btn span { display: none; }
.media-btn:hover { background: #000; }
@container (max-width: 139px) { .media-actions { display: none !important; } }
.gif-badge { position: absolute; left: 8px; top: 8px; min-width: 22px; height: 20px; padding: 0 5px; display: grid; place-items: center; border-radius: 5px; background: rgba(0, 0, 0, .62); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; pointer-events: none; }
.card-caption { padding: 8px 12px; font-size: 13px; color: var(--muted); }
.card-caption:empty:not([contenteditable]) { display: none; }
.missing-file::after { content: "Image not found"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

/* Link */
.type-link { overflow: hidden; }
.link-shot img { display: block; width: 100%; height: auto; pointer-events: none; }
.link-shot.empty, .link-shot.loading { height: 120px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.link-shot.loading span { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .link-shot.loading span { animation: none; } }
.link-meta { padding: 10px 14px 12px; }
.link-title { font-weight: 600; line-height: 1.3; }
.link-desc { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-desc:empty:not([contenteditable]) { display: none; }
.link-desc[contenteditable], .link-desc.is-list, .link-desc.is-full { display: block; -webkit-line-clamp: unset; }
/* A video's views and date take a line of their own, leaving two for its description. */
.link-desc.has-stats { -webkit-line-clamp: 3; }
.link-desc ol { margin: 6px 0 0; padding-left: 20px; }
.link-desc li { margin: 2px 0; }
.link-desc a { color: inherit; text-decoration: underline; }
.link-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 6px 6px 0; }
.link-gallery img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; }
.link-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.link-tag { padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; }
.link-tag.top { color: var(--text); font-weight: 600; }
.link-foot { margin-top: 6px; }
.link-host { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12.5px; text-decoration: none; max-width: 100%; }
.link-host span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-host:hover { color: var(--accent); }

/* Palette */
.type-palette { padding: 12px; }
.palette-name { font-weight: 600; margin: 0 2px 8px; }
.swatches { display: flex; border-radius: 8px; overflow: hidden; min-height: 92px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 10%, transparent); }
.swatch { flex: 1 1 0; min-width: 0; position: relative; }
.swatch-copy { position: absolute; inset: 0; width: 100%; height: 100%; cursor: copy; }
.swatch-hex { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 0; text-align: center; font: 10.5px ui-monospace, Consolas, monospace; background: color-mix(in srgb, var(--card) 86%, transparent); pointer-events: none; overflow: hidden; }
.swatch-edit, .swatch-del { position: absolute; top: 4px; width: 20px; height: 20px; border-radius: 6px; display: none; place-items: center; background: var(--surface); box-shadow: var(--shadow-s); cursor: var(--cur-pointer, pointer); }
.swatch-edit { left: 4px; }
.swatch-del { right: 4px; }
.swatch:hover .swatch-edit, .swatch:hover .swatch-del { display: grid; }
.swatch-edit input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: var(--cur-pointer, pointer); padding: 0; border: 0; }
.palette-tools { display: flex; gap: 4px; margin-top: 6px; }
.palette-btn { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12.5px; padding: 3px 7px 3px 4px; border-radius: 6px; }
.palette-btn:hover { background: var(--surface-2); color: var(--text); }

/* Colour card and its editor */
.type-color { padding: 8px; border-radius: 12px; }
.color-swatch { aspect-ratio: 80 / 66; border-radius: 8px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 10%, transparent); }
.color-name { margin-top: 5px; font-size: 12px; line-height: 1.3; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.color-hex { color: var(--muted); font-size: 11px; line-height: 1.3; }
#color-editor { z-index: 16; width: 224px; padding: 12px; }
.ce-wheel-wrap { position: relative; width: 200px; height: 200px; }
.ce-wheel { display: block; width: 200px; height: 200px; border-radius: 50%; cursor: var(--cur-crosshair, crosshair); touch-action: none; }
.ce-handle { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .4); pointer-events: none; }
.ce-value { display: block; width: 100%; height: 14px; margin: 12px 0; appearance: none; border-radius: 7px; background: linear-gradient(to right, #000, var(--slider-end, #fff)); cursor: var(--cur-pointer, pointer); }
.ce-value::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border-radius: 50%; background: transparent; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.ce-value::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: transparent; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.ce-row { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; gap: 6px 10px; }
.ce-swatch { width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 12%, transparent); }
.ce-pick { width: 30px; height: 30px; }
.ce-text, .ce-number { width: 100%; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); outline: 0; font-size: 13px; }
.ce-text:focus, .ce-number:focus { border-color: var(--accent); }
.ce-number { padding: 0 4px; text-align: center; appearance: textfield; }
.ce-number::-webkit-inner-spin-button, .ce-number::-webkit-outer-spin-button { appearance: none; margin: 0; }
.ce-hsl { display: flex; gap: 6px; margin-top: 8px; }
.ce-part { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 650; color: var(--muted); }

/* Column */
.type-column { background: var(--surface-3); border-radius: 12px; padding: 0 10px 8px; border-top: 4px solid var(--ink-gray); }
.color-yellow.type-column { border-top-color: var(--ink-yellow); } .color-orange.type-column { border-top-color: var(--ink-orange); }
.color-red.type-column { border-top-color: var(--ink-red); } .color-pink.type-column { border-top-color: var(--ink-pink); }
.color-purple.type-column { border-top-color: var(--ink-purple); } .color-blue.type-column { border-top-color: var(--ink-blue); }
.color-teal.type-column { border-top-color: var(--ink-teal); } .color-green.type-column { border-top-color: var(--ink-green); }
.col-head { display: flex; align-items: center; gap: 6px; padding: 10px 2px 8px; }
.col-title { flex: 1; min-width: 0; font-weight: 650; }
.col-count { color: var(--muted); font-size: 12.5px; }
.col-toggle { color: var(--muted); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; }
.col-toggle:hover { background: var(--surface); }
.col-toggle.collapsed svg { transform: rotate(-90deg); }
.col-body { display: flex; flex-direction: column; gap: 8px; min-height: 44px; }
.col-body.hidden { display: none; }
.col-body:empty::before { content: attr(data-placeholder); display: grid; place-items: center; height: 56px; color: var(--muted); font-size: 12.5px; border: 1.5px dashed color-mix(in srgb, var(--muted) 45%, transparent); border-radius: 8px; }
.col-add { display: flex; align-items: center; gap: 4px; width: 100%; margin-top: 4px; padding: 4px; color: var(--muted); border-radius: 7px; font-size: 13px; }
.col-add:hover { background: var(--surface); color: var(--text); }

/* Section */
.type-section { border: calc(1.5px / var(--z)) solid var(--ink-blue); background: color-mix(in srgb, var(--ink-blue) 7%, transparent); border-radius: 14px; }
.color-yellow.type-section { border-color: var(--ink-yellow); background: color-mix(in srgb, var(--ink-yellow) 8%, transparent); }
.color-orange.type-section { border-color: var(--ink-orange); background: color-mix(in srgb, var(--ink-orange) 8%, transparent); }
.color-red.type-section { border-color: var(--ink-red); background: color-mix(in srgb, var(--ink-red) 7%, transparent); }
.color-pink.type-section { border-color: var(--ink-pink); background: color-mix(in srgb, var(--ink-pink) 7%, transparent); }
.color-purple.type-section { border-color: var(--ink-purple); background: color-mix(in srgb, var(--ink-purple) 7%, transparent); }
.color-teal.type-section { border-color: var(--ink-teal); background: color-mix(in srgb, var(--ink-teal) 7%, transparent); }
.color-green.type-section { border-color: var(--ink-green); background: color-mix(in srgb, var(--ink-green) 7%, transparent); }
.color-gray.type-section { border-color: var(--ink-gray); background: color-mix(in srgb, var(--ink-gray) 8%, transparent); }
.section-title:empty:not([contenteditable]) { display: none; }
.section-title { position: absolute; left: 10px; top: 8px; max-width: calc(100% - 20px); min-width: 60px; padding: 2px 10px; border-radius: 7px; background: var(--surface); font-weight: 650; box-shadow: var(--shadow-s); cursor: var(--cur-grab, grab); }

/* Board */
/* A narrow board card stacks its name under the tile. */
.type-board { container-type: inline-size; }
.board-body { display: flex; align-items: center; gap: 12px; padding: 12px; }
@container (max-width: 200px) {
  .board-body { flex-direction: column; gap: 6px; padding: 10px 6px; text-align: center; }
  .board-text { width: 100%; font-size: 12.5px; }
}
.board-emoji { font-size: 28px; line-height: 1; font-family: "Noto Color Emoji", "Segoe UI Emoji", sans-serif; }
.board-tile { flex: none; width: 56px; height: 56px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.board-text { min-width: 0; flex: 1; }
.board-name { font-weight: 650; }
.board-count { color: var(--muted); font-size: 12.5px; }

/* File */
.type-file { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.file-icon { color: var(--muted); display: grid; }
.file-text { flex: 1; min-width: 0; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); font-size: 12.5px; }
.file-open { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.file-open:hover { background: var(--surface-2); color: var(--text); }

/* Marker and stamps */
.type-stroke { pointer-events: none; border-radius: 0; }
.type-stroke svg { display: block; width: 100%; height: 100%; overflow: visible; }
.stroke-ink { fill: none; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.stroke-hit { fill: none; stroke: transparent; stroke-linecap: round; pointer-events: stroke; }
.type-stamp { display: grid; place-items: center; line-height: 1; border-radius: 8px; }
.stamp-glyph { display: block; pointer-events: none; font-family: "Noto Color Emoji", "Segoe UI Emoji", "Apple Color Emoji", sans-serif; }
/* A sticker's white edge, sized with the stamp. */
.stamp-glyph, .ghost-stamp { filter: drop-shadow(.045em 0 0 #fff) drop-shadow(-.045em 0 0 #fff) drop-shadow(0 .045em 0 #fff) drop-shadow(0 -.045em 0 #fff) drop-shadow(0 .02em .05em rgba(0, 0, 0, .35)); }

/* Connectors */
.link-line { fill: none; stroke-width: 2.2; stroke-linecap: round; }
.link-head { stroke-width: 1.5; stroke-linejoin: round; }
.link-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: var(--cur-pointer, pointer); }
body:not([data-tool="select"]) .link-hit { pointer-events: none; }
.link.selected .link-line { stroke-width: 3.2; }
.link.selected .link-line, .link.selected .link-head { filter: drop-shadow(0 0 3px var(--accent)); }

/* Handles (drawn in screen space so they stay one size at any zoom) */
.handle { position: absolute; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; background: var(--surface); border: 2px solid var(--accent); border-radius: 3px; pointer-events: auto; }
.link-dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--accent); opacity: .5; pointer-events: auto; cursor: var(--cur-crosshair, crosshair); }
.link-dot:hover { opacity: 1; transform: scale(1.3); }
.crop-shade { position: absolute; background: color-mix(in srgb, var(--bg) 72%, transparent); }
.crop-box { position: absolute; outline: 2px solid var(--accent); }
.crop-handle { position: absolute; transform: translate(-50%, -50%); background: #fff; border: 2px solid var(--accent); border-radius: 4px; pointer-events: auto; touch-action: none; }
.crop-wide { width: 30px; height: 10px; }
.crop-tall { width: 10px; height: 30px; }
.crop-corner { width: 14px; height: 14px; }
.crop-done { position: absolute; transform: translateX(-50%); height: 28px; padding: 0 14px; border-radius: 14px; background: #1e1e1e; color: #fff; font-size: 13px; font-weight: 600; pointer-events: auto; }
.multi-box { position: absolute; border: 1.5px dashed var(--accent); border-radius: 6px; }
.multi-box.is-group { border-style: solid; }
.size-label { position: absolute; transform: translateX(-50%); padding: 2px 8px; border-radius: 6px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.swap-dot { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); pointer-events: auto; cursor: var(--cur-grab, grab); opacity: .85; }
.swap-dot:hover { opacity: 1; background: var(--accent); }
.grid-handle { position: absolute; width: 8px; height: 28px; margin: -14px 0 0 -4px; border-radius: 4px; background: var(--accent); pointer-events: auto; cursor: ew-resize; }
#world .item.swap-target { outline: 2px dashed var(--accent); outline-offset: 4px; }

/* ---- Floating chrome ---- */
.pill { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-m); }
#topbar-left { position: fixed; top: 12px; z-index: 20; display: flex; align-items: center; height: 44px; padding: 0 6px; gap: 2px; }
/* The left side is 10 dots wide and the right side 6, at 100% zoom. */
#topbar-left { left: 12px; width: var(--layers-w, 240px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 6px 8px; border-radius: 8px; letter-spacing: -.01em; }
.brand:hover { background: var(--surface-2); }
/* The logo doubles as the saved status: blue when saved, red if a save failed. */
.brand-mark { width: 18px; height: 18px; border-radius: 6px; background: #0d99ff; position: relative; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28); }
.brand-mark::after { content: ""; position: absolute; width: 7px; height: 7px; right: 3px; bottom: 3px; border-radius: 50%; background: #fff; }
.brand-mark[data-state="not-saved"], .brand-mark[data-backup="off"] { background: #e5352b; }
/* Plain text on the canvas, clear of the Neuro bar and of Unsorted. Only the words take clicks. */
#breadcrumbs { position: fixed; top: 12px; left: calc(var(--layers-w, 240px) + 24px); z-index: 19; display: flex; align-items: center; gap: 2px; height: 44px; max-width: calc(100vw - var(--layers-w, 240px) - var(--unsorted-w, 184px) - 24px); overflow: hidden; white-space: nowrap; font-size: 15px; font-weight: 600; pointer-events: none; }
#breadcrumbs > * { pointer-events: auto; }
.crumb, .crumb-here, .crumb-input { flex: 0 1 auto; min-width: 24px; padding: 4px 6px; border-radius: 6px; color: var(--text); font: inherit; overflow: hidden; text-overflow: ellipsis; }
.crumb:hover { background: var(--surface-2); }
.crumb-here { pointer-events: none !important; }
.crumb-sep { color: var(--text); pointer-events: none !important; }
.crumb-input { field-sizing: content; min-width: 44px; border: 0; background: transparent; outline: 0; }
.crumb-input:focus { background: var(--surface-2); }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.text-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 9px; border-radius: 8px; font-weight: 500; }
.text-btn:hover { background: var(--surface-2); }
.text-btn > span:first-child { display: inline-grid; color: var(--muted); }

/* Toolbar: one tray along the bottom, split by full-height hairlines, FigJam style */
/* With the pet beside it, the toolbar moves left so the two are centred together. */
#toolbar { position: fixed; left: 50%; bottom: 12px; transform: translateX(calc(-50% - var(--pet-shift, 0px))); z-index: 20; display: flex; align-items: stretch; height: 48px; background: var(--surface); border-radius: 14px; box-shadow: 0 0 0 1px var(--line), var(--shadow-m); max-width: calc(100vw - 16px); overflow: hidden; }
.tool-group { flex: none; display: flex; align-items: center; gap: 4px; padding: 0 10px; }
.tool-group + .tool-group { border-left: 1px solid var(--line); }
.tool { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--text); }
.tool:hover { background: var(--surface-2); }
.tool.on { background: var(--tool-on); color: #fff; }
.tool.tool-art { width: auto; height: 100%; align-self: flex-end; border-radius: 0; align-items: start; background: none; overflow: hidden; }
.tool-art svg { display: block; transform: translateY(5px); transition: transform .14s ease-out; }
.tool-art:hover svg { transform: translateY(2px); }
.tool-art.on svg { transform: translateY(0); }
.tool.tool-art.on { background: var(--surface-2); border-radius: 10px 10px 0 0; }
.pen-body { fill: var(--pen-body); stroke: var(--pen-edge); }
.pen-collar { fill: var(--pen-collar); stroke: var(--pen-edge); }
.pen-shade { fill: var(--pen-shade); }
.pen-edge { stroke: var(--pen-edge); }
/* Arranging the toolbar */
#toolbar .tool, .more-row { touch-action: none; }
.tool-dragging { opacity: .3; }
body.dragging-tool, body.dragging-tool * { user-select: none; cursor: var(--cur-grabbing, grabbing) !important; }
.tool-drag-tile { position: fixed; z-index: 40; width: 36px; height: 36px; margin: -18px 0 0 -18px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-m); pointer-events: none; }
.tool-drop-mark { position: fixed; z-index: 39; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--tool-on); pointer-events: none; }
.tool-drop-mark.in-menu { height: 2px; margin: -1px 0 0; }
.tool-drop-target { outline: 2px solid var(--tool-on); outline-offset: 2px; }
.more-hint { padding: 6px 8px 2px; font-size: 12px; color: var(--muted); }
/* The three recent shapes, each its own button, standing in the tray like the pens. */
.tool-shapes { position: relative; width: 72px !important; padding: 0; cursor: var(--cur-default, default); --shape-art: var(--card); }
.shape-slot { position: absolute; display: grid; place-items: center; color: var(--muted); border-radius: 6px; transition: transform .14s ease-out; }
.shape-slot:hover { color: var(--text); transform: translateY(-3px); }
.shape-slot.current { color: var(--tool-on); }
.slot-0 { left: 2px; bottom: 8px; width: 32px; height: 32px; }
.slot-1 { right: 6px; top: 2px; width: 26px; height: 26px; }
.slot-2 { right: 3px; bottom: -8px; width: 32px; height: 32px; }
@media (prefers-reduced-motion: reduce) { .shape-slot { transition: none; } }
@media (prefers-reduced-motion: reduce) { .tool-art svg { transition: none; } }
.tools-more .tool { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); }
.tools-more .tool:hover { background: var(--surface-3); }
.tools-more .tool.on { background: var(--tool-on); }
.more-menu { display: flex; flex-direction: column; min-width: 210px; }
.more-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 8px; text-align: left; }
.more-row:hover { background: var(--surface-2); }
.more-ic { display: inline-grid; color: var(--muted); }
.more-label { flex: 1; }
.more-key { font-family: inherit; font-size: 12px; color: var(--muted); }

.popover { position: fixed; z-index: 21; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-m); padding: 8px; }
/* Right-click menus */
#context-menu { z-index: 30; min-width: 210px; padding: 6px; background: #1e1e1e; color: #fff; font-size: 13.5px; font-weight: 600; }
.ctx-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; height: 32px; padding: 0 10px; border-radius: 7px; color: inherit; text-align: left; white-space: nowrap; cursor: var(--cur-pointer, pointer); }
.ctx-row:hover, .ctx-parent:focus-within { background: rgba(255, 255, 255, .12); }
.ctx-danger { color: #ff6b6b; }
.ctx-key { font: inherit; font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, .55); }
.ctx-arrow { display: grid; transform: rotate(-90deg); }
.ctx-sub { position: absolute; left: 100%; top: -6px; display: none; min-width: 180px; padding: 6px; border-radius: 12px; background: #1e1e1e; box-shadow: var(--shadow-m); }
.ctx-parent:hover > .ctx-sub, .ctx-parent:focus-within > .ctx-sub { display: block; }
.sub-left .ctx-sub { left: auto; right: 100%; }
.tray-stack { display: flex; flex-direction: column; gap: 8px; }
.tray-line { display: flex; align-items: center; gap: 6px; }
.tray-modes { display: flex; gap: 2px; }
.tray-btn { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; }
.tray-btn:hover { background: var(--surface-2); }
.tray-btn.on { background: var(--accent-soft); color: var(--accent); }
.tray-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.tray-pens { display: flex; align-items: flex-end; gap: 2px; margin-bottom: -8px; height: 44px; overflow: hidden; }
.tray-pen { width: 38px; height: 44px; display: flex; align-items: flex-start; justify-content: center; border-radius: 9px 9px 0 0; overflow: hidden; }
.tray-pen svg { display: block; transform: translateY(6px); transition: transform .14s ease-out; }
.tray-pen:hover svg, .tray-pen.on svg { transform: translateY(0); }
.tray-pen.on { background: var(--accent-soft); }
.tray-fill { display: flex; align-items: center; gap: 3px; height: 36px; padding: 0 6px; border-radius: 9px; color: var(--muted); }
.tray-fill:hover { background: var(--surface-2); }
.fill-dot { display: block; flex: none; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .6); }
.fill-dot.is-none { position: relative; overflow: hidden; }
.fill-dot.is-none::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: #f24822; transform: rotate(45deg); }
.color-custom { position: relative; display: block; overflow: hidden; cursor: var(--cur-pointer, pointer); background: conic-gradient(#f24822, #ffcd29, #14ae5c, #1bc4bb, #0d99ff, #9747ff, #ff24bd, #f24822); }
.color-custom input { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); padding: 0; border: 0; opacity: 0; cursor: var(--cur-pointer, pointer); }

/* The dark menus for colours and shapes */
#bar-pop { z-index: 22; background: #1e1e1e; color: #fff; padding: 10px; border-radius: 12px; }
#bar-pop .color-dot { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); }
#bar-pop .color-dot.on { outline-color: #b98cff; }
.colour-menu { display: flex; flex-direction: column; gap: 8px; }
.colour-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.colour-grid { display: flex; flex-direction: column; gap: 6px; }
.colour-row { display: flex; gap: 6px; }
.colour-row .color-dot { flex: none; width: 24px; height: 24px; }
.color-pick { display: grid; place-items: center; color: inherit; background: none; }
.color-pick:hover { background: rgba(255, 255, 255, .14); }
#bar-pop .color-pick { box-shadow: none; }
.colour-top .value-slider { flex: 1; min-width: 0; }
.colour-top .vs-range { flex: 1; width: auto; min-width: 0; }
.colour-none { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px 0 4px; color: inherit; border-radius: 7px; font-size: 13px; }
.colour-none:hover { background: rgba(255, 255, 255, .12); }
.colour-none.on { background: rgba(255, 255, 255, .18); }
.width-row { display: flex; gap: 4px; }
.width-btn { flex: 1; height: 28px; display: grid; align-items: center; padding: 0 8px; border-radius: 7px; color: inherit; }
.width-btn span { display: block; width: 100%; border-radius: 4px; background: currentColor; }
.width-btn:hover { background: rgba(255, 255, 255, .12); }
.width-btn.on { background: rgba(255, 255, 255, .22); }
.shape-menu { display: grid; grid-template-columns: repeat(5, 32px); gap: 2px; --shape-art: transparent; }

/* Stamp wheel and the emoji behind it */
#stamp-wheel { position: fixed; z-index: 23; width: 240px; height: 240px; border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 1px var(--line), var(--shadow-m); }
.wheel-lines { position: absolute; inset: 0; stroke: var(--line); stroke-width: 1.5; pointer-events: none; }
.wheel-stamp { position: absolute; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; display: grid; place-items: center; font-size: 31px; line-height: 1; font-family: "Noto Color Emoji", "Segoe UI Emoji", "Apple Color Emoji", sans-serif; transition: transform .1s ease-out; }
.wheel-stamp:hover { background: var(--surface-2); transform: scale(1.12); }
.wheel-stamp.on { background: var(--accent-soft); }
.wheel-more { position: absolute; left: 50%; top: 50%; width: 88px; height: 88px; margin: -44px 0 0 -44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1.5px var(--line); }
.wheel-more:hover { background: var(--accent-soft); color: var(--accent); }
#emoji-set { z-index: 24; width: 344px; display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.emoji-tabs { display: flex; justify-content: space-between; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.emoji-tab { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; color: var(--muted); }
.emoji-tab:hover { background: var(--surface-2); color: var(--text); }
.emoji-search { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); outline: 0; }
.emoji-search:focus { border-color: var(--tool-on); }
.emoji-body { position: relative; height: 280px; overflow: hidden auto; }
.tile-dot { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; font-size: 13px; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .6); }
.bar-emoji { font-size: 17px; line-height: 1; font-family: "Noto Color Emoji", "Segoe UI Emoji", sans-serif; }
.tile-menu { display: flex; flex-direction: column; gap: 8px; width: 300px; }
.tile-icon-head { display: flex; align-items: center; justify-content: space-between; min-height: 28px; font-size: 12.5px; font-weight: 600; }
.tile-menu .emoji-search { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .2); }
.tile-menu .emoji-heading { color: rgba(255, 255, 255, .6); }
.tile-menu .emoji-body { height: 200px; }
.tile-menu .sc-reset { background: rgba(255, 255, 255, .12); color: #fff; }
.emoji-heading { padding: 8px 2px 4px; font-size: 13px; font-weight: 650; }
.emoji-heading:first-child { padding-top: 0; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 1px; }
.emoji-btn { min-width: 0; height: 34px; overflow: hidden; border-radius: 7px; font-size: 21px; line-height: 1; font-family: "Noto Color Emoji", "Segoe UI Emoji", "Apple Color Emoji", sans-serif; }
.emoji-btn:hover { background: var(--surface-2); }
.emoji-none { padding: 24px 8px; text-align: center; color: var(--muted); }

/* A slider with a typed value, for tool sizes and fill opacity */
.value-slider { display: flex; align-items: center; gap: 8px; }
.vs-range { width: 110px; height: 4px; margin: 0; appearance: none; border-radius: 2px; background: color-mix(in srgb, currentColor 30%, transparent); cursor: var(--cur-pointer, pointer); }
.vs-range::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--tool-on); box-shadow: 0 0 0 2px var(--surface); }
.vs-range::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--tool-on); }
.vs-number { width: 46px; height: 28px; padding: 0 4px; border: 1px solid color-mix(in srgb, currentColor 22%, transparent); border-radius: 7px; background: transparent; color: inherit; outline: 0; text-align: center; font-size: 13px; appearance: textfield; }
.vs-number:focus { border-color: var(--tool-on); }
.vs-number::-webkit-inner-spin-button, .vs-number::-webkit-outer-spin-button { appearance: none; margin: 0; }

/* A faint copy of the note or stamp under the pointer */
#tool-ghost { position: fixed; z-index: 14; pointer-events: none; opacity: .65; }
.ghost-sticky { border-radius: 3px; box-shadow: var(--shadow-m); }
.ghost-stamp { display: grid; place-items: center; line-height: 1; font-family: "Noto Color Emoji", "Segoe UI Emoji", "Apple Color Emoji", sans-serif; }
.swatch-row { display: flex; gap: 4px; align-items: center; }
.color-dot { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 18%, transparent); }
.color-dot:hover { transform: scale(1.12); }
.color-dot.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.link-input { width: min(320px, 70vw); height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); outline: 0; }
.link-input:focus { border-color: var(--accent); }
.tray-go { height: 36px; padding: 0 14px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 600; }

#selbar { position: fixed; z-index: 15; display: flex; align-items: center; gap: 2px; padding: 4px 6px; min-height: 40px; background: #1e1e1e; color: #fff; }
#selbar.hide-while-drag { display: none; }
.bar-btn { width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; color: #fff; }
.bar-btn:hover { background: rgba(255, 255, 255, .14); }
.bar-btn.on { background: rgba(255, 255, 255, .24); }
.bar-text { width: auto; padding: 0 8px; font-size: 13px; }
.bar-sep { width: 1px; height: 20px; margin: 0 5px; background: rgba(255, 255, 255, .22); }
.bar-drop { display: flex; align-items: center; gap: 3px; height: 32px; padding: 0 5px; border-radius: 7px; color: #fff; }
.bar-drop:hover { background: rgba(255, 255, 255, .14); }
.outline-art { display: grid; place-items: center; }

/* The bin sits right of the zoom bar, with the usual 12px all round, so the bar ends 48px sooner. */
#bin-btn { position: fixed; right: 12px; bottom: 12px; z-index: 19; width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); }
#bin-btn:hover, #bin-btn.on { color: var(--text); }
#bin { right: 12px; bottom: 60px; z-index: 22; width: 288px; max-height: min(560px, calc(100vh - 140px)); display: flex; flex-direction: column; gap: 8px; padding: 10px; }
#bin[hidden] { display: none; }
.bin-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px; }
.bin-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 2px; }
.bin-row { flex: none; cursor: var(--cur-grab, grab); touch-action: none; user-select: none; }
.bin-row.lifted { opacity: .35; }
.bin-row .un-card { cursor: inherit; }
.bin-row .un-card:hover .bin-back { display: grid; }
.bin-back { right: 6px; }
.bin-meta { margin-top: 4px; font-size: 12px; color: var(--muted); }
.bin-empty { margin: 4px 2px; font-size: 12.5px; color: var(--muted); }
#zoom { position: fixed; right: 60px; bottom: 12px; z-index: 19; width: max(136px, calc(var(--unsorted-w, 184px) - 48px)); height: 36px; display: flex; align-items: center; justify-content: space-between; padding: 3px; }
#zoom .icon-btn { width: 28px; height: 30px; }
#zoom-val { height: 30px; min-width: 46px; justify-content: center; font-size: 12.5px; font-variant-numeric: tabular-nums; padding: 0 4px; }

/* ---- Unsorted panel ---- */
.side-panel { position: fixed; top: 64px; z-index: 18; display: flex; flex-direction: column; max-height: calc(100vh - 150px); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-m); }
.side-panel.collapsed { height: auto !important; }
.side-panel.collapsed .panel-body, .side-panel.collapsed .panel-grip { display: none; }
.panel-head { flex: none; display: flex; align-items: center; gap: 8px; width: 100%; height: 40px; padding: 0 12px 0 14px; border-radius: 14px; text-align: left; }
.panel-head:hover { background: var(--surface-2); }
.panel-title { font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.panel-count { font-size: 12px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.panel-toggle { margin-left: auto; display: inline-grid; color: var(--muted); }
.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 8px; }
.panel-side-grip { position: absolute; top: 12px; bottom: 12px; width: 10px; cursor: ew-resize; touch-action: none; border-radius: 5px; }
.panel-side-grip.on-right { right: -5px; }
.panel-side-grip.on-left { left: -5px; }
.panel-side-grip::after { content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px; border-radius: 1px; background: transparent; }
.panel-side-grip:hover::after, body.resizing-panel .panel-side-grip:hover::after { background: var(--tool-on); }
body.resizing-panel, body.resizing-panel * { user-select: none; cursor: ew-resize !important; }
.panel-grip { flex: none; height: 14px; display: grid; place-items: center; cursor: ns-resize; touch-action: none; }
.panel-grip::after { content: ""; width: 30px; height: 3px; border-radius: 3px; background: var(--line); }
.panel-grip:hover::after { background: var(--faint); }

/* The same 12px gap below the panel as above the Neuro bar. */
#layers { left: 12px; width: var(--layers-w, 240px); max-height: calc(100vh - 124px); }
#shortcuts-btn { position: fixed; left: 12px; bottom: 12px; z-index: 19; display: flex; align-items: center; gap: 8px; width: var(--layers-w, 240px); height: 36px; padding: 0 12px; color: var(--muted); font-size: 12.5px; font-weight: 500; text-align: left; }
#shortcuts-btn:hover { color: var(--text); background: var(--surface-2); }
.shortcuts-ic { display: grid; }
#layers-list { overflow-y: auto; gap: 1px; }
.layer-row { flex: none; display: flex; align-items: center; height: 30px; padding-right: 4px; border-radius: 7px; }
.layer-row:hover { background: var(--surface-2); }
.layer-row.on { background: var(--accent-soft); }
.layer-rename { flex: 1; min-width: 0; height: 22px; padding: 0 4px; border: 1px solid var(--accent); border-radius: 5px; background: var(--surface); outline: 0; font-size: 13px; }
.layer-row.layer-dragging { opacity: .4; }
.layer-row.layer-drop-in { box-shadow: inset 0 0 0 2px var(--accent); }
.layer-line { position: fixed; z-index: 40; height: 2px; border-radius: 2px; background: var(--accent); pointer-events: none; }
.layer-twisty { flex: none; width: 18px; height: 100%; display: grid; place-items: center; color: var(--muted); border-radius: 5px; }
button.layer-twisty:hover { color: var(--text); }
.layer-twisty.closed svg { transform: rotate(-90deg); }
.layer-main { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: 8px; border-radius: 7px; text-align: left; }
.panel-extra { position: absolute; top: 9px; right: 34px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px; color: var(--muted); }
.panel-extra:hover { background: var(--surface-3); color: var(--text); }
.side-panel.collapsed .panel-extra { display: none; }
.layer-icon { flex: none; display: inline-grid; color: var(--muted); }
.layer-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.layer-hidden .layer-main { opacity: .45; }
.layer-act { flex: none; display: none; place-items: center; width: 22px; height: 22px; border-radius: 5px; color: var(--muted); }
.layer-act:hover { background: var(--surface-3); color: var(--text); }
.layer-row:hover .layer-act, .layer-act:focus-visible, .layer-act.on { display: grid; }
.layer-empty { padding: 10px 7px 4px; font-size: 13px; color: var(--muted); }

.item.is-hidden { display: none; }
.item.is-locked, .item.is-locked * { pointer-events: none !important; }

/* Runs from the top edge down to the zoom panel, with the same 12px gap at each end. */
#unsorted { top: 12px; right: 12px; width: var(--unsorted-w, 184px); max-height: calc(100vh - 72px); }
/* The same height open or closed, so the title, count and button never move. */
#unsorted .panel-head { height: 36px; }
#unsorted.drop-target { outline: 3px solid var(--accent); outline-offset: -3px; }
#quick-note { flex: none; width: 100%; resize: none; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); outline: 0; }
#quick-note:focus { border-color: var(--accent); }
#unsorted-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px; margin: 8px -2px 0; }
.un-card { position: relative; cursor: var(--cur-grab, grab); flex: none; border-radius: 10px; touch-action: none; user-select: none; }
.un-card.lifted { opacity: .35; }
.un-card.flash { outline: 3px solid var(--accent); }
.un-card .item { position: relative; pointer-events: none; }
.un-card .item.type-note, .un-card .item.type-todo, .un-card .item.type-link, .un-card .item.type-palette, .un-card .item.type-color, .un-card .item.type-image, .un-card .item.type-file, .un-card .item.type-board { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.un-card .note-body { max-height: 180px; overflow: hidden; }
.un-card .sticky-body { max-height: 160px; overflow: hidden; }
.un-del, .un-copy { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 7px; background: var(--surface); box-shadow: var(--shadow-s); display: none; place-items: center; color: var(--muted); }
.un-copy { right: 36px; }
.un-card:hover .un-del, .un-card:hover .un-copy { display: grid; }
.un-del:hover { color: var(--danger); }
.un-copy:hover { color: var(--text); }
#unsorted-list:empty { display: none; }
#unsorted-new-group { flex: none; height: 28px; margin-top: 8px; border-radius: 7px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; }
#unsorted-new-group:hover { background: var(--surface-3); color: var(--text); }
.un-group { flex: none; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.un-group.lifted { opacity: .35; }
.un-group.drop-into { outline: 2px solid var(--accent); }
.un-group-head { position: relative; display: flex; align-items: center; gap: 4px; height: 34px; padding: 0 8px 0 6px; cursor: var(--cur-grab, grab); touch-action: none; user-select: none; }
.un-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; }
.un-group-input { flex: 1; min-width: 0; height: 24px; padding: 0 6px; border: 1px solid var(--accent); border-radius: 5px; background: var(--surface); color: var(--text); font-size: 12.5px; font-weight: 600; outline: 0; }
.un-group-count { font-size: 12px; color: var(--muted); }
.un-group-head .un-del, .un-group-head .un-copy { top: 4px; }
.un-group-head:hover .un-del, .un-group-head:hover .un-copy { display: grid; }
.un-group-body { display: flex; flex-direction: column; gap: 8px; padding: 0 6px 6px; }
.un-group-empty { padding: 10px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 12.5px; text-align: center; }
#shaders { z-index: 23; left: 50%; top: 64px; transform: translateX(-50%); display: flex; flex-direction: column; width: min(830px, calc(100vw - 24px)); max-height: calc(100vh - 136px); padding: 0; overflow: hidden; }
#shaders[hidden] { display: none; }
.sh-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); cursor: var(--cur-grab, grab); touch-action: none; user-select: none; }
.sh-title { display: flex; align-items: center; gap: 8px; }
.sh-main { flex: 1; min-height: 0; display: flex; }
.sh-side { flex: none; display: flex; flex-direction: column; width: 300px; min-height: 0; }
.sh-tabs { flex: none; display: flex; gap: 2px; margin: 12px 12px 0; padding: 3px; border-radius: 9px; background: var(--surface-2); }
.sh-tab { flex: 1; height: 28px; border-radius: 7px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.sh-tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-s); }
.sh-strip { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 72px; padding: 12px 0; overflow: hidden auto; border-right: 1px solid var(--line); scrollbar-width: thin; scrollbar-gutter: stable; }
.sh-thumb { overflow: hidden; }
.sh-thumb canvas { display: block; width: 100%; height: 100%; border-radius: 8px; pointer-events: none; }
.sh-thumb { flex: none; width: 44px; height: 44px; border-radius: 8px; background: #f2f2f2 center / cover; box-shadow: inset 0 0 0 1px var(--line); }
.sh-thumb.on { box-shadow: 0 0 0 2px var(--tool-on); }
.sh-controls { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 12px; }
.sh-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; }
.sh-label { flex: none; width: 76px; font-size: 12.5px; color: var(--muted); }
.sh-slider { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 0 0 10px; border-radius: 7px; background: var(--surface-2); }
.sh-slider .vs-range { flex: 1; width: auto; min-width: 0; }
.sh-value { flex: none; width: 52px; height: 30px; padding: 0 8px; border: 0; border-left: 2px solid var(--surface); border-radius: 0 7px 7px 0; background: var(--surface-2); color: var(--text); font-size: 12.5px; font-variant-numeric: tabular-nums; outline: 0; }
.sh-value:focus { box-shadow: inset 0 0 0 1px var(--tool-on); }
.sh-colour { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 0 0 8px; border-radius: 7px; background: var(--surface-2); }
.sh-colour .sh-hex { flex: 1; width: auto; border-left: 0; text-transform: uppercase; }
.sh-swatch { flex: none; width: 16px; height: 16px; border-radius: 4px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .5); cursor: var(--cur-pointer, pointer); }
.sh-swatch input { opacity: 0; width: 16px; height: 16px; margin: 0; padding: 0; border: 0; cursor: inherit; }
.sh-row .menu-select { flex: 1; min-width: 0; height: 30px; }
.sh-row.menu-toggle .sh-label { width: auto; }
.sh-seg { flex: 1; display: flex; gap: 2px; padding: 2px; border-radius: 7px; background: var(--surface-2); }
.sh-seg-btn { flex: 1; height: 26px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); font-size: 12.5px; }
.sh-seg-btn.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-s); }
.sh-effects-head { display: flex; align-items: center; justify-content: space-between; min-height: 30px; font-size: 12.5px; font-weight: 600; }
.sh-effect { display: flex; align-items: center; gap: 2px; padding-left: 8px; border-radius: 7px; background: var(--surface-2); }
.sh-effect.off .sh-effect-name { color: var(--muted); }
.sh-effect-name { flex: 1; height: 30px; text-align: left; font-size: 12.5px; }
.sh-effect .icon-btn, .sh-eye { width: 28px; height: 28px; }
.sh-crumb { display: flex; align-items: center; justify-content: space-between; min-height: 30px; }
.sh-back { display: flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; }
.sh-back svg { transform: rotate(90deg); }
.sh-menu { position: relative; z-index: 2; display: flex; flex-direction: column; padding: 4px; border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-m), 0 0 0 1px var(--line); }
.sh-menu-up { position: absolute; bottom: calc(100% + 6px); left: 0; min-width: 190px; }
.sh-menu-row { height: 30px; padding: 0 10px; border-radius: 6px; text-align: left; font-size: 12.5px; white-space: pre; }
.sh-menu-row:hover { background: var(--surface-2); }
.sh-empty { margin: 0; color: var(--muted); font-size: 12.5px; }
.sh-actions { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px 12px; }
.sh-split { position: relative; flex: 1; display: flex; gap: 2px; }
.sh-go { flex: 1; height: 32px; padding: 0 10px; border-radius: 8px; white-space: nowrap; }
.sh-go:only-child { border-radius: 8px; }
.sh-caret { flex: none; width: 28px; height: 32px; padding: 0; display: grid; place-items: center; border-radius: 0 8px 8px 0; }
.sh-actions > .menu-choose, .sh-dots { height: 32px; }
.sh-shuffle { width: 32px; padding: 0; display: grid; place-items: center; }
.sh-dots-wrap { position: relative; }
.sh-dots-wrap .sh-menu-up { left: auto; right: 0; }
.sh-preview { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; margin: 12px 12px 12px 0; border-radius: 10px; background: #f2f2f2; overflow: hidden; }
.sh-canvas { display: block; max-width: 100%; max-height: min(460px, calc(100vh - 220px)); object-fit: contain; border-radius: 6px; }
/* Patterns repeat seamlessly, so their preview can fill the whole frame. */
.sh-preview.fill .sh-canvas { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; border-radius: 0; }
@media (max-width: 640px) {
  .sh-main { flex-direction: column; overflow-y: auto; }
  .sh-side { width: auto; border-right: 0; }
  .sh-controls { overflow: visible; }
}
.un-ghost { position: fixed; z-index: 40; pointer-events: none; transform: translate(-50%, -24px) rotate(-1.5deg); box-shadow: var(--shadow-m); opacity: .95; }

/* ---- Search ---- */
.modal { position: fixed; inset: 0; z-index: 30; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: color-mix(in srgb, #000 28%, transparent); }
.sc-card { width: min(420px, 100%); max-height: 76vh; }
.sc-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.sc-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 8px; }
.sc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 8px; }
.lr-card { width: min(560px, 100%); }
.ai-card { width: min(460px, 100%); }
/* Neuro, the assistant's pet, beside the toolbar. */
#ai-pet { position: fixed; bottom: 12px; z-index: 20; display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border-radius: 50%; }
#ai-pet[hidden] { display: none; }
#ai-pet canvas { width: 40px; height: 40px; }
#ai-pet:hover, #ai-pet.on { background: var(--surface-2); }
body.docked #ai-pet { bottom: 4px; }
.ai-form { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.ai-form .lr-input { flex: 1; }
.ai-note { margin: 0; color: var(--muted); font-size: 12.5px; }
.ai-note a { color: var(--accent); }
#assistant { bottom: 72px; z-index: 23; display: flex; flex-direction: column; width: min(440px, calc(100vw - 24px)); height: min(520px, calc(100vh - 160px)); padding: 0; overflow: hidden; }
#assistant[hidden] { display: none; }
.ai-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); }
.ai-head .sh-title { flex: 1; }
.ai-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; }
.ai-msg { max-width: 92%; padding: 8px 10px; border-radius: 10px; font-size: 13px; line-height: 1.45; }
.ai-msg.user { align-self: flex-end; background: color-mix(in srgb, var(--accent) 18%, transparent); }
.ai-msg.ai { align-self: flex-start; background: var(--surface-2); }
.ai-msg.error { color: var(--danger); }
.ai-msg.busy { color: var(--muted); }
.ai-text { white-space: pre-wrap; }
/* A new message rises into place, and Neuro's thinking dots bounce. */
.ai-msg.fresh { animation: ai-in .28s cubic-bezier(.2, .8, .3, 1.1) both; }
@keyframes ai-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.ai-thinking { display: flex; align-items: center; gap: 8px; }
.ai-dots { display: inline-flex; gap: 3px; }
.ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: ai-dot 1s ease-in-out infinite; }
.ai-dots i:nth-child(2) { animation-delay: .15s; }
.ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ai-msg.fresh, .ai-dots i { animation: none; } }
.ai-actions { display: flex; gap: 6px; margin-top: 8px; }
.ai-empty { margin: auto; text-align: center; color: var(--muted); font-size: 13px; }
.ai-empty strong { color: var(--text); }
.ai-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; }
.ai-chip { height: 28px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); color: var(--text); font-size: 12.5px; }
.ai-chip:hover { background: var(--surface-2); }
.ai-send { flex: none; display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); }
.ai-input { flex: 1; resize: none; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; outline: 0; }
.ai-input:focus { border-color: var(--accent); }
.ai-send .tray-go { height: 36px; }
.lr-rule { display: flex; flex-direction: column; gap: 8px; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.lr-rule:last-child { border-bottom: 0; }
.lr-top { display: flex; align-items: center; gap: 8px; }
.lr-site { flex: 1; font-size: 13px; }
.lr-input { flex: 1; min-width: 0; height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--text); font-size: 13px; outline: 0; }
.lr-input:focus { border-color: var(--tool-on); }
.lr-top .menu-select { width: 168px; }
.lr-parts { display: flex; flex-wrap: wrap; gap: 6px; }
.lr-part { height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 600; }
.lr-part.on { border-color: var(--tool-on); background: color-mix(in srgb, var(--tool-on) 18%, transparent); color: var(--text); }
.sc-label { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sc-ic { display: grid; flex: none; color: var(--muted); }
.sc-key { min-width: 64px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; }
.sc-key:hover { border-color: var(--tool-on); }
.sc-key.waiting { border-color: var(--tool-on); color: var(--tool-on); }
.sc-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); }
.sc-note { font-size: 12.5px; color: var(--muted); }
.sc-reset { flex: none; height: 28px; padding: 0 10px; border-radius: 7px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; }
.sc-reset:hover { background: var(--surface-3); }
.modal-card { width: min(620px, 100%); max-height: 70vh; display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-m); overflow: hidden; }
#search-input { width: 100%; padding: 16px 18px; font-size: 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; outline: 0; }
#search-results { overflow-y: auto; padding: 6px; }
.search-hint { padding: 18px 14px; color: var(--muted); }
.search-row { display: flex; gap: 12px; width: 100%; padding: 9px 12px; text-align: left; border-radius: 9px; align-items: flex-start; }
.search-row:hover, .search-row:focus { background: var(--surface-2); outline: 0; }
.search-type { color: var(--muted); margin-top: 1px; display: inline-grid; }
.search-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.search-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-snippet mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.search-where { font-size: 12.5px; color: var(--muted); }

/* ---- Menu ---- */
.pop-menu { top: 62px; left: 12px; width: 330px; padding: 6px; max-height: calc(100vh - 76px); overflow-y: auto; }
.menu-row { display: flex; gap: 11px; align-items: flex-start; width: 100%; padding: 8px 10px; text-align: left; border-radius: 8px; cursor: var(--cur-pointer, pointer); }
.menu-row:hover { background: var(--surface-2); }
.menu-ic { color: var(--muted); display: inline-grid; margin-top: 1px; }
/* Sits in line with the option switches, whose width it shares. */
.menu-action { flex: none; width: 34px; justify-items: center; margin-top: 0; }
.menu-label { flex: 1; font-weight: 500; }
.menu-label small { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); }
.menu-toggle { align-items: center; }
.menu-toggle input { appearance: none; flex: none; position: relative; width: 34px; height: 20px; margin: 0; border-radius: 10px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); cursor: var(--cur-pointer, pointer); transition: background .12s; }
.menu-toggle input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .35); transition: transform .12s; }
.menu-toggle input:checked { background: var(--tool-on); box-shadow: none; }
.menu-toggle input:checked::after { transform: translateX(14px); }
.mixer-toggle .menu-action { transition: transform .12s; }
.mixer-toggle.open .menu-action { transform: rotate(180deg); }
.mixer { display: flex; flex-direction: column; gap: 10px; margin: 0 6px 6px; padding: 10px; border-radius: 9px; background: var(--surface-2); }
.mixer[hidden] { display: none; }
.mixer-group { display: flex; flex-direction: column; gap: 4px; }
.mixer-title { font-size: 12.5px; font-weight: 600; }
.mixer-row .menu-select { flex: none; width: 118px; }
.mixer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mixer-label { flex: none; width: 58px; font-size: 12.5px; }
.mixer-row .value-slider { flex: 1; min-width: 0; }
.mixer-row .vs-range { flex: 1; width: auto; min-width: 0; }
.mixer-reset { align-self: flex-end; }
.menu-controls { flex: none; display: flex; align-items: center; gap: 8px; align-self: center; cursor: default; }
.menu-choose { flex: none; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; }
.menu-choose:hover:not(:disabled) { border-color: var(--tool-on); }
.menu-choose:disabled { opacity: .5; cursor: var(--cur-default, default); }
#snap-btn.on, #tilt-btn.on { color: var(--tool-on); }
#tilt-btn:not(.on) { color: var(--text); }
.menu-select { flex: none; height: 28px; padding: 0 4px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--text); font-size: 12.5px; }
.menu-select:disabled { opacity: .5; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-note { padding: 6px 10px 8px; font-size: 12.5px; color: var(--muted); }

/* ---- Toasts ---- */
#toasts { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 9px; box-shadow: var(--shadow-m); font-size: 13px; max-width: min(460px, 90vw); transition: opacity .25s; }
.toast.error { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .toast.error { color: #1c0d0d; }
.toast.leaving { opacity: 0; }
.fatal { position: fixed; z-index: 99; top: 16px; left: 16px; right: 16px; padding: 14px 18px; border-radius: 10px; background: var(--danger); color: #fff; }

/* Ctrl+\ leaves just the board. */
/* The docked interface: every panel meets the screen edges, with hairlines instead of gaps. */
body.docked #topbar-left, body.docked #layers, body.docked #unsorted, body.docked #zoom, body.docked #bin-btn, body.docked #shortcuts-btn { border-radius: 0; box-shadow: 0 0 0 1px var(--line); }
body.docked .panel-head { border-radius: 0; }
body.docked #topbar-left { top: 0; left: 0; }
body.docked #breadcrumbs { top: 0; left: calc(var(--layers-w, 240px) + 12px); }
body.docked #layers { top: 44px; left: 0; max-height: none; }
body.docked #layers:not(.collapsed) { height: calc(100vh - 80px) !important; }
body.docked #unsorted { top: 0; right: 0; max-height: none; }
body.docked #unsorted:not(.collapsed) { height: calc(100vh - 36px) !important; }
body.docked .side-panel .panel-grip { display: none; }
body.docked #shortcuts-btn { left: 0; bottom: 0; }
body.docked #zoom { right: 36px; bottom: 0; width: max(136px, calc(var(--unsorted-w, 184px) - 36px)); }
body.docked #bin-btn { right: 0; bottom: 0; }
body.docked #bin { right: 0; bottom: 36px; border-radius: 12px 0 0 0; }
body.docked #toolbar { bottom: 0; border-radius: 14px 14px 0 0; }
body.docked .pop-menu { top: 44px; left: 0; max-height: calc(100vh - 44px); border-radius: 0 0 12px 0; }
body.ui-hidden #shaders, body.ui-hidden #assistant, body.ui-hidden #ai-pet, body.ui-hidden #bin-btn, body.ui-hidden #bin, body.ui-hidden #shortcuts-btn, body.ui-hidden #topbar-left, body.ui-hidden #breadcrumbs, body.ui-hidden #layers, body.ui-hidden #unsorted, body.ui-hidden #toolbar, body.ui-hidden #zoom,
body.ui-hidden #selbar, body.ui-hidden #menu, body.ui-hidden #context-menu, body.ui-hidden #tool-pop, body.ui-hidden #bar-pop, body.ui-hidden #color-editor,
body.ui-hidden #stamp-wheel, body.ui-hidden #emoji-set { visibility: hidden; }

@media (max-width: 900px) {
  /* Keeps the zoom control clear of the toolbar when space runs short. */
  #zoom, #bin-btn, #shortcuts-btn { bottom: 80px; }
  body.docked #zoom, body.docked #bin-btn, body.docked #shortcuts-btn { bottom: 48px; }
}
