:root {
  --model-material: #9ca6b5;
  --canvas-bg: #efeff1;
  --rail-bg: #ffffff;
  --rail-border: #e9e9ec;
  --ink: #2b2d31;
  --ink-soft: #8a8d94;
  --ink-faint: #b6b9c0;
  --card-bg: #ffffff;
  --symbol-on-light: #22252b;
  --symbol-on-dark: #ffffff;
  --card-border: #e7e7ea;
  --card-shadow: 0 1px 2px rgba(28, 30, 38, 0.06), 0 4px 14px rgba(28, 30, 38, 0.06);
  --card-shadow-hover: 0 2px 6px rgba(28, 30, 38, 0.1), 0 10px 28px rgba(28, 30, 38, 0.12);
  --hover: #f1f1f3;
  --hover-strong: #e6e6ea;
  --danger: #c0392b;
  --grid-dot: rgba(0, 0, 0, 0.055);
  --control-border: #cfd2d8;
  --ink-body: #3c3f45;
  --select-soft: #e9f0ff;
  --column-bg: #fbfbfc;
  --comment-bg: #fff9f0;
  --comment-border: #f0e2cc;
  --danger-soft: #fdf1f0;
  --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;
  color-scheme: light dark;
}

/* Dark mode follows the system (decision D8): only the tokens change. */
@media (prefers-color-scheme: dark) {
  :root {
    --canvas-bg: #17181b;
    --rail-bg: #212226;
    --rail-border: #33353b;
    --ink: #e8e9ec;
    --ink-soft: #a3a6ad;
    --ink-faint: #70737b;
    --card-bg: #26282d;
    --card-border: #393b42;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
    --card-shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.45);
    --hover: #2e3036;
    --hover-strong: #3a3d44;
    --danger: #f0786b;
    --grid-dot: rgba(255, 255, 255, 0.07);
    --control-border: #5a5d65;
    --ink-body: #d3d5da;
    --select-soft: #1f2d4a;
    --column-bg: #1f2024;
    --comment-bg: #2d2a22;
    --comment-border: #4a4231;
    --danger-soft: #3a2422;
  }
  /* :root raises specificity over the base #quicknotes block further down */
  :root #quicknotes {
    --qn-screen: #17181b;
    --qn-surface: #212226;
    --qn-ink: #e5e7eb;
    --qn-head: #f3f4f6;
    --qn-soft: #b0b8c4;
    --qn-muted: #8d96a3;
    --qn-faint: #737c89;
    --qn-accent: #8a97ab;
    --qn-hair: #2c2f35;
    --qn-bar-hair: #33363c;
    --qn-sheet: #1c1d21;
    --qn-grab: #4a4f57;
  }
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none; /* no pull-to-refresh or rubber-band, in the browser or the home-screen app */
}
/* A long press on a card is the app's, not iOS's link/image callout; fields keep theirs. */
#stage,
.item {
  -webkit-touch-callout: none;
}
.item input,
.item textarea,
.item [contenteditable='true'] {
  -webkit-touch-callout: default;
}
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: var(--rail-bg);
  border-bottom: 1px solid var(--rail-border);
}
.dots {
  display: flex;
  gap: 7px;
  margin-right: 6px;
}
.dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: block;
}
.dots .r {
  background: #ff5f57;
}
.dots .y {
  background: #febc2e;
}
.dots .g {
  background: #28c840;
}
#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: var(--hover);
}
#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: 0.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: var(--hover);
}
.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: var(--hover);
  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 var(--rail-bg);
}
.top-phone-badge[hidden] {
  display: none;
}
.zoomwrap {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--hover);
  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: var(--hover-strong);
}
.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: 0.2px;
}
.tool svg,
.tool i {
  width: 22px;
  height: 22px;
  display: block;
}
.tool i svg {
  width: 22px;
  height: 22px;
}
.tool:hover {
  background: var(--hover);
  color: var(--ink);
}
.tool.armed {
  background: var(--select-soft);
  color: var(--accent);
}
.tool.armed svg {
  color: var(--accent);
}
.rail-sep {
  width: 28px;
  height: 1px;
  background: var(--rail-border);
  margin: 8px 0;
}
#railCreate,
#railBoard {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 2px;
}
#railBoard[hidden],
#railCreate[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, 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);
}

/* ---------- canvas / world ---------- */
#stage {
  position: fixed;
  top: 52px;
  left: 64px;
  right: 0;
  bottom: 0;
  overflow: hidden;
  background: radial-gradient(circle at 1px 1px, var(--grid-dot) 1px, transparent 0);
  background-size: 22px 22px;
  background-color: var(--canvas-bg);
  cursor: grab;
}
#stage.panning {
  cursor: grabbing;
}
#stage.armed {
  cursor: crosshair;
}
#railCreate .tool {
  touch-action: none;
  user-select: none;
}
body.tool-dragging,
body.tool-dragging * {
  cursor: grabbing !important;
}
.tool-preview {
  user-select: none;
}
#stage,
.item {
  touch-action: none;
}
.item.editing {
  touch-action: auto;
}
#world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

/* ---------- generic card ---------- */
.item {
  position: absolute;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  transition:
    box-shadow 0.12s ease,
    border-color 0.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: var(--select);
  box-shadow:
    0 0 0 2px rgba(47, 109, 240, 0.35),
    var(--card-shadow-hover);
}
.card-connect {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--card-bg);
  cursor: crosshair;
  opacity: 0;
  z-index: 30;
  touch-action: none;
}
.card-connect::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
}
.image > .card-connect {
  top: 6px;
  right: 6px;
}
.item:hover > .card-connect,
.item.selected > .card-connect,
.card-connect:focus-visible {
  opacity: 1;
}
.card-connect:hover,
.card-connect:focus-visible {
  background: var(--select-soft);
  outline: 2px solid var(--select-soft);
}
.item.connection-target {
  outline: 2px solid var(--c-teal);
  outline-offset: 3px;
}
.board.board-drop-target .tile {
  outline: 3px solid var(--accent);
  outline-offset: 5px;
  box-shadow: 0 0 0 8px var(--select-soft);
}
.board.board-drop-target .btitle {
  color: var(--accent);
}
.connection-preview .line-ghost {
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
}
.connection-preview .line-head {
  fill: var(--accent);
  stroke: none;
}
@media (hover: none) {
  .card-connect {
    opacity: 1;
  }
}

