:root {
  --canvas-bg: #efeff1;
  --rail-bg: #ffffff;
  --rail-border: #e9e9ec;
  --ink: #2b2d31;
  --ink-soft: #8a8d94;
  --ink-faint: #b6b9c0;
  --card-bg: #ffffff;
  --card-border: #e7e7ea;
  --card-shadow: 0 1px 2px rgba(28, 30, 38, .06), 0 4px 14px rgba(28, 30, 38, .06);
  --card-shadow-hover: 0 2px 6px rgba(28, 30, 38, .10), 0 10px 28px rgba(28, 30, 38, .12);
  --accent: #2f6df0;
  --select: #2f6df0;
  --radius: 12px;
  --serif: "Fraunces", ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  /* swatch palette (icon tile background) */
  --c-slate: #565d6b;   --c-gray: #c4c7ce;  --c-teal: #15a39a;
  --c-green: #57bb6c;   --c-brown: #b07a4f; --c-yellow: #f4c542;
  --c-orange: #f5862b;  --c-red: #ef4b4b;   --c-pink: #ff1f8e;
  --c-purple: #7c4dff;  --c-blue: #4aa3ff;  --c-indigo: #3a5bd9;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--canvas-bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: var(--sans); }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 40;
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: #fff; border-bottom: 1px solid var(--rail-border);
}
.top-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
#boardTools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#crumbs { display: flex; align-items: center; gap: 6px; font-size: 14px; min-width: 0; flex: 1; overflow: hidden; }
#crumbs .crumb {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 8px; border-radius: 7px;
  color: var(--ink); background: none; border: none; max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#crumbs .crumb:hover { background: #f1f1f3; }
