/* =============================================================================
   MD Vault — Direction A
   -----------------------------------------------------------------------------
   One coherent editor over the site's own markdown vault, composed as ITS OWN TOOL
   — not a collage of other editors. The signature is the floating white document
   sheet: the canvas is the hero, a Google-Docs-grade page of paper drifting on a
   cool near-white workspace, with a Docs-blue accent and a sans face throughout.
   Navigation is the ACTUAL folder tree at arbitrary depth (never imposed levels).
   Comments (Phase 3) are real overlay cards in the RIGHT margin; the outline
   lives on the LEFT. Anti-references (Obsidian, a fused right rail, OneNote
   purple/boxes, export-WYSIWYG) are deliberately avoided.

   The module commits to the light Docs look regardless of the portal's theme —
   Direction A is locked to a light/cool canvas, so it reads as "opening a
   document tool" rather than tinting to the dark chrome above it.
============================================================================= */

#portal-mdvault {
  /* -------------------------------------------------------------------------
     Palette v2 — an OKLCH tonal system (the W3C-standard perceptual color space):
     one cool, low-chroma neutral ramp + a single electric-blue accent RESERVED
     for interaction. Depth comes from TONE + hairlines, not skeuomorphic paper
     shadows (post-Material-You / Apple-deference). Type identity lives only in the
     file-type badges — the one place color carries data. Self-contained: never
     inherits the dark portal theme.
     ------------------------------------------------------------------------- */
  --nb-blue:        oklch(0.585 0.175 256);        /* accent — electric technical blue */
  --nb-blue-ink:    oklch(0.505 0.185 256);        /* accent text on light */
  --nb-blue-soft:   oklch(0.955 0.024 256);        /* selection wash (faint) */
  --nb-accent-tint: oklch(0.928 0.052 256);        /* hover fill (clearly blue) */
  --nb-accent-ring: oklch(0.585 0.175 256 / .42);  /* focus / drop ring */
  --nb-canvas:      #ffffff;                         /* the document sheet — stays calm */
  --nb-workspace:   oklch(0.966 0.004 256);        /* cool near-white workspace */
  --nb-chrome:      oklch(0.982 0.0035 256);       /* rail / toolbar surface */
  --nb-hover:       oklch(0.945 0.006 256);        /* neutral hover */
  --nb-ink:         oklch(0.285 0.021 264);        /* primary text */
  --nb-ink-dim:     oklch(0.505 0.017 264);        /* secondary */
  --nb-ink-mute:    oklch(0.635 0.013 264);        /* tertiary */
  --nb-line:        oklch(0.912 0.005 256);        /* hairlines */
  --nb-line-hi:     oklch(0.85 0.008 256);
  --nb-highlight:   #fff2b2;                         /* comment-anchored text */
  --nb-radius:    8px;
  --nb-serif:     'Source Serif 4', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --nb-font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --nb-mono:      'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --nb-shadow:    0 1px 2px oklch(0.42 0.03 264 / .10), 0 8px 26px oklch(0.42 0.03 264 / .07);
  --nb-shadow-sm: 0 1px 2px oklch(0.42 0.03 264 / .09), 0 2px 8px oklch(0.42 0.03 264 / .06);
  --nb-zoom:      1;                 /* document zoom (View ▸ size / toolbar magnifier) */
  --nb-doc-font:  var(--nb-font);    /* document face — Sans / Serif / Mono switcher */
  /* Fixed physical page geometry (a .docx-viewer sheet, not a fluid column):
     8.5in × 11in @ 96dpi. The page never depends on the pane width — resizing
     the widget scrolls the workspace, it never reflows the text. Only the % zoom
     changes what fits on a line. */
  --nb-page-w:    816px;   /* 8.5in — portrait text width */
  --nb-page-h:    1056px;  /* 11in  — portrait min height */
  --nb-rail-w:    264px;   /* Files rail width (drag-resizable, persisted) */

  display: flex;
  overflow: hidden;              /* the module is an app pane — panes scroll, not the page */
  color: var(--nb-ink);
  font-family: var(--nb-font);
}
/* The Notebook OWNS the viewport below the portal chrome: it fills edge-to-edge
   (canceling main's padding + its own), scrolls only INTERNALLY, and the page
   itself never scrolls while it's open. */
body:has(#portal-mdvault) { overflow: hidden; margin: 0; }
#portal-mdvault.portal-fit {
  padding: 0; min-height: 0;
  /* full-bleed to the viewport edges regardless of main's padding/margins */
  width: 100vw; margin-left: calc(50% - 50vw);
  height: calc(100dvh - var(--portal-chrome-h, 120px));
  overflow: hidden;
}
/* min-height:0 is REQUIRED on every flex link in the chain, or a tall document
   inflates the pane to its own height and gets clipped instead of scrolling. */
#portal-mdvault #nb-app { flex: 1; min-width: 0; min-height: 0; display: flex; }

/* The whole tool: a light surface that fills the app viewport, edge to edge. */
.nb {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--nb-workspace);
  overflow: hidden;
}
.nb *,
.nb *::before,
.nb *::after { box-sizing: border-box; }
.nb button { font-family: inherit; cursor: pointer; }

/* --- row 0: Chrome-style document tabs ----------------------------------- */
.nb-tabs {
  display: flex; align-items: flex-end; gap: 2px;
  padding: 6px 8px 0;
  background: var(--nb-workspace);
  border-bottom: 1px solid var(--nb-line);
  overflow-x: auto; scrollbar-width: thin;
  min-height: 40px;
}
.nb-tabs::-webkit-scrollbar { height: 6px; }
.nb-tabs::-webkit-scrollbar-thumb { background: var(--nb-line-hi); border-radius: 999px; }
.nb-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 10px 9px 14px;
  max-width: 220px; flex: 0 0 auto;
  border: 1px solid transparent; border-bottom: none;
  border-radius: 9px 9px 0 0;
  background: transparent; color: var(--nb-ink-dim);
  font-size: 13px; font-weight: 500; line-height: 1;
  position: relative; top: 1px;
  transition: background .12s ease, color .12s ease;
}
.nb-tab:hover { background: var(--nb-hover); color: var(--nb-ink); }
.nb-tab.active {
  background: var(--nb-canvas); color: var(--nb-ink);
  border-color: var(--nb-line);
  box-shadow: 0 -1px 2px rgba(60,64,67,.04);
}
.nb-tab-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--nb-blue); flex: none; opacity: 0; }
.nb-tab.dirty .nb-tab-dot { opacity: 1; }
.nb-tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-tab-close {
  border: none; background: none; color: var(--nb-ink-mute);
  width: 18px; height: 18px; border-radius: 5px; flex: none;
  display: grid; place-items: center; font-size: 15px; line-height: 1;
  opacity: 0; transition: opacity .12s, background .12s;
}
.nb-tab:hover .nb-tab-close, .nb-tab.active .nb-tab-close { opacity: 1; }
.nb-tab-close:hover { background: var(--nb-line-hi); color: var(--nb-ink); }
.nb-tab-new {
  border: none; background: none; color: var(--nb-ink-dim);
  width: 30px; height: 30px; border-radius: 7px; flex: none;
  display: grid; place-items: center; font-size: 19px; margin: 0 2px 4px;
  align-self: center;
}
.nb-tab-new:hover { background: var(--nb-hover); color: var(--nb-ink); }

/* --- row 1: title + Docs-style menu bar + mode toggle -------------------- */
.nb-titlebar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px; background: var(--nb-canvas);
  border-bottom: 1px solid var(--nb-line);
}
.nb-doc-mark { color: var(--nb-blue); font-size: 12px; flex: none; }
/* Filename fills the whole middle span (menu at far left, modes at far right) so
   long titles read in full instead of collapsing to "…". */