/* 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;
}
.item.editing {
  cursor: text;
}
.item.editing [data-edit] {
  pointer-events: auto;
}
[data-nodrag] {
  pointer-events: auto !important;
}

.resize {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  z-index: 5;
}
.resize::after {
  content: '';
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink-faint);
  border-bottom: 2px solid var(--ink-faint);
  border-radius: 0 0 3px 0;
}

.card-tools {
  position: absolute;
  top: -34px;
  left: 0;
  display: none;
  gap: 4px;
  z-index: 20;
  background: #2b2d31;
  padding: 4px;
  border-radius: 9px;
  box-shadow: var(--card-shadow-hover);
}
.item.selected .card-tools {
  display: flex;
}
.card-tools button {
  border: none;
  background: none;
  color: #d6d8de;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.card-tools button:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.card-tools .swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  cursor: pointer;
}

/* ---------- note ---------- */
.note {
  padding: 14px 16px;
}
.note .nbody {
  font-size: 13.5px;
  line-height: 1.5;
  border: none;
  outline: none;
  width: 100%;
  background: none;
  color: var(--ink-body);
  resize: none;
  min-height: 20px;
}
.note .accent {
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 4px;
}

/* ---------- swatch ---------- */
.swatch-card {
  padding: 8px;
}
.swatch-card .sw-chip {
  aspect-ratio: 1;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--card-border);
  cursor: copy;
}
.swatch-card .sw-hex {
  width: 100%;
  margin-top: 6px;
  border: none;
  outline: none;
  background: none;
  color: var(--ink);
  font:
    600 13px ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  text-transform: lowercase;
}

/* ---------- table ---------- */
.table {
  padding: 0;
}
.table .tformula-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--card-border);
  color: var(--ink-soft);
  font-size: 12px;
  min-width: 0;
}
.table-grip {
  display: grid;
  grid-template-columns: repeat(3, 3px);
  justify-content: center;
  align-content: center;
  gap: 2px;
  width: 20px;
  height: 22px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: var(--ink-soft);
  background: none;
  cursor: grab;
  touch-action: none;
}
.table-grip span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  pointer-events: none;
}
.table-grip:hover {
  color: var(--ink);
  background: var(--hover);
}
.table-grip:active {
  cursor: grabbing;
}
.table-grip:disabled {
  opacity: 0.4;
  cursor: default;
}
.table .taddress {
  min-width: 30px;
  color: var(--accent);
  font-weight: 600;
}
.table .tformula {
  flex: 1;
  width: 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--ink);
  font:
    12px ui-monospace,
    monospace;
}
.table .tscroll {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  max-height: 560px;
  border-radius: 0;
}
.table.in-column .tscroll {
  overflow-x: auto;
}
.table .tgrid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.table td {
  border: 1px solid var(--card-border);
  padding: 0;
}
.table .tgrid th {
  background: var(--column-bg);
  color: var(--ink-soft);
  border: 1px solid var(--card-border);
  padding: 5px;
  font: 11px var(--sans);
  height: 26px;
  user-select: none;
}
.table .tgrid thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.table .tgrid tbody th {
  position: sticky;
  left: 0;
}
.table.selected td.tactive {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.table.formula-editing .tformula-bar {
  background: var(--select-soft);
}
.table td.treference {
  background: var(--select-soft);
  outline: 1px dashed var(--c-teal);
  outline-offset: -3px;
}
.table .tcell {
  min-width: 0;
  width: 100%;
  padding: 7px 8px;
  height: 32px;
  border: none;
  outline: none;
  background: none;
  color: var(--ink-body);
  font: 13px var(--sans);
  cursor: text;
}
.table .tcell:focus {
  background: var(--select-soft);
  cursor: text;
  user-select: text;
}
.table .tformula-cell {
  color: var(--accent);
}
.table .terror {
  color: var(--danger);
}
.table .tfooter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 28px 5px 10px;
  min-height: 30px;
  color: var(--ink-soft);
  background: var(--column-bg);
  font: 10px var(--sans);
  border-radius: 0 0 12px 12px;
}
.table .tsize {
  flex: none;
}
.table .thint {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.table .tmenu {
  position: relative;
}
.table .tmenu summary {
  cursor: pointer;
  list-style: none;
  font-size: 18px;
  padding: 0 5px;
}
.table .tmenu > div {
  position: absolute;
  right: 0;
  bottom: 24px;
  z-index: 5;
  min-width: 170px;
  padding: 5px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}
.table .tmenu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  padding: 8px;
  border-radius: 4px;
  color: var(--ink);
  background: none;
  font: 12px var(--sans);
}
.table .tmenu button:hover {
  background: var(--hover);
}
.table .tmenu button:disabled {
  color: var(--ink-faint);
  cursor: default;
}
.table .table-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 27px;
  height: 29px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: nwse-resize;
  touch-action: none;
  font-size: 19px;
}
.table .table-resize:hover,
.table .table-resize:focus-visible {
  color: var(--accent);
  background: var(--select-soft);
  border-radius: 6px;
}
.table .table-resize:disabled {
  opacity: 0.4;
  cursor: default;
}
.document .dopen {
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--ink-soft);
  font: 12px var(--sans);
  padding: 3px 8px;
  cursor: pointer;
}
.document .dopen:hover {
  background: var(--hover);
}