#crumbs .crumb.current { color: var(--ink); font-weight: 600; cursor: default; }
#crumbs .crumb.current:hover { background: none; }
#crumbs .sep { color: var(--ink-faint); }
.crumb .chip { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto; }
#title { font-family: var(--serif); font-weight: 600; font-size: 19px; letter-spacing: .2px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 13px; }
.top-right .ghost { padding: 6px 10px; border-radius: 8px; }
.top-right .ghost:hover { background: #f1f1f3; }
.top-phone {
  position: relative; border: none; background: none; color: var(--ink-soft);
  width: 36px; height: 32px; border-radius: 8px; padding: 0;
  display: grid; place-items: center;
}
.top-phone:hover, .top-phone[aria-expanded="true"] { background: #f1f1f3; color: var(--ink); }
.top-phone :is(svg, i) { width: 20px; height: 20px; display: block; }
.top-phone-badge {
  position: absolute; top: 1px; right: 0; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: #ef4b4b; color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  pointer-events: none; box-shadow: 0 0 0 2px #fff;
}
.top-phone-badge[hidden] { display: none; }
.zoomwrap { display: flex; align-items: center; gap: 2px; background: #f3f3f5; border-radius: 9px; padding: 2px; }
.zoomwrap button { border: none; background: none; width: 26px; height: 24px; border-radius: 7px; font-size: 15px; color: var(--ink); }
.zoomwrap button:hover { background: #e6e6ea; }
.zoomwrap .lvl { font-size: 12px; color: var(--ink-soft); width: 40px; text-align: center; }

/* ---------- tool rail ---------- */
#rail {
  position: fixed; top: 52px; bottom: 0; left: 0; width: 64px; z-index: 35;
  background: var(--rail-bg); border-right: 1px solid var(--rail-border);
  display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 2px; overflow-y: auto;
}
#rail::-webkit-scrollbar { display: none; }
.tool {
  width: 56px; border: none; background: none; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0; border-radius: 10px; font-size: 10px; letter-spacing: .2px;
}
.tool svg, .tool i { width: 22px; height: 22px; display: block; }
.tool i svg { width: 22px; height: 22px; }
.tool:hover { background: #f3f3f5; color: var(--ink); }
.tool.armed { background: #e9f0ff; color: var(--accent); }
.tool.armed svg { color: var(--accent); }
.rail-sep { width: 28px; height: 1px; background: var(--rail-border); margin: 8px 0; }
#railCreate, #railBoard, #railSwatch, #railCard { display: flex; flex-direction: column; align-items: center; width: 100%; gap: 2px; }
#railHistory { margin-top: auto; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 8px; border-top: 1px solid var(--rail-border); }
#railHistory .tool:disabled { opacity: .35; cursor: default; }
#railBoard[hidden], #railCreate[hidden], #railSwatch[hidden], #railCard[hidden] { display: none; }
.rail-swatch {
  width: 22px; height: 22px; border-radius: 6px; display: block;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.rail-icon { width: 22px; height: 22px; display: grid; place-items: center; color: var(--ink); }
.rail-icon svg { width: 22px; height: 22px; }
#railBoard .tool { color: var(--ink); }
#railSwatch .tool, #railCard .tool { color: #737985; }
.rail-display-glyph { width: 28px; height: 22px; border-radius: 4px; background: #e7e9ed; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #4d5665; }
#swatchEditor { position: fixed; z-index: 42; left: 70px; top: 72px; width: 244px; background: #fff; border: 1px solid #dfe1e5; box-shadow: 0 12px 32px rgba(28,30,38,.18); border-radius: 9px; padding: 14px; }
#swatchEditor[hidden] { display: none; }
.swatch-editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 14px; }
.swatch-editor-head button { border: 0; background: none; font-size: 22px; color: var(--ink-soft); }
.swatch-editor-field { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: var(--ink-soft); }
.swatch-editor-field input, .swatch-editor-field textarea { width: 100%; border: 1px solid #dfe1e5; border-radius: 5px; padding: 8px; font-size: 13px; color: var(--ink); resize: vertical; }
.swatch-editor-picker { width: 100%; height: 56px; margin-bottom: 12px; border: 0; cursor: pointer; }
.swatch-display-options { display: flex; gap: 8px; }
.swatch-display-options button { flex: 1; padding: 8px; border: 1px solid #dfe1e5; border-radius: 5px; background: #fff; }
.swatch-display-options button.active { border-color: var(--accent); background: #ebf1ff; color: var(--accent); }
.swatch-delete { width: 100%; padding: 9px; border: 1px solid #e8c8c8; border-radius: 5px; background: #fff4f4; color: #ac3131; }
.swatch-more-action { display: block; width: 100%; padding: 9px; margin-bottom: 7px; text-align: left; border: 1px solid #e2e4e8; border-radius: 5px; background: #fff; color: var(--ink); }

/* ---------- canvas / world ---------- */
#stage {
  position: fixed; top: 52px; left: 64px; right: 0; bottom: 0;
  overflow: hidden; background:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,.055) 1px, transparent 0);
  background-size: 22px 22px; background-color: var(--canvas-bg);
  cursor: default;
}
#stage.panning { cursor: grabbing; }
#stage.hand-ready, #stage.hand-ready .item, #stage.hand-ready .stroke-hit { cursor: grab !important; }
#stage.panning, #stage.panning .item, #stage.panning .stroke-hit { cursor: grabbing !important; }
#stage.armed { cursor: crosshair; }
#selectionMarquee { position: absolute; z-index: 24; border: 1px solid #2f6df0; background: rgba(47,109,240,.12); pointer-events: none; }
#selectionMarquee[hidden] { display: none; }
#multiSelectionToolbar { position: fixed; z-index: 45; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 7px 10px; background: #fff; border: 1px solid #dce0e5; box-shadow: 0 8px 30px rgba(20,25,35,.17); border-radius: 5px; color: #4d5664; font-size: 12px; }
#multiSelectionToolbar[hidden] { display: none; }
#multiSelectionToolbar button { border: 1px solid #dce0e5; background: #fff; border-radius: 4px; padding: 6px 9px; cursor: pointer; }
#stage, .item { touch-action: none; }
.item.editing { touch-action: auto; }
#world { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.drawing-layer { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; z-index: 100000; }
.stroke-hit { pointer-events: stroke; cursor: move; }
.stroke-selection { fill: rgba(38,104,216,.06); stroke: #2668d8; stroke-width: 2.5; stroke-dasharray: 6 4; pointer-events: none; }
.stroke-resize { fill: #fff; stroke: #2668d8; stroke-width: 2; pointer-events: all; cursor: nwse-resize; }
#strokeToolbar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: #fff; border: 1px solid #dce0e5; box-shadow: 0 8px 30px rgba(20,25,35,.17); border-radius: 5px; color: #4d5664; font-size: 12px; }
#strokeToolbar[hidden] { display: none; }
#strokeToolbar label { display: flex; align-items: center; gap: 5px; }
#strokeColor { width: 27px; height: 27px; border: 0; padding: 0; background: transparent; cursor: pointer; }
#strokeSize { width: 100px; accent-color: #3f63ab; }
#strokeToolbar button { border: 1px solid #dce0e5; background: #fff; border-radius: 4px; padding: 6px 9px; cursor: pointer; }
#drawInput { position: absolute; inset: 0; z-index: 20; touch-action: none; cursor: crosshair; }
#drawInput[hidden] { display: none; }
#drawInput.eraser { cursor: none; }
#drawInput.cursor { cursor: grab; }
#drawInput.select { cursor: default; }
#eraserCursor { position: fixed; pointer-events: none; z-index: 100; transform: translate(-50%, -50%); display: none; }
#eraserCursor.visible { display: block; }
#eraserCursor svg { width: 22px; height: 22px; }
body.drawing-mode #world .item { opacity: .55; }
body.drawing-mode #rail, body.drawing-mode #mfooter { pointer-events: none; opacity: .55; }
#drawingToolbar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 5px; max-width: calc(100vw - 24px); padding: 5px; background: #fff; box-shadow: 0 8px 30px rgba(20,25,35,.17); border: 1px solid #e0e2e7; border-radius: 9px; }
#drawingToolbar[hidden] { display: none; }
#drawingToolbar button { flex: 0 0 auto; min-width: 32px; height: 32px; border: 0; border-radius: 5px; background: none; color: #4d5664; display: grid; place-items: center; padding: 0 8px; }
#drawingToolbar button svg { width: 18px; height: 18px; }
#drawingToolbar button:hover:not(:disabled), #drawingToolbar button.active { background: #e9efff; color: #2b4f9f; }
#drawingToolbar button:disabled { opacity: .32; cursor: default; }
#drawingToolbar #drawSave { background: #ed5b26; color: #fff; font-weight: 700; }
#drawingToolbar #drawDiscard { border: 1px solid #c7ccd6; }
.draw-separator { height: 22px; width: 1px; background: #e3e5ea; margin: 0 3px; flex: 0 0 auto; }
.draw-color-label { width: 29px; height: 29px; display: grid; place-items: center; flex: 0 0 auto; }
#drawColor { width: 26px; height: 26px; border: 0; padding: 0; background: transparent; cursor: pointer; }

/* Size button group */
.draw-size-group { display: inline-flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.draw-size-btn {
  border: 0; background: none; color: #5d6673; width: 32px; height: 32px;
  display: grid; place-items: center; border-radius: 6px; padding: 0;
  transition: background .12s, color .12s;
}
.draw-size-btn svg { width: 18px; height: 18px; }
.draw-size-btn:hover { background: #e9efff; color: #2b4f9f; }
.draw-size-btn.active { background: #e9efff; color: #2b4f9f; }

/* Response button group */
.draw-response-group { display: inline-flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.draw-response-btn {
  border: 0; background: none; color: #5d6673; width: 44px; height: 32px;
  display: grid; place-items: center; border-radius: 6px; padding: 0;
  transition: background .12s, color .12s;
}
.draw-response-btn svg { width: 36px; height: 18px; }
.draw-response-btn:hover { background: #e9efff; color: #2b4f9f; }
.draw-response-btn.active { background: #e9efff; color: #2b4f9f; }

/* Dynamic width toggle */
.draw-pressure-label {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  width: 32px; height: 32px; justify-content: center; border-radius: 6px;
  transition: background .12s, color .12s; flex: 0 0 auto;
}
.draw-pressure-label:hover { background: #e9efff; color: #2b4f9f; }
.draw-pressure-label:has(input:checked) { background: #e9efff; color: #2b4f9f; }
.draw-pressure-label input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.draw-pressure-icon { display: grid; place-items: center; }
.draw-pressure-icon svg { width: 18px; height: 18px; }

@media (max-width: 640px) { #drawingToolbar { bottom: calc(98px + env(safe-area-inset-bottom)); gap: 2px; flex-wrap: wrap; justify-content: center; width: min(360px, calc(100vw - 16px)); } .draw-separator { margin: 0 1px; } .draw-pressure-label { font-size: 10px; } }
@media (max-width: 640px) { #strokeToolbar { bottom: calc(98px + env(safe-area-inset-bottom)); max-width: calc(100vw - 16px); gap: 5px; } #strokeSize { width: 64px; } }
@media (max-width: 640px) { #multiSelectionToolbar { bottom: calc(98px + env(safe-area-inset-bottom)); } }

/* ---------- generic card ---------- */
.item {
  position: absolute; background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 0; box-shadow: var(--card-shadow);
  transition: box-shadow .12s ease, border-color .12s ease;
  display: flex; flex-direction: column;
}
.item.dragging { box-shadow: var(--card-shadow-hover); cursor: grabbing; z-index: 9999 !important; }
.item:hover { box-shadow: var(--card-shadow-hover); }
.item.selected { border-color: #20242a; box-shadow: 0 0 0 2px #20242a, var(--card-shadow-hover); }
.item.selected.image, .item.selected.link { overflow: visible; }
.selection-corner { display: none; position: absolute; top: -5px; right: -5px; width: 8px; height: 8px; border-radius: 50%; background: #fff; border: 1px solid #d8dce2; z-index: 6; pointer-events: none; }
.item.selected .selection-corner { display: block; }

/* editable text fields are inert until the card is in edit mode, so a click
   on text starts a drag instead of stealing focus */
[data-edit] { pointer-events: none; cursor: inherit; }
textarea[data-edit] { overflow: hidden; }
.item.editing { cursor: text; }
.item.editing [data-edit] { pointer-events: auto; }
[data-nodrag] { pointer-events: auto !important; }

.resize { display: none; position: absolute; right: 0; bottom: 0; width: 20px; height: 20px; cursor: nwse-resize; z-index: 5; touch-action: none; }
.item.selected .resize { display: block; }
.resize svg { position: absolute; right: 1px; bottom: 1px; width: 15px; height: 15px; fill: none; stroke: #8c939d; stroke-width: 1.2; pointer-events: none; }
.card-extras { padding: 6px 0 0; color: #777f8a; font-size: 11px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image .card-extras { position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 6px; background: rgba(255,255,255,.9); border-radius: 0; }

/* ---------- note ---------- */
.note { padding: 14px 16px; }
.note .ntitle { font-family: var(--serif); font-weight: 600; font-size: 16px; border: none; outline: none; width: 100%; background: none; color: var(--ink); resize: none; margin-bottom: 4px; }
.note .nbody { font-size: 13.5px; line-height: 1.5; border: none; outline: none; width: 100%; background: none; color: #3c3f45; resize: none; min-height: 20px; }
.note .ntitle::placeholder, .note .nbody::placeholder { color: var(--ink-faint); }


/* ---------- todo ---------- */
.todo { padding: 14px 16px; }
.todo .ttitle { font-family: var(--serif); font-weight: 600; font-size: 15px; border: none; outline: none; width: 100%; background: none; margin-bottom: 8px; }
.todo .tasks { display: flex; flex-direction: column; gap: 2px; }
.task { display: flex; align-items: flex-start; gap: 9px; padding: 3px 0; }
.task input[type=checkbox] { appearance: none; width: 17px; height: 17px; border: 1.6px solid #cfd2d8; border-radius: 5px; margin-top: 1px; flex: 0 0 auto; cursor: pointer; position: relative; }
.task input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
.task input[type=checkbox]:checked::after { content: ""; position: absolute; left: 5px; top: 1px; width: 4px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.task .txt { border: none; outline: none; background: none; width: 100%; font-size: 13.5px; line-height: 1.4; color: #3c3f45; resize: none; }
.task.done .txt { color: var(--ink-faint); text-decoration: line-through; }
.task .del { opacity: 0; border: none; background: none; color: var(--ink-faint); font-size: 16px; line-height: 1; padding: 0 2px; }
.task:hover .del { opacity: 1; }
.todo .add { margin-top: 6px; border: none; background: none; color: var(--ink-soft); font-size: 13px; padding: 4px 0; display: inline-flex; align-items: center; gap: 6px; }
.todo .add:hover { color: var(--accent); }

/* ---------- link ---------- */
.link { padding: 0; overflow: hidden; border-radius: 0; }
.link .link-thumbnail { display: block; position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #e9eaec; }
.link .link-thumbnail img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; user-select: none; }
.link .link-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 56px; height: 40px; padding-left: 4px; border: 0; border-radius: 10px; background: rgba(24, 27, 33, .82); color: #fff; font-size: 22px; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.24); }
.link .link-play:hover { background: #e63127; }
/* Platform-specific play buttons mirroring each network's own player chrome:
   YouTube = its red rounded-rect badge; X/Twitter = the translucent dark
   circle with a white triangle used by X's inline video player. */
.link .link-play.yt { background: #f00; border-radius: 12px; }
.link .link-play.yt:hover { background: #d90000; }
.link .link-play.tw { width: 58px; height: 58px; border-radius: 50%; padding-left: 5px; background: rgba(15, 20, 25, .64); font-size: 24px; backdrop-filter: blur(2px); }
.link .link-play.tw:hover { background: rgba(15, 20, 25, .88); }
/* Instagram reel play button: the brand-gradient circle IG itself overlays on
   reel thumbnails (posts/carousels keep the ⇄ slides button instead). */
.link .link-play.ig { width: 58px; height: 58px; border-radius: 50%; padding-left: 4px; font-size: 24px; background: radial-gradient(circle at 30% 110%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285aeb 90%); }
.link .link-play.ig:hover { filter: brightness(1.12); }
/* Instagram cards show the image uncropped at its natural aspect ratio; photo
   posts show the ⇄ button (the embed is the only way to swipe a carousel),
   while reels show the gradient ▶ that opens IG's own embed player. */
.item.type-link.ig-photo .link-thumbnail { aspect-ratio: auto; background: #f1f2f4; }
.item.type-link.ig-photo .link-thumbnail img { height: auto; object-fit: contain; }
/* Pinterest pins are portrait; same natural-aspect treatment as IG so the
   full pin image shows instead of a 16:9 crop of its middle. */
.item.type-link.pin-photo .link-thumbnail { aspect-ratio: auto; background: #f1f2f4; }
.item.type-link.pin-photo .link-thumbnail img { height: auto; object-fit: contain; }
.link .link-slides { position: absolute; top: 8px; left: 8px; display: grid; place-items: center; width: 30px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: rgba(24, 27, 33, .82); color: #fff; font-size: 14px; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.link .link-slides:hover { background: #c13584; }
/* X/Twitter rich post preview toggle (top-right): swaps the thumbnail for
   X's official embed widget — real tweet text, follow button, interaction
   counts. Off by default; the plain thumbnail style stays the default. */
.link .link-tw-toggle { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: rgba(24, 27, 33, .82); cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.link .link-tw-toggle:hover { background: #0f1419; }
.link .link-tw-toggle img { width: 13px; height: 13px; filter: brightness(0) invert(1); }
.link .link-tweet { position: relative; width: 100%; height: 560px; background: #fff; border: 1px solid #e1e8ed; border-radius: 14px; overflow: hidden; }
.link .link-tweet iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.link .link-player { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #111; overflow: hidden; }
/* Absolute + inset keeps the frame inside the card even if the embed reports
   an intrinsic size; the old min-height transferred through aspect-ratio into
   a 356px min-width and leaked out of the card. */
.link .link-player iframe, .link .link-player video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.link .link-player-bar { display: none; }
/* The lightbox is detached to <body>, so it has no `.link` ancestor — list it
   explicitly or the close button renders unstyled (invisible). */
.link .link-player-close, .link-player.link-lightbox .link-player-close { position: absolute; top: 8px; left: 8px; z-index: 3; width: 26px; height: 26px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .62); color: #fff; font-size: 13px; line-height: 1; cursor: pointer; }
.link .link-player-close:hover, .link-player.link-lightbox .link-player-close:hover { background: rgba(0, 0, 0, .85); }
/* Instagram slides viewer: centered lightbox cropped to just the post media
   (IG's header/likes/comment chrome are clipped away by the JS sizing below),
   keeping IG's own slide dots and swipe arrows usable. NOTE: no `.link`
   ancestor selector — the lightbox is detached to <body> at runtime because
   position:fixed inside the transformed canvas is relative to the card. */
/* overflow:hidden clips the IG header (iframe is offset -60px so the embed's
   chrome falls outside) and its likes/comment chrome below — without it they
   "ghost" over whatever is behind the lightbox. */
.link-player.link-lightbox { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 80; width: min(480px, 92vw); overflow: hidden; border-radius: 4px; box-shadow: 0 12px 48px rgba(0, 0, 0, .4); }
.link-player.link-lightbox iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Placeholder holding the thumbnail's exact box while the lightbox is detached
   to <body> — without it the card collapses and the board layout drifts. */
.link .link-slot { background: #e9eaec; }
.link .link-info { padding: 12px 14px 15px; }
.link .link-source { display: flex; align-items: center; gap: 6px; min-width: 0; color: #9199a4; font-size: 11px; }
.link .link-provider-icon { flex: none; display: grid; place-items: center; width: 17px; height: 17px; color: #66717d; }
.link .link-provider-icon img { display: block; width: 16px; height: 16px; }
.link .link-provider-icon svg { width: 16px; height: 16px; }
.link .link-provider-name { flex: none; color: #67717f; }
.link .link-address { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #9199a4; text-decoration: none; }
.link .link-address:hover { text-decoration: underline; }
.link .link-title { margin-top: 9px; color: #c74c2b; font-size: 14px; line-height: 1.35; font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; overflow-wrap: anywhere; }
.link a.open { flex: none; color: #79828e; font-size: 10px; line-height: 1.4; text-decoration: none; }
.link a.open:hover { color: #c45230; text-decoration: underline; }
.link .link-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.link .link-label, .link .link-reactions { padding: 3px 7px; background: #f0f2f4; color: #5b6571; font-size: 11px; line-height: 1.25; }
.link .link-comment { display: flex; align-items: flex-start; gap: 5px; width: 100%; padding-top: 5px; color: #69727e; font-size: 11px; line-height: 1.4; }
.link .link-comment svg { flex: none; width: 13px; height: 13px; }
.link .link-comment span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; white-space: pre-wrap; }
.link .link-editor { display: none; padding: 14px; }
.link .link-editor input { display: block; box-sizing: border-box; width: 100%; padding: 7px 0; border: 0; outline: none; background: transparent; font: inherit; }
.link .link-editor .lurl { color: #343b45; }
.link .link-editor .ltitle { color: #7e8791; font-size: 12px; }
.link.link-empty .link-preview, .link.editing .link-preview { display: none; }
.link.link-empty .link-editor, .link.editing .link-editor { display: block; }

/* ---------- image ---------- */
.image { padding: 6px; overflow: hidden; }
.image img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; display: block; pointer-events: none; }

/* ---------- board ---------- */
.board { padding: 16px 14px 14px; align-items: center; text-align: center; cursor: pointer; }
.board .tile { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.board .tile svg { width: 28px; height: 28px; color: #fff; }
.board .btitle { font-family: var(--serif); font-weight: 600; font-size: 15px; outline: none; border: none; background: none; text-align: center; width: 100%; }
.board .bmeta { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; }
.board.drop-target { outline: 3px dashed var(--accent); outline-offset: 5px; background: rgba(47,109,240,.08); }

/* ---------- column ---------- */
.column { background: #fbfbfc; border: 1px solid var(--card-border); padding: 12px 12px 14px; }
.column .col-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.column .col-chip { width: 16px; height: 16px; border-radius: 5px; flex: 0 0 auto; }
.column .col-title { font-family: var(--serif); font-weight: 600; font-size: 15px; outline: none; border: none; background: none; width: 100%; }
.column .col-body { display: flex; flex-direction: column; gap: 10px; min-height: 48px; border-radius: 9px; padding: 2px; }
.column.drop-target .col-body { outline: 2px dashed var(--accent); outline-offset: 2px; background: rgba(47,109,240,.05); }
.column .col-empty { color: var(--ink-faint); font-size: 12.5px; text-align: center; padding: 14px 4px; border: 1.5px dashed #e1e2e6; border-radius: 9px; }
/* children laid out inside a column become static (flow) cards */
.item.in-column { position: static !important; width: 100% !important; box-shadow: none; border-color: #ececef; }
.item.in-column:hover { box-shadow: var(--card-shadow); }
.item.in-column .resize, .item.in-column .selection-corner { display: none; }

/* ---------- search ---------- */
.top-search { border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; padding: 7px; }
.top-search svg { width: 18px; height: 18px; }
#searchPanel { position: fixed; inset: 0; z-index: 10000; background: rgba(25, 29, 38, .24); display: flex; justify-content: center; align-items: flex-start; padding: min(14vh, 120px) 18px 18px; }
#searchPanel[hidden] { display: none; }

/* ---------- export ---------- */
#exportPanel {
  position: fixed; inset: 0; z-index: 100000;
  background: rgba(20, 24, 32, .5);
  display: flex; align-items: center; justify-content: center;
}
.export-dialog {
  width: min(430px, calc(100vw - 32px)); max-height: min(86vh, 720px);
  overflow: auto; background: #fff; border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,.28);
  padding: 18px 18px 14px; display: flex; flex-direction: column; gap: 14px;
}
.export-head { display: flex; align-items: center; justify-content: space-between; }
.export-head strong { font-size: 17px; }
.export-close { border: 0; background: none; color: #6a7280; cursor: pointer; display: grid; place-items: center; padding: 4px; border-radius: 6px; }
.export-close:hover { background: #f1f1f3; color: #333; }
.export-close svg { width: 18px; height: 18px; }
.export-scope { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; background: #f7f8fa; border-radius: 10px; }
.export-scope-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; font-size: 13.5px; color: #39404a; }
.export-scope-row input { accent-color: #3f63ab; }
.export-formats { display: flex; flex-direction: column; gap: 2px; }
.export-format {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px;
  border-radius: 10px; cursor: pointer; border: 1px solid transparent;
}
.export-format:hover { background: #f5f6f8; }
.export-format:has(input:checked) { background: #eef3fd; border-color: #c8d7f6; }
.export-format input { accent-color: #3f63ab; margin: 0; }
.export-format-icon { display: grid; place-items: center; color: #566072; }
.export-format-icon svg { width: 19px; height: 19px; }
.export-format-text { display: flex; flex-direction: column; gap: 1px; }
.export-format-text strong { font-size: 13.5px; font-weight: 600; color: #2c333d; }
.export-format-text small { font-size: 12px; color: #7a828e; }
.export-foot { display: flex; justify-content: flex-end; padding-top: 2px; }
.export-go {
  border: 0; background: #3f63ab; color: #fff; font-weight: 600; font-size: 14px;
  padding: 9px 22px; border-radius: 9px; cursor: pointer;
}
.export-go:hover { background: #35569a; }
.export-go:disabled { opacity: .55; cursor: default; }

.search-dialog { width: min(560px, 100%); max-height: 70vh; overflow: hidden; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--card-border); border-radius: 14px; box-shadow: 0 24px 80px rgba(0,0,0,.22); }
#searchQuery { width: 100%; border: 0; border-bottom: 1px solid var(--card-border); outline: 0; padding: 17px 18px; font: inherit; font-size: 16px; }
#searchResults { overflow: auto; padding: 10px; color: var(--ink-soft); font-size: 13px; }
.search-result { width: 100%; border: 0; background: none; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; padding: 10px; border-radius: 8px; cursor: pointer; color: var(--ink); }
.search-result:hover, .search-result:focus { background: #f1f3f8; }
.search-result strong { font-weight: 600; }


#sketchOverlay {
  position: fixed; inset: 0; z-index: 100000;
  background: rgba(20, 24, 32, .55);
  display: flex; align-items: center; justify-content: center;
}
.sketch-canvas {
  position: absolute; background: #fff; box-shadow: 0 18px 60px rgba(10,14,20,.35);
  cursor: crosshair; touch-action: none;
}
.sketch-canvas.erasing { cursor: cell; }
.sketch-canvas svg { display: block; pointer-events: none; }
.sketch-toolbar {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 5px; padding: 5px;
  background: #fff; border: 1px solid #e0e2e7; border-radius: 9px;
  box-shadow: 0 8px 30px rgba(20,25,35,.17); z-index: 100001;
  max-width: calc(100vw - 24px);
}
.sketch-btn {
  border: 0; background: none; color: #5d6673; width: 32px; height: 32px;
  display: grid; place-items: center; border-radius: 6px; cursor: pointer; padding: 0;
  transition: background .12s, color .12s; flex: 0 0 auto;
}
.sketch-btn i { display: inline-block; width: 16px; height: 16px; }
.sketch-btn svg { width: 16px; height: 16px; }
.sketch-btn:hover { background: #e9efff; color: #2b4f9f; }
.sketch-btn.active { background: #e9efff; color: #2b4f9f; }
.sketch-btn:disabled { opacity: .4; cursor: default; }
.sketch-btn:disabled:hover { background: none; color: #5d6673; }
.sketch-btn svg { width: 16px; height: 16px; }
.sketch-dot { display: block; border-radius: 50%; background: currentColor; }
.sketch-color-wrap {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 6px; cursor: pointer; flex: none;
}
.sketch-color-wrap:hover { background: #e9efff; }
.sketch-color-wrap input { width: 20px; height: 20px; border: 0; padding: 0; background: none; cursor: pointer; }
.sketch-cancel, .sketch-save {
  border: 1px solid #dce0e5; background: #fff; color: #3d4550; height: 30px;
  padding: 0 14px; border-radius: 6px; cursor: pointer; font-size: 12.5px; font-family: var(--sans);
  margin-left: 4px;
}
.sketch-cancel:hover { background: #f1f2f4; }
.sketch-save { background: #3f63ab; border-color: #3f63ab; color: #fff; }
.sketch-save:hover:not(:disabled) { background: #33528f; }
.sketch-save:disabled { opacity: .45; cursor: default; }

/* ---------- comment thread ---------- */
/* The comment card is just the circular avatar pin: no card box behind it.
   The element keeps its square hit area for dragging; the visuals are the
   circle only, and selection draws a circular ring. */
.item.type-comment {
  overflow: visible; min-height: 52px; border-radius: 50%;
  background: none; border-color: transparent; box-shadow: none;
}
.item.type-comment:hover { box-shadow: none; }
.item.type-comment.selected {
  border-color: transparent;
  box-shadow: 0 0 0 2px #20242a, 0 4px 14px rgba(20,25,35,.14);
}
.item.type-comment.dragging { box-shadow: 0 6px 18px rgba(20,25,35,.2); }
.item.type-comment:has(.ctp:not([hidden])) { z-index: 900 !important; }
.item.type-comment:hover { z-index: 400 !important; }
.cthread { position: relative; width: 100%; height: 100%; }
.cthread-pin {
  width: 100%; height: 100%; min-height: 50px; border: 0; background: none;
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.cthread-avatar {
  width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  background: #fff; border: 2px solid currentColor;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  color: inherit; box-shadow: 0 2px 6px rgba(20,25,35,.12);
  transition: transform .12s ease, box-shadow .12s ease;
}
.cthread-pin:hover .cthread-avatar { transform: scale(1.08); box-shadow: 0 3px 10px rgba(20,25,35,.18); }
.cthread-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cthread-avatar.small { width: 24px; height: 24px; font-size: 9.5px; border-width: 1px; box-shadow: none; }
.cthread-count {
  position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 999px; border: 2px solid #fff;
  background: var(--ink, #26292f); color: #fff;
  font-size: 9px; font-weight: 700; line-height: 12px; text-align: center;
  box-shadow: 0 1px 3px rgba(20,25,35,.2);
}
.cthread-check {
  position: absolute; bottom: 6px; left: 6px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--c-green, #16a34a); color: #fff;
  display: grid; place-items: center; border: 2px solid #fff;
}
.cthread-check svg { width: 8px; height: 8px; }
.item.type-comment .resize { display: none !important; }

.ctp {
  position: absolute; left: calc(100% + 12px); top: -8px; width: 340px; max-width: calc(100vw - 40px);
  display: flex; flex-direction: column;
  background: var(--card-bg, #fff); border: 1px solid var(--card-border);
  border-radius: 10px; box-shadow: var(--card-shadow-hover);
  font-family: var(--sans); z-index: 460; overflow: hidden;
}
.ctp[hidden] { display: none !important; }
.ctp-head {
  display: flex; align-items: center; gap: 7px; padding: 8px 10px;
  border-bottom: 1px solid #ececef; flex: none;
}
.ctp-resolve-label { font-size: 11.5px; color: #5d6673; white-space: nowrap; }
.ctp-switch {
  position: relative; flex: none; width: 28px; height: 16px; border-radius: 999px;
  border: 0; background: #c6ccd4; cursor: pointer; padding: 0; transition: background .12s;
}
.ctp-switch.on { background: var(--c-green, #16a34a); }
.ctp-switch:disabled { opacity: .45; cursor: default; }
.ctp-switch span {
  position: absolute; top: 2px; left: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: #fff; transition: left .12s;
}
.ctp-switch.on span { left: 14px; }
.ctp-colors { display: flex; align-items: center; gap: 4px; margin-left: 2px; }
.ctp-dot {
  width: 13px; height: 13px; border-radius: 50%; border: 1px solid rgba(255,255,255,.9);
  outline: 0; cursor: pointer; padding: 0; transition: outline .08s;
}
.ctp-dot.active { outline: 2px solid #8c939d; outline-offset: 1px; }
.ctp-dot:disabled { opacity: .5; cursor: default; }
.ctp-iconbtn {
  border: 0; background: none; color: #5d6673; width: 26px; height: 26px;
  display: grid; place-items: center; border-radius: 6px; cursor: pointer; padding: 0;
}
.ctp-iconbtn:hover { background: #f1f2f4; color: var(--ink, #26292f); }
.ctp-iconbtn:disabled { opacity: .45; cursor: default; }
.ctp-iconbtn svg { width: 15px; height: 15px; }
.ctp-iconbtn.small { width: 22px; height: 22px; }
.ctp-iconbtn.small svg { width: 13px; height: 13px; }
.ctp-more-wrap { position: relative; margin-left: auto; }
.ctp-menu {
  position: absolute; right: 0; top: 30px; width: 170px; padding: 4px; z-index: 5;
  background: var(--card-bg, #fff); border: 1px solid var(--card-border);
  border-radius: 8px; box-shadow: var(--card-shadow-hover);
}
.ctp-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px;
  border: 0; background: none; border-radius: 5px; cursor: pointer;
  font-size: 12.5px; color: var(--ink, #26292f); text-align: left; font-family: var(--sans);
}
.ctp-menu button:hover { background: #f1f2f4; }
.ctp-menu button.danger { color: #b3402e; }
.ctp-menu button.danger:hover { background: #fbeeec; }
.ctp-menu button:disabled { opacity: .45; cursor: default; }
.ctp-menu svg { width: 14px; height: 14px; }

.ctp-list { min-height: 0; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.ctp-empty { display: flex; align-items: center; justify-content: center; gap: 7px; color: #9aa1ab; font-size: 12.5px; min-height: 110px; }
.ctp-empty svg { width: 15px; height: 15px; }
.ctp-comment { border-bottom: 1px solid #ececef; padding-bottom: 10px; }
.ctp-comment:last-child { border-bottom: 0; padding-bottom: 2px; }
.ctp-meta { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; font-size: 11px; }
.ctp-meta strong { color: var(--ink, #26292f); font-size: 11.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctp-meta .cthread-avatar { flex: none; }
.ctp-time { color: #9aa1ab; flex: none; margin-left: auto; }
.ctp-cdel {
  border: 0; background: none; color: #9aa1ab; width: 20px; height: 20px; flex: none;
  display: grid; place-items: center; border-radius: 5px; cursor: pointer; padding: 0;
  opacity: 0; transition: opacity .1s, background .1s, color .1s;
}
.ctp-comment:hover .ctp-cdel, .ctp-cdel:focus-visible { opacity: 1; }
.ctp-cdel:hover { background: #fbeeec; color: #b3402e; }
.ctp-cdel svg { width: 12px; height: 12px; }
.ctp-comment p { margin: 0; font-size: 13px; line-height: 1.45; color: #3c3f45; overflow-wrap: anywhere; white-space: pre-wrap; }
.ctp-audio { margin-top: 6px; }
.ctp-audio audio { width: 100%; max-width: 280px; height: 32px; }
.ctp-audio-loading { font-size: 11px; color: #9aa1ab; }
.ctp-audio-error { color: #b3402e; }
.ctp-reactions { display: flex; align-items: center; gap: 4px; margin-top: 6px; position: relative; flex-wrap: wrap; }
.ctp-chip {
  border: 0; background: #f1f2f4; color: #5d6673; border-radius: 999px;
  padding: 2px 8px; font-size: 11px; cursor: pointer; line-height: 1.5;
}
.ctp-chip:hover { background: #e6e8ec; }
.ctp-chip.mine { background: #f5e9dd; color: #a05a20; }
.ctp-chip:disabled { opacity: .5; cursor: default; }
.ctp-picker {
  position: absolute; bottom: calc(100% + 6px); right: 0; z-index: 6;
  display: flex; gap: 2px; padding: 5px; border-radius: 8px;
  background: var(--card-bg, #fff); border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow-hover);
}
.ctp-picker[hidden] { display: none; }
.ctp-picker button { border: 0; background: none; font-size: 16px; cursor: pointer; padding: 2px 3px; border-radius: 4px; line-height: 1; }
.ctp-picker button:hover { background: #f1f2f4; }

.ctp-compose {
  display: flex; align-items: center; gap: 2px; min-height: 46px; flex: none;
  border-top: 1px solid #ececef; padding: 6px 8px;
}
.ctp-input {
  flex: 1; min-width: 0; border: 0; outline: none; background: none;
  font-family: var(--sans); font-size: 13px; color: var(--ink, #26292f);
}
.ctp-input::placeholder { color: var(--ink-faint, #a7adb6); }
.ctp-input:disabled { cursor: default; }
.ctp-profile {
  position: relative; width: 30px; height: 30px; flex: none; border: 0; padding: 0;
  background: none; cursor: pointer; border-radius: 50%;
}
.ctp-profile .cthread-avatar { width: 26px; height: 26px; font-size: 10px; border-width: 1.5px; color: #9aa1ab; }
.ctp-profile:hover .cthread-avatar { transform: scale(1.06); }
.ctp-profile-plus {
  position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--ink, #26292f); color: #fff;
  display: grid; place-items: center; border: 1.5px solid #fff;
}
.ctp-profile-plus svg { width: 7px; height: 7px; }
.ctp-emoji-wrap { position: relative; flex: none; }
.ctp-emoji-wrap .ctp-picker { bottom: calc(100% + 8px); }
.ctp-mic {
  border: 0; background: none; color: #5d6673; width: 28px; height: 28px;
  display: grid; place-items: center; border-radius: 50%; cursor: pointer; padding: 0; flex: none;
}
.ctp-mic:hover { background: #f1f2f4; color: var(--ink, #26292f); }
.ctp-mic:disabled { opacity: .45; cursor: default; }
.ctp-mic svg { width: 15px; height: 15px; }
.ctp-mic.recording { background: #fbeeec; color: #b3402e; }
.ctp-mic-status { font-size: 10.5px; color: #b3402e; flex: none; max-width: 90px; padding-right: 2px; }
.ctp-send {
  border: 0; background: none; color: #b9bfc8; width: 28px; height: 28px;
  display: grid; place-items: center; border-radius: 50%; cursor: pointer; padding: 0; flex: none;
}
.ctp-send:not(:disabled) { color: #c47a3a; }
.ctp-send:not(:disabled):hover { background: #f5e9dd; }
.ctp-send:disabled { cursor: default; }
.ctp-send svg { width: 15px; height: 15px; }

@media (max-width: 640px) {
  .ctp { position: fixed; left: 50% !important; top: auto !important; bottom: calc(98px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(340px, calc(100vw - 16px)); max-height: 60vh; }
}

/* ---------- file ---------- */
.file { padding: 0; gap: 0; overflow: hidden; min-width: 300px; }
.file audio, .file video { width: 100%; max-height: 220px; border-radius: 8px; margin: 10px 10px 0; }
.file .fpreview {
  width: 100%; height: 260px; background: #fff; position: relative;
  display: grid; place-items: center; border-bottom: 1px solid var(--card-border);
}
.file .fpreview.pdf embed { width: 100%; height: 100%; display: block; border: 0; }
.file .fpreview.pdf { cursor: pointer; flex: 1 1 auto; height: auto; min-height: 260px; }
.file .fpreview.pdf canvas.pdf-page {
  /* Absolutely positioned: as an in-flow grid item, percentage height
     resolves against the content-sized row, overflowing the 260px box
     and covering the card footer. Absolute + inset makes it fill the box. */
  position: absolute; inset: 0; margin: auto;
  width: 100%; height: 100%; display: block; object-fit: contain;
  background: #fff; pointer-events: none;
}
.file .fpreview.pdf canvas.pdf-page:not([data-rendered]) { opacity: 0; }
.file .fpreview.pdf canvas.pdf-page[data-rendered="1"] { opacity: 1; transition: opacity .15s ease; }
/* DOCX: mammoth.js HTML preview fills the card above the footer and scrolls. */
.file .fpreview.docx {
  cursor: pointer; flex: 1 1 auto; height: auto; min-height: 260px;
  display: block; overflow-y: auto; text-align: left;
}
.file .fpreview.docx .docx-page {
  padding: 16px 18px; background: #fff; color: #23272e;
  font: 400 9.5px/1.55 Georgia, 'Times New Roman', serif;
  word-wrap: break-word;
}
.file .fpreview.docx .docx-page p { margin: 0 0 7px; }
.file .fpreview.docx .docx-page h1 { font-size: 14px; font-weight: 700; margin: 8px 0 5px; }
.file .fpreview.docx .docx-page h2 { font-size: 12px; font-weight: 700; margin: 7px 0 4px; }
.file .fpreview.docx .docx-page h3,
.file .fpreview.docx .docx-page h4,
.file .fpreview.docx .docx-page h5,
.file .fpreview.docx .docx-page h6 { font-size: 10.5px; font-weight: 700; margin: 6px 0 4px; }
.file .fpreview.docx .docx-page ul,
.file .fpreview.docx .docx-page ol { margin: 0 0 7px; padding-left: 18px; }
.file .fpreview.docx .docx-page img { max-width: 100%; height: auto; }
.file .fpreview.docx .docx-page table { border-collapse: collapse; margin: 0 0 7px; }
.file .fpreview.docx .docx-page td,
.file .fpreview.docx .docx-page th { border: 1px solid #c9cdd4; padding: 2px 5px; font-size: 9px; }
.file .fpreview.docx .docx-page a { color: #2a609d; }
.file .fbadge {
  display: inline-grid; place-items: center; color: #fff;
  font: 700 10px Figtree, sans-serif; letter-spacing: .02em;
  border-radius: 4px; padding: 3px 5px; line-height: 1;
}
.file .fbadge.big { font-size: 15px; padding: 9px 12px; border-radius: 8px; }
.file .ffoot {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; min-width: 0;
}
.file .fname {
  font: 600 13px Figtree, sans-serif; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0;
}
.file .factions { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.file .flink { font: 12px Figtree, sans-serif; color: var(--accent); text-decoration: underline; cursor: pointer; }
.file .fsep { color: var(--ink-soft); font-size: 12px; }
.file .fsize { font: 12px Figtree, sans-serif; color: var(--ink-soft); padding: 0 12px 9px; }
.fileinfo-row { display: flex; justify-content: space-between; gap: 12px; font: 13px Figtree, sans-serif; color: var(--ink); padding: 3px 0; }
.fileinfo-row span:first-child { color: var(--ink-soft); flex: 0 0 auto; }
.fileinfo-row span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fileinfo-actions { display: flex; gap: 8px; margin-top: 6px; }
.fileinfo-link { text-decoration: underline; color: var(--accent); cursor: pointer; }
.fileinfo-link:hover { opacity: .8; }
.file:has(.fpreview.pdf) { padding: 0; }
.file .fname {
  font-weight: 600; font-size: 13.5px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%;
}
.file audio, .file video { width: 100%; max-height: 220px; border-radius: 8px; }

/* ---------- documents and color swatches ---------- */
.document { padding: 16px; min-height: 180px; gap: 9px; }
.document > svg { width: 21px; height: 21px; color: var(--ink-soft); }
.document .doc-title { font-family: var(--serif); font-size: 17px; font-weight: 600; border: 0; outline: 0; background: none; width: 100%; }
.document .doc-body { font: inherit; font-size: 13.5px; line-height: 1.5; border: 0; outline: 0; background: none; resize: none; min-height: 110px; width: 100%; }
.swatch-card { padding: 0; border-radius: 0; overflow: visible; min-height: 150px; }
.swatch-card .swatch-color-panel { width: 100%; min-height: 94px; flex: 1; display: flex; align-items: flex-start; padding: 18px 22px; }
.swatch-card .swatch-value { font: 700 14px var(--sans); }
.swatch-card .swatch-caption { height: 56px; width: 100%; padding: 0 22px; border: 0; outline: 0; background: #fff; color: #6c7480; font-size: 12px; }
.swatch-card .swatch-caption::placeholder { color: #a6aab2; }
.swatch-card .swatch-meta { padding: 0 22px 11px; color: #7d8491; font-size: 11px; background: #fff; overflow: hidden; text-overflow: ellipsis; }
.swatch-card.selected { border-color: #252a33; box-shadow: 0 0 0 2px #252a33; }

.item.locked { cursor: default; }
.lock-badge { display: grid; place-items: center; color: #d6d8de; width: 28px; height: 28px; }
.lock-badge svg { width: 14px; height: 14px; }
.lock-badge.board-lock {
  position: absolute; top: 8px; right: 8px; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 8px; background: #2b2d31; color: #d6d8de;
}

/* ---------- board tile lucide ---------- */
.board .tile svg { width: 28px; height: 28px; color: #fff; stroke-width: 1.75; }

/* ---------- color + icon popover ---------- */
#palette {
  position: fixed; z-index: 60; background: #fff; border: 1px solid var(--rail-border);
  border-radius: 12px; box-shadow: var(--card-shadow-hover); padding: 12px; display: none;
  grid-template-columns: repeat(6, 1fr); gap: 8px; width: 196px;
}
#palette.open { display: grid; }
#palette.board-palette { width: 268px; grid-template-columns: repeat(6, 1fr); }
#palette.icon-only { width: 268px; }
#palette.icon-only .icon-grid { margin: 0; }
#palette .sw { width: 24px; height: 24px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
#palette .sw:hover { transform: scale(1.08); }
#palette .sw.sel { border-color: #2b2d31; }
#palette .pal-sep {
  grid-column: 1 / -1; height: 1px; background: var(--rail-border); margin: 4px 0;
}
#palette .icon-grid {
  grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
}
#palette .icon-pick {
  width: 36px; height: 36px; border: 1px solid transparent; border-radius: 8px;
  background: #f6f6f8; color: var(--ink); display: grid; place-items: center; padding: 0;
}
#palette .icon-pick:hover { background: #ececf0; }
#palette .icon-pick.sel { border-color: var(--accent); background: #e9f0ff; color: var(--accent); }
#palette .icon-pick svg { width: 18px; height: 18px; }

/* ---------- context menu ---------- */
#ctxmenu {
  position: fixed; z-index: 70; min-width: 210px; display: none;
  background: #fff; border: 1px solid var(--rail-border); border-radius: 10px;
  box-shadow: var(--card-shadow-hover); padding: 6px; color: var(--ink);
}
#ctxmenu.open { display: block; }
#ctxmenu .ctx-item {
  width: 100%; border: none; background: none; display: flex; align-items: center;
  justify-content: space-between; gap: 18px; padding: 8px 10px; border-radius: 7px;
  font-size: 13px; color: var(--ink); text-align: left;
}
#ctxmenu .ctx-item:hover:not(:disabled) { background: #f3f3f5; }
#ctxmenu .ctx-item:disabled { opacity: .4; cursor: default; }
#ctxmenu .ctx-item.danger { color: #c0392b; }
#ctxmenu .ctx-item kbd { font-family: var(--sans); font-size: 11px; color: var(--ink-faint); }
#ctxmenu .ctx-sep { height: 1px; background: var(--rail-border); margin: 4px 6px; }

/* hidden file inputs */
#fileInput, #uploadInput { display: none; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #2b2d31; color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 80; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

/* ---------- mobile chrome (header + footer, Milanote style) ---------- */
/* Hidden on desktop; the media query below turns them on and hides the
   desktop top bar + tool rail instead. */
#mheader, #mfooter, #msheet, #mBoardSheet { display: none; }
#hint .hint-mobile { display: none; }

@media (max-width: 768px) {
  /* Pin the document itself so iOS can't rubber-band / page-zoom the chrome
     away from the screen edges. Scrollable regions opt back into pan below. */
  html, body {
    position: fixed; inset: 0; width: 100%; height: 100%; height: 100dvh;
    overflow: hidden; overscroll-behavior: none; touch-action: none;
  }
  .qn-scroll, .qn-chips, textarea, input { touch-action: pan-y; }
  .mf-tools { touch-action: pan-x; }

  #topbar, #rail { display: none; }
  #stage { top: 0; left: 0; right: 0; bottom: 0; touch-action: none; }
  #hint .hint-desktop { display: none; }
  #hint .hint-mobile { display: block; }
  .toast { bottom: calc(104px + env(safe-area-inset-bottom)); }

  /* header: back chevron / serif board title / share bubble */
  #mheader:not([hidden]) {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    display: flex; align-items: center; gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
    background: #fff; border-bottom: 1px solid var(--rail-border);
    touch-action: none;
  }
  .mh-btn {
    border: none; background: none; color: var(--ink); flex: 0 0 auto;
    width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; padding: 0;
  }
  .mh-btn svg { width: 26px; height: 26px; }
  .mh-round { background: #f1f1f3; border-radius: 50%; }
  .mh-round svg { width: 21px; height: 21px; }
  #mTitle {
    flex: 1; min-width: 0; margin: 0; text-align: center;
    font-family: var(--serif); font-weight: 600; font-size: 22px; letter-spacing: .2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #37414f;
  }

  /* footer: glued to the screen bottom — never part of the canvas zoom. */
  #mfooter {
    position: fixed; left: 0; right: 0; bottom: 0; width: 100%;
    z-index: 100;
    display: block; background: #fff; border-top: 1px solid var(--rail-border);
    padding-bottom: env(safe-area-inset-bottom);
    touch-action: none;
  }
  .mf-row { display: flex; align-items: center; min-height: 86px; padding: 0 10px; gap: 6px; }
  .mf-row[hidden] { display: none; }
  #mfNav { justify-content: space-between; }
  .mf-icon {
    border: none; background: none; color: var(--ink); flex: 0 0 auto;
    width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; padding: 0;
  }
  .mf-icon svg { width: 26px; height: 26px; }
  .mf-tabs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; }
  .mf-tab {
    border: none; background: none; color: var(--ink-soft); white-space: nowrap;
    font-size: 16px; font-weight: 600; padding: 11px 14px; border-radius: 12px;
  }
  .mf-tab.active { background: #f1f1f3; color: var(--ink); }

  /* swap-in tool tray: white icon tiles with labels, scrolls sideways */
  .mf-tools {
    display: flex; align-items: flex-start; gap: 2px; flex: 1; min-width: 0;
    overflow-x: auto; padding: 12px 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .mf-tools::-webkit-scrollbar { display: none; }
  .mtool {
    border: none; background: none; color: var(--ink); flex: 0 0 auto; width: 66px;
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    font-size: 13px; padding: 0;
  }
  .mtool svg, .mtool i {
    width: 46px; height: 46px; padding: 11px; display: block; box-sizing: border-box;
    background: #fff; border: 1px solid #d9dade; border-radius: 10px;
    box-shadow: 0 1px 2px rgba(28, 30, 38, .05); color: var(--ink);
  }
  .mtool.armed { color: var(--accent); }
  .mtool.armed svg { background: #5b7cfa; border-color: #5b7cfa; color: #fff; }

  /* Board selection footer: Color · Icon · Rename · More | Done */
  #mfBoard, #mfCard {
    display: flex; align-items: center; gap: 8px;
    min-height: 86px; padding: 8px 12px; justify-content: space-between;
  }
  #mfBoard[hidden], #mfCard[hidden], #mfCard [hidden] { display: none; }
  #swatchEditor { left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); width: min(320px, calc(100vw - 24px)); z-index: 102; }
  .mf-board-actions {
    display: flex; align-items: stretch; gap: 4px; min-width: 0; flex: 1;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .mf-board-actions::-webkit-scrollbar { display: none; }
  .mf-bact {
    border: none; background: none; color: var(--ink); flex: 0 0 auto; width: 68px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; padding: 0;
  }
  .mf-bact-swatch, .mf-bact-icon, .mf-bact-glyph {
    width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
    background: #f1f1f3; border: 1px solid #e4e5e9; box-sizing: border-box;
  }
  .mf-bact-swatch { border: none; }
  .mf-bact-icon svg, .mf-bact-glyph svg, .mf-bact-glyph i { width: 22px; height: 22px; color: var(--ink); }
  .mf-done {
    border: none; background: none; color: #e85d04; font-size: 17px; font-weight: 700;
    padding: 10px 8px; flex: 0 0 auto;
  }

  #mBoardSheet:not([hidden]) {
    position: fixed; z-index: 101; left: 12px;
    bottom: calc(98px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; min-width: 180px;
    background: #fff; border: 1px solid var(--rail-border); border-radius: 14px;
    box-shadow: var(--card-shadow-hover); padding: 6px;
  }
  #mBoardSheet button {
    border: none; background: none; text-align: left; color: var(--ink);
    font-size: 15px; padding: 11px 12px; border-radius: 9px;
  }
  #mBoardSheet button.danger { color: #c0392b; }
  #mBoardSheet button:hover, #mBoardSheet button:active { background: #f1f1f3; }

  /* Quick notes takes over the whole viewport, canvas chrome included */
  #quicknotes:not([hidden]) { display: block; }

  /* ••• action sheet */
  #msheet:not([hidden]) {
    position: fixed; z-index: 101; left: 12px;
    bottom: calc(98px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; min-width: 180px;
    background: #fff; border: 1px solid var(--rail-border); border-radius: 14px;
    box-shadow: var(--card-shadow-hover); padding: 6px;
  }
  #msheet button {
    border: none; background: none; text-align: left; color: var(--ink);
    font-size: 15px; padding: 11px 12px; border-radius: 9px;
  }
  #msheet button:hover, #msheet button:active { background: #f1f1f3; }
}

/* =========================================================================
   Quick notes — task workspace (overview → list → task + search).

   Its own design tokens: a lighter, Reminders-style palette. Mobile: fullscreen
   inside the media query above. Desktop: phone-sized popover under #phoneNotes
   when body.qn-desk is set.
   ========================================================================= */
#quicknotes {
  display: none;
  position: fixed; inset: 0; z-index: 120;
  background: var(--qn-screen);
  font-family: var(--sans);

  --qn-screen: #EDEFF1;
  --qn-surface: #ffffff;
  --qn-shadow: 0 1px 2px rgba(15, 23, 42, .05);
  --qn-ink: #273142;
  --qn-head: #1E2530;
  --qn-soft: #5A6575;
  --qn-muted: #8A94A3;
  --qn-faint: #9AA4B2;
  --qn-accent: #3D4A5C;
  --qn-hair: #EEF0F3;
  --qn-bar-hair: #E4E7EB;
  --qn-star: #E8B94A;
  --qn-star-off: #B4BCC7;
  --qn-due: #C2410C;
  --qn-sheet: #F4F5F7;
  --qn-grab: #C9D0D9;
  --qn-serif: "Source Serif 4", Georgia, serif;
  --qn-ease: cubic-bezier(.32, .72, .28, 1);
}
.qn-deskhead { display: none; }
/* :where() keeps the reset at zero specificity so the component classes below
   (and their padding/background) still win */
:where(#quicknotes) button { border: none; background: none; padding: 0; color: inherit; font-family: inherit; }
:where(#quicknotes) input, :where(#quicknotes) textarea { font-family: inherit; }
/* icons are <i data-lucide> until the CDN swaps in an <svg>; size both so the
   layout and the tap targets survive a CDN that never answers */
#quicknotes i[data-lucide] { display: block; }

.qn-screen {
  position: absolute; inset: 0; background: var(--qn-screen);
  display: flex; flex-direction: column;
  padding-top: calc(12px + env(safe-area-inset-top));
  transition: transform .38s var(--qn-ease);
}
#qnHome { z-index: 1; }
#qnList { z-index: 2; transform: translateX(100%); }
#qnTask { z-index: 3; transform: translateX(100%); }
#qnSearch { z-index: 4; transform: translateY(100%); }

.qn-scroll {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; display: flex; flex-direction: column; gap: 16px;
  padding: 14px 20px 40px;
}
.qn-scroll::-webkit-scrollbar { display: none; }
.qn-home-scroll { padding-bottom: 120px; }
.qn-list-scroll { gap: 14px; padding-bottom: 130px; }
.qn-task-scroll { padding-bottom: 90px; }

/* ---------- shared bits ---------- */
.qn-card { background: var(--qn-surface); border-radius: 18px; box-shadow: var(--qn-shadow); }
.qn-circle {
  border-radius: 999px; display: grid; place-items: center; flex: 0 0 auto; color: #fff;
}
.qn-circle :is(svg, i) { width: 16px; height: 16px; stroke-width: 2; }
.qn-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.qn-chips[hidden] { display: none; }
.qn-chip {
  background: var(--qn-surface); color: var(--qn-soft); border-radius: 999px;
  padding: 7px 14px; font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s;
}
.qn-chip.on { background: var(--qn-accent); color: #fff; }
.qn-chips-scroll {
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  padding: 14px 20px 0; flex: 0 0 auto;
}
.qn-chips-scroll::-webkit-scrollbar { display: none; }
.qn-chips-scroll .qn-chip { flex: 0 0 auto; }
.qn-tag { background: var(--qn-hair); color: var(--qn-soft); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.qn-empty { padding: 22px 18px; text-align: center; color: var(--qn-muted); font-size: 14px; line-height: 1.5; }

/* checkbox + star, shared by every task row */
.qn-box {
  width: 22px; height: 22px; border: 2px solid #64748B; border-radius: 7px;
  display: grid; place-items: center; flex: 0 0 auto;
  transition: background .15s, border-color .15s;
}
.qn-box :is(svg, i) { width: 13px; height: 13px; color: #fff; stroke-width: 3.5; opacity: 0; transition: opacity .15s; }
.qn-box.on { background: var(--qn-accent); border-color: var(--qn-accent); }
.qn-box.on :is(svg, i) { opacity: 1; }
.qn-box-lg { width: 24px; height: 24px; border-radius: 8px; margin-top: 5px; }
.qn-box-lg :is(svg, i) { width: 14px; height: 14px; }
.qn-star { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto; }
.qn-star :is(svg, i) { width: 20px; height: 20px; color: var(--qn-star-off); stroke-width: 1.8; }
.qn-star.on :is(svg, i) { color: var(--qn-star); fill: var(--qn-star); }
.qn-star-lg { width: 32px; height: 32px; margin-top: 5px; }
.qn-star-lg :is(svg, i) { width: 24px; height: 24px; stroke-width: 1.6; }
.qn-x { width: 24px; height: 24px; display: grid; place-items: center; flex: 0 0 auto; }
.qn-x :is(svg, i) { width: 16px; height: 16px; color: var(--qn-faint); stroke-width: 2.2; }
/* the small glyph buttons keep their drawn size but take a 44px tap area */
.qn-box, .qn-star, .qn-x { position: relative; }
.qn-box::after, .qn-star::after, .qn-x::after { content: ""; position: absolute; inset: -10px; }

/* ---------- overview ---------- */
.qn-titlerow { display: flex; align-items: center; gap: 10px; }
.qn-title { flex: 1; margin: 0; font-family: var(--qn-serif); font-size: 34px; font-weight: 700; color: var(--qn-head); }
.qn-round {
  width: 38px; height: 38px; background: var(--qn-surface); border-radius: 999px;
  display: grid; place-items: center; flex: 0 0 auto; box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}
.qn-round :is(svg, i) { width: 18px; height: 18px; color: var(--qn-accent); stroke-width: 2.2; }

.qn-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.qn-tiles[hidden] { display: none; }
.qn-tile {
  background: var(--qn-surface); border-radius: 18px; box-shadow: var(--qn-shadow);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; text-align: left;
}
.qn-tile-top { display: flex; align-items: flex-start; justify-content: space-between; }
.qn-tile .qn-circle { width: 32px; height: 32px; }
.qn-tile-count { font-size: 26px; font-weight: 700; color: var(--qn-head); }
.qn-tile-label { font-size: 15px; font-weight: 600; color: var(--qn-soft); }

.qn-section { display: flex; flex-direction: column; gap: 10px; }
.qn-h2 { margin: 0; font-family: var(--qn-serif); font-size: 21px; font-weight: 700; color: var(--qn-head); }
.qn-rows { display: flex; flex-direction: column; overflow: hidden; }
.qn-row-btn {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  border-bottom: 1px solid var(--qn-hair); text-align: left; min-height: 62px;
}
.qn-row-btn:last-child { border-bottom: none; }
.qn-row-btn .qn-circle { width: 34px; height: 34px; }
.qn-row-name { flex: 1; font-size: 17px; font-weight: 600; color: var(--qn-ink); min-width: 0; }
.qn-row-count { font-size: 15px; color: var(--qn-muted); }
.qn-chev { display: flex; flex: 0 0 auto; color: var(--qn-faint); }
.qn-chev :is(svg, i) { width: 15px; height: 15px; stroke-width: 2; }

.qn-bar {
  position: absolute; bottom: 0; left: 0; right: 0; background: var(--qn-surface);
  border-top: 1px solid var(--qn-bar-hair); display: flex; align-items: center;
  justify-content: space-between; padding: 12px 24px calc(26px + env(safe-area-inset-bottom));
}
.qn-bar-icon { width: 44px; height: 44px; display: grid; place-items: center; }
.qn-bar-icon :is(svg, i) { width: 24px; height: 24px; color: var(--qn-ink); stroke-width: 2; }
.qn-bar-tabs { display: flex; align-items: center; gap: 10px; }
.qn-bar-tab { font-size: 16px; font-weight: 600; color: var(--qn-muted); padding: 8px 12px; white-space: nowrap; }
.qn-bar-tab.active { color: var(--qn-ink); background: var(--qn-hair); border-radius: 12px; padding: 8px 14px; }

/* ---------- list detail ---------- */
.qn-navrow {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px 0; flex: 0 0 auto;
}
.qn-back { display: flex; align-items: center; gap: 6px; font-size: 17px; font-weight: 600; color: var(--qn-accent); min-height: 44px; }
.qn-back :is(svg, i) { width: 18px; height: 18px; stroke-width: 2.4; }
.qn-dots { width: 44px; height: 44px; display: grid; place-items: center; }
.qn-dots :is(svg, i) { width: 20px; height: 20px; color: var(--qn-accent); stroke-width: 2; }

.qn-listhead { display: flex; flex-direction: column; gap: 8px; }
.qn-listtitle {
  font-family: var(--qn-serif); font-size: 32px; font-weight: 700; color: var(--qn-head);
  outline: none; word-break: break-word;
}
.qn-listtitle:focus { color: var(--qn-ink); }
.qn-listmeta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--qn-muted); }

.qn-tasks { display: flex; flex-direction: column; gap: 8px; }
.qn-task {
  background: var(--qn-surface); border-radius: 14px; box-shadow: var(--qn-shadow);
  display: flex; align-items: center; gap: 14px; padding: 15px 16px; text-align: left; width: 100%;
}
.qn-task.done { opacity: .75; }
.qn-task-mid { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.qn-task-text { font-size: 16px; color: var(--qn-ink); }
.qn-task.done .qn-task-text { color: var(--qn-faint); text-decoration: line-through; }
.qn-task-sub { font-size: 13px; color: var(--qn-muted); }
.qn-task-due { font-size: 13px; display: flex; align-items: center; gap: 5px; }
.qn-task-due :is(svg, i) { width: 13px; height: 13px; stroke-width: 2; }
.qn-comphead {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px 2px;
  color: var(--qn-muted); font-size: 14px; font-weight: 600;
}
.qn-comphead :is(svg, i) { width: 14px; height: 14px; stroke-width: 2; transition: transform .2s; }
.qn-comphead.closed :is(svg, i) { transform: rotate(-90deg); }

.qn-addbar {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 14px 20px calc(30px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(237, 239, 241, 0) 0%, var(--qn-screen) 40%);
}
.qn-addbar[hidden] { display: none; }
.qn-addbtn {
  width: 100%; background: var(--qn-accent); border-radius: 16px; display: flex; align-items: center;
  gap: 12px; padding: 16px 18px; box-shadow: 0 8px 20px rgba(15, 23, 42, .2);
  font-size: 16px; font-weight: 600; color: #fff;
}
.qn-addbtn :is(svg, i) { width: 20px; height: 20px; stroke-width: 2.2; }
.qn-addbtn[hidden], .qn-addfield[hidden] { display: none; }
.qn-addfield {
  background: var(--qn-surface); border-radius: 16px; display: flex; align-items: center;
  gap: 12px; padding: 6px 18px; box-shadow: 0 8px 20px rgba(15, 23, 42, .2);
}
.qn-addfield input {
  flex: 1; min-width: 0; border: none; outline: none; background: none;
  font-size: 16px; color: var(--qn-ink); padding: 14px 0;
}

/* ---------- task detail ---------- */
.qn-taskhead { display: flex; align-items: flex-start; gap: 14px; }
.qn-tasktitle {
  flex: 1; margin: 0; font-family: var(--qn-serif); font-size: 24px; font-weight: 700;
  color: var(--qn-head); line-height: 1.3; outline: none; word-break: break-word;
}
.qn-tasktitle.done { color: var(--qn-faint); text-decoration: line-through; }
.qn-details { display: flex; flex-direction: column; border-radius: 16px; }
.qn-row {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 16px 18px;
  border-bottom: 1px solid var(--qn-hair);
}
.qn-row:last-child { border-bottom: none; }
.qn-row > :is(svg, i) { width: 20px; height: 20px; color: var(--qn-accent); stroke-width: 2; flex: 0 0 auto; }
.qn-row.empty > :is(svg, i) { color: var(--qn-muted); }
.qn-row-mid { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.qn-due-label { font-size: 16px; font-weight: 600; color: var(--qn-ink); }
.qn-due-sub { font-size: 13px; color: var(--qn-muted); }
.qn-due-add { flex: 1; font-size: 16px; color: var(--qn-muted); text-align: left; }
.qn-dateinput { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: none; background: none; }
.qn-row .qn-x { position: relative; z-index: 1; }
.qn-taglist { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qn-taglist .qn-tag { padding: 6px 12px; font-size: 13px; }
.qn-addtag {
  border: 1.5px dashed var(--qn-star-off); color: var(--qn-muted); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-weight: 600;
}
.qn-notecard { border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.qn-noterow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.qn-notelabel { font-size: 13px; font-weight: 600; color: var(--qn-muted); letter-spacing: .02em; }
.qn-fmt { display: flex; gap: 4px; background: var(--qn-sheet); border-radius: 10px; padding: 3px; }
.qn-fmt button {
  width: 30px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  color: var(--qn-soft); font-size: 14px; transition: background .15s, color .15s;
}
.qn-fmt button :is(svg, i) { width: 16px; height: 16px; stroke-width: 2; }
.qn-fmt button.on { background: var(--qn-accent); color: #fff; }
.qn-fmt .qn-fmt-b { font-weight: 800; }
.qn-fmt .qn-fmt-i { font-style: italic; font-family: Georgia, serif; font-weight: 600; }
.qn-fmt .qn-fmt-u { text-decoration: underline; font-weight: 600; }
#qnNote {
  border: none; outline: none; resize: none; background: none; padding: 0;
  font-size: 15px; color: var(--qn-ink); line-height: 1.55;
}
#qnNote::placeholder { color: var(--qn-muted); }
.qn-taskfoot {
  position: absolute; bottom: 0; left: 0; right: 0; display: flex; align-items: center;
  justify-content: space-between; padding: 14px 24px calc(30px + env(safe-area-inset-bottom));
  background: var(--qn-screen); border-top: 1px solid var(--qn-bar-hair);
}
.qn-foot-pad { width: 20px; }
.qn-created { font-size: 14px; color: var(--qn-muted); }
.qn-trash { width: 44px; height: 44px; display: grid; place-items: center; }
.qn-trash :is(svg, i) { width: 20px; height: 20px; color: var(--qn-soft); stroke-width: 2; }

/* ---------- search ---------- */
.qn-searchbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px 0; flex: 0 0 auto; }
.qn-searchfield {
  flex: 1; min-width: 0; background: var(--qn-surface); border-radius: 14px; display: flex;
  align-items: center; gap: 10px; padding: 0 14px; box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}
.qn-searchfield :is(svg, i) { width: 17px; height: 17px; color: var(--qn-muted); stroke-width: 2.2; flex: 0 0 auto; }
.qn-searchfield input {
  flex: 1; min-width: 0; border: none; outline: none; background: none;
  font-size: 16px; color: var(--qn-ink); padding: 13px 0;
}
.qn-searchfield .qn-x[hidden] { display: none; }
.qn-cancel { font-size: 16px; font-weight: 600; color: var(--qn-accent); padding: 10px 0; }
.qn-results { gap: 8px; }
.qn-count { font-size: 13px; font-weight: 600; color: var(--qn-muted); padding: 2px 4px; }
.qn-blank { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 80px 30px 0; text-align: center; }
.qn-blank :is(svg, i) { width: 34px; height: 34px; color: var(--qn-grab); stroke-width: 1.8; }
.qn-blank .qn-blank-1 { font-size: 16px; font-weight: 600; color: var(--qn-soft); }
.qn-blank .qn-blank-2 { font-size: 15px; color: var(--qn-muted); line-height: 1.5; }

/* ---------- bottom sheet ---------- */
.qn-dim {
  position: absolute; inset: 0; z-index: 5; background: rgba(23, 28, 36, .4);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.qn-dim.open { opacity: 1; pointer-events: auto; }
.qn-sheet {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 6; background: var(--qn-sheet);
  border-radius: 24px 24px 0 0; padding: 10px 24px calc(34px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; box-shadow: 0 -12px 32px rgba(15, 23, 42, .18);
  transform: translateY(110%); transition: transform .35s var(--qn-ease);
}
.qn-sheet.open { transform: translateY(0); }
.qn-grabber { width: 40px; height: 5px; background: var(--qn-grab); border-radius: 999px; align-self: center; margin-bottom: 8px; }
.qn-sheet-row {
  display: flex; align-items: center; gap: 16px; padding: 18px 4px;
  border-bottom: 1px solid var(--qn-bar-hair); font-size: 18px; font-weight: 600;
  color: var(--qn-ink); text-align: left; width: 100%;
}
.qn-sheet-row:last-child { border-bottom: none; }
.qn-sheet-row :is(svg, i) { width: 24px; height: 24px; color: var(--qn-accent); stroke-width: 1.8; flex: 0 0 auto; }
.qn-sheet-row.danger { color: #C0392B; }
.qn-sheet-row.danger :is(svg, i) { color: #C0392B; }
.qn-sheet-row .qn-sheet-label { flex: 1; }
.qn-sheet-state { font-size: 15px; font-weight: 600; color: var(--qn-muted); }
.qn-sheet-row.on .qn-sheet-state { color: var(--qn-accent); }
.qn-sheet-field { display: flex; align-items: center; gap: 16px; padding: 14px 4px; }
.qn-sheet-field input {
  flex: 1; min-width: 0; background: var(--qn-surface); border: 1px solid var(--qn-bar-hair);
  border-radius: 12px; outline: none; font-size: 16px; color: var(--qn-ink); padding: 12px 14px;
}

/* toast matches the Quick notes palette while the workspace is open */
body.qn-open .toast {
  background: #16181C; border-radius: 999px; padding: 10px 18px;
  font-size: 14px; font-weight: 600; z-index: 130;
  bottom: calc(112px + env(safe-area-inset-bottom));
}

/* ---------- desktop: "From your phone" popover ---------- */
@media (min-width: 769px) {
  body.qn-desk #quicknotes:not([hidden]) {
    display: flex; flex-direction: column;
    inset: auto; width: 360px; height: min(72vh, 640px);
    /* clip parked stack screens (translateX/Y) + sheet — they leak if visible */
    border-radius: 12px; overflow: hidden;
    border: 1px solid #dde0e5;
    box-shadow: 0 8px 28px rgba(28, 30, 38, .14), 0 2px 8px rgba(28, 30, 38, .08);
    animation: qn-desk-in .18s var(--qn-ease) both;
  }
  body.qn-desk .qn-deskhead {
    display: block; flex: 0 0 auto; position: relative; z-index: 4;
    background: #f3f4f6; color: #3a414d; border-radius: 12px 12px 0 0;
    font-size: 15px; font-weight: 700; letter-spacing: .01em;
    padding: 14px 16px 12px; border-bottom: 1px solid #e4e6ea;
  }
  body.qn-desk .qn-deskhead[hidden] { display: none; }
  /* stack screens under the desk head; same transform nav as mobile */
  body.qn-desk .qn-screen {
    top: 46px; padding-top: 8px; border-radius: 0 0 12px 12px; overflow: hidden;
  }
  body.qn-desk .qn-bar { display: none; }
  body.qn-desk .qn-home-scroll { padding-bottom: 28px; }
  body.qn-desk .qn-title { font-size: 28px; }
  body.qn-desk .qn-scroll {
    scrollbar-width: thin; scrollbar-color: #c5cad3 transparent;
  }
  body.qn-desk .qn-scroll::-webkit-scrollbar { display: block; width: 7px; }
  body.qn-desk .qn-scroll::-webkit-scrollbar-thumb {
    background: #c5cad3; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
  }
  body.qn-desk .qn-sheet {
    left: 10px; right: 10px; bottom: 10px; border-radius: 16px;

  }
  body.qn-open.qn-desk .toast { bottom: 24px; }
}

@keyframes qn-desk-in {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Trash panel */
#trashPanel { position: fixed; inset: 0; z-index: 10000; background: rgba(25, 29, 38, .24); display: flex; justify-content: center; align-items: flex-start; padding: min(14vh, 120px) 18px 18px; }
#trashPanel[hidden] { display: none; }
.trash-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--card-border); }
.trash-head strong { font-weight: 600; }
.trash-danger { border: 0; background: none; color: #b3403a; font: inherit; font-size: 13px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.trash-danger:hover { background: #fbeeed; }
#trashResults { overflow-y: auto; padding: 6px; }
.trash-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 10px; border-radius: 8px; }
.trash-row:hover { background: #f1f3f8; }
.trash-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.trash-info strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-info small { color: var(--ink-soft); }
.trash-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.trash-restore { border: 1px solid var(--card-border); background: #fff; color: var(--ink); font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.trash-restore:hover { background: #f1f3f8; }
.trash-purge { border: 0; background: none; color: #b3403a; cursor: pointer; padding: 5px; border-radius: 6px; display: grid; place-items: center; }
.trash-purge:hover { background: #fbeeed; }
.trash-purge :is(svg, i) { width: 16px; height: 16px; }

/* Connector lines */
.line-layer { position: absolute; overflow: visible; pointer-events: none; z-index: 0; }
.line { pointer-events: none; }
.line .line-hit { pointer-events: stroke; cursor: pointer; }
.line .line-path { transition: stroke-width .1s; }
.line.selected .line-path { filter: drop-shadow(0 0 3px rgba(0, 0, 0, .35)); }
.line-endpoint { fill: #fff; stroke: #3f63ab; stroke-width: 2; cursor: move; pointer-events: all; }
.line.preview { opacity: .75; }
.line-label { font: 600 12px Figtree, sans-serif; fill: #30343a; paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.line-swatch { width: 18px; height: 18px; border-radius: 50%; padding: 0 !important; border: 2px solid #fff !important; box-shadow: 0 0 0 1px var(--card-border); flex: 0 0 auto; }
.line-swatch.sel { box-shadow: 0 0 0 2px #3f63ab; }
#railLine[hidden] { display: none; }
#railLine .tool { width: 100%; }
#railLine .tool.sel { background: #e9f0ff; color: var(--accent); }
#railLinePop { position: fixed; left: 70px; z-index: 60; background: #fff; border: 1px solid var(--card-border); border-radius: 10px; box-shadow: 0 10px 32px rgba(0,0,0,.16); padding: 10px; }
.rail-pop-colors { display: grid; grid-template-columns: repeat(3, 22px); gap: 7px; }
.rail-pop-colors .line-swatch { width: 22px; height: 22px; }
.rail-pop-weights { display: flex; flex-direction: column; gap: 4px; }
.rail-pop-weight { border: 0; background: none; border-radius: 6px; padding: 5px 10px; cursor: pointer; display: grid; place-items: center; }
.rail-pop-weight:hover { background: #f1f3f8; }
.rail-pop-weight.sel { background: #e9f0ff; }
.rail-pop-more { display: flex; flex-direction: column; }
.rail-pop-danger { border: 0; background: none; color: #b3403a; font: 13px Figtree, sans-serif; padding: 7px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; text-align: left; }
.rail-pop-danger:hover { background: #fbeeed; }
/* On-canvas line editing handles (scale-independent sizes are set in JS). */
.line-vertex { fill: #fff; stroke: #3f63ab; stroke-width: 2; cursor: move; pointer-events: all; }
.line-vertex:hover { stroke: #b3403a; }
.line-bend { fill: #fff; stroke: #3f63ab; stroke-width: 2; cursor: move; pointer-events: all; }
.line-bend:hover { stroke: #b3403a; }
.line.selected .line-label { pointer-events: all; cursor: text; }
/* Inline label editor: floats at the label's screen position while editing. */
.line-label-editor { position: fixed; z-index: 10002; transform: translate(-50%, -50%); min-width: 90px; max-width: 280px; font: 600 12px Figtree, sans-serif; color: #30343a; background: #fff; border: 1px solid #3f63ab; border-radius: 6px; padding: 3px 8px; outline: none; box-shadow: 0 4px 16px rgba(0, 0, 0, .18); }

/* Custom minimal YouTube controls (native chrome disabled via controls=0) */
/* The iframe is rendered 150% tall and shifted up 25%, clipped by the card's
   overflow:hidden. YouTube letterboxes the video, so the video stays fully
   visible while YouTube's paused/hover chrome — title bar, channel avatar,
   suggestion strip, watermark logo — anchored to the iframe's top and bottom
   edges falls outside the clip and never appears. */
.link .link-player .yt-host { position: absolute; left: 0; top: -25%; width: 100%; height: 150%; border: 0; }
.link .yt-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: linear-gradient(transparent, rgba(0,0,0,.72)); opacity: 0; transition: opacity .15s; }
.link .link-player:hover .yt-bar, .link .link-player.paused .yt-bar { opacity: 1; }
.link .yt-bar button { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; background: none; color: #fff; cursor: pointer; opacity: .9; }
.link .yt-bar button:hover { opacity: 1; }
.link .yt-seek { flex: 1; height: 4px; margin: 0; accent-color: #f03; cursor: pointer; }
.link .yt-time { font: 11px Figtree, sans-serif; color: #fff; opacity: .85; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Milanote-style per-card caption and link preview mode */
.card-caption { padding: 6px 12px 9px; font: 12.5px/1.45 Figtree, sans-serif; color: var(--ink-soft); border-top: 1px solid var(--card-border); }
.item.type-link.preview-mode { background: #000 !important; border-color: #000; }
.item.type-link.preview-mode .card-extras, .item.type-link.preview-mode .card-caption { color: #cbd0d8; border-top-color: rgba(255,255,255,.14); background: transparent; }


/* ---------- GPU compositing / smooth zoom ---------- */
#world { will-change: transform; contain: layout style; backface-visibility: hidden; }
#world.zooming-smooth { transition: transform .13s ease-out; }
#drawInput, .drawing-layer { shape-rendering: geometricPrecision; }
#stage.no-grid { background-image: none; }

/* ---------- interface scale (chrome only; canvas math unaffected) ---------- */
html[data-ui-scale="small"]  { --ui-zoom: 0.88; }
html[data-ui-scale="medium"] { --ui-zoom: 1; }
html[data-ui-scale="large"]  { --ui-zoom: 1.15; }
#topbar { zoom: var(--ui-zoom, 1); }
#rail { zoom: var(--ui-zoom, 1); }
/* Desktop only — on phones this must not override the mobile full-bleed
   #stage reset inside the media query above, or the canvas crops. */
@media (min-width: 769px) {
  #stage { top: calc(52px * var(--ui-zoom, 1)); left: calc(64px * var(--ui-zoom, 1)); }
}
.search-dialog, .export-dialog, .settings-dialog { zoom: var(--ui-zoom, 1); }

/* ---------- dark theme ---------- */
html[data-theme="dark"] {
  --canvas-bg: #1b1d22;
  --rail-bg: #23262d;
  --rail-border: #34383f;
  --ink: #e8eaee;
  --ink-soft: #9aa1ad;
  --ink-faint: #5c626d;
  --card-bg: #2a2e35;
  --card-border: #3a3e47;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .28);
  --card-shadow-hover: 0 2px 6px rgba(0, 0, 0, .45), 0 10px 28px rgba(0, 0, 0, .38);
}
html[data-theme="dark"] #topbar { background: #23262d; border-bottom-color: #34383f; }
html[data-theme="dark"] #crumbs .crumb:hover { background: #2e323a; }
html[data-theme="dark"] .top-right .ghost:hover,
html[data-theme="dark"] .top-phone:hover,
html[data-theme="dark"] .top-phone[aria-expanded="true"],
html[data-theme="dark"] .top-search:hover { background: #2e323a; }
html[data-theme="dark"] .top-phone-badge { box-shadow: 0 0 0 2px #23262d; }
html[data-theme="dark"] .zoomwrap { background: #2e323a; }
html[data-theme="dark"] .zoomwrap button:hover { background: #3a3e47; }
html[data-theme="dark"] .tool:hover { background: #2e323a; }
html[data-theme="dark"] .tool.armed { background: #21304d; }
html[data-theme="dark"] .rail-sep, html[data-theme="dark"] #railHistory { border-color: #34383f; }
html[data-theme="dark"] .column { background: #262a31; }
html[data-theme="dark"] .column .col-empty { border-color: #3a3e47; }
html[data-theme="dark"] .item.in-column { border-color: #3a3e47; }
html[data-theme="dark"] .link .link-thumbnail, html[data-theme="dark"] .link .link-slot { background: #262a31; }
html[data-theme="dark"] .link .link-label, html[data-theme="dark"] .link .link-reactions { background: #34383f; color: #9aa1ad; }
html[data-theme="dark"] .task input[type=checkbox] { border-color: #4a4f59; }
html[data-theme="dark"] .search-dialog { background: #23262d; border-color: #34383f; }
html[data-theme="dark"] #searchQuery { border-bottom-color: #34383f; color: var(--ink); }
html[data-theme="dark"] .search-result:hover, html[data-theme="dark"] .search-result:focus { background: #2e323a; }
html[data-theme="dark"] .export-dialog, html[data-theme="dark"] .settings-dialog { background: #23262d; }
html[data-theme="dark"] .export-scope { background: #262a31; }
html[data-theme="dark"] .export-format:hover { background: #2e323a; }
html[data-theme="dark"] .export-format:has(input:checked) { background: #21304d; border-color: #35569a; }
html[data-theme="dark"] .export-close, html[data-theme="dark"] .settings-close { color: #9aa1ad; }
html[data-theme="dark"] .export-close:hover, html[data-theme="dark"] .settings-close:hover { background: #2e323a; }
html[data-theme="dark"] .export-format-text small, html[data-theme="dark"] .settings-row-text small { color: #8b93a0; }
html[data-theme="dark"] #drawingToolbar, html[data-theme="dark"] #strokeToolbar,
html[data-theme="dark"] #multiSelectionToolbar, html[data-theme="dark"] #swatchEditor { background: #23262d; border-color: #3a3e47; color: #9aa1ad; }
html[data-theme="dark"] #drawingToolbar button { color: #9aa1ad; }
html[data-theme="dark"] #drawingToolbar button:hover:not(:disabled),
html[data-theme="dark"] #drawingToolbar button.active { background: #21304d; color: #9db9f0; }
html[data-theme="dark"] #strokeToolbar button { background: #23262d; border-color: #3a3e47; }
html[data-theme="dark"] .trash-danger { color: #ff8a8a; }
html[data-theme="dark"] ::selection { background: #35569a; color: #fff; }

/* ---------- serif toggle ---------- */
html.no-serif-headings .note .ntitle,
html.no-serif-headings .todo .ttitle,
html.no-serif-headings .board .btitle,
html.no-serif-headings .column .col-title,
html.no-serif-headings #title,
html.no-serif-headings .doc-title { font-family: var(--sans); }

.search-result small { color: var(--ink-soft); }

/* ---------- empty hint ---------- */
#hint { position: fixed; left: 50%; top: 58%; transform: translate(-50%,-50%); text-align: center; color: var(--ink-faint); pointer-events: none; z-index: 1; }
#hint h2 { font-family: var(--serif); font-weight: 600; color: var(--ink-soft); font-size: 22px; margin: 0 0 6px; }
#hint p { margin: 0; font-size: 14px; }


.tool svg, .tool [data-lucide], .tool i { width: 22px; height: 22px; display: block; }
.tool i svg { width: 22px; height: 22px; }

/* ---------- sketch ---------- */
.sketch { padding: 0; touch-action: none; }
.sketch-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sketch-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  color: #b9bfc8; font-size: 13px; pointer-events: none; user-select: none;
}
.sketch-empty svg { width: 26px; height: 26px; }

/* ---------- settings panel ---------- */
#settingsPanel {
  position: fixed; inset: 0; z-index: 100000;
  background: rgba(20, 24, 32, .5);
  display: flex; align-items: center; justify-content: center;
}
.settings-dialog {
  width: min(820px, calc(100vw - 32px)); height: min(620px, calc(100vh - 48px));
  background: #fff; border-radius: 14px; box-shadow: 0 24px 80px rgba(0,0,0,.28);
  display: flex; overflow: hidden;
}
.settings-nav {
  width: 210px; flex: 0 0 auto; background: #f7f8fa; border-right: 1px solid #ececef;
  display: flex; flex-direction: column; gap: 2px; padding: 14px 10px;
}
.settings-nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border: 0; background: none; border-radius: 9px; font: 500 13.5px var(--sans, sans-serif);
  color: #4d5664; cursor: pointer; text-align: left;
}
.settings-nav-item:hover { background: #eef0f4; }
.settings-nav-item.active { background: #e9efff; color: #2b4f9f; }
.settings-nav-item svg { width: 17px; height: 17px; }
.settings-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid #ececef;
}
.settings-head strong { font-size: 17px; }
.settings-close { border: 0; background: none; color: #6a7280; cursor: pointer; display: grid; place-items: center; padding: 4px; border-radius: 6px; }
.settings-close:hover { background: #f1f1f3; color: #333; }
.settings-close svg { width: 18px; height: 18px; }
.settings-body { flex: 1; overflow: auto; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.settings-section-title { margin: 8px 0 0; font-size: 13px; font-weight: 700; letter-spacing: .02em; color: #566072; }
.settings-note { font-size: 12.5px; color: #7a828e; margin: 0; line-height: 1.45; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px; border: 1px solid #ececef; border-radius: 10px; }
.settings-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-row-text strong { font-size: 13.5px; font-weight: 600; color: #2c333d; }
.settings-row-text small { font-size: 12px; color: #7a828e; }
.settings-toggle {
  position: relative; flex: 0 0 auto; width: 40px; height: 22px; border: 0; border-radius: 999px;
  background: #ccd1d9; cursor: pointer; transition: background .15s ease;
}
.settings-toggle.on { background: #34a853; }
.settings-knob {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s ease;
}
.settings-toggle.on .settings-knob { left: 20px; }
.settings-cards { display: flex; gap: 10px; flex-wrap: wrap; }
.settings-card {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  min-width: 130px; padding: 10px; background: #fff; border: 1.5px solid #dfe1e5;
  border-radius: 10px; cursor: pointer; font: 500 12.5px var(--sans, sans-serif); color: #4d5664;
}
.settings-card:hover { border-color: #c3c9d4; }
.settings-card.active { border-color: #2f6df0; box-shadow: 0 0 0 1px #2f6df0; color: #2b4f9f; }
.settings-card-preview { width: 96px; height: 60px; border-radius: 5px; display: block; }
.settings-card-label { font-size: 12px; }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.settings-btn {
  border: 1px solid #dfe1e5; background: #fff; color: #2c333d; font: 600 13px var(--sans, sans-serif);
  padding: 9px 16px; border-radius: 9px; cursor: pointer;
}
.settings-btn:hover { background: #f5f6f8; }
.settings-btn.primary { background: #3f63ab; border-color: #3f63ab; color: #fff; }
.settings-btn.primary:hover { background: #35569a; }
.settings-btn.danger { color: #ac3131; border-color: #e8c8c8; background: #fff4f4; }
.settings-btn.danger:hover { background: #fdeaea; }
.settings-stats { display: flex; flex-direction: column; gap: 2px; border: 1px solid #ececef; border-radius: 10px; padding: 8px 12px; }
.settings-stat-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; color: #4d5664; border-bottom: 1px solid #f3f4f6; }
.settings-stat-row:last-child { border-bottom: 0; }
.settings-search {
  width: 100%; border: 1px solid #dfe1e5; border-radius: 9px; padding: 9px 12px;
  font: 13.5px var(--sans, sans-serif); outline: none;
}
.settings-search:focus { border-color: #9db9f0; box-shadow: 0 0 0 2px rgba(47,109,240,.15); }
.settings-shortcuts { display: flex; flex-direction: column; gap: 2px; }
.settings-shortcut-group { font-size: 12px; font-weight: 700; color: #8b93a0; letter-spacing: .04em; text-transform: uppercase; margin: 10px 0 4px; }
.settings-shortcut-group:first-child { margin-top: 0; }
.settings-shortcut-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 12px; border-radius: 8px;
}
.settings-shortcut-row:hover { background: #f5f6f8; }
.settings-shortcut-label { font-size: 13.5px; color: #2c333d; }
.settings-keycap {
  border: 1px solid #d8dce2; background: #f7f8fa; color: #39404a; border-radius: 6px;
  font: 600 12px var(--sans, sans-serif); padding: 4px 10px; min-width: 74px; cursor: pointer;
}
.settings-keycap:hover { border-color: #b9c0cc; }
.settings-keycap.overridden { border-color: #9db9f0; background: #eef3fd; color: #2b4f9f; }
.settings-keycap.listening { border-color: #2f6df0; background: #e9efff; color: #2b4f9f; animation: keyPulse 1s ease-in-out infinite; }
@keyframes keyPulse { 50% { opacity: .55; } }
.settings-colors { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.settings-color-swatch {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.settings-color-swatch.sel { border-color: #2f6df0; }
.settings-select {
  border: 1px solid #dfe1e5; border-radius: 7px; padding: 7px 9px; font: 13px var(--sans, sans-serif);
  color: #2c333d; background: #fff;
}
.settings-tips { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #4d5664; line-height: 1.45; }

html[data-theme="dark"] .settings-nav { background: #262a31; border-color: #34383f; }
html[data-theme="dark"] .settings-nav-item { color: #9aa1ad; }
html[data-theme="dark"] .settings-nav-item:hover { background: #2e323a; }
html[data-theme="dark"] .settings-nav-item.active { background: #21304d; color: #9db9f0; }
html[data-theme="dark"] .settings-head { border-color: #34383f; }
html[data-theme="dark"] .settings-row,
html[data-theme="dark"] .settings-stats { border-color: #34383f; }
html[data-theme="dark"] .settings-stat-row { color: #9aa1ad; border-color: #2e323a; }
html[data-theme="dark"] .settings-stat-row strong,
html[data-theme="dark"] .settings-shortcut-label,
html[data-theme="dark"] .settings-row-text strong,
html[data-theme="dark"] .settings-about strong { color: #e8eaee; }
html[data-theme="dark"] .settings-btn { background: #2a2e35; border-color: #3a3e47; color: #e8eaee; }
html[data-theme="dark"] .settings-btn:hover { background: #34383f; }
html[data-theme="dark"] .settings-btn.primary { background: #35569a; border-color: #35569a; color: #fff; }
html[data-theme="dark"] .settings-btn.danger { background: #3a2727; border-color: #5c3232; color: #ff8a8a; }
html[data-theme="dark"] .settings-card { background: #2a2e35; border-color: #3a3e47; color: #9aa1ad; }
html[data-theme="dark"] .settings-card.active { border-color: #4a7af0; box-shadow: 0 0 0 1px #4a7af0; color: #cfe0ff; }
html[data-theme="dark"] .settings-keycap { background: #2a2e35; border-color: #3a3e47; color: #cfd4dc; }
html[data-theme="dark"] .settings-keycap.overridden { background: #21304d; border-color: #35569a; color: #9db9f0; }
html[data-theme="dark"] .settings-search { background: #2a2e35; border-color: #3a3e47; color: #e8eaee; }
html[data-theme="dark"] .settings-select { background: #2a2e35; border-color: #3a3e47; color: #e8eaee; }
html[data-theme="dark"] .settings-section-title { color: #8b93a0; }
html[data-theme="dark"] .settings-note,
html[data-theme="dark"] .settings-tips { color: #9aa1ad; }
html[data-theme="dark"] .settings-shortcut-row:hover { background: #2e323a; }

/* ---------- login overlay ---------- */
#loginPanel {
  position: fixed; inset: 0; z-index: 200000;
  background: rgba(20, 24, 32, .6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login-dialog {
  width: min(340px, 100%); background: #fff; border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,.3); padding: 26px 24px 20px;
  display: flex; flex-direction: column; gap: 10px; text-align: center;
}
.login-logo {
  width: 46px; height: 46px; margin: 0 auto 2px; border-radius: 13px;
  background: #2f6df0; color: #fff; display: grid; place-items: center;
}
.login-logo svg { width: 24px; height: 24px; }
.login-dialog h2 { margin: 0; font-family: var(--serif, Georgia, serif); font-size: 20px; color: #2b2d31; }
.login-sub { margin: 0 0 4px; font-size: 13px; color: #7a828e; }
.login-error { min-height: 16px; font-size: 12px; color: #c0392b; }
.login-input {
  width: 100%; border: 1px solid #dfe1e5; border-radius: 9px; padding: 11px 12px;
  font: 14px var(--sans, sans-serif); outline: none; box-sizing: border-box;
}
.login-input:focus { border-color: #9db9f0; box-shadow: 0 0 0 2px rgba(47,109,240,.15); }
.login-btn {
  border: 0; border-radius: 9px; padding: 11px; font: 600 14px var(--sans, sans-serif); cursor: pointer;
}
.login-btn.primary { background: #2f6df0; color: #fff; }
.login-btn.primary:hover { background: #275fd6; }
.login-btn.ghosted { background: #f1f2f4; color: #2c333d; }
.login-btn.ghosted:hover { background: #e7e8ec; }
.login-or { font-size: 11px; color: #b6b9c0; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- top-bar user chip ---------- */
.user-chip {
  display: flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px;
  border: 0; background: none; border-radius: 999px; cursor: pointer; color: var(--ink-soft);
  font: 500 12.5px var(--sans, sans-serif);
}
.user-chip:hover { background: #f1f1f3; }
.user-chip-avatar {
  width: 24px; height: 24px; border-radius: 50%; background: #2f6df0; color: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: 0 0 auto;
}

/* card author tag (shown when someone other than the board owner created it) */
.card-by { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--ink-faint); }
.card-by::before { content: '—'; opacity: .6; }

html[data-theme="dark"] #loginPanel { background: rgba(10, 12, 16, .7); }
html[data-theme="dark"] .login-dialog { background: #23262d; }
html[data-theme="dark"] .login-dialog h2 { color: var(--ink); }
html[data-theme="dark"] .login-input { background: #2a2e35; border-color: #3a3e47; color: var(--ink); }
html[data-theme="dark"] .login-btn.ghosted { background: #2e323a; color: #e8eaee; }
html[data-theme="dark"] .user-chip:hover { background: #2e323a; }

/* ---------- share links ---------- */
.share-form { display: flex; flex-direction: column; gap: 10px; }
.share-role { display: flex; gap: 8px; }
.share-role-option {
  flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;
  border: 1.5px solid #dfe1e5; border-radius: 10px; cursor: pointer;
  background: #fff;
}
.share-role-option:hover { border-color: #c3c9d4; }
.share-role-option.active { border-color: #2f6df0; box-shadow: 0 0 0 1px #2f6df0; }
.share-role-option input { position: absolute; opacity: 0; pointer-events: none; }
.share-role-option strong { font-size: 13px; color: #2c333d; }
.share-role-option small { font-size: 11.5px; color: #7a828e; }
.share-result { display: flex; gap: 8px; }
.share-result .login-input { font-family: ui-monospace, monospace; font-size: 12px; flex: 1; }
.share-list { display: flex; flex-direction: column; gap: 6px; }
.share-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border: 1px solid #ececef; border-radius: 10px;
}
.share-row.revoked { opacity: .55; }
.share-row .settings-btn { flex: 0 0 auto; padding: 6px 12px; font-size: 12px; }

html[data-theme="dark"] .share-role-option { background: #2a2e35; border-color: #3a3e47; }
html[data-theme="dark"] .share-role-option.active { border-color: #4a7af0; box-shadow: 0 0 0 1px #4a7af0; }
html[data-theme="dark"] .share-role-option strong { color: #e8eaee; }
html[data-theme="dark"] .share-row { border-color: #34383f; }

.settings-about { display: flex; flex-direction: column; gap: 3px; }
.settings-about strong { font-size: 13.5px; color: #2c333d; }
.settings-about small { font-size: 12px; color: #7a828e; }

.settings-stat-row strong { color: #2c333d; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Save and recovery controls stay compact in the board chrome. */
.save-status { border: 0; background: transparent; color: #597267; font: inherit; font-size: 11px; cursor: pointer; padding: 6px; }
.save-status[data-status="error"] { color: #ad3c30; }
.mobile-save-status { display: none; }
@media (max-width: 768px) {
  .mobile-save-status:not([data-status="saved"]) { display: block; position: fixed; right: 12px; bottom: 84px; z-index: 3000; max-width: 80vw; background: #fff8eb; border: 1px solid #d8c8ac; border-radius: 8px; padding: 9px 12px; box-shadow: 0 2px 8px #0002; }
}
.save-recovery-dialog { width: min(620px, 90vw); max-height: 85vh; overflow: auto; border: 1px solid #dedbd4; border-radius: 12px; padding: 24px; }
.save-recovery-dialog::backdrop { background: #17202b66; }
.save-recovery-dialog textarea { display: block; box-sizing: border-box; width: 100%; min-height: 120px; margin: 8px 0 16px; }
.save-recovery-dialog button { margin: 8px 8px 0 0; padding: 8px 12px; }