.nb-filename {
  border: 1px solid transparent; background: transparent;
  font: 600 15px/1.2 var(--nb-font); color: var(--nb-ink);
  padding: 3px 8px; border-radius: 6px;
  flex: 1 1 auto; min-width: 8ch; max-width: none;
  text-overflow: ellipsis; overflow: hidden;
}
.nb-filename:not([readonly]):hover { border-color: var(--nb-line); }
.nb-filename:focus { outline: none; border-color: var(--nb-blue); background: #fff; }
.nb-menubar { display: flex; gap: 2px; flex: none; }
.nb-menu-btn {
  border: none; background: none; color: var(--nb-ink-dim);
  font-size: 13px; padding: 4px 9px; border-radius: 6px;
}
.nb-menu-btn:hover { background: var(--nb-hover); color: var(--nb-ink); }
.nb-menu-btn[disabled] { opacity: .45; cursor: default; }
.nb-titlebar .nb-spacer { flex: 1; }

/* segmented Edit · Read · Source mode toggle */
.nb-modes { display: inline-flex; background: var(--nb-chrome); border: 1px solid var(--nb-line); border-radius: 999px; padding: 2px; }
.nb-mode {
  border: none; background: none; color: var(--nb-ink-dim);
  font-size: 12.5px; font-weight: 600; padding: 4px 13px; border-radius: 999px;
  transition: background .12s, color .12s;
}
.nb-mode[aria-selected="true"] { background: var(--nb-blue); color: #fff; box-shadow: 0 1px 2px rgba(26,115,232,.35); }
.nb-mode[disabled] { opacity: .4; cursor: default; }

/* --- row 2: formatting toolbar (Docs-style; filled in Phase 2) ----------- */
.nb-toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 12px; background: var(--nb-chrome);
  border-bottom: 1px solid var(--nb-line);
  min-height: 40px; overflow-x: auto; scrollbar-width: none;
}
.nb-toolbar::-webkit-scrollbar { display: none; }
.nb-tool {
  border: none; background: none; color: var(--nb-ink-dim);
  width: 30px; height: 30px; border-radius: 6px; flex: none;
  display: grid; place-items: center; font-size: 14px;
}
.nb-tool:hover:not([disabled]) { background: var(--nb-hover); color: var(--nb-ink); }
.nb-tool[disabled] { opacity: .4; cursor: default; }
.nb-tool.wide { width: auto; display: inline-flex; align-items: center; padding: 0 10px; gap: 6px; font-size: 12.5px; font-weight: 600; }
.nb-caret { font-size: 9px; opacity: .7; margin-left: 2px; }
#nb-zoom-label { font-size: 11.5px; font-variant-numeric: tabular-nums; }
.nb-fontname { display: inline-block; max-width: 104px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
/* give the font-menu items room to show each name in its own face */
.nb-menu-pop .nb-menu-item span:first-child { font-size: 14px; }
.nb-tool-sep { width: 1px; height: 20px; background: var(--nb-line); margin: 0 5px; flex: none; }
.nb-toolbar .nb-spacer { flex: 1; }
.nb-search {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--nb-canvas); border: 1px solid var(--nb-line);
  border-radius: 999px; padding: 3px 12px; min-width: 200px;
}
.nb-search:focus-within { border-color: var(--nb-blue); box-shadow: 0 0 0 3px var(--nb-blue-soft); }
.nb-search svg { color: var(--nb-ink-mute); flex: none; }
.nb-search input {
  border: none; background: none; outline: none; flex: 1; min-width: 0;
  font: 500 13px var(--nb-font); color: var(--nb-ink);
}

/* --- body: rail | canvas | comments-margin ------------------------------- */
.nb-body { flex: 1; min-height: 0; display: flex; background: var(--nb-workspace); }

.nb-rail {
  width: var(--nb-rail-w); flex: none; display: flex; flex-direction: column;
  background: var(--nb-chrome); border-right: 1px solid var(--nb-line);
  position: relative;
}
/* the drag-resize handle sits on the rail's right edge */
.nb-rail-resize {
  position: absolute; top: 0; right: -3px; width: 7px; height: 100%;
  cursor: col-resize; z-index: 8; touch-action: none;
}
.nb-rail-resize::after {
  content: ""; position: absolute; top: 0; left: 3px; width: 1px; height: 100%;
  background: transparent; transition: background .12s;
}
.nb-rail-resize:hover::after, .nb.rail-resizing .nb-rail-resize::after { background: var(--nb-blue); }
.nb.rail-resizing { cursor: col-resize; user-select: none; }
.nb.rail-collapsed .nb-rail { width: 0; overflow: hidden; border-right: none; }
.nb.rail-collapsed .nb-rail-resize { display: none; }
/* rail header: title + "＋" create + collapse */
.nb-rail-head {
  flex: none; display: flex; align-items: center; gap: 4px;
  padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--nb-line);
}
.nb-rail-title { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--nb-ink-dim); }
.nb-rail-head .nb-spacer { flex: 1; }
.nb-rail-btn {
  border: none; background: none; color: var(--nb-ink-dim);
  width: 28px; height: 28px; border-radius: 7px; flex: none;
  display: grid; place-items: center; font-size: 15px; transition: background .12s, color .12s;
}
.nb-rail-btn:hover { background: var(--nb-hover); color: var(--nb-ink); }
.nb-rail-btn svg { width: 17px; height: 17px; }
.nb-create-btn { color: var(--nb-blue); }
.nb-rail-panel { flex: 1; min-height: 0; overflow: auto; scrollbar-width: thin; padding: 8px 6px 24px; }

/* folder tree — arbitrary depth. Monochrome geometric icons; kind is read from
   SHAPE (filled folder vs outlined page) + weight, not skeuomorphic color. State
   (hover/select/drag) is carried by the single accent, tonally. */
.nb-tree, .nb-tree ul { list-style: none; margin: 0; padding: 0; }
.nb-tree ul { padding-left: 14px; margin-left: 6px; border-left: 1px solid var(--nb-line); }
.nb-node {
  position: relative; display: flex; align-items: center; gap: 7px;
  padding: 5px 8px; border-radius: 7px; cursor: pointer;
  font: 500 13px/1.35 var(--nb-font); color: var(--nb-ink);
  user-select: none; transition: background .11s ease, color .11s ease;
}
/* left accent bar rendered via a pseudo so it animates cleanly */
.nb-node::before {
  content: ""; position: absolute; left: 2px; top: 50%; transform: translateY(-50%) scaleY(0);
  width: 2.5px; height: 15px; border-radius: 2px; background: var(--nb-blue);
  transition: transform .12s cubic-bezier(.2,.9,.3,1.2);
}
.nb-node:hover { background: var(--nb-accent-tint); }
.nb-node.active { background: var(--nb-blue-soft); color: var(--nb-blue-ink); font-weight: 600; }
.nb-node.active::before { transform: translateY(-50%) scaleY(1); }
.nb-node.nb-dragging { opacity: .4; }
.nb-node.is-dir.nb-drop { background: var(--nb-accent-tint); box-shadow: inset 0 0 0 1.5px var(--nb-accent-ring); }
.nb-node-chev {
  width: 12px; flex: none; color: var(--nb-ink-mute); font-size: 9px;
  transition: transform .13s ease; display: inline-grid; place-items: center;
}
.nb-node.open > .nb-node-chev { transform: rotate(90deg); }
.nb-node-ico { flex: none; width: 17px; height: 17px; display: inline-grid; place-items: center; }
.nb-node-ico svg { width: 16px; height: 16px; display: block; }
/* folder = solid neutral (a container reads heavier); file = hollow, lighter */
.nb-ico-folder svg { fill: color-mix(in oklch, var(--nb-ink-dim) 22%, transparent); stroke: var(--nb-ink-dim); stroke-width: 1.4; }
.nb-node.open > .nb-ico-folder svg { fill: color-mix(in oklch, var(--nb-blue) 20%, transparent); stroke: var(--nb-blue-ink); }
.nb-ico-file svg { fill: none; stroke: var(--nb-ink-mute); stroke-width: 1.5; }
.nb-node.active .nb-ico-file svg { stroke: var(--nb-blue); }
.nb-node.is-dir { font-weight: 600; letter-spacing: -.005em; }
.nb-node-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* dropping onto empty rail space → move to vault root */
.nb-rail-panel.nb-drop-root { box-shadow: inset 0 0 0 2px var(--nb-accent-ring); border-radius: 10px; }
.nb-tree-loading, .nb-tree-empty { padding: 8px 12px; color: var(--nb-ink-mute); font-size: 12px; }