/* ---------- document ---------- */
.document {
  padding: 14px 16px;
}
.document .doc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
}
.document .doc-head svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.document .dtitle {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  color: var(--ink);
  font: 600 15px var(--serif);
}
.document .dsnip {
  margin: 8px 0;
  color: var(--ink-body);
  font-size: 12.5px;
  line-height: 1.45;
  max-height: 5.8em;
  overflow: hidden;
  white-space: pre-line;
}
.document .dsnip:empty {
  display: none;
}
.document .dfoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-faint);
  font-size: 12px;
}
#docDialog {
  width: min(1100px, calc(100vw - 48px));
  height: min(920px, calc(100dvh - 64px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: none;
  background: transparent;
  overflow: visible;
  color: var(--ink);
  font-family: var(--sans);
}
#docDialog[open] {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
}
#docDialog::backdrop {
  background: color-mix(in srgb, var(--canvas-bg) 30%, transparent);
}
#docDialog:has(.doc-comments:not([hidden])) {
  width: min(1380px, calc(100vw - 48px));
  grid-template-columns: 180px minmax(0, 1fr) 240px;
}
#docDialog [hidden] {
  display: none !important;
}
.doc-paper {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--card-shadow-hover);
  overflow: hidden;
}
.doc-toolbar,
.doc-comments {
  align-self: start;
  padding: 16px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  max-height: 100%;
  overflow: auto;
}
.doc-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
  max-height: calc(100% - 24px);
}
.doc-toolbar label {
  color: var(--ink-soft);
  font-size: 12px;
}
.doc-toolbar select,
.doc-toolbar input,
.doc-comments textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--ink);
  padding: 8px;
  font: 13px var(--sans);
}
.doc-toolbar button,
.doc-comments button {
  border: 1px solid var(--card-border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--ink-body);
  padding: 7px;
  font: 12px var(--sans);
}
.doc-toolbar button:hover,
.doc-comments button:hover {
  background: var(--hover);
}
.doc-toolbar button[aria-pressed='true'] {
  background: var(--select-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.doc-toolbar button:disabled {
  opacity: 0.4;
  cursor: default;
}
.doc-toolbar :focus-visible,
.doc-comments :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.doc-tool-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 10px 0;
  border-top: 1px solid var(--card-border);
  border-bottom: 1px solid var(--card-border);
}
.doc-tool-grid button {
  display: grid;
  place-items: center;
  height: 32px;
  padding: 0;
}
.doc-tool-grid svg {
  width: 16px;
  height: 16px;
}
.doc-insert-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.doc-emojis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.doc-emojis button {
  font-size: 18px;
  padding: 4px;
}
.doc-comments h2 {
  margin-top: 0;
  font-size: 15px;
}
.doc-comments p {
  color: var(--ink-body);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.doc-comments blockquote,
.doc-comment-quote {
  margin: 0;
  padding-left: 8px;
  border-left: 2px solid var(--accent);
  color: var(--ink-soft);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.doc-comments textarea {
  min-height: 90px;
  resize: vertical;
  margin: 8px 0;
}
.doc-comment {
  padding: 16px 0;
  border-top: 1px solid var(--card-border);
}
.doc-comment button {
  margin: 4px 4px 0 0;
}
.doc-comment.resolved {
  opacity: 0.65;
}
.doc-mention {
  color: var(--accent);
  background: var(--select-soft);
  border-radius: 3px;
  padding: 1px 3px;
}
.doc-comment-anchor {
  background: var(--comment-bg);
  border-bottom: 2px solid var(--c-yellow);
}
.rich [data-text-size='small'] {
  font-size: 0.82em;
}
.rich [data-indent='1'] {
  margin-inline-start: 1.5em;
}
.rich [data-indent='2'] {
  margin-inline-start: 3em;
}
.rich [data-indent='3'] {
  margin-inline-start: 4.5em;
}
.rich [data-indent='4'] {
  margin-inline-start: 6em;
}
.rich [data-indent='5'] {
  margin-inline-start: 7.5em;
}
.rich [data-indent='6'] {
  margin-inline-start: 9em;
}
#docDialog .doc-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rail-border);
  background: var(--rail-bg);
}
#docDialog .doc-title {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  color: var(--ink);
  font: 600 18px var(--serif);
}
#docDialog .doc-count {
  color: var(--ink-faint);
  font-size: 13px;
  white-space: nowrap;
}
#docDialog .doc-body {
  flex: 1;
  overflow: auto;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 32px 40px 80px;
  color: var(--ink-body);
  font-size: 17px;
  line-height: 1.7;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--ink-faint) 30%, transparent) transparent;
}
#docDialog .doc-body::-webkit-scrollbar {
  width: 10px;
}
#docDialog .doc-body::-webkit-scrollbar-track {
  background: transparent;
}
#docDialog .doc-body::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ink-faint) 35%, transparent);
  background-clip: content-box;
}
#docDialog .doc-body::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--ink-faint) 55%, transparent);
  background-clip: content-box;
}
#docDialog .doc-body .ProseMirror {
  outline: none;
  min-height: 60vh;
}
#docDialog .doc-body h1 {
  font-size: 34px;
  line-height: 1.2;
  margin-bottom: 14px;
}
#docDialog .doc-body h2 {
  font-size: 26px;
  line-height: 1.25;
  margin-bottom: 10px;
}
#docDialog .doc-body h3 {
  font-size: 20px;
  line-height: 1.3;
  margin-bottom: 8px;
}
#docDialog .doc-body h4 {
  font-size: 17px;
  line-height: 1.35;
  margin-bottom: 6px;
}
#docDialog .doc-body p {
  margin-bottom: 10px;
}
.doc-colors {
  display: grid;
  gap: 5px;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
}
.doc-colors legend {
  padding: 0;
  color: var(--ink-soft);
  font-size: 12px;
}
.doc-colors label,
.doc-colors button {
  color: var(--ink-body);
  font: 12px var(--sans);
}
.doc-colors > div {
  display: flex;
  align-items: center;
  gap: 6px;
}
.doc-colors label {
  flex: 1;
}
.doc-colors input[type='color'] {
  width: 28px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--control-border);
  border-radius: 4px;
  background: none;
  cursor: pointer;
}
.doc-colors button {
  padding: 4px 6px;
  border: 1px solid var(--card-border);
  border-radius: 5px;
  background: var(--card-bg);
}
.doc-colors button:hover {
  background: var(--hover);
}
.password-form {
  display: grid;
  gap: 8px;
  padding: 0 18px 18px;
}
.password-form h3 {
  margin: 0;
  font: 600 16px var(--sans);
}
.password-form label {
  margin-top: 4px;
  color: var(--ink-body);
  font-size: 13px;
}
.password-form input {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--ink);
  font: 14px var(--sans);
}
.password-form button {
  margin-top: 6px;
  padding: 10px;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font: 600 14px var(--sans);
}
.password-form button:disabled {
  opacity: 0.6;
  cursor: wait;
}
.password-form .password-help,
.account-forgot,
.account-email {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}
.account-email {
  padding: 0 18px 12px;
  color: var(--ink-body);
  font-size: 13px;
}
.account-forgot {
  padding: 0 18px 18px;
}
.account-invite {
  margin: 0 18px 18px;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}
