html, body { margin: 0; user-select: none; -webkit-user-select: none; height: 100%; overflow: hidden; background: #fafaf8; color: #222; font-family: system-ui, sans-serif; }
#canvas {
  position: fixed; inset: 0; overflow: hidden; touch-action: none;
  background: #fafaf8 radial-gradient(#d9d9d4 1px, transparent 1px) 0 0 / 18px 18px;
}
/* A note's card and body clip or scroll, which makes each a scroll container, and a browser only
   reads touch-action up to the nearest one: without this a finger on a note is the browser's to
   pan, and the drag gets a pointercancel. The open editor keeps vertical scrolling for long notes. */
#canvas * { touch-action: none; }
#canvas .pocket-body[contenteditable="true"] { touch-action: pan-y; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
#frames { position: absolute; left: 0; top: 0; pointer-events: none; }
#links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
#clusters { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.bar {
  position: fixed; z-index: 10; display: flex; gap: 6px; align-items: center; padding: 6px;
  background: #fff; border: 1px solid #d6d6d0; border-radius: 12px; font-size: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
}
#topbar { left: 10px; top: 10px; z-index: 15; } /* above #rail and the edge picker so the board menu isn't covered; toast is 20 */
#status-wrap { right: 10px; top: 10px; }
#rail { left: 10px; top: 70px; flex-direction: column; }
.tool {
  width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; color: #555;
  font-size: 15px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.tool:disabled { opacity: .35; cursor: default; }
.tool[aria-pressed="true"] { background: #4a9a2e; color: #fff; }
.pill {
  border: 1px solid #d6d6d0; border-radius: 8px; padding: 5px 9px; font-size: 12px; color: #333;
  background: #fff; white-space: nowrap; font-family: inherit;
}
button.pill { cursor: pointer; }
input.pill { user-select: text; -webkit-user-select: text; width: 110px; outline: none; }
input.pill:focus { border-color: #4a9a2e; }
#chip {
  position: fixed; z-index: 10; transform: translate(-50%, -100%); display: flex; align-items: center; gap: 2px;
  background: #fff; border: 1px solid #d6d6d0; color: #555; border-radius: 99px; padding: 2px 4px;
  font-size: 11px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}
#chip > span { padding: 0 8px; }
.chip-btn { border: 0; background: none; border-radius: 99px; padding: 3px 8px; font: inherit; color: #333; cursor: pointer; }
.chip-btn:hover { background: #f1f1ec; }
.chip-btn:last-child { color: #b7650c; }
#marquee { position: absolute; border: 1px solid #4a9a2e; background: rgba(74, 154, 46, .08); pointer-events: none; }
#toast {
  position: fixed; z-index: 20; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: #222; color: #fff; border-radius: 8px; padding: 8px 14px; font-size: 13px;
}
#dialog { position: fixed; inset: 0; z-index: 31; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .35); }
.dialog-panel { background: #fff; border-radius: 12px; padding: 20px; width: min(360px, calc(100vw - 32px)); box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.dialog-panel h2 { margin: 0 0 6px; font-size: 16px; }
.dialog-panel p { margin: 0 0 16px; font-size: 14px; color: #444; white-space: pre-line; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.dialog-btn { border: 1px solid #d4d4cc; background: #fff; border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.dialog-btn:hover { background: #f1f1ec; }
#popover { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .7); }
#popover[hidden] { display: none; }
.popover-panel { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 92vw; }
.popover-image { max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: 6px; }
.popover-missing { padding: 40px 60px; background: #fff; border-radius: 8px; color: #666; font-size: 14px; }
.popover-caption { margin: 0; color: #fff; font-size: 14px; text-align: center; }
.popover-close { position: fixed; top: 14px; right: 14px; border: 0; border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 13px; background: #fff; cursor: pointer; }
.dialog-btn[data-tone="danger"] { background: #c0392b; border-color: #c0392b; color: #fff; }
[hidden] { display: none !important; }

/* App shell: tabs always; the canvas and board pills only on a board (body.on-board) */
.tabs { display: flex; gap: 4px; }
a.tab, #board-back { text-decoration: none; }
.tab[aria-current="page"] { background: #4a9a2e; border-color: #4a9a2e; color: #fff; }
body:not(.on-board) :is(#canvas, #rail, #edge-picker, #chip, #board-back, #board-name, #board-menu, #tag-filter, #tags-button, #tag-panel, #outlines-button, #outline-panel, #shelf-button, #shelf, #shelf-close, #mode-bar, #action-strip) { display: none !important; }
.page {
  position: fixed; inset: 0; overflow-y: auto; box-sizing: border-box; padding: 64px 16px 32px;
  user-select: text; -webkit-user-select: text;
}
.page > * { max-width: 720px; margin-left: auto; margin-right: auto; }
body:not(.on-board):not(.on-node) #status-wrap { display: none !important; }
#account { display: flex; gap: 6px; align-items: center; }
#account:empty { display: none; }
.account-name { color: #555; padding: 0 4px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-panel {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-top: 15vh;
  background: #fff; border: 1px solid #d6d6d0; border-radius: 12px; padding: 20px; font-size: 14px;
}
.auth-panel p { margin: 0; }
.auth-sub { display: block; user-select: all; -webkit-user-select: all; word-break: break-all; font-size: 13px; color: #444; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.page-title { margin: 0; font-size: 20px; }
.page-form .menu-form { margin-bottom: 12px; }
.list { display: flex; flex-direction: column; background: #fff; border: 1px solid #d6d6d0; border-radius: 12px; overflow: hidden; }
.list:has(.list-empty) { background: none; border: 0; }
.list-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: baseline; padding: 12px 14px;
  border-top: 1px solid #ecece6; color: inherit; text-decoration: none; font-size: 14px;
}
.list-row:first-child { border-top: 0; }
.list-row:hover { background: #f6f6f1; }
.list-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.list-row-count, .list-row-time { color: #777; font-size: 12px; white-space: nowrap; }
.board-row { grid-template-columns: 1fr auto auto auto; cursor: pointer; }
.board-row .list-row-name { color: inherit; text-decoration: none; }
.list-row-delete {
  border: 0; background: none; padding: 2px 4px; margin: -2px -4px; color: #999; font-size: 12px; font-family: inherit; cursor: pointer;
}
.list-row-delete:hover, .list-row-delete:focus-visible { color: #c0392b; text-decoration: underline; }
.list-row-delete:disabled { color: #ccc; cursor: default; text-decoration: none; }
.list-empty { color: #777; font-size: 14px; text-align: center; padding: 32px 0; }

/* Notes tab: filter bar, rows with a tag-colour band, the boards popover */
.page-actions { display: flex; gap: 6px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; font-size: 12px; }
.filters .filters-search { flex: 1 1 160px; width: auto; min-width: 0; }
.filters-tags { position: relative; flex: 1 1 120px; display: flex; }
.filters-tags .filters-tags-input { flex: 1 1 auto; width: auto; min-width: 0; }
.filters-tags .tag-suggest { top: 100%; left: 0; max-width: none; }
select.pill { max-width: 160px; cursor: pointer; }
.filters-kind { display: flex; gap: 2px; }
.filters-kind-btn[aria-pressed="true"] { background: #4a9a2e; border-color: #4a9a2e; color: #fff; }
.filters-tag-colours { position: relative; }
.filters-toggle, .fab, .page-more { display: none; }
.filters-fold { display: contents; }
.notes-tag-panel {
  position: absolute; z-index: 15; right: 0; top: calc(100% + 4px); width: min(280px, calc(100vw - 32px)); max-height: 60vh; overflow-y: auto; padding: 8px;
  background: #fff; border: 1px solid #d6d6d0; border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
  display: flex; flex-direction: column; gap: 2px; font-size: 13px; user-select: none;
}
.notes-drop { border-radius: 12px; }
.notes-drop-active { outline: 2px dashed #4a9a2e; outline-offset: 4px; }
.list-row.note-row {
  grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; cursor: pointer;
  border-left: 4px solid var(--band, transparent); padding-left: 10px;
}
.note-row-icon { width: 18px; color: #8a8a82; font-size: 14px; line-height: 1.4; text-align: center; }
.note-row-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.note-row-title { color: inherit; text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-row-snippet { color: #666; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-row-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.note-row-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row-on-board { background: #f6faf3; }
.row-on-board-label { color: #4a9a2e; font-size: 11px; white-space: nowrap; }
.row-boards {
  border: 1px solid #e3e3dc; border-radius: 99px; background: #f1f1ec; color: #555; font: inherit; font-size: 11px;
  padding: 1px 8px; cursor: pointer; white-space: nowrap;
}
.row-boards:hover, .row-boards[aria-expanded="true"] { border-color: #4a9a2e; color: #2f6b2a; }
.list-more-wrap { display: flex; justify-content: center; padding: 12px 0; }

/* Notes shelf: the notes list over the right of the canvas; rows drag onto the board */
#shelf-button[aria-pressed="true"] { background: #4a9a2e; border-color: #4a9a2e; color: #fff; }
.shelf {
  position: fixed; z-index: 12; top: 56px; right: 10px; bottom: 10px; width: 360px; max-width: calc(100vw - 32px);
  box-sizing: border-box; overflow-y: auto; padding: 10px; background: #fafaf8; border: 1px solid #d6d6d0;
  border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}
.shelf .filters { margin-bottom: 8px; }
.shelf .list-row { gap: 8px; padding: 9px 10px 9px 8px; font-size: 13px; }
.shelf .note-row { cursor: grab; -webkit-touch-callout: none; }
.shelf .note-row.row-on-board { cursor: default; opacity: .55; }
.shelf-ghost {
  position: fixed; z-index: 30; left: 0; top: 0; max-width: 220px; margin: -16px 0 0 -16px; padding: 6px 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none;
  background: #fff; border: 1px solid #4a9a2e; border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); font-size: 13px;
}
@media (max-width: 420px) {
  .shelf { left: 10px; right: 10px; width: auto; max-width: none; }
}
.boards-popover {
  position: fixed; z-index: 25; min-width: 180px; max-width: min(280px, calc(100vw - 16px)); padding: 6px;
  background: #fff; border: 1px solid #d6d6d0; border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); font-size: 13px;
}
.boards-popover-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.boards-popover-row { display: flex; align-items: center; gap: 12px; padding: 5px 8px; border-radius: 8px; }
.boards-popover-row:hover { background: #f1f1ec; }
.boards-popover-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boards-popover-open { color: #2f6b2a; text-decoration: none; font-size: 12px; }
.boards-popover-open:hover { text-decoration: underline; }

/* Frames: click-through interior; only the tab, edge strips and handle take pointer events */
.frame {
  --band: calc(10px * var(--inv-scale, 1));
  --tab-k: clamp(1, var(--inv-scale, 1), 4);
  position: absolute; box-sizing: border-box; pointer-events: none;
  border: 1.5px dashed #b8b8b0; background: rgba(0, 0, 0, .025);
}
.frame-tab {
  position: absolute; left: -1.5px; bottom: 100%; max-width: 100%; box-sizing: border-box; pointer-events: auto; cursor: grab;
  background: #e6e6e0; color: #444; font-size: calc(13px * var(--tab-k)); line-height: 1.3;
  padding: calc(3px * var(--tab-k)) calc(10px * var(--tab-k)); border-radius: calc(6px * var(--tab-k)) calc(6px * var(--tab-k)) 0 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none;
}
.frame-edge { position: absolute; pointer-events: auto; cursor: grab; }
.frame-edge-top, .frame-edge-bottom { left: calc(var(--band) / -2); right: calc(var(--band) / -2); height: var(--band); }
.frame-edge-left, .frame-edge-right { top: calc(var(--band) / -2); bottom: calc(var(--band) / -2); width: var(--band); }
.frame-edge-top { top: calc(var(--band) / -2); }
.frame-edge-bottom { bottom: calc(var(--band) / -2); }
.frame-edge-left { left: calc(var(--band) / -2); }
.frame-edge-right { right: calc(var(--band) / -2); }
.frame-resize { position: absolute; right: 0; bottom: 0; pointer-events: auto; --hit: calc(24px * var(--inv-scale, 1)); width: min(var(--hit), 50%); height: min(var(--hit), 50%); cursor: nwse-resize; touch-action: none; }
.frame-resize::after {
  content: ''; position: absolute; right: calc(3px * var(--inv-scale, 1)); bottom: calc(3px * var(--inv-scale, 1)); width: calc(9px * var(--inv-scale, 1)); height: calc(9px * var(--inv-scale, 1));
  border-right: calc(2px * var(--inv-scale, 1)) solid #4a9a2e; border-bottom: calc(2px * var(--inv-scale, 1)) solid #4a9a2e; border-bottom-right-radius: 3px;
}
.frame-drop { border: 1.5px solid #4a9a2e; }
.frame-selected { border: 1.5px solid #4a9a2e; }
.frame-selected .frame-tab { background: #4a9a2e; color: #fff; }
.frame-invalid { border: 1.5px solid #e8890c; }

#frame-preview {
  position: absolute; z-index: 5; box-sizing: border-box; pointer-events: none;
  border: 1.5px dashed #4a9a2e; background: rgba(74, 154, 46, .06);
}
#frame-preview.frame-preview-invalid { border: 1.5px solid #e8890c; background: rgba(232, 137, 12, .06); }
.frame-titling .frame-tab { visibility: hidden; }
.frame-title-input {
  position: absolute; left: -1.5px; bottom: 100%; width: calc(260px * var(--tab-k)); max-width: 100%; box-sizing: border-box; pointer-events: auto;
  font: inherit; font-size: calc(13px * var(--tab-k)); line-height: 1.3; color: #222; background: #fff;
  border: 1px solid #4a9a2e; outline: none; padding: calc(3px * var(--tab-k)) calc(10px * var(--tab-k));
  border-radius: calc(6px * var(--tab-k)) calc(6px * var(--tab-k)) 0 0; user-select: text; -webkit-user-select: text;
}

/* Note and image pages: the card's typography at reading width */
.node-page-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.node-page-bar a.pill { text-decoration: none; }
.node-page-spacer { flex: 1 1 auto; }
.node-page-delete:hover { border-color: #c0392b; color: #c0392b; }
.node-page-meta { color: #777; font-size: 12px; margin-top: 10px; }
.node-page-actions { display: flex; gap: 6px; margin-top: 10px; }
.note-page-card {
  display: flex; flex-direction: column; background: #fff; border: 1px solid #d6d6d0; border-radius: 10px;
  border-left: 5px solid var(--band, #d6d6d0); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); font-size: 15px; line-height: 1.5;
}
.note-page .note-page-body { min-height: 40vh; padding: 16px 18px; flex: 1 1 auto; }
.note-page-tag-wrap { position: relative; display: flex; padding: 0 0 4px; }
.note-page-tag-wrap .pocket-tag-input { flex: 1 1 auto; min-width: 0; margin: 0 14px 10px; font-size: 13px; }
.note-page-tag-wrap .tag-suggest { top: calc(100% - 8px); left: 14px; }
/* Doc pages: Ravel's page read-only, in one serif at one size and colour */
.doc-page {
  min-height: 40vh; padding: 20px 24px; flex: 1 1 auto; user-select: text; -webkit-user-select: text;
  font-family: Georgia, 'Times New Roman', serif; font-size: 17px; line-height: 1.6; color: #222; overflow-wrap: anywhere;
}
.doc-page p { margin: 0; text-indent: 1.5em; white-space: pre-wrap; }
.doc-page p.flush { text-indent: 0; }
.doc-page p:empty { min-height: 1.6em; }
.doc-page span.i { font-style: italic; }
.doc-page span.b { font-weight: bold; }
.doc-page span.u { text-decoration: underline; }
a.doc-page-ravel { text-decoration: none; color: inherit; }
a.doc-page-ravel[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.image-page-frame { background: #f1f1ec; border-radius: 10px; overflow: hidden; }
.image-page-img { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain; }
.image-page-caption {
  display: block; width: 100%; box-sizing: border-box; margin-top: 10px; padding: 6px 10px; font: inherit; font-size: 14px; color: #333;
  background: #fff; border: 1px solid #d6d6d0; border-radius: 8px; outline: none;
}
.image-page-caption:focus { border-color: #4a9a2e; }

/* Pockets */
.pocket {
  position: absolute; box-sizing: border-box; background: #fff; border: 1px solid #d6d6d0; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08); font-size: 14px; line-height: 1.4; overflow: hidden;
  display: flex; flex-direction: column; user-select: none;
}
.pocket-selected { border-color: #4a9a2e; outline: 2px solid #4a9a2e; outline-offset: -1px; }
.pocket-dimmed { opacity: .3; }
.pocket-body { padding: 8px 10px; flex: 1 1 auto; min-height: 0; overflow-wrap: anywhere; }
.pocket-full .pocket-body { overflow: auto; }
.pocket-card .pocket-body { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pocket-tags { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px 8px; flex: 0 0 auto; }
/* Beats the selected and editing border colours so the band always shows. */
.pocket.pocket-banded { border-left: 5px solid var(--band); }
.pocket-tag-dot { display: inline-block; width: 7px; height: 7px; border-radius: 99px; margin-right: 4px; vertical-align: 0; }
.pocket-tag { background: #f1f1ec; border: 1px solid #e3e3dc; border-radius: 99px; padding: 0 7px; font-size: 11px; color: #555; white-space: nowrap; }
.pocket-tag-anno { border-style: dashed; background: #fff; }
.pocket-tag-anno svg { display: inline-block; margin-right: 3px; vertical-align: -1px; } /* Tailwind's preflight makes svg a block */
/* On more than one board: the Notes list's marker, top right of the card. */
.pocket-shared {
  position: absolute; top: 4px; right: 4px; z-index: 1; border: 1px solid #e3e3dc; border-radius: 99px; background: #f1f1ec;
  color: #555; font: inherit; font-size: 11px; line-height: 1.4; padding: 0 7px; cursor: pointer; white-space: nowrap;
}
.pocket-shared:hover, .pocket-shared[aria-expanded="true"] { border-color: #4a9a2e; color: #2f6b2a; }
.pocket-shared[hidden] { display: none; }
.pocket-is-shared .pocket-body { padding-right: 44px; }
.pocket-resize { position: absolute; right: 0; bottom: 0; --hit: calc(24px * var(--inv-scale, 1)); width: min(var(--hit), 50%); height: min(var(--hit), 50%); cursor: nwse-resize; touch-action: none; }
.pocket-resize::after {
  content: ''; position: absolute; right: calc(3px * var(--inv-scale, 1)); bottom: calc(3px * var(--inv-scale, 1)); width: calc(9px * var(--inv-scale, 1)); height: calc(9px * var(--inv-scale, 1));
  border-right: calc(2px * var(--inv-scale, 1)) solid #b8b8b0; border-bottom: calc(2px * var(--inv-scale, 1)) solid #b8b8b0; border-bottom-right-radius: 3px;
}

/* Images: no border, shadow or radius, so the picture box is exactly w x h and never distorts. */
.pocket[data-kind="image"] { overflow: visible; background: none; border: 0; box-shadow: none; border-radius: 0; }
.pocket[data-kind="image"].pocket-selected { outline: 2px solid #4a9a2e; outline-offset: 0; }
.pocket-image { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: #f1f1ec; }
.pocket-image img { width: 100%; height: 100%; object-fit: fill; display: block; }
.image-icon, .image-missing { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; color: #8a8a82; }
.image-missing { display: flex; font-size: 12px; text-align: center; }
.image-missing[hidden], .image-picture[hidden], .image-caption[hidden] { display: none; }
.image-icon svg { width: 60%; height: 60%; }
.image-icon-mode .image-icon { display: flex; }
.image-outlines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.image-outlines * { fill: none; stroke-linejoin: round; }
.outline-under * { stroke: rgba(0, 0, 0, .35); stroke-width: 3px; }
.outline-over * { stroke: rgba(255, 255, 255, .85); stroke-width: 1.5px; }
.image-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.image-label {
  position: absolute; transform: translateY(-100%); white-space: nowrap; padding: 0 3px;
  font-size: calc(11px * var(--inv-scale, 1)); line-height: 1.3; color: #fff; background: rgba(0, 0, 0, .55); border-radius: 2px;
}
.image-label-below { transform: none; }
.image-icon-mode .image-outlines, .image-icon-mode .image-labels { display: none; }
.image-icon-mode .image-picture, .image-icon-mode .image-missing { display: none; }
.image-caption {
  position: absolute; top: 100%; left: 0; right: 0; padding: 2px 2px 0; pointer-events: auto;
  font-size: 12px; line-height: 1.3; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pocket-selected .image-caption:empty::before { content: 'Add caption'; color: #a0a098; }
.image-captioning .image-caption { color: transparent; }
.image-caption-input {
  display: block; width: 100%; box-sizing: border-box; font: inherit; color: #222; background: #fff;
  border: 1px solid #4a9a2e; border-radius: 4px; outline: none; padding: 1px 4px; user-select: text; -webkit-user-select: text;
}

.pocket-editing { border-color: #4a9a2e; user-select: text; -webkit-user-select: text; }
.pocket-editing .pocket-tags { display: none; }
.pocket-body[contenteditable="true"] { outline: none; cursor: text; user-select: text; -webkit-user-select: text; }
.pocket-tag-input {
  flex: 0 0 auto; margin: 0 10px 8px; padding: 2px 7px; font: inherit; font-size: 12px; color: #444;
  border: 1px solid #e3e3dc; border-radius: 99px; outline: none; background: #fafaf8; user-select: text;
}
.pocket-tag-input:focus { border-color: #4a9a2e; }
.pocket-editing { overflow: visible; }
.tag-suggest {
  position: absolute; z-index: 5; min-width: 120px; max-width: 90%; margin: 2px 0 0; padding: 3px; list-style: none; box-sizing: border-box;
  background: #fff; border: 1px solid #d6d6d0; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, .15); font-size: 12px; user-select: none;
}
.tag-suggest[hidden] { display: none; }
.tag-suggest li { padding: 3px 8px; border-radius: 5px; cursor: pointer; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-suggest li.tag-suggest-active, .tag-suggest li:hover { background: #eaf3e5; }
#chip .chip-url { width: 200px; border: 1px solid #d6d6d0; border-radius: 99px; padding: 2px 8px; font: inherit; color: #333; }

/* Links */
.link-hit { cursor: pointer; }
.chip-select { border: 1px solid #d6d6d0; border-radius: 99px; padding: 2px 6px; font: inherit; color: #333; background: #fff; }

/* Edge type picker */
#edge-picker { left: 64px; top: 70px; flex-direction: column; align-items: stretch; min-width: 130px; }
.picker-row { display: flex; align-items: center; gap: 2px; }
.picker-pick {
  flex: 1 1 auto; display: flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 8px;
  background: none; padding: 4px 6px; font: inherit; color: #333; cursor: pointer; text-align: left;
}
.picker-pick[aria-pressed="true"] { border-color: #4a9a2e; background: #f3f8ef; }
.picker-swatch { width: 12px; height: 12px; border-radius: 99px; flex: 0 0 auto; }
.picker-btn { border: 0; background: none; border-radius: 8px; padding: 3px 7px; font: inherit; color: #555; cursor: pointer; }
.picker-btn:hover { background: #f1f1ec; }
.picker-add { font-size: 15px; }
.picker-form { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 4px; border-top: 1px solid #e3e3dc; }
.picker-input { flex: 1 1 90px; min-width: 0; border: 1px solid #d6d6d0; border-radius: 8px; padding: 3px 6px; font: inherit; user-select: text; -webkit-user-select: text; }
.picker-color { width: 30px; height: 26px; padding: 0; border: 1px solid #d6d6d0; border-radius: 6px; background: none; }
.picker-actions { display: flex; gap: 2px; flex: 1 0 100%; }
.picker-save { color: #4a9a2e; }
.picker-delete { color: #b7650c; margin-left: auto; }
.picker-error { flex: 1 0 100%; color: #b7650c; font-size: 11px; }

#clusters .cluster-dot circle { pointer-events: auto; cursor: pointer; }
#clusters .cluster-frame rect { pointer-events: auto; cursor: pointer; }
#clusters .cluster-frame-title, #clusters .cluster-frame-count { pointer-events: none; user-select: none; }
#clusters .cluster-count { font: 600 13px system-ui, sans-serif; pointer-events: none; user-select: none; }

/* Status pill */
.status-dot { color: #8a8a84; }
#status[data-status="saving"] .status-dot { color: #4a9a2e; }
#status[data-status="unsaved"] .status-dot, #status[data-status="offline"] .status-dot { color: #e8890c; }
#status[data-status="error"] .status-dot { color: #c0392b; }

/* Tags panel, and the Outlines panel beside it */
#tag-panel, #outline-panel {
  position: fixed; z-index: 15; left: 10px; top: 56px; width: 280px; max-height: calc(100vh - 80px); overflow-y: auto; padding: 8px;
  background: #fff; border: 1px solid #d6d6d0; border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
  display: flex; flex-direction: column; gap: 2px; font-size: 13px;
}
.outline-row { cursor: pointer; }
.outline-row input { margin: 0; }
#canvas[data-tool="pan"], #canvas[data-tool="pan"] .pocket { cursor: grab; }
.tag-title { font-weight: 600; padding: 2px 4px; }
.tag-ranked { display: flex; flex-direction: column; gap: 2px; }
.tag-row { display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: 6px; background: #fff; }
.tag-row:hover { background: #f6f6f2; }
.tag-row-dragging { background: #f3f8ef; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.tag-grip { width: 14px; color: #bbb; font-size: 11px; cursor: grab; touch-action: none; text-align: center; }
.tag-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-count { color: #999; font-size: 12px; }
.tag-swatch { width: 18px; height: 18px; flex: 0 0 auto; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .12); padding: 0; cursor: pointer; }
.tag-swatch-none { background: repeating-linear-gradient(45deg, #fff 0 3px, #e5e5df 3px 6px); }
.tag-swatch-on { outline: 2px solid #222; outline-offset: 1px; }
.tag-palette { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 4px 8px 26px; align-items: center; }
.tag-custom { width: 26px; height: 22px; padding: 0; border: 1px solid #d6d6d0; border-radius: 4px; background: none; cursor: pointer; }
.tag-sep { border-top: 1px dashed #e3e3dc; margin-top: 4px; padding: 6px 4px 2px; font-size: 11px; color: #999; text-transform: uppercase; letter-spacing: .04em; }

/* Board menu */
#board-menu {
  position: fixed; z-index: 15; left: 10px; top: 56px; min-width: 220px; max-width: 280px; padding: 6px;
  background: #fff; border: 1px solid #d6d6d0; border-radius: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
  display: flex; flex-direction: column; gap: 2px; font-size: 13px;
}
.menu-boards { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; }
.menu-item {
  border: 0; background: none; border-radius: 8px; padding: 6px 8px; font: inherit; color: #333;
  text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-item:hover { background: #f1f1ec; }
.menu-board[aria-current="true"] { font-weight: 600; background: #f3f8ef; }
.menu-danger-text { color: #b7650c; }
.menu-sep { border: 0; border-top: 1px solid #e3e3dc; margin: 4px 0; width: 100%; }
.menu-form { display: flex; gap: 4px; }
.menu-form-col { flex-direction: column; }
.menu-input { flex: 1 1 auto; min-width: 0; border: 1px solid #d6d6d0; border-radius: 8px; padding: 5px 8px; font: inherit; user-select: text; -webkit-user-select: text; }
.menu-input:focus { outline: none; border-color: #4a9a2e; }
.menu-ok { border: 0; border-radius: 8px; padding: 5px 10px; background: #4a9a2e; color: #fff; font: inherit; cursor: pointer; }
.menu-ok:disabled { opacity: .4; cursor: default; }
.menu-danger { background: #e8890c; }
.menu-hint { color: #666; font-size: 12px; padding: 2px 2px 4px; }
.menu-error { color: #b7650c; font-size: 12px; padding: 4px 8px; }

/* Image drop and upload */
.canvas-drop { outline: 2px dashed #4a9a2e; outline-offset: -4px; }
.image-drop-target { outline: 3px solid #4a9a2e; outline-offset: 2px; }
.image-uploading { opacity: .5; }
.image-placeholder {
  position: absolute; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; background: #f1f1ec; border: 1px dashed #b8b8b0; border-radius: 10px; font-size: 12px; color: #666;
  pointer-events: none; overflow: hidden;
}
.image-placeholder-name { max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-spinner { width: 18px; height: 18px; border: 2px solid #d6d6d0; border-top-color: #4a9a2e; border-radius: 50%; animation: image-spin .8s linear infinite; }
@keyframes image-spin { to { transform: rotate(360deg); } }

/* Annotation editor (fills #popover) */
.annotation-editor { position: fixed; inset: 0; display: flex; flex-direction: column; background: #fafaf8; }
.annotation-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px;
  background: #fff; border-bottom: 1px solid #d6d6d0; font-size: 12px;
}
.annotation-toolbar .pill[aria-pressed="true"] { background: #4a9a2e; border-color: #4a9a2e; color: #fff; }
.annotation-sep { width: 1px; align-self: stretch; background: #e3e3dc; margin: 0 4px; }
.annotation-toggle { display: flex; align-items: center; gap: 4px; padding: 0 4px; cursor: pointer; }
.annotation-spacer { margin-left: auto; }
.annotation-body { flex: 1 1 auto; min-height: 0; display: flex; }
.annotation-stage {
  position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; touch-action: none; cursor: crosshair;
  background: #e9e9e4 repeating-conic-gradient(#e1e1db 0 25%, #ededea 0 50%) 0 0 / 16px 16px;
}
.annotation-stage[data-tool="select"] { cursor: default; }
.annotation-image { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; }
.annotation-missing { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #666; font-size: 14px; }
.annotation-overlay { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
/* --kind is the colour of the shape's kind; without one the editor's green shows. */
.annotation-shape { fill: color-mix(in srgb, var(--kind, #4a9a2e) 12%, transparent); stroke: var(--kind, #2f7a17); stroke-width: 1.5px; stroke-linejoin: round; }
.annotation-selected { fill: color-mix(in srgb, var(--kind, #4a9a2e) 28%, transparent); stroke: var(--kind, #4a9a2e); stroke-width: 3px; }
.annotation-stage[data-panning] { cursor: grab; }
.annotation-ghost { fill: none; stroke: #777; stroke-width: 1.5px; stroke-dasharray: 5 4; opacity: .6; }
.annotation-draft { stroke-dasharray: 4 3; }
.annotation-handle-hit { fill: rgba(255, 255, 255, .01); }
.annotation-handle-dot { fill: #fff; stroke: #2f7a17; stroke-width: 1.5px; }
.annotation-handle-mid .annotation-handle-dot { fill: #4a9a2e; stroke: #fff; }
.annotation-handle-on .annotation-handle-dot { fill: #e8890c; stroke: #fff; }
/* The panel is a column: the list takes the spare height and scrolls alone, the rest stays in view. */
.annotation-panel { flex: 0 0 280px; min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: #fff; }
.annotation-resizer { flex: 0 0 7px; margin-left: -3px; z-index: 1; cursor: col-resize; touch-action: none; border-right: 1px solid #d6d6d0; }
.annotation-resizer:hover, .annotation-resizer-on { border-right: 3px solid #4a9a2e; }
.annotation-panel > .annotation-section { flex: 0 0 auto; }
.annotation-panel > .annotation-list-section { flex: 1 1 0; min-height: 96px; }
.annotation-list-section .annotation-list { flex: 1 1 0; min-height: 0; overflow-y: auto; }
.annotation-selected-section { max-height: 45%; overflow-y: auto; background: #fbfbf8; border-top: 1px solid #d6d6d0; }
.annotation-fields { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 8px; }
.annotation-fields .annotation-heading { padding-top: 0; }
.annotation-buttons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.annotation-count { color: #aaa; }
.annotation-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .15); }
.annotation-dot-none { background: none; border: 1px dashed #bbb; }
.annotation-fold > summary { cursor: pointer; padding-top: 0; display: flex; align-items: center; gap: 6px; list-style: none; }
.annotation-fold > summary::-webkit-details-marker { display: none; }
.annotation-fold > summary::before { content: '▸'; font-size: 10px; }
.annotation-fold[open] > summary::before { content: '▾'; }
.annotation-readout { margin-left: auto; text-transform: none; letter-spacing: 0; }
.annotation-kinds { display: flex; flex-direction: column; gap: 2px; max-height: 132px; overflow-y: auto; }
.annotation-kind { display: flex; align-items: center; gap: 6px; }
.annotation-kind-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.annotation-swatch { flex: 0 0 auto; width: 26px; height: 22px; padding: 0; border: 1px solid #d6d6d0; border-radius: 4px; background: none; cursor: pointer; }
.annotation-add { display: flex; gap: 6px; align-items: center; }
.annotation-add .annotation-name { flex: 1 1 auto; min-width: 0; }
.annotation-notes { max-height: 88px; overflow-y: auto; }
/* Side panel */
.annotation-panel { font-size: 13px; color: #333; }
.annotation-section { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-bottom: 1px solid #ecece6; }
.annotation-section[hidden] { display: none; }
.annotation-heading { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: .04em; padding-top: 4px; }
.annotation-hint { color: #777; font-size: 12px; }
.annotation-list { display: flex; flex-direction: column; gap: 2px; }
.annotation-row { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; border-radius: 6px; background: #fff; }
.annotation-row:hover { background: #f6f6f2; }
.annotation-row[aria-current="true"] { background: #e8f2e2; }
.annotation-row-hidden .annotation-row-name { color: #999; }
.annotation-row-dragging { background: #f3f8ef; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.annotation-row-name {
  flex: 1 1 auto; min-width: 0; min-height: 32px; border: 0; background: none; padding: 0 6px; font: inherit; color: inherit;
  text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.annotation-icon {
  flex: 0 0 auto; width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; color: #555; font-size: 11px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.annotation-icon:hover:not(:disabled) { background: #ecece6; }
.annotation-icon:disabled { opacity: .3; cursor: default; }
.annotation-grip { flex: 0 0 auto; width: 28px; height: 32px; line-height: 32px; color: #aaa; font-size: 12px; text-align: center; cursor: grab; touch-action: none; }
.annotation-name {
  min-width: 0; background: #fff; border: 1px solid #d6d6d0; border-radius: 8px; padding: 6px 8px; font: inherit; user-select: text; -webkit-user-select: text; outline: none;
}
.annotation-name:focus { border-color: #4a9a2e; }
.annotation-message { color: #b7650c; font-size: 12px; }
.annotation-panel .pill { align-self: flex-start; min-height: 32px; }
.annotation-panel .pill:disabled { opacity: .4; cursor: default; }
.annotation-delete { color: #b7650c; }
.annotation-notes { display: flex; flex-direction: column; gap: 2px; }
.annotation-note {
  border: 0; background: none; border-radius: 6px; padding: 6px; min-height: 32px; font: inherit; color: #2f6b2a; text-align: left;
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.annotation-note:hover { background: #f1f1ec; }
.annotation-anchors { display: grid; grid-template-columns: repeat(3, 36px); gap: 4px; }
.annotation-anchor { width: 36px; height: 36px; border: 1px solid #d6d6d0; border-radius: 6px; background: #fff; cursor: pointer; padding: 0; position: relative; }
.annotation-anchor::after { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #bbb; }
.annotation-anchor[aria-pressed="true"] { border-color: #4a9a2e; background: #e8f2e2; }
.annotation-anchor[aria-pressed="true"]::after { background: #4a9a2e; width: 10px; height: 10px; margin: -5px; }
.annotation-cursor { font-variant-numeric: tabular-nums; color: #333; }
@media (pointer: coarse) {
  .annotation-icon, .annotation-grip, .annotation-row-name, .annotation-note, .annotation-panel .pill { min-height: 40px; }
  .annotation-icon { width: 40px; height: 40px; }
  .annotation-grip { width: 36px; height: 40px; line-height: 40px; }
  .annotation-anchors { grid-template-columns: repeat(3, 44px); }
  .annotation-anchor { width: 44px; height: 44px; }
}
/* Narrow windows (an iPad in portrait): the panel stacks below the stage. */
@media (max-width: 900px) {
  .annotation-body { flex-direction: column; }
  .annotation-stage { flex: 1 1 60%; }
  .annotation-panel { flex: 0 0 auto; max-height: 40%; border-left: 0; border-top: 1px solid #d6d6d0; }
}

/* Touch layout */
body.touch #rail, body.touch #chip { display: none !important; }
body.touch [data-handle] { display: none; }
body.touch[data-mode="notes"] .pocket-selected [data-handle],
body.touch[data-mode="notes"] .frame-selected [data-handle] { display: block; }
body.touch .link-from { outline: 2px dashed var(--link-from-color, #9a9a92); outline-offset: 3px; }

/* Mode bar and action strip: fixed at the bottom, clear of the home indicator */
body.touch { --strip-bottom: calc(68px + env(safe-area-inset-bottom)); } /* 8px + the bar (40px buttons, 6px padding, 1px border) + 6px */
body.touch #mode-bar { left: 8px; right: 8px; bottom: 8px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
.mode-btn {
  flex: 1 1 0; min-width: 0; min-height: 40px; border: 0; border-radius: 8px; background: none;
  font: inherit; font-size: 14px; color: #333; cursor: pointer;
}
.mode-btn[aria-pressed="true"] { background: #4a9a2e; color: #fff; }
body.touch #action-strip {
  position: fixed; z-index: 10; left: 8px; right: 8px; bottom: var(--strip-bottom);
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; overflow: hidden;
  pointer-events: none; /* the gaps between buttons are canvas */
}
body.touch #action-strip > * { pointer-events: auto; }
.strip-btn {
  min-height: 40px; padding: 0 14px; border: 1px solid #d6d6d0; border-radius: 8px; background: #fff;
  font: inherit; font-size: 14px; color: #333; white-space: nowrap; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
}
.strip-btn:disabled { opacity: .4; cursor: default; }
.strip-btn[data-item="remove"], .strip-btn[data-item="delete"] { color: #b7650c; }
.strip-hint {
  flex: 1 1 100%; order: -1; box-sizing: border-box; padding: 6px 10px; border-radius: 8px; background: #fff;
  border: 1px solid #d6d6d0; font-size: 13px; color: #444; text-align: center; overflow-wrap: anywhere;
}
body.touch #action-strip .chip-url { min-height: 40px; box-sizing: border-box; max-width: 100%; border: 1px solid #d6d6d0; border-radius: 8px; padding: 0 8px; font: inherit; }
.more-menu {
  position: fixed; z-index: 16; display: flex; flex-direction: column; min-width: 140px; max-width: calc(100vw - 16px);
  padding: 4px; background: #fff; border: 1px solid #d6d6d0; border-radius: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
}
.more-item {
  min-height: 40px; padding: 0 12px; border: 0; border-radius: 8px; background: none; text-align: left;
  font: inherit; font-size: 14px; color: #333; cursor: pointer;
}
.more-item:hover { background: #f1f1ec; }
body.touch #edge-picker { left: 8px; right: 8px; top: auto; bottom: var(--picker-bottom, calc(var(--strip-bottom) + 52px)); max-height: 50vh; overflow-y: auto; }
body.touch .picker-pick, body.touch .picker-btn { min-height: 40px; }
body.touch #toast { bottom: calc(var(--strip-bottom) + 52px); }

/* Top bar: the save status joins the bar's flow; above phone width the bar may wrap */
body.touch #topbar { max-width: calc(100vw - 20px); flex-wrap: wrap; }
body.touch #topbar :is(.pill, .tab) { min-height: 40px; box-sizing: border-box; display: inline-flex; align-items: center; }
/* Page controls outside the top bar reach 40px too */
body.touch :is(.pill, .list-row-delete, .row-boards, .pocket-tag-input, .image-page-caption) { min-height: 40px; box-sizing: border-box; }
body.touch :is(a.pill, button.pill, .list-row-delete, .row-boards) { display: inline-flex; align-items: center; justify-content: center; }
/* ...which must not undo a hide: these are !important, as [hidden] is. Above phone width the Notes list's
   Filter, + New note and ⋯ and the note page's ⋯ are not offered; the shelf's fold never folds, so no Filter */
body.touch:not(.phone) :is(.filters-toggle, .fab, .page-more, .node-page-more), body.touch .shelf .filters-toggle { display: none !important; }
#topbar #status-wrap, .node-page-status #status-wrap { position: static; padding: 0; border: 0; box-shadow: none; background: none; }
body:not(.phone.on-board) #topbar #board-more { display: none; }

/* Phone width */
#shelf-close { display: none; }
body.touch.phone .shelf {
  z-index: 14; inset: 0; width: auto; max-width: none; padding: 56px 10px 10px; border: 0; border-radius: 0; box-shadow: none;
}
body.touch.phone #shelf:not([hidden]) + #shelf-close {
  display: block; position: fixed; z-index: 15; top: 8px; right: 10px; min-height: 40px; padding: 0 16px;
  border: 1px solid #d6d6d0; border-radius: 8px; background: #fff; font: inherit; font-size: 14px; color: #333; cursor: pointer;
}
body.touch.phone .shelf :is(button, select, input) { min-height: 40px; }
body.touch.phone .shelf .list-row { min-height: 40px; }
body.touch.phone .shelf .note-row { cursor: pointer; }

/* Phone width: the top bar keeps the board name, the save status and a menu */
body.phone #topbar { left: 8px; right: 8px; max-width: none; }
/* off a board the bar is one row: the email gives way, Sign out stays */
body.phone:not(.on-board) #topbar { flex-wrap: nowrap; }
body.phone .account-name { display: none; }
body.phone.on-board :is(.tabs, #tags-button, #outlines-button, #shelf-button, #account),
body.phone.on-board:not(.filter-row) #tag-filter { display: none !important; }
body.phone.on-board #board-name { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: left; }
body.phone.on-board #board-more { display: inline-flex; align-items: center; justify-content: center; }
body.phone.on-board.filter-row #tag-filter {
  display: block; position: fixed; z-index: 15; left: 8px; right: 8px; top: 60px; width: auto; box-sizing: border-box;
}
body.phone :is(#tag-panel, #outline-panel) { left: 8px; right: 8px; width: auto; top: 60px; max-height: 70vh; overflow: auto; }
body.phone #board-menu { left: 8px; right: 8px; max-width: none; top: 60px; }
body.touch.phone.on-board.filter-row #tag-filter, body.touch.phone :is(#tag-panel, #outline-panel, #board-menu) { top: 72px; }
body.touch.phone #tag-filter { min-height: 40px; }
body.phone.on-board .back-label { display: none; }
body.touch.phone #board-back { min-width: 40px; justify-content: center; }
body.touch #board-back { gap: .3em; }

/* Phone width: the Notes list folds its filters and moves its actions */
/* the search row is the top of the page: the title is in the top bar's tab, the ⋯ sits beside Filter.
   Only the Notes list's header: the Boards list keeps its title and New board */
body.phone .notes-page-header { display: none; }
body.phone .page-more { display: inline-block; order: 2; }
body.phone .notes-drop .filters-fold { order: 3; }
body.phone .notes-drop { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
body.phone .notes-drop .filters .filters-search { flex: 1 1 0; }
body.phone .notes-drop .filters-toggle { display: inline-block; }
body.phone .notes-drop .filters-toggle[aria-pressed="true"] { background: #4a9a2e; border-color: #4a9a2e; color: #fff; }
body.phone .notes-drop .filters-fold { display: none; }
body.phone .notes-drop .filters.open .filters-fold { display: flex; flex: 1 1 100%; flex-wrap: wrap; gap: 6px; align-items: center; }
body.phone .notes-drop .filters-tags { flex: 1 1 100%; }
body.phone .notes-drop .filters-fold select.pill { flex: 1 1 100%; max-width: none; }
body.phone .notes-drop .filters-tag-colours { position: static; }
body.phone .notes-drop .filters-tag-colours > button { display: none; }
body.phone .notes-tag-panel { position: fixed; left: 8px; right: 8px; top: 60px; width: auto; max-height: 70vh; }
body.phone .fab {
  display: block; position: fixed; z-index: 12; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); height: 44px; padding: 0 20px;
  border: 0; border-radius: 22px; background: #4a9a2e; color: #fff; font: inherit; font-size: 15px; box-shadow: 0 3px 10px rgba(0, 0, 0, .25); cursor: pointer;
}
body.phone .fab:disabled { opacity: .6; cursor: default; }
body.touch.phone :is(.page-more, .notes-drop .filters :is(.pill, .filters-kind-btn)) { min-height: 40px; box-sizing: border-box; }
body.touch.phone .page-more { min-width: 40px; }

/* Phone width: the note page fills the visual viewport (--vvh), the body scrolls inside the card,
   the format row sits at the foot while editing; the bar folds Delete, boards and dates into ⋯ */
.node-page-more, .format-row, .node-page-status:empty { display: none; }
.node-page-status { flex: 0 0 auto; }
.more-item:disabled { color: #777; font-size: 12px; cursor: default; background: none; }
body.phone .page:has(> .note-edit-page) { bottom: auto; height: var(--vvh, 100dvh); padding-bottom: 0; overflow: hidden; }
body.phone .note-edit-page { display: flex; flex-direction: column; height: 100%; }
body.phone .note-edit-page .node-page-bar { flex: 0 0 auto; margin-bottom: 8px; }
body.phone .note-edit-page :is(.row-boards, .node-page-delete), body.phone .note-edit-page .node-page-meta { display: none; }
body.phone .note-edit-page .node-page-more { display: inline-block; flex: 0 0 auto; }
body.phone .node-page-bar a.pill { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; } /* the back link: note, image and doc pages */
body.phone .note-edit-page .note-page-card { flex: 1 1 0; min-height: 0; margin-bottom: 8px; }
body.phone .note-edit-page .note-page-body { min-height: 0; overflow-y: auto; }
body.phone .note-edit-page .note-page-tag-wrap { flex: 0 0 auto; padding-top: 6px; border-top: 1px solid #ecece6; }
body.phone .note-edit-page .note-page-tag-wrap .tag-suggest { top: auto; bottom: calc(100% + 2px); }
body.phone .note-edit-page.formatting .format-row {
  display: flex; flex: 0 0 auto; gap: 4px; margin: 0 -16px; padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
  background: #f1f1ec; border-top: 1px solid #d6d6d0;
}
.format-btn {
  flex: 1 1 0; min-width: 0; min-height: 36px; padding: 0 4px; border: 1px solid #d6d6d0; border-radius: 8px; background: #fff;
  font: inherit; font-size: 14px; color: #333; cursor: pointer; touch-action: manipulation;
}
.format-btn.format-bold { font-weight: 700; }
.format-btn:is(.format-tags, .format-done) { flex: 1.4 1 0; }
.format-btn.format-done { background: #4a9a2e; border-color: #4a9a2e; color: #fff; }
body.touch .format-btn { min-height: 40px; }
body.touch.phone .note-edit-page .node-page-bar :is(a.pill, .node-page-more) { height: 40px; box-sizing: border-box; padding-top: 0; padding-bottom: 0; line-height: 38px; }
body.touch.phone .note-edit-page .node-page-more { min-width: 40px; }
/* The 40px rule makes pills inline-flex, and a flex container shows no ellipsis: the back link is a block again. */
body.touch.phone .node-page-bar a.pill { display: block; height: 40px; box-sizing: border-box; padding-top: 0; padding-bottom: 0; line-height: 38px; }
body.phone .image-page-annotate { display: none !important; } /* §9: no annotation editor on the phone page */