/* search results in the rail */
.nb-results-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 10px 8px; font-size: 12px; color: var(--nb-ink-dim); font-weight: 600;
}
.nb-results-back { border: none; background: none; color: var(--nb-blue); font-size: 12px; font-weight: 600; }
.nb-result {
  display: block; padding: 7px 10px; border-radius: 6px; cursor: pointer; margin-bottom: 1px;
}
.nb-result:hover { background: var(--nb-hover); }
.nb-result-path { font-size: 12px; font-weight: 600; color: var(--nb-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-result-prev { font-size: 11.5px; color: var(--nb-ink-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-result mark { background: var(--nb-highlight); color: inherit; border-radius: 2px; padding: 0 1px; }

/* outline */
.nb-outline-item {
  display: block; padding: 4px 10px; border-radius: 6px; cursor: pointer;
  font-size: 12.5px; color: var(--nb-ink-dim); line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nb-outline-item:hover { background: var(--nb-hover); color: var(--nb-ink); }
.nb-outline-item.h1 { font-weight: 700; color: var(--nb-ink); }
.nb-outline-item.h2 { padding-left: 20px; }
.nb-outline-item.h3 { padding-left: 32px; }
.nb-outline-item.h4 { padding-left: 44px; }
.nb-outline-item.h5, .nb-outline-item.h6 { padding-left: 56px; }
.nb-rail-empty { padding: 14px 12px; color: var(--nb-ink-mute); font-size: 12.5px; line-height: 1.5; }

/* --- Outline as a Google-Docs-style pop-out column ------------------------ */
/* Collapsed: a slim strip with just the dotted icon, right beside the Files rail.
   Expanded: the icon strip + a panel of headings. */
.nb-outline-col {
  flex: none; display: flex; background: var(--nb-chrome);
  border-right: 1px solid var(--nb-line);
}
.nb-outline-tab {
  flex: none; width: 34px; border: none; background: none; color: var(--nb-ink-mute);
  display: grid; place-items: start center; padding-top: 10px; cursor: pointer;
  transition: background .12s, color .12s;
}
.nb-outline-tab:hover { background: var(--nb-hover); color: var(--nb-blue); }
.nb-outline-col.expanded .nb-outline-tab { color: var(--nb-blue); }
.nb-outline-tab svg { width: 18px; height: 18px; }
.nb-outline-body { width: 0; overflow: hidden; transition: width .18s ease; }
.nb-outline-col.expanded .nb-outline-body { width: 220px; overflow: auto; scrollbar-width: thin; }
.nb-outline-head {
  display: flex; align-items: center; padding: 9px 6px 9px 12px; border-bottom: 1px solid var(--nb-line);
  font: 700 12px/1 var(--nb-font); letter-spacing: .04em; text-transform: uppercase; color: var(--nb-ink-dim);
  position: sticky; top: 0; background: var(--nb-chrome);
}
#nb-outline { padding: 8px 6px 24px; }
.nb.rail-collapsed .nb-outline-col { display: none; }

/* --- "+" create menu (Google-Drive-style expand) ------------------------- */
.nb-create-menu {
  position: fixed; z-index: 220; min-width: 210px;
  background: var(--nb-canvas); border: 1px solid var(--nb-line);
  border-radius: 11px; box-shadow: var(--nb-shadow); padding: 6px;
  transform-origin: top left; animation: nb-pop-in .13s cubic-bezier(.2,.9,.3,1.2) both;
}
@keyframes nb-pop-in { from { opacity: 0; transform: scale(.9) translateY(-4px); } to { opacity: 1; transform: none; } }
.nb-create-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: none; background: none; padding: 8px 10px; border-radius: 7px;
  font: 500 13px var(--nb-font); color: var(--nb-ink);
}
.nb-create-item:hover { background: var(--nb-hover); }
.nb-create-ico { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 5px; }
.nb-create-ico svg { width: 15px; height: 15px; }
.nb-create-ico.k-md { color: var(--nb-blue); } .nb-create-ico.k-md svg { fill: #fff; stroke: var(--nb-blue); }
.nb-create-ico.k-docx { color: #2b579a; } .nb-create-ico.k-docx svg { fill: #fff; stroke: #2b579a; }
.nb-create-ico.k-xlsx { color: #1a7f4b; } .nb-create-ico.k-xlsx svg { fill: #fff; stroke: #1a7f4b; }
.nb-create-ico.dir svg { fill: color-mix(in oklch, var(--nb-ink-dim) 22%, transparent); stroke: var(--nb-ink-dim); stroke-width: 1.4; }

/* --- rail head: the way home ------------------------------------------------
   The head is a single button carrying the vault's mark + name; it returns to
   the home view (recent notes, tags, search) from wherever you are. */
.nb-nb-switch {
  display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0;
  border: none; background: none; cursor: pointer; text-align: left;
  padding: 5px 8px; border-radius: 8px;
  font: 700 13.5px var(--nb-font); color: var(--nb-ink);
  transition: background .12s;
}
.nb-nb-switch:hover { background: var(--nb-hover); }
.nb-nb-dot { flex: none; width: 11px; height: 11px; border-radius: 50%; background: var(--nb-blue); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.nb-nb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- search in the rail -----------------------------------------------------
   Vault-wide (ripgrep-backed) and always one keystroke away (⌘K). While a query
   is in the box the rail shows hits grouped by note instead of the tree. */
.nb-search-row { flex: none; padding: 0 10px 9px; border-bottom: 1px solid var(--nb-line); }
.nb-search {
  width: 100%; border: 1px solid var(--nb-line); border-radius: 8px;
  background: var(--nb-canvas); color: var(--nb-ink);
  font: 500 12.5px var(--nb-font); padding: 7px 10px;
  -webkit-appearance: none; appearance: none;
}
.nb-search::placeholder { color: var(--nb-ink-mute); }
.nb-search:focus { outline: none; border-color: var(--nb-blue); box-shadow: 0 0 0 3px var(--nb-blue-soft); }
.nb.rail-collapsed .nb-search-row { display: none; }

.nb-search-head {
  font: 700 10.5px var(--nb-font); letter-spacing: .06em; text-transform: uppercase;
  color: var(--nb-ink-mute); padding: 4px 4px 8px;
}
.nb-hits { display: flex; flex-direction: column; gap: 6px; }
.nb-hit {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: 1px solid var(--nb-line); border-radius: 9px; background: var(--nb-canvas);
  padding: 9px 11px; transition: border-color .12s, background .12s;
}
.nb-hit:hover { border-color: var(--nb-line-hi); background: var(--nb-hover); }
.nb-hit-top { display: flex; align-items: center; gap: 7px; }
.nb-hit-name { font: 600 12.5px var(--nb-font); color: var(--nb-ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-hit-count {
  flex: none; font: 700 10px var(--nb-mono); color: var(--nb-blue-ink);
  background: var(--nb-blue-soft); border-radius: 999px; padding: 1px 6px;
}
.nb-hit-path { font: 400 10.5px var(--nb-font); color: var(--nb-ink-mute); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-hit-line { display: flex; gap: 7px; margin-top: 5px; align-items: baseline; }
.nb-hit-ln { flex: none; font: 500 10px var(--nb-mono); color: var(--nb-ink-mute); }
.nb-hit-text {
  font: 400 11.5px/1.45 var(--nb-mono); color: var(--nb-ink-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* rail re-open handle when collapsed */
.nb-rail-toggle {
  flex: none; width: 22px; display: grid; place-items: center;
  background: var(--nb-chrome); border-right: 1px solid var(--nb-line);
  color: var(--nb-ink-mute); cursor: pointer; font-size: 12px; user-select: none;
}
.nb-rail-toggle:hover { background: var(--nb-hover); color: var(--nb-ink); }
.nb:not(.rail-collapsed) .nb-rail-toggle { display: none; }

/* --- the canvas: a floating sheet (the hero) ----------------------------- */
/* The workspace centers a FIXED-width page and scrolls in both axes. `safe
   center` keeps the page's left edge reachable when the pane is narrower than the
   sheet — so a narrow widget scrolls the page instead of reflowing its text. */
.nb-canvas-wrap {
  flex: 1; min-width: 0; min-height: 0; overflow: auto;
  padding: 34px 40px 120px; scroll-behavior: smooth;
  display: flex; flex-direction: column; align-items: safe center;
}
.nb-doc {
  background: var(--nb-canvas);
  width: var(--nb-page-w); flex: none; min-height: var(--nb-page-h);
  padding: 68px 84px 96px;
  border-radius: 3px; box-shadow: var(--nb-shadow);
  color: var(--nb-ink);
  font-family: var(--nb-doc-font);
  font-size: calc(16px * var(--nb-zoom)); line-height: 1.72;
}
.nb-doc.is-empty {
  width: auto; align-self: stretch; min-height: 60vh;
  display: grid; place-items: center; box-shadow: none; background: transparent;
}


/* rendered markdown (Read view) — Docs-grade prose */
.nb-doc h1, .nb-doc h2, .nb-doc h3, .nb-doc h4, .nb-doc h5, .nb-doc h6 {
  color: var(--nb-ink); font-weight: 700; line-height: 1.28;
  margin: 1.7em 0 .5em; letter-spacing: -.01em; scroll-margin-top: 20px;
}
.nb-doc h1 { font-size: 2em; margin-top: .2em; font-weight: 800; }
.nb-doc h2 { font-size: 1.55em; }
.nb-doc h3 { font-size: 1.28em; }
.nb-doc h4 { font-size: 1.1em; }
.nb-doc h5, .nb-doc h6 { font-size: 1em; color: var(--nb-ink-dim); }
.nb-doc p { margin: 0 0 1em; }
.nb-doc a { color: var(--nb-blue); text-decoration: none; }
.nb-doc a:hover { text-decoration: underline; }
.nb-doc a.nb-wikilink { color: var(--nb-blue-ink); background: var(--nb-blue-soft); padding: 0 4px; border-radius: 4px; font-weight: 500; }
.nb-doc a.nb-wikilink:hover { background: #d7e6fd; text-decoration: none; }
.nb-doc a.nb-wikilink.missing { color: #b02a37; background: #fce8e9; }
.nb-doc ul, .nb-doc ol { margin: 0 0 1em; padding-left: 1.5em; }
.nb-doc li { margin: .25em 0; }
.nb-doc li > ul, .nb-doc li > ol { margin: .25em 0; }
.nb-doc blockquote {
  margin: 1em 0; padding: .3em 1.1em; border-left: 3px solid var(--nb-line-hi);
  color: var(--nb-ink-dim);
}
.nb-doc code {
  font-family: var(--nb-mono); font-size: .88em;
  background: #f1f3f4; padding: .12em .4em; border-radius: 4px; color: #37474f;
}
.nb-doc pre {
  background: #f6f8fa; border: 1px solid var(--nb-line); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; margin: 1em 0; line-height: 1.5;
}
.nb-doc pre code { background: none; padding: 0; font-size: .85rem; color: #24292f; }
.nb-doc hr { border: none; border-top: 1px solid var(--nb-line); margin: 2em 0; }
.nb-doc img { max-width: 100%; border-radius: 6px; }
.nb-doc table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: .95em; display: block; overflow-x: auto; }
.nb-doc th, .nb-doc td { border: 1px solid var(--nb-line); padding: 7px 12px; text-align: left; }
.nb-doc th { background: var(--nb-chrome); font-weight: 700; }
.nb-doc :first-child { margin-top: 0; }
.nb-doc input[type="checkbox"] { margin-right: .5em; }

/* frontmatter block (--- ... ---) rendered as a quiet metadata card */
.nb-doc .nb-frontmatter {
  background: var(--nb-chrome); border: 1px solid var(--nb-line); border-radius: 8px;
  padding: 12px 16px; margin: 0 0 1.4em; font-family: var(--nb-mono);
  font-size: 12.5px; color: var(--nb-ink-dim); white-space: pre-wrap; line-height: 1.6;
}

/* source view — raw markdown */
.nb-doc.is-source {
  position: relative;
  font-family: var(--nb-mono); font-size: calc(13.5px * var(--nb-zoom)); line-height: 1.7;
  white-space: pre-wrap; word-break: break-word; color: #37474f;
  padding: 40px 48px;
}
.nb-source-copy {
  position: sticky; top: 0; float: right; margin: -20px -24px 0 0;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--nb-chrome); border: 1px solid var(--nb-line); color: var(--nb-ink-dim);
  border-radius: 999px; padding: 5px 13px; font: 600 12px var(--nb-font); z-index: 2;
}
.nb-source-copy:hover { background: var(--nb-hover); color: var(--nb-ink); border-color: var(--nb-line-hi); }

/* linked-mentions (backlinks) footer under the read view */
.nb-backlinks { max-width: 816px; margin: 26px auto 0; }
.nb-backlinks-head { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--nb-ink-mute); margin: 0 0 8px; padding-left: 2px; }
.nb-backlink {
  display: block; background: var(--nb-canvas); border: 1px solid var(--nb-line);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; cursor: pointer;
}
.nb-backlink:hover { border-color: var(--nb-line-hi); box-shadow: 0 1px 4px rgba(60,64,67,.08); }
.nb-backlink-path { font-size: 12.5px; font-weight: 600; color: var(--nb-blue-ink); }
.nb-backlink-prev { font-size: 12.5px; color: var(--nb-ink-dim); margin-top: 2px; }

/* loading + error states */
.nb-loading { display: grid; place-items: center; min-height: 40vh; color: var(--nb-ink-mute); font-size: 13px; }
.nb-vault-down {
  max-width: 440px; margin: 12vh auto; text-align: center; color: var(--nb-ink-dim);
  background: var(--nb-canvas); border: 1px solid var(--nb-line); border-radius: 12px; padding: 32px;
}
.nb-vault-down h2 { color: var(--nb-ink); font-size: 18px; margin: 0 0 8px; }
.nb-vault-down p { font-size: 13.5px; line-height: 1.6; margin: 0; }

/* comments margin (Phase 3 mount — kept quiet until populated) */
.nb-comments-margin { width: 0; flex: none; }

/* --- Phase 3: comments as overlay cards (Docs-style, never a rail) --------- */
/* The canvas scrolls; the annotation layer is absolute INSIDE it so highlights
   and cards scroll with the document. When a note has open comments, the canvas
   grows a right margin so cards sit beside the text, not over it. */
.nb-canvas-wrap { position: relative; }
.nb-canvas-wrap.has-comments { padding-right: 320px; }
.nb-anno { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 4; }
.nb-anno > * { pointer-events: auto; }
.nb-hl {
  position: absolute; background: rgba(255, 214, 74, .5); border-radius: 2px;
  mix-blend-mode: multiply; cursor: pointer;
}
.nb-hl:hover { background: rgba(255, 200, 30, .65); }

.nb-comment-card {
  position: absolute; width: 288px;
  background: var(--nb-canvas); border: 1px solid var(--nb-line);
  border-radius: 10px; box-shadow: var(--nb-shadow);
  padding: 12px 14px; font-size: 13px; transition: box-shadow .12s, border-color .12s;
}
.nb-comment-card.focused { border-color: var(--nb-blue); box-shadow: 0 0 0 3px var(--nb-blue-soft), var(--nb-shadow); }
.nb-comment { padding-bottom: 8px; }
.nb-comment + .nb-comment { border-top: 1px solid var(--nb-line); padding-top: 8px; }
.nb-comment-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.nb-comment-author { font-weight: 700; color: var(--nb-ink); font-size: 12.5px; }
.nb-comment-time { color: var(--nb-ink-mute); font-size: 11px; }
.nb-comment-body { color: var(--nb-ink); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.nb-comment-actions { display: flex; gap: 6px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--nb-line); }
.nb-comment-mini {
  border: none; background: none; color: var(--nb-ink-dim); font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: 6px;
}
.nb-comment-mini:hover { background: var(--nb-hover); color: var(--nb-ink); }
.nb-comment-mini.primary { color: var(--nb-blue); }
.nb-comment-mini.danger:hover { background: #fce8e9; color: #b02a37; }

.nb-compose { margin-top: 8px; }
.nb-compose.floating {
  position: absolute; width: 288px; background: var(--nb-canvas);
  border: 1px solid var(--nb-line); border-radius: 10px; box-shadow: var(--nb-shadow); padding: 12px;
}
.nb-compose textarea {
  width: 100%; border: 1px solid var(--nb-line); border-radius: 8px; padding: 8px 10px;
  font: 400 13px/1.5 var(--nb-font); color: var(--nb-ink); resize: vertical; background: #fff;
}
.nb-compose textarea:focus { outline: none; border-color: var(--nb-blue); box-shadow: 0 0 0 3px var(--nb-blue-soft); }
.nb-compose-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.nb-compose-btn {
  position: absolute; display: inline-flex; align-items: center; gap: 5px;
  background: var(--nb-blue); color: #fff; border: none; border-radius: 999px;
  padding: 5px 12px; font-size: 12px; font-weight: 600; box-shadow: var(--nb-shadow); white-space: nowrap;
}
.nb-compose-btn:hover { background: var(--nb-blue-ink); }

@media (max-width: 1100px) {
  .nb-canvas-wrap.has-comments { padding-right: 40px; }
  .nb-comment-card, .nb-compose.floating { width: 240px; }
}

/* --- Phase 2: menu bar dropdowns, toolbar save state, live-preview editor -- */
.nb-menu { position: relative; }
.nb-menu-pop {
  position: absolute; top: 100%; left: 0; margin-top: 5px; z-index: 60;
  min-width: 210px; background: var(--nb-canvas); border: 1px solid var(--nb-line);
  border-radius: 9px; box-shadow: var(--nb-shadow); padding: 6px;
}
.nb-menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 26px;
  width: 100%; text-align: left; border: none; background: none;
  padding: 7px 10px; border-radius: 6px; font-size: 13px; color: var(--nb-ink);
}
.nb-menu-item:hover { background: var(--nb-hover); }
.nb-menu-hint { color: var(--nb-ink-mute); font-size: 11px; font-family: var(--nb-mono); }
.nb-menu-sep { height: 1px; background: var(--nb-line); margin: 5px 4px; }
.nb-menu.open > .nb-menu-btn, .nb-menu.open > .nb-tool { background: var(--nb-hover); color: var(--nb-ink); }

#nb-save-btn { color: var(--nb-ink-mute); font-weight: 600; }
#nb-save-btn.is-dirty { color: var(--nb-blue); }
#nb-save-btn.is-saving { color: var(--nb-ink-mute); }
.nb-tool.glyph { font-size: 13px; }

/* In Edit mode the sheet is the SAME fixed 8.5×11 page as Read: CodeMirror grows
   to its content and the WORKSPACE (.nb-canvas-wrap) owns scrolling — so the page
   width is constant (no horizontal reflow on resize) and the sheet is always at
   least a full 11in tall. CM provides the inner page margins. */
.nb-doc.is-edit {
  padding: 0; min-height: var(--nb-page-h); height: auto;
  display: flex; flex-direction: column; overflow: visible;
}
.nb-doc.is-edit .cm-editor { flex: 1; min-height: var(--nb-page-h); width: 100%; background: transparent; }
.nb-doc.is-edit .cm-editor.cm-focused { outline: none; }
/* Document face + zoom flow into the editor too (id-scoped to beat the CM theme). */
#portal-mdvault .cm-scroller { font-family: var(--nb-doc-font); font-size: calc(16px * var(--nb-zoom)); }
/* CM must NOT be its own scroll box here — let the page grow and the workspace
   scroll, so wrap points depend only on the fixed page width + zoom. */
#portal-mdvault .nb-doc.is-edit .cm-editor { height: auto; }
#portal-mdvault .nb-doc.is-edit .cm-scroller { overflow: visible; }

/* live-preview decoration classes (markdown stays canonical underneath; em so
   they scale with the document zoom) */
#portal-mdvault .cm-nb-h1 { font-size: 2em;   font-weight: 800; letter-spacing: -.01em; }
#portal-mdvault .cm-nb-h2 { font-size: 1.55em; font-weight: 700; letter-spacing: -.01em; }
#portal-mdvault .cm-nb-h3 { font-size: 1.28em; font-weight: 700; }
#portal-mdvault .cm-nb-h4 { font-size: 1.1em;  font-weight: 700; }
#portal-mdvault .cm-nb-h5, #portal-mdvault .cm-nb-h6 { font-size: 1em; font-weight: 700; color: var(--nb-ink-dim); }
#portal-mdvault .cm-nb-strong { font-weight: 700; }
#portal-mdvault .cm-nb-em { font-style: italic; }
#portal-mdvault .cm-nb-strike { text-decoration: line-through; color: var(--nb-ink-mute); }
#portal-mdvault .cm-nb-code {
  font-family: var(--nb-mono); font-size: .88em; background: #f1f3f4;
  padding: .1em .35em; border-radius: 4px; color: #37474f;
}
#portal-mdvault .cm-nb-link { color: var(--nb-blue); }
#portal-mdvault .cm-nb-wikilink { color: var(--nb-blue-ink); background: var(--nb-blue-soft); border-radius: 4px; padding: 0 3px; }
#portal-mdvault .cm-nb-quote { border-left: 3px solid var(--nb-line-hi); padding-left: 12px; color: var(--nb-ink-dim); }
#portal-mdvault .cm-nb-codeline { font-family: var(--nb-mono); font-size: .9em; background: #f6f8fa; }
#portal-mdvault .cm-nb-hr { color: var(--nb-line-hi); }

/* --- toolbar icons: never wrap; SVG/glyph centered ------------------------- */
.nb-tool { white-space: nowrap; overflow: hidden; }
.nb-tool svg { width: 17px; height: 17px; display: block; }
.nb-tool b, .nb-tool i { font-size: 14px; }

/* --- custom tooltips (hover-delay label) ---------------------------------- */
.nb-tip {
  position: fixed; z-index: 200; pointer-events: none;
  background: #202124; color: #fff; font: 500 11.5px var(--nb-font);
  padding: 4px 9px; border-radius: 6px; white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0,0,0,.28);
  opacity: 0; transform: translateY(-2px); transition: opacity .1s ease;
}
.nb-tip.show { opacity: 1; transform: none; }

/* --- node action menu (right-click / double-click) ------------------------ */
.nb-ctx {
  position: fixed; z-index: 210; min-width: 196px;
  background: var(--nb-canvas); border: 1px solid var(--nb-line);
  border-radius: 11px; box-shadow: var(--nb-shadow); padding: 5px;
  transform-origin: top left; animation: nb-pop-in .12s cubic-bezier(.2,.9,.3,1.2) both;
}
.nb-ctx button {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 7px 11px; border-radius: 7px; font: 500 13px var(--nb-font); color: var(--nb-ink);
  transition: background .1s;
}
.nb-ctx button:hover { background: var(--nb-accent-tint); }
.nb-ctx button.danger { color: oklch(0.55 0.19 25); }
.nb-ctx button.danger:hover { background: oklch(0.95 0.04 25); }
.nb-ctx-sep { height: 1px; background: var(--nb-line); margin: 5px 6px; }

/* --- move modal ----------------------------------------------------------- */
.nb-modal-backdrop { position: fixed; inset: 0; z-index: 220; background: rgba(20,24,31,.45); display: grid; place-items: center; }
.nb-modal {
  width: min(520px, 92vw); background: var(--nb-canvas); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35); padding: 22px 24px; color: var(--nb-ink);
}
.nb-modal h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.nb-modal p { margin: 0 0 14px; font-size: 12.5px; color: var(--nb-ink-dim); }
.nb-modal input {
  width: 100%; border: 1px solid var(--nb-line); border-radius: 8px; padding: 9px 12px;
  font: 500 13.5px var(--nb-mono); color: var(--nb-ink); background: #fff;
}
.nb-modal input:focus { outline: none; border-color: var(--nb-blue); box-shadow: 0 0 0 3px var(--nb-blue-soft); }
.nb-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.nb-modal .btn-x { border: none; background: none; font: 600 13px var(--nb-font); padding: 8px 14px; border-radius: 8px; color: var(--nb-ink-dim); }
.nb-modal .btn-x:hover { background: var(--nb-hover); color: var(--nb-ink); }
.nb-modal .btn-x.primary { background: var(--nb-blue); color: #fff; }
.nb-modal .btn-x.primary:hover { background: var(--nb-blue-ink); }

@media (max-width: 820px) {
  .nb-rail { position: absolute; z-index: 20; height: 100%; box-shadow: var(--nb-shadow); }
  .nb-canvas-wrap { padding: 18px 12px 90px; }
  .nb-doc { padding: 40px 24px 64px; }
  .nb-menubar { display: none; }
}

/* =============================================================================
   File-type badges (color-coded, in the Files tree) + multi-format viewers
   (.docx / .pdf / .csv / .xlsx) rendered as physical 8.5×11 / landscape pages,
   with an Apple-style morph when the page geometry changes.
============================================================================= */

/* --- file-type badges: tonal chips (type identity as data, monospace) ----- */
.nb-node-badge {
  flex: none; margin-left: auto;
  font: 700 9px/1 var(--nb-mono); letter-spacing: .02em; text-transform: uppercase;
  color: var(--c, var(--nb-ink-mute));
  background: color-mix(in oklch, var(--c, var(--nb-ink-mute)) 12%, var(--nb-canvas));
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--c, var(--nb-ink-mute)) 26%, transparent);
  padding: 2.5px 5px; border-radius: 5px;
}
.nb-node-badge[data-ext="md"], .nb-node-badge[data-ext="markdown"], .nb-node-badge[data-ext="mdx"] { --c: var(--nb-blue); }
.nb-node-badge[data-ext="docx"], .nb-node-badge[data-ext="doc"] { --c: #2b579a; }
.nb-node-badge[data-ext="pdf"] { --c: #d93025; }
.nb-node-badge[data-ext="xlsx"], .nb-node-badge[data-ext="xls"] { --c: #1a7f4b; }
.nb-node-badge[data-ext="csv"], .nb-node-badge[data-ext="tsv"] { --c: #0f9488; }
.nb-node-badge[data-ext="txt"] { --c: var(--nb-ink-mute); }
.nb-node-badge[data-ext="json"], .nb-node-badge[data-ext="yaml"], .nb-node-badge[data-ext="yml"] { --c: #b7791f; }
.nb-node-badge[data-ext="png"], .nb-node-badge[data-ext="jpg"], .nb-node-badge[data-ext="jpeg"],
.nb-node-badge[data-ext="gif"], .nb-node-badge[data-ext="svg"], .nb-node-badge[data-ext="webp"] { --c: #7c4dff; }

/* The full formatting toolbar is ALWAYS visible in every view (this is the "md
   toolbar" shown on the .docx viewer too). On a read-only format the editing tools
   are dimmed + inert (the file isn't editable); the font switcher + zoom stay live
   so the font control governs rich docx text. */
.nb.is-readonly .nb-tool[data-edit],
.nb.is-readonly .nb-menu[data-edit],
.nb.is-readonly #nb-save-btn { opacity: .38; pointer-events: none; }

/* When the canvas hosts a multi-page format, .nb-doc stops being a sheet itself
   and just stacks the .nb-page / canvas sheets, centered, scrolling as needed. */
.nb-doc.is-format {
  width: auto; align-self: stretch; background: transparent; box-shadow: none;
  padding: 0; min-height: 0;
  display: flex; flex-direction: column; align-items: safe center;
}

/* --- physical page sheets (docx / spreadsheet) --------------------------- */
.nb-page {
  background: var(--nb-canvas); flex: none; position: relative;
  width: var(--nb-page-w); min-height: var(--nb-page-h);
  padding: 68px 84px 96px; margin-bottom: 26px;
  border-radius: 3px; box-shadow: var(--nb-shadow);
  color: var(--nb-ink); font-family: var(--nb-doc-font);
  font-size: calc(16px * var(--nb-zoom)); line-height: 1.72;
}
.nb-page.landscape { width: var(--nb-page-h); min-height: var(--nb-page-w); padding: 56px 64px; }
.nb-page-num {
  position: absolute; bottom: 30px; right: 40px;
  font: 500 11px var(--nb-font); color: var(--nb-ink-mute);
}
/* docx prose (mirror the Read-view prose so the font switcher + zoom govern it) */
.nb-page h1, .nb-page h2, .nb-page h3, .nb-page h4, .nb-page h5, .nb-page h6 {
  color: var(--nb-ink); font-weight: 700; line-height: 1.28; margin: 1.5em 0 .5em; letter-spacing: -.01em;
}
.nb-page h1 { font-size: 2em; font-weight: 800; } .nb-page h2 { font-size: 1.55em; }
.nb-page h3 { font-size: 1.28em; } .nb-page h4 { font-size: 1.1em; }
.nb-page :first-child { margin-top: 0; }
.nb-page p { margin: 0 0 .8em; }
.nb-page strong { font-weight: 700; } .nb-page em { font-style: italic; } .nb-page u { text-decoration: underline; }
.nb-page ul, .nb-page ol { margin: 0 0 .8em; padding-left: 1.6em; }
.nb-page li { margin: .2em 0; }
.nb-page blockquote { margin: 1em 0; padding: .3em 1.1em; border-left: 3px solid var(--nb-line-hi); color: var(--nb-ink-dim); }
.nb-page table { border-collapse: collapse; margin: 1em 0; font-size: .95em; }
.nb-page th, .nb-page td { border: 1px solid var(--nb-line); padding: 6px 11px; text-align: left; vertical-align: top; }
.nb-page th { background: var(--nb-chrome); font-weight: 700; }
.nb-page img { max-width: 100%; }
.nb-fallback-note {
  font: 500 12px var(--nb-font); color: var(--nb-ink-mute);
  background: var(--nb-chrome); border: 1px solid var(--nb-line);
  border-radius: 6px; padding: 6px 10px; margin-bottom: 16px;
}

/* --- home view: what the vault opens on ------------------------------------
   The notes most recently written (by an agent or by Ryder), their tags, their
   sources, and one field that searches everything. Reading surface first — the
   rows are quiet cards, and the only saturated marks are state (tag counts,
   the agent badge), never decoration. */
.nb-home { width: min(760px, 100%); padding-top: 6px; }
.nb-home-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.nb-home-head h2 { margin: 0 0 4px; font: 800 22px var(--nb-font); color: var(--nb-ink); letter-spacing: -.02em; }
.nb-home-head p { margin: 0; font: 400 13px/1.55 var(--nb-font); color: var(--nb-ink-dim); max-width: 54ch; }
.nb-home-new {
  margin-left: auto; flex: none; border: none; background: var(--nb-blue); color: #fff;
  font: 600 12.5px var(--nb-font); padding: 8px 15px; border-radius: 8px; cursor: pointer;
}
.nb-home-new:hover { background: var(--nb-blue-ink); }

.nb-home-find { margin-bottom: 14px; }
.nb-home-search {
  width: 100%; border: 1px solid var(--nb-line); border-radius: 10px;
  background: var(--nb-canvas); color: var(--nb-ink);
  font: 500 14px var(--nb-font); padding: 11px 14px;
  -webkit-appearance: none; appearance: none; box-shadow: var(--nb-shadow-sm);
}
.nb-home-search::placeholder { color: var(--nb-ink-mute); }
.nb-home-search:focus { outline: none; border-color: var(--nb-blue); box-shadow: 0 0 0 3px var(--nb-blue-soft); }

.nb-home-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.nb-tag-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--nb-line); background: var(--nb-canvas); border-radius: 999px;
  padding: 4px 10px; font: 500 11.5px var(--nb-font); color: var(--nb-ink-dim);
  transition: border-color .12s, color .12s, background .12s;
}
.nb-tag-chip:hover { border-color: var(--nb-blue); color: var(--nb-blue-ink); background: var(--nb-blue-soft); }
.nb-tag-n { font: 700 10px var(--nb-mono); color: var(--nb-ink-mute); }
.nb-tag-chip:hover .nb-tag-n { color: var(--nb-blue-ink); }

.nb-home-label {
  font: 700 10.5px var(--nb-font); letter-spacing: .07em; text-transform: uppercase;
  color: var(--nb-ink-mute); margin: 0 0 9px 2px;
}
.nb-home-list { display: flex; flex-direction: column; gap: 8px; }
.nb-home-row {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--nb-canvas); border: 1px solid var(--nb-line); border-radius: 12px;
  padding: 13px 16px; box-shadow: var(--nb-shadow-sm);
  transition: border-color .12s, transform .12s;
}
.nb-home-row:hover { border-color: var(--nb-line-hi); transform: translateY(-1px); }
.nb-home-row-top { display: flex; align-items: baseline; gap: 8px; }
.nb-home-title { font: 600 14.5px var(--nb-font); color: var(--nb-ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-home-by {
  flex: none; font: 700 9.5px var(--nb-font); letter-spacing: .05em; text-transform: uppercase;
  color: var(--nb-blue-ink); background: var(--nb-blue-soft); border-radius: 999px; padding: 2px 7px;
}
.nb-home-row .nb-spacer { flex: 1; }
.nb-home-when { flex: none; font: 500 11px var(--nb-mono); color: var(--nb-ink-mute); }
.nb-home-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; }
.nb-home-dir { font: 400 11px var(--nb-font); color: var(--nb-ink-mute); }
.nb-home-tag {
  font: 500 10.5px var(--nb-font); color: var(--nb-ink-dim);
  background: var(--nb-hover); border-radius: 999px; padding: 1px 7px;
}
.nb-home-snip {
  margin-top: 7px; font: 400 12.5px/1.55 var(--nb-font); color: var(--nb-ink-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.nb-home-src { margin-top: 6px; display: flex; align-items: center; gap: 5px; font: 400 11px var(--nb-mono); color: var(--nb-ink-mute); }
.nb-home-src-ico { color: var(--nb-blue); }

/* --- frontmatter as a document header, not a wall of YAML ----------------- */
.nb-doc .nb-fm {
  margin: 0 0 26px; padding: 0 0 16px; border-bottom: 1px solid var(--nb-line);
}
.nb-fm-title { font: 800 calc(1.5em * 1) var(--nb-font); color: var(--nb-ink); letter-spacing: -.02em; line-height: 1.25; }
.nb-fm-line { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 8px; }
.nb-fm-date { font: 500 11px var(--nb-mono); color: var(--nb-ink-mute); }
.nb-fm-by {
  font: 700 9.5px var(--nb-font); letter-spacing: .05em; text-transform: uppercase;
  color: var(--nb-blue-ink); background: var(--nb-blue-soft); border-radius: 999px; padding: 2px 8px;
}
.nb-fm-tag { font: 500 11px var(--nb-font); color: var(--nb-ink-dim); background: var(--nb-hover); border-radius: 999px; padding: 2px 9px; }
.nb-fm-src { display: inline-block; margin-top: 8px; font: 400 11.5px var(--nb-mono); color: var(--nb-blue-ink); text-decoration: none; word-break: break-all; }
.nb-fm-src:hover { text-decoration: underline; }

/* --- Recently Deleted: rail footer + trash view -------------------------- */
.nb-trash-foot {
  flex: none; display: flex; align-items: center; gap: 8px;
  border: none; border-top: 1px solid var(--nb-line); background: var(--nb-chrome);
  padding: 10px 12px; color: var(--nb-ink-dim); font: 600 12.5px var(--nb-font);
  cursor: pointer; text-align: left; transition: background .12s, color .12s;
}
.nb-trash-foot:hover { background: var(--nb-hover); color: var(--nb-ink); }
.nb-trash-foot.active { color: var(--nb-blue-ink); background: var(--nb-blue-soft); }
.nb-trash-foot .nb-node-ico { width: 17px; height: 17px; flex: none; }
.nb-trash-foot .nb-node-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.nb-trash-foot-label { flex: 1; }
.nb-trash-foot-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: none;
  place-items: center; font: 700 10.5px var(--nb-mono); background: var(--nb-ink-mute); color: #fff;
}
.nb-trash-foot.has-items .nb-trash-foot-count { display: grid; }
.nb.rail-collapsed .nb-trash-foot { display: none; }

.nb-trash { width: min(760px, 100%); padding-top: 6px; }
.nb-trash-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.nb-trash-head h2 { margin: 0 0 4px; font: 800 22px var(--nb-font); color: var(--nb-ink); letter-spacing: -.02em; }
.nb-trash-head p { margin: 0; font: 400 13px/1.5 var(--nb-font); color: var(--nb-ink-dim); max-width: 46ch; }
.nb-trash-emptybtn {
  margin-left: auto; flex: none; border: 1px solid var(--nb-line); background: var(--nb-canvas);
  color: var(--nb-ink-dim); font: 600 12.5px var(--nb-font); padding: 7px 14px; border-radius: 8px;
}
.nb-trash-emptybtn:hover { background: oklch(0.95 0.045 25); color: oklch(0.5 0.19 25); border-color: oklch(0.82 0.09 25); }
.nb-trash-zero { color: var(--nb-ink-mute); font: 400 13.5px/1.6 var(--nb-font); padding: 30px 4px; }
.nb-trash-list { display: flex; flex-direction: column; gap: 8px; }
.nb-trash-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--nb-canvas); border: 1px solid var(--nb-line); border-radius: 12px;
  padding: 13px 16px; box-shadow: var(--nb-shadow-sm);
}
.nb-trash-row > .nb-node-ico { width: 22px; height: 22px; flex: none; }
.nb-trash-row > .nb-node-ico svg { width: 20px; height: 20px; }
.nb-trash-main { flex: 1; min-width: 0; }
.nb-trash-title { display: flex; align-items: center; gap: 8px; }
.nb-trash-name { font: 600 14px var(--nb-font); color: var(--nb-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-trash-meta { font: 400 11.5px var(--nb-font); color: var(--nb-ink-mute); margin: 2px 0 9px; }
/* proportional countdown of the 30-day window (drains as expiry nears) */
.nb-trash-barwrap { height: 5px; border-radius: 999px; background: var(--nb-hover); overflow: hidden; max-width: 420px; }
.nb-trash-bar { height: 100%; border-radius: 999px; transition: width .35s ease; }
.nb-trash-bar[data-level="ok"]   { background: oklch(0.64 0.15 152); }
.nb-trash-bar[data-level="warn"] { background: oklch(0.76 0.15 78); }
.nb-trash-bar[data-level="crit"] { background: oklch(0.60 0.20 25); }
.nb-trash-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }
.nb-trash-days { font: 500 11px var(--nb-mono); color: var(--nb-ink-mute); white-space: nowrap; }
.nb-trash-btns { display: flex; gap: 8px; }
.nb-trash-btn { border: 1px solid var(--nb-line); background: var(--nb-canvas); font: 600 12px var(--nb-font); padding: 6px 13px; border-radius: 8px; color: var(--nb-ink-dim); white-space: nowrap; }
.nb-trash-btn.primary { border-color: color-mix(in oklch, var(--nb-blue) 42%, var(--nb-line)); color: var(--nb-blue-ink); }
.nb-trash-btn.primary:hover { background: var(--nb-blue-soft); }
.nb-trash-btn.danger:hover { background: oklch(0.95 0.045 25); color: oklch(0.5 0.19 25); border-color: oklch(0.82 0.09 25); }
/* editable docx page (contenteditable) */
.nb-page.nb-docx-edit { cursor: text; caret-color: var(--nb-blue); }
.nb-page.nb-docx-edit:focus { outline: none; box-shadow: var(--nb-shadow), 0 0 0 2px var(--nb-blue-soft); }
.nb-page.nb-docx-edit :focus { outline: none; }

/* --- spreadsheet: edge-to-edge, editable grid (fills the surface) --------- */
/* When a sheet is open the workspace stops centering a page — the grid fills the
   whole area, horizontally, and scrolls INSIDE itself under a sticky tab bar. */
.nb.is-sheet .nb-canvas-wrap { padding: 0; overflow: hidden; }
.nb-doc.is-sheet {
  width: 100%; height: 100%; min-height: 0; align-self: stretch;
  padding: 0; background: var(--nb-canvas); box-shadow: none;
  display: flex; flex-direction: column;
}
.nb-sheet-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; }
/* rich-text tools don't apply to a spreadsheet — dim them (but keep Save live) */
.nb.is-sheet .nb-tool[data-edit], .nb.is-sheet .nb-menu[data-edit] { opacity: .35; pointer-events: none; }

.nb-sheet-bar {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 7px 14px; border-bottom: 1px solid var(--nb-line); background: var(--nb-chrome);
}
.nb-sheet-tabs { display: flex; gap: 3px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.nb-sheet-tabs::-webkit-scrollbar { display: none; }
.nb-sheet-tab {
  border: none; background: transparent; color: var(--nb-ink-dim);
  font: 600 12.5px var(--nb-font); padding: 6px 14px; border-radius: 8px; white-space: nowrap;
  transition: background .13s ease, color .13s ease, box-shadow .13s ease;
}
.nb-sheet-tab:hover { background: var(--nb-hover); color: var(--nb-ink); }
.nb-sheet-tab[aria-selected="true"] {
  background: var(--nb-canvas); color: #157347; box-shadow: 0 1px 2px rgba(60,64,67,.14), 0 0 0 1px var(--nb-line);
}
.nb-sheet-act {
  border: 1px solid var(--nb-line); background: var(--nb-canvas); color: var(--nb-ink-dim);
  font: 600 12px var(--nb-font); padding: 5px 11px; border-radius: 7px; white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.nb-sheet-act:hover { background: #e7f5ec; color: #157347; border-color: #9cd4b3; }
.nb-sheet-warn { font: 500 11px var(--nb-font); color: var(--nb-ink-mute); max-width: 340px; line-height: 1.35; }

.nb-sheet-scroll { flex: 1; min-height: 0; overflow: auto; }
.nb-sheet-trunc { padding: 6px 12px; font: 500 11px var(--nb-font); color: var(--nb-ink-mute); position: sticky; left: 0; }
.nb-sheet-table { border-collapse: separate; border-spacing: 0; font: 400 calc(13px * var(--nb-zoom))/1.4 var(--nb-font); color: var(--nb-ink); }
.nb-sheet-table td, .nb-sheet-table th {
  border-right: 1px solid var(--nb-line); border-bottom: 1px solid var(--nb-line);
  padding: 5px 10px; text-align: left; white-space: nowrap;
  max-width: 380px; overflow: hidden; text-overflow: ellipsis;
}
.nb-sheet-table thead th, .nb-sheet-table th.nb-sheet-rowhead {
  background: var(--nb-chrome); font-weight: 700; color: var(--nb-ink-mute);
  position: sticky; text-align: center; font-size: .86em;
}
.nb-sheet-table thead th { top: 0; z-index: 2; }
.nb-sheet-table th.nb-sheet-rowhead { left: 0; z-index: 1; min-width: 40px; }
.nb-sheet-table thead th:first-child { left: 0; z-index: 3; }
.nb-sheet-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
/* editable cells */
.nb-sheet-table td[contenteditable] { cursor: cell; }
.nb-sheet-table td[contenteditable]:hover { background: #f3f7fb; }
.nb-sheet-table td[contenteditable]:focus {
  outline: none; overflow: visible; white-space: normal; max-width: none;
  box-shadow: inset 0 0 0 2px var(--nb-blue); background: #fff; position: relative; z-index: 4;
}

/* --- pdf (faithful pages via PDF.js) ------------------------------------- */
.nb-pdf-page {
  display: block; margin: 0 auto 26px; background: #fff;
  box-shadow: var(--nb-shadow); border-radius: 3px; max-width: 100%; height: auto;
}
.nb-pdf-loading { color: var(--nb-ink-mute); font-size: 13px; padding: 40px; text-align: center; }

/* format loading / error inside the canvas */
.nb-fmt-msg {
  align-self: center; max-width: 460px; margin: 12vh auto; text-align: center;
  background: var(--nb-canvas); border: 1px solid var(--nb-line); border-radius: 12px;
  padding: 28px 30px; color: var(--nb-ink-dim);
}
.nb-fmt-msg h3 { color: var(--nb-ink); font-size: 16px; margin: 0 0 8px; }
.nb-fmt-msg p { font-size: 13px; line-height: 1.6; margin: 0; }
.nb-fmt-msg code { font-family: var(--nb-mono); font-size: 12px; background: #f1f3f4; padding: 1px 5px; border-radius: 4px; }

/* --- Apple-style morph: page reshapes to fit the new dimensions/data ------ */
.nb-morph .nb-doc:not(.is-empty),
.nb-morph .nb-page,
.nb-morph .nb-pdf-page { animation: nb-morph-in .46s cubic-bezier(.34, 1.16, .44, 1) both; }
@keyframes nb-morph-in {
  0%   { opacity: 0; transform: scale(.93) translateY(10px); filter: blur(1.5px); }
  60%  { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .nb-morph .nb-doc, .nb-morph .nb-page, .nb-morph .nb-pdf-page { animation: none; }
}