.account-invite h3 {
  margin: 0 0 4px;
  font: 600 16px var(--sans);
}
.account-invite .invite-help {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 12px;
}
.invite-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.invite-row code {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--canvas-bg);
  color: var(--ink);
  font:
    13px ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  overflow-wrap: anywhere;
  user-select: all;
}
.invite-row button {
  padding: 9px 12px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--ink);
  font: 13px var(--sans);
}
.invite-row button:hover {
  background: var(--hover);
}
#inviteClosed {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}
#passwordMessage {
  padding: 8px;
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
}
#passwordMessage.ok {
  background: var(--select-soft);
  color: var(--accent);
}
@media (max-width: 800px) {
  #docDialog:has(.doc-comments:not([hidden])) {
    grid-template-columns: 150px minmax(0, 1fr);
  }
  #docDialog[open] {
    grid-template-columns: 150px minmax(0, 1fr);
    width: calc(100vw - 24px);
    gap: 8px;
  }
  #docDialog .doc-body {
    padding: 24px 20px 60px;
  }
  .doc-comments {
    position: absolute;
    right: 8px;
    top: 60px;
    width: min(280px, 80vw);
    max-height: calc(100% - 80px);
    z-index: 2;
  }
}
@media (max-width: 560px) {
  #docDialog[open],
  #docDialog:has(.doc-comments:not([hidden])) {
    display: flex;
    flex-direction: column;
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
  }
  .doc-paper {
    flex: 1;
    order: 0;
  }
  .doc-toolbar {
    order: 1;
    width: 100%;
    margin: 0;
    padding: 8px;
    max-height: 190px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .doc-toolbar > label {
    display: none;
  }
  .doc-tool-grid {
    grid-column: 1 / -1;
    grid-template-columns: repeat(7, 1fr);
    padding: 6px 0;
  }
  .doc-insert-panel,
  .doc-emojis {
    grid-column: 1 / -1;
  }
  .doc-comments {
    order: 2;
  }
  #docDialog .doc-count {
    font-size: 11px;
  }
}

/* ---------- lines (lines.js) ---------- */
#lines {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
  z-index: 0;
}
#lines .line-hit {
  stroke: transparent;
  stroke-width: 14;
  pointer-events: stroke;
  cursor: pointer;
}
#lines .line-stroke,
#lines .line-ghost {
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
#lines .line-ghost {
  stroke: var(--accent);
  stroke-dasharray: 5 5;
}
#lines .line-head {
  fill: currentColor;
  pointer-events: none;
}
#lines .line.selected .line-hit {
  stroke: var(--select-soft);
}
#lines .line-label {
  fill: var(--ink);
  font: 600 12px var(--sans);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--canvas-bg);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
}
.line-label-edit {
  position: absolute;
  z-index: 100000;
  width: 160px;
  transform: translate(-50%, -50%);
  padding: 4px 8px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--ink);
  font: 12px var(--sans);
  outline: none;
}

/* ---------- sketch ---------- */
.sketch {
  padding: 6px;
}
.sketch .sk-pad {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 400 / 280;
  border-radius: 6px;
  touch-action: none;
}
.sketch.editing .sk-pad {
  cursor: crosshair;
  box-shadow: inset 0 0 0 1px var(--card-border);
}
.sketch .sk-pad path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sketch .skbar {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}
.sketch.editing .skbar {
  display: flex;
}
.sketch .skbar button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--control-border);
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--ink-soft);
  cursor: pointer;
}
.sketch .skbar button.on {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.sketch .sk-size span {
  border-radius: 50%;
  background: var(--ink);
}
.sketch .sk-color {
  width: 16px;
  height: 16px;
}
.sketch .sk-erase svg {
  width: 13px;
  height: 13px;
}

/* ---------- 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 3px calc(var(--indent, 0) * 20px);
  position: relative;
}
.task .grip {
  position: absolute;
  left: calc(var(--indent, 0) * 20px - 16px);
  top: 4px;
  display: grid;
  color: var(--ink-faint);
  opacity: 0;
  cursor: grab;
  touch-action: none;
}
.task .grip svg {
  width: 14px;
  height: 14px;
}
.task:hover .grip,
.task.dragging .grip {
  opacity: 1;
}
@media (hover: none) {
  .task .grip {
    opacity: 0.55; /* no hover to reveal it on touch screens */
  }
}
.task.dragging {
  background: var(--hover);
  border-radius: 6px;
}
.task .tbody {
  flex: 1;
  min-width: 0;
}
.task .tmeta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 1px;
  font-size: 11.5px;
}
.task .tdue,
.task .ttag {
  color: var(--ink-soft);
}
.task .tdue.overdue {
  color: var(--danger);
}
.task input[type='checkbox'] {
  appearance: none;
  width: 17px;
  height: 17px;
  border: 1.6px solid var(--control-border);
  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: var(--ink-body);
  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;
}
.link .lbar {
  height: 6px;
  background: var(--c-blue);
}
.link .lbody {
  padding: 12px 14px;
}
.link .link-preview-image {
  display: block;
  width: 100%;
  max-height: 180px;
  aspect-ratio: 1.91 / 1;
  object-fit: cover;
  background: var(--canvas-bg);
}
.link .link-preview-image[hidden] {
  display: none;
}
.link .link-description {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.link .link-description[hidden] {
  display: none;
}
.link .ltitle {
  font-weight: 600;
  font-size: 13.5px;
  outline: none;
  border: none;
  width: 100%;
  background: none;
  margin-bottom: 4px;
}
.link .lurl {
  font-size: 12px;
  color: var(--accent);
  word-break: break-all;
  outline: none;
  border: none;
  width: 100%;
  background: none;
}
.link a.open {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  display: inline-block;
  margin-top: 6px;
}

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

.image .icaption {
  display: block;
  width: 100%;
  border: none;
  background: none;
  outline: none;
  padding: 6px 4px 0;
  font: 12.5px var(--sans);
  color: var(--ink-soft);
  text-align: center;
}
/* an empty caption only shows while editing */
.image:not(.editing) .icaption:placeholder-shown {
  display: none;
}
.item.image.transparent {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

/* ---------- embeds (YouTube / Vimeo / Spotify link cards) ---------- */
.link .embed-frame {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #000;
}
.link .embed-frame.audio {
  aspect-ratio: auto;
  height: 152px;
  background: none;
}
/* the player only takes the pointer once its card is selected, so it can't
   swallow drags and canvas scrolling */
.link.embed:not(.selected) .embed-frame {
  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, 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;
}

.shortcut .tile {
  position: relative;
}
.shortcut .sc-badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--card-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.board.shortcut .sc-badge svg {
  width: 12px;
  height: 12px;
  color: var(--ink);
}
.shortcut.broken .tile svg {
  color: var(--ink-soft);
}
.shortcut.broken .btitle {
  color: var(--ink-faint);
  text-decoration: line-through;
}

/* ---------- column ---------- */
.column {
  background: var(--column-bg);
  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-count {
  flex: none;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--hover);
  color: var(--ink-soft);
  font: 600 11.5px var(--sans);
  text-align: center;
}
.column .col-fold {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}
.column .col-fold:hover {
  background: var(--hover);
}
.column .col-fold svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s;
}
.column.collapsed .col-fold svg {
  transform: rotate(-90deg);
}
.column.collapsed .col-head {
  margin-bottom: 0;
}
.column.collapsed .col-body {
  display: none;
}
.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, 0.05);
}
.column .col-empty {
  color: var(--ink-faint);
  font-size: 12.5px;
  text-align: center;
  padding: 14px 4px;
  border: 1.5px dashed var(--card-border);
  border-radius: 9px;
}
/* Column children remain in flow, with their controls anchored to each card. */
.item.in-column {
  position: relative !important;
  width: 100% !important;
  box-shadow: none;
  border-color: var(--card-border);
}
.item.in-column:hover {
  box-shadow: var(--card-shadow);
}
.item.in-column .resize {
  display: none;
}

/* ---------- 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;
}

/* ---------- comment ---------- */
.comment {
  padding: 14px 14px 14px 42px;
  background: var(--comment-bg);
  border-color: var(--comment-border);
  position: relative;
}
.comment .cmark {
  position: absolute;
  left: 12px;
  top: 14px;
  color: #c47a3a;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
}
.comment .cmark svg {
  width: 18px;
  height: 18px;
}
.comment .cbody {
  font-size: 13.5px;
  line-height: 1.45;
  border: none;
  outline: none;
  width: 100%;
  background: none;
  color: var(--ink-body);
  resize: none;
  min-height: 20px;
}

/* ---------- file ---------- */
.file {
  padding: 14px 16px;
  gap: 8px;
  align-items: flex-start;
}
.file .ficon {
  color: var(--ink-soft);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
}
.file .ficon svg {
  width: 24px;
  height: 24px;
}
.file .fname {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}
.file .fopen {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}
.file .fmedia {
  width: 100%;
  margin-top: 4px;
  border-radius: 8px;
}

/* ---------- lightbox ---------- */
#lightbox {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
  background: rgba(16, 17, 21, 0.92);
  color: #fff;
}
#lightbox[open] {
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
}
#lightbox img {
  max-width: calc(100vw - 160px);
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 6px;
}
#lightbox .lb-caption {
  padding: 14px 16px 22px;
  font: 14px var(--sans);
  color: #d9dbe0;
  text-align: center;
}
#lightbox .lb-btn {
  position: fixed;
  top: 50%;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
#lightbox .lb-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}
#lightbox .lb-btn[hidden] {
  display: none;
}
#lightbox .lb-prev {
  left: 20px;
}
#lightbox .lb-next {
  right: 20px;
}
#lightbox .lb-close {
  top: 20px;
  right: 20px;
  margin-top: 0;
}
@media (max-width: 640px) {
  #lightbox img {
    max-width: calc(100vw - 24px);
  }
  #lightbox .lb-prev,
  #lightbox .lb-next {
    top: auto;
    bottom: 16px;
    margin-top: 0;
  }
}

.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: var(--rail-bg);
  border: 1px solid var(--rail-border);
  border-radius: 12px;
  box-shadow: var(--card-shadow-hover);
  padding: 12px;
  display: none;
  width: 248px;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow: auto;
}
#palette.open {
  display: block;
}
#palette.board-palette {
  width: 360px;
}
#palette.icon-only {
  width: 360px;
}
#palette.icon-only .icon-grid {
  margin: 0;
}
#palette .sw {
  width: 100%;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
}
#palette .sw:hover {
  transform: scale(1.08);
}
#palette .sw.sel {
  border-color: var(--ink);
}
#palette .pal-sep {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--rail-border);
  margin: 12px 0;
}
#palette .icon-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
#palette .icon-pick {
  width: 100%;
  height: 38px;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--hover);
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
}
#palette .icon-pick:hover {
  background: var(--hover-strong);
}
#palette .icon-pick.sel {
  border-color: var(--accent);
  background: var(--select-soft);
  color: var(--accent);
}
#palette .icon-pick svg {
  width: 18px;
  height: 18px;
}
#palette .color-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
#palette .custom-color {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--ink-soft);
  font: 12px var(--sans);
}
#palette .custom-color label {
  display: flex;
  align-items: center;
  gap: 4px;
}
#palette .custom-color input[type='color'] {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--control-border);
  background: none;
  cursor: pointer;
}
#palette .custom-color input[type='text'] {
  width: 0;
  flex: 1;
  min-width: 55px;
  padding: 5px;
  border: 1px solid var(--control-border);
  border-radius: 5px;
  background: var(--card-bg);
  color: var(--ink);
  font:
    12px ui-monospace,
    monospace;
}
#palette .custom-color button,
.icon-more,
.icon-upload {
  border: 1px solid var(--control-border);
  border-radius: 5px;
  background: var(--card-bg);
  color: var(--ink);
  padding: 6px;
  font: 12px var(--sans);
}
.icon-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 10px;
}
.icon-tabs button {
  padding: 8px 3px;
  border: 0;
  border-radius: 6px;
  background: var(--hover);
  color: var(--ink-body);
  font: 12px var(--sans);
}
.icon-tabs button[aria-selected='true'] {
  background: var(--select-soft);
  color: var(--accent);
}
.board-icon-picker > input {
  width: 100%;
  min-width: 0;
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  color: var(--ink);
  background: var(--card-bg);
  font: 13px var(--sans);
}
.icon-results {
  max-height: 280px;
  overflow-y: auto;
  padding: 2px;
}
.icon-more {
  width: 100%;
  margin-top: 8px;
}
.picker-status,
.icon-results > p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font: 12px var(--sans);
}
.icon-upload-preview {
  display: block;
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin: 10px auto;
}
.icon-upload {
  margin-top: 12px;
  width: 100%;
}
.board-emoji-icon {
  display: inline-block;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  font-size: 26px;
  line-height: 1;
}
.board .tile > .board-emoji-icon {
  font-size: 36px;
}
.board .tile svg {
  color: var(--board-symbol-ink, var(--symbol-on-dark));
}
.board .tile > .board-image-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
#railBoardIconGlyph .board-emoji-icon,
#mfBoardIconGlyph .board-emoji-icon {
  font-size: 22px;
}
#railBoardIconGlyph .board-image-icon,
#mfBoardIconGlyph .board-image-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.item[data-card-color]:not(.board):not(.transparent),
.doc-paper[data-card-color] {
  background: var(--item-bg);
}
.item[data-card-color]:not(.board):not(.selected):not(.transparent) {
  border-color: color-mix(in srgb, var(--item-color) 38%, var(--card-border));
}
.column[data-card-color] > .col-head,
.table[data-card-color] .tgrid th,
.table[data-card-color] .tfooter {
  background: color-mix(in srgb, var(--item-color) 16%, var(--column-bg));
}
.column[data-card-color] > .col-body {
  background: transparent;
}
#docDialog .doc-paper[data-card-color] .doc-bar {
  background: var(--item-bg);
}

/* ---------- context menu ---------- */
#ctxmenu {
  position: fixed;
  z-index: 70;
  min-width: 210px;
  display: none;
  background: var(--rail-bg);
  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: var(--hover);
}
#ctxmenu .ctx-item:disabled {
  opacity: 0.4;
  cursor: default;
}
#ctxmenu .ctx-item.danger {
  color: var(--danger);
}
#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 0.2s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
}
.toast.show.has-action {
  pointer-events: auto;
}
.toast-action {
  margin-left: 14px;
  background: none;
  border: 0;
  padding: 0;
  color: #8ab4ff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- 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,
  textarea,
  input {
    touch-action: pan-y;
  }
  .qn-chips {
    touch-action: pan-x pan-y; /* the search screen's chip row scrolls sideways */
  }
  /* The lock above is for the canvas. In the iOS home-screen app the pan-y
     opt-backs didn't get through it, so Quick notes couldn't scroll there
     (Safari and Chrome tabs were fine). While Quick notes is open it covers
     the canvas, which ignores input, so the lock has nothing to protect. */
  html.qn-open,
  html.qn-open body {
    touch-action: auto;
  }
  .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: var(--rail-bg);
    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: var(--hover);
    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: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ink);
  }

  /* 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: var(--rail-bg);
    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: var(--hover);
    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: var(--rail-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(28, 30, 38, 0.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 {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 86px;
    padding: 8px 12px;
    justify-content: space-between;
  }
  #mfBoard[hidden] {
    display: none;
  }
  .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: var(--hover);
    border: 1px solid var(--card-border);
    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: var(--rail-bg);
    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: var(--danger);
  }
  #mBoardSheet button:hover,
  #mBoardSheet button:active {
    background: var(--hover);
  }

  /* 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: var(--rail-bg);
    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: var(--hover);
  }
}

/* =========================================================================
   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, 0.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(0.32, 0.72, 0.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 0.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;
  overscroll-behavior-y: contain;
  -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 0.15s,
    color 0.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 0.15s,
    border-color 0.15s;
}
.qn-box :is(svg, i) {
  width: 13px;
  height: 13px;
  color: #fff;
  stroke-width: 3.5;
  opacity: 0;
  transition: opacity 0.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, 0.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: 0.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 0.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, 0.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, 0.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: 0.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 0.15s,
    color 0.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, 0.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, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.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, 0.18);
  transform: translateY(110%);
  transition: transform 0.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: var(--danger);
}
.qn-sheet-row.danger :is(svg, i) {
  color: var(--danger);
}
.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);
}
/* tag picker: a toggle per tag, selected ones filled and tinted */
.qn-sheet-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 4px 10px;
}
.qn-sheet-title {
  font-family: var(--qn-serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--qn-head);
}
.qn-sheet-sub {
  font-size: 14px;
  color: var(--qn-muted);
}
.qn-sheet-row.qn-tagrow {
  gap: 14px;
  padding: 14px 12px;
  margin: 2px 0;
  border-bottom: none;
  border-radius: 14px;
  font-weight: 400;
  color: var(--qn-soft);
}
.qn-sheet-row.qn-tagrow.on {
  background: var(--qn-surface);
  font-weight: 600;
  color: var(--qn-head);
}
.qn-tagmark {
  width: 24px;
  height: 24px;
  border: 2px solid var(--qn-faint);
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.qn-sheet-row .qn-tagmark :is(svg, i) {
  width: 14px;
  height: 14px;
  color: #fff;
  stroke-width: 3.5;
  opacity: 0;
}
.qn-tagrow.on .qn-tagmark {
  background: var(--qn-accent);
  border-color: var(--qn-accent);
}
.qn-sheet-row.qn-tagrow.on .qn-tagmark :is(svg, i) {
  opacity: 1;
}
.qn-sheet-field {
  display: flex;
  align-items: center;
  gap: 10px;
  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;
}

.qn-sheet-add {
  flex: 0 0 auto;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--qn-head);
  color: var(--qn-screen);
  font-size: 16px;
  font-weight: 600;
}
.qn-sheet-add:disabled {
  opacity: 0.4;
}

/* 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 var(--qn-bar-hair);
    box-shadow:
      0 8px 28px rgba(28, 30, 38, 0.14),
      0 2px 8px rgba(28, 30, 38, 0.08);
    animation: qn-desk-in 0.18s var(--qn-ease) both;
  }
  body.qn-desk .qn-deskhead {
    display: block;
    flex: 0 0 auto;
    position: relative;
    z-index: 4;
    background: var(--qn-sheet);
    color: var(--qn-head);
    border-radius: 12px 12px 0 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.01em;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--qn-bar-hair);
  }
  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: var(--qn-grab) transparent;
  }
  body.qn-desk .qn-scroll::-webkit-scrollbar {
    display: block;
    width: 7px;
  }
  body.qn-desk .qn-scroll::-webkit-scrollbar-thumb {
    background: var(--qn-grab);
    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(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---- 3D objects: no canvas/model exists until explicitly opened ---- */
.model-card {
  padding: 14px;
}
.model-title {
  width: 100%;
  border: none;
  outline: none;
  background: none;
  color: var(--ink);
  font: 600 15px var(--sans);
}
.model-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  color: var(--ink-body);
  overflow-wrap: anywhere;
  font-size: 13px;
}
.model-summary svg {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  color: var(--ink-soft);
}
.model-file-info,
.model-format-help,
.model-status {
  margin: 8px 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.5;
}
.model-status:empty {
  display: none;
}
.model-status[data-state='error'],
#modelDialogStatus[data-state='error'] {
  color: var(--danger);
}
.model-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 12px 0 5px;
}
.model-actions button,
.model-dialog-head button,
.model-dialog-foot button {
  border: 1px solid var(--control-border);
  border-radius: 6px;
  padding: 7px 9px;
  background: var(--rail-bg);
  color: var(--ink);
  font: 12px var(--sans);
  cursor: pointer;
}
.model-actions button:disabled,
.model-dialog-foot button:disabled {
  opacity: 0.45;
  cursor: default;
}
.model-actions button svg {
  width: 16px;
  height: 16px;
  display: block;
}
.model-eye[aria-pressed='true'] {
  color: var(--accent);
  background: var(--select-soft);
}
.model-download {
  color: var(--accent);
  font-size: 11px;
}
.model-preview {
  width: 100%;
  height: 190px;
  margin-top: 10px;
  border: 1px solid var(--card-border);
  border-radius: 7px;
  background: var(--canvas-bg);
  overflow: hidden;
  touch-action: none;
}
.model-preview[hidden],
.model-download[hidden] {
  display: none;
}
.model-preview canvas,
.model-dialog-host canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}
#modelDialog {
  padding: 0;
  width: min(1100px, calc(100vw - 32px));
  height: min(800px, calc(100dvh - 40px));
  max-width: none;
  max-height: none;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--rail-bg);
  color: var(--ink);
  box-shadow: var(--card-shadow-hover);
  font-family: var(--sans);
}
#modelDialog[open] {
  display: flex;
  flex-direction: column;
}
#modelDialog::backdrop {
  background: var(--canvas-bg);
  opacity: 0.75;
}
.model-dialog-head,
.model-dialog-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
}
.model-dialog-head h2 {
  flex: 1;
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 17px;
}
.model-dialog-host {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: var(--canvas-bg);
  touch-action: none;
}
#modelDialogStatus {
  flex: 1;
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

/* ---- Hashtags: inline decorations, plain-field mirrors and global browser ---- */
.hashtag-badge {
  background: var(--select-soft);
  color: var(--accent);
  border-radius: 5px;
  padding: 1px 4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  overflow-wrap: anywhere;
}
.card-hashtags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 10px 9px;
}
.card-hashtags button {
  border: none;
  cursor: pointer;
  font: 12px var(--sans);
}
.hashtag-field {
  position: relative;
  min-width: 0;
  width: 100%;
}
.hashtag-field-preview {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  display: none;
  color: var(--ink-body);
}
.hashtag-field.has-hashtags:not(:focus-within) > .hashtag-field-preview {
  display: block;
}
.hashtag-field.has-hashtags:not(:focus-within) > input,
.hashtag-field.has-hashtags:not(:focus-within) > textarea {
  color: transparent;
}
dialog#hashtagsDialog {
  width: min(960px, calc(100vw - 32px));
  max-height: min(780px, calc(100dvh - 40px));
}
#hashtagsDialog .trash-head h2 {
  flex: 1;
}
.hashtags-workspace {
  display: flex;
  height: min(620px, calc(100dvh - 140px));
  min-height: 300px;
  overflow: hidden;
  border-top: 1px solid var(--card-border);
}
.hashtags-sidebar {
  width: 240px;
  flex-shrink: 0;
  padding: 14px;
  overflow-y: auto;
  border-right: 1px solid var(--card-border);
}
#hashtagsFilter {
  width: 100%;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  padding: 8px;
  background: var(--card-bg);
  color: var(--ink);
  font: 13px var(--sans);
}
.hashtags-help,
#hashtagsStatus {
  color: var(--ink-soft);
  font-size: 12px;
}
.hashtags-category {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: none;
  border-radius: 6px;
  padding: 9px;
  background: none;
  color: var(--ink);
  text-align: left;
  font: 13px var(--sans);
  overflow-wrap: anywhere;
  cursor: pointer;
}
.hashtags-category:hover {
  background: var(--hover);
}
.hashtags-category[aria-pressed='true'] {
  background: var(--select-soft);
  color: var(--accent);
}
.hashtags-count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.hashtags-matches {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}
#hashtagsSelection {
  margin: 0;
  font-size: 17px;
}
#hashtagsResults {
  list-style: none;
  margin: 0;
  padding: 0;
}
.hashtag-result {
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  border-radius: 8px;
  padding: 14px;
  margin: 12px 0;
}
.hashtag-result header {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--ink-soft);
  font-size: 12px;
}
.hashtag-result header svg {
  width: 16px;
  height: 16px;
}
.hashtag-result h4 {
  margin: 10px 0 4px;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.hashtag-path {
  color: var(--ink-soft);
  font-size: 11px;
}
.hashtag-snippet {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.hashtag-table-preview {
  table-layout: fixed;
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  margin-bottom: 12px;
}
.hashtag-table-preview td {
  border: 1px solid var(--card-border);
  padding: 5px;
  overflow-wrap: anywhere;
}
.hashtag-result footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}
.hashtag-result footer button {
  border: 1px solid var(--control-border);
  border-radius: 5px;
  padding: 6px 10px;
  background: var(--rail-bg);
  color: var(--ink);
  cursor: pointer;
}
.hashtag-result footer a {
  color: var(--accent);
  font-size: 12px;
}
@media (max-width: 600px) {
  .hashtags-workspace {
    flex-direction: column;
  }
  .hashtags-sidebar {
    width: 100%;
    max-height: 30dvh;
    border-right: none;
    border-bottom: 1px solid var(--card-border);
  }
}

/* ---- Trash sheet ------------------------------------------------------- */
#trashDialog,
#shortcutsDialog,
#templateDialog,
#labelDialog,
#searchDialog,
#hashtagsDialog,
#accountDialog {
  background: var(--rail-bg);
  width: min(440px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 64px));
  padding: 0;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow-hover);
  color: var(--ink);
  font-family: var(--sans);
}
#trashDialog[open],
#shortcutsDialog[open],
#templateDialog[open],
#labelDialog[open],
#searchDialog[open],
#hashtagsDialog[open],
#accountDialog[open] {
  display: flex;
  flex-direction: column;
}
#accountDialog[open] {
  overflow-y: auto;
  max-height: min(620px, calc(100dvh - 32px));
}
#trashDialog::backdrop,
#shortcutsDialog::backdrop,
#templateDialog::backdrop,
#labelDialog::backdrop,
#searchDialog::backdrop,
#hashtagsDialog::backdrop,
#accountDialog::backdrop {
  background: rgba(28, 30, 38, 0.25);
}
.trash-head,
.trash-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 12px 18px;
}
.trash-head h2 {
  margin: 0;
  font: 600 17px var(--sans);
}
.trash-foot {
  border-top: 1px solid var(--card-border);
  justify-content: flex-end;
}
#trashList {
  list-style: none;
  margin: 0;
  padding: 0 8px;
  overflow-y: auto;
}
#trashList li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
}
#trashList li:hover {
  background: var(--hover);
}
.trash-icon {
  flex: none;
  color: var(--ink-soft);
}
.trash-icon :is(svg, i) {
  width: 18px;
  height: 18px;
  display: block;
}
.trash-text {
  flex: 1;
  min-width: 0;
}
.trash-name,
.trash-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trash-name {
  font-size: 14px;
}
.trash-meta {
  font-size: 12px;
  color: var(--ink-soft);
}
.trash-restore,
.trash-empty {
  flex: none;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  border-radius: 8px;
  padding: 6px 12px;
  font: 500 13px var(--sans);
  color: var(--ink);
  cursor: pointer;
}
.trash-restore:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.trash-restore:disabled {
  color: var(--ink-faint);
  cursor: not-allowed;
}
.trash-empty {
  color: var(--danger);
}
.trash-empty:hover:not(:disabled) {
  background: var(--danger-soft);
}
.trash-empty:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#trashEmptyNote {
  margin: 0;
  padding: 24px 18px;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---- Selection box + space-to-pan -------------------------------------- */
.marquee {
  position: absolute;
  z-index: 50;
  border: 1px solid var(--select);
  background: color-mix(in srgb, var(--select) 10%, transparent);
  border-radius: 2px;
  pointer-events: none;
}
#stage.space-pan,
#stage.space-pan .item {
  cursor: grab;
}
#stage.space-pan.panning,
#stage.space-pan.panning .item {
  cursor: grabbing;
}

/* ---- Shortcuts sheet --------------------------------------------------- */
.shortcuts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  margin: 0;
  padding: 4px 18px 18px;
  overflow-y: auto;
  font-size: 13px;
}
.shortcuts dt {
  font-family: ui-monospace, monospace;
  color: var(--ink-soft);
}
.shortcuts dd {
  margin: 0;
}

/* Palette "None" swatch: a struck-through blank. */
#palette .sw-none {
  background: linear-gradient(to top right, transparent 46%, #c4c6cc 46% 54%, transparent 54%), var(--rail-bg);
  border-color: var(--rail-border);
}

#crumbs .crumb-input {
  font: inherit;
  font-weight: 600;
  padding: 3px 8px;
  border: 1px solid var(--rail-border);
  border-radius: 7px;
  max-width: 240px;
}
#crumbs .crumb.current {
  cursor: text;
}

/* ---- Rich text (note / comment bodies) --------------------------------- */
.rich {
  min-height: 1.5em;
  overflow-wrap: anywhere;
  cursor: text;
}
.item:not(.editing) .rich {
  cursor: inherit;
}
.rich .ProseMirror {
  outline: none;
}
.rich :is(p, h1, h2, h3, h4, h5, h6, ul, ol, blockquote, pre) {
  margin: 0 0 6px;
}
.rich > :last-child,
.rich .ProseMirror > :last-child {
  margin-bottom: 0;
}
.rich :is(h1, h2, h3, h4) {
  font-family: var(--serif);
  color: var(--ink);
  line-height: 1.25;
}
.rich h1 {
  font-size: 20px;
}
.rich h2 {
  font-size: 16px;
}
.rich h3 {
  font-size: 14.5px;
}
.rich h4 {
  font-size: 13.5px;
}
.rich :is(ul, ol) {
  padding-left: 20px;
}
.rich ul[data-type='taskList'] {
  list-style: none;
  padding-left: 2px;
}
.rich ul[data-type='taskList'] li {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.rich ul[data-type='taskList'] li > label,
.rich ul[data-type='taskList'] li > input {
  margin-top: 3px;
}
.rich ul[data-type='taskList'] li > div {
  flex: 1;
  min-width: 0;
}
.rich li[data-checked='true'] > div {
  color: var(--ink-soft);
  text-decoration: line-through;
}
.rich blockquote {
  background: var(--hover);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--ink-soft);
  font-style: italic;
}
.rich code {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
  background: var(--hover);
  border-radius: 4px;
  padding: 1px 4px;
}
.rich pre {
  background: var(--hover);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
}
.rich pre code {
  background: none;
  padding: 0;
}
.rich mark {
  background: #fde68a;
  color: #2b2d31; /* dark ink on the yellow fill, in both themes */
  border-radius: 2px;
}
.rich a {
  color: var(--c-blue);
  text-decoration: underline;
}
.rich hr {
  border: none;
  border-top: 1px solid var(--rail-border);
  margin: 8px 0;
}
/* Placeholder: TipTap's on the editor, ours on an empty static body. */
.rich[data-empty]::before,
.rich .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: var(--ink-faint);
  pointer-events: none;
}
.rich .ProseMirror p.is-editor-empty:first-child::before {
  float: left;
  height: 0;
}
.rich[data-empty] > p:only-child {
  display: none;
}

/* ---- Search ------------------------------------------------------------- */
#searchDialog {
  margin-top: 12vh;
  width: min(560px, calc(100vw - 32px));
}
#searchInput {
  font: 16px var(--sans);
  padding: 14px 18px;
  border: none;
  border-bottom: 1px solid var(--card-border);
  outline: none;
  color: var(--ink);
  background: none;
}
#searchResults {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
}
#searchResults:empty {
  display: none;
}
.sr-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.sr-item:hover,
.sr-item:focus-visible {
  background: var(--hover);
}
.sr-item :is(svg, i) {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--ink-soft);
}
.sr-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sr-title,
.sr-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sr-path {
  font-size: 12px;
  color: var(--ink-soft);
}
#searchEmpty {
  margin: 0;
  padding: 14px 18px;
  color: var(--ink-soft);
}

/* ---- Export menu -------------------------------------------------------- */
#exportMenu,
#filterMenu {
  position: fixed;
  z-index: 70;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  padding: 6px;
  background: var(--rail-bg);
  border: 1px solid var(--rail-border);
  border-radius: 10px;
  box-shadow: var(--card-shadow-hover);
}
#exportMenu[hidden],
#filterMenu[hidden] {
  display: none;
}
#exportMenu a {
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
}
#exportMenu a:hover {
  background: var(--hover);
}
.top-right button.ghost {
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

#templateList {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow: auto;
}
#templateList .tpl-pick {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font: 600 14px var(--serif);
  text-align: left;
  cursor: pointer;
}
#templateList .tpl-pick:hover {
  background: var(--hover);
}

/* ---------- labels (labels.js) ---------- */
.card-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.col-head .card-labels {
  margin: 0;
}
.label-chip {
  padding: 1px 7px;
  border-radius: 9px;
  color: #fff;
  font: 600 11px var(--sans);
  white-space: nowrap;
}
.label-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.item.filtered-out {
  opacity: 0.18;
}
body.filter-hide .item.filtered-out {
  display: none;
}
#filterBtn.on {
  color: var(--accent);
  font-weight: 600;
}
#filterMenu {
  max-width: 300px;
}
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--ink);
  cursor: pointer;
}
.filter-row:hover {
  background: var(--hover);
}
.filter-mode {
  margin-top: 4px;
  border-top: 1px solid var(--rail-border);
  border-radius: 0;
  color: var(--ink-soft);
}
.filter-empty {
  margin: 6px 10px;
  color: var(--ink-soft);
  font-size: 13px;
}
#labelList {
  padding: 6px;
  overflow: auto;
}
#labelNew {
  margin: 6px 12px 14px;
  padding: 8px 10px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--ink);
  font: 14px var(--sans);
}
