    /* main viewer */
    .main {
      overflow: hidden;
      display: flex;
      flex-direction: column;
      position: relative;
    }

    /* No open tabs: keep the content canvas visible for the centered
     * empty prompt, but hide every chrome strip/button around it. */
    .main.no-file > :not(.main-body) {
      display: none;
    }

    /* Chrome-style find bar — floats top-right of the main pane, just
     * under the tab strip. Driven from `state.find`; UI lives in
     * `FindBar.tsx`. The bar's height matches the chrome row so it
     * doesn't visually push the edit toggle out of alignment. */
    .find-bar {
      position: absolute;
      /* Sits at the top of the document area, just below the
       * back/forward + breadcrumb + edit-toggle chrome row (which
       * itself sits at `top: 44px`). Right-aligned to mirror Chrome's
       * placement and so it doesn't fight the centered breadcrumb. */
      top: 78px;
      right: 14px;
      display: flex;
      align-items: center;
      gap: 4px;
      padding: 4px 6px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 6px;
      box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
      z-index: 10;
    }
    .find-input {
      width: 180px;
      height: 24px;
      padding: 0 6px;
      border: 1px solid var(--border);
      border-radius: 4px;
      background: var(--bg);
      color: var(--fg);
      font-size: 12.5px;
      font-family: inherit;
      outline: none;
    }
    .find-input:focus {
      border-color: var(--accent);
    }
    .find-input.no-match {
      color: #c0392b;
      border-color: #f5b7b1;
    }
    .find-count {
      min-width: 38px;
      padding: 0 4px;
      color: var(--muted);
      font-size: 11.5px;
      font-variant-numeric: tabular-nums;
      text-align: right;
    }
    .find-toggle, .find-step, .find-close, .find-all-files {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 24px;
      height: 24px;
      padding: 0 6px;
      border: 1px solid transparent;
      border-radius: 4px;
      background: transparent;
      color: var(--muted);
      cursor: pointer;
      font: inherit;
    }
    .find-step, .find-close {
      width: 24px;
      padding: 0;
    }
    .find-toggle {
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.5px;
    }
    .find-all-files {
      font-size: 11.5px;
      color: var(--muted);
      white-space: nowrap;
    }
    .find-toggle.on {
      color: var(--accent);
      border-color: var(--accent);
      background: rgba(8, 145, 178, 0.08);
    }
    .find-toggle:hover, .find-step:hover, .find-close:hover, .find-all-files:hover:not(:disabled) {
      background: var(--hover);
      color: var(--fg);
    }
    .find-step:disabled, .find-all-files:disabled {
      color: var(--border);
      cursor: default;
    }
    .find-step:disabled:hover, .find-all-files:disabled:hover {
      background: transparent;
      color: var(--border);
    }

    /* Iframe previews paint their own `::highlight(stash-find*)` rules
     * via inline <style> (findIframe.ts for MD, server/html.ts bootstrap
     * for HTML) — those rules only need to exist in the iframe's
     * document, not the parent. Skipping them here also keeps
     * lightningcss from warning about the (real but unrecognised) CSS
     * Custom Highlight pseudo-element. */

    /* CM6's built-in match decoration (used by our editor controller).
     * Match Chrome's palette so the editor and previews feel uniform. */
    .cm-searchMatch {
      background: #ffe082 !important;
    }
    .cm-searchMatch.cm-searchMatch-selected,
    .cm-searchMatch-selected {
      background: #1a73e8 !important;
      color: #fff !important;
    }

    /* Floating actions in the main pane's top-right. Replaces the
     * old `.main-head` strip (filename was redundant with the sidebar
     * selection; format badge was redundant with the sidebar icon
     * color). The edit toggle lives here on its own; the save status
     * tucks in next to it while editing. */
    .main-floating-actions {
      position: absolute;
      /* Sits below the tab strip (when one is rendered). The strip is
       * unconditionally present whenever there's an open file, so a
       * fixed offset is safe. */
      top: 44px;
      right: 14px;
      display: flex;
      align-items: center;
      gap: 8px;
      z-index: 5;
    }

    /* Mirror of `.main-floating-actions` for back/forward nav. Sits
     * top-left of the main pane; buttons inherit `.icon-btn` styling
     * with a disabled state that grays them out without hiding. */
    .main-nav-actions {
      position: absolute;
      top: 44px;
      left: 14px;
      display: flex;
      align-items: center;
      gap: 2px;
      z-index: 5;
    }
    .nav-btn {
      width: 28px;
      height: 28px;
    }
    .nav-btn svg {
      width: 14px;
      height: 14px;
    }
    .nav-btn:disabled {
      color: var(--border, #e5e5e5);
      cursor: default;
      background: transparent;
    }
    .nav-btn:disabled:hover {
      background: transparent;
    }

    /* Centered file path, Obsidian-style. Sits in the same row as the
     * back/forward buttons (left) and edit toggle (right). Absolute +
     * 50% transform centers it relative to .main; the inner max-width
     * leaves breathing room so the title never collides with the icon
     * clusters. Long paths truncate with ellipsis. */
    .main-breadcrumb {
      position: absolute;
      top: 44px;
      left: 50%;
      transform: translateX(-50%);
      max-width: calc(100% - 220px);
      height: 28px;
      display: flex;
      align-items: center;
      gap: 0;
      font-size: 13px;
      color: var(--muted);
      white-space: nowrap;
      overflow: hidden;
      z-index: 4;
    }
    .main-breadcrumb .seg {
      background: none;
      border: 0;
      padding: 2px 4px;
      margin: 0;
      font: inherit;
      color: var(--muted);
      cursor: pointer;
      border-radius: 4px;
      white-space: nowrap;
    }
    .main-breadcrumb .seg:hover {
      background: var(--hover);
      color: var(--fg);
    }
    .main-breadcrumb .seg.current {
      color: var(--fg);
    }
    .main-breadcrumb .sep {
      color: var(--muted);
      opacity: 0.6;
      user-select: none;
    }

    .edit-toggle {
      width: 28px;
      height: 28px;
    }
    .edit-toggle:hover {
      background: var(--hover);
    }

    .edit-toggle[hidden] {
      display: none;
    }

    .edit-toggle svg {
      width: 18px;
      height: 18px;
    }
    /* The pencil glyph's artwork fills nearly its whole 24×24 viewBox,
     * while the open-book preview glyph leaves more margin — so at equal
     * SVG sizes the pencil reads ~30% larger. Scale it down to match the
     * preview's optical size (scales from center; layout box unchanged). */
    .edit-toggle .icon-edit {
      transform: scale(0.85);
    }

    /* Two icons live inside the toggle; CSS picks which one shows
     * based on whether `.editing` is on the button (mirrors React's
     * `state.editMode`). Read mode → edit icon, edit mode → preview
     * icon (eye), so the button always shows the action it does. */
    .edit-toggle .icon-preview { display: none; }
    .edit-toggle.editing .icon-edit { display: none; }
    .edit-toggle.editing .icon-preview { display: block; }

    /* Two-pane edit layout for HTML / MD. Source + preview; each pane
     scrolls independently. CodeMirror takes the source pane, the
     existing viewer mounts in the preview pane. The track template
     (columns vs rows, and the ratio) is set inline by `Split.tsx`
     from the persisted ratio + orientation — only the structural /
     divider styling lives here. */
    .split {
      display: grid;
      height: 100%;
      /* live inside main-body */
      overflow: hidden;
      min-width: 0;
      min-height: 0;
    }

    .split-source {
      overflow: auto;
      background: var(--bg);
      min-width: 0;
      min-height: 0;
    }

    .split-preview {
      overflow: hidden;
      background: var(--bg);
      position: relative;
      min-width: 0;
      min-height: 0;
    }

    /* Draggable divider — its own grid track so a grab anywhere on it
     * resizes the split rather than landing in either pane. Hosts the
     * orientation-flip button centered on the bar. */
    .split-divider {
      position: relative;
      background: var(--border);
      display: grid;
      place-items: center;
      z-index: 1;
      transition: background 0.12s ease;
    }
    .split-divider:hover {
      background: var(--accent, #4a8cff);
    }
    .split-divider-horizontal {
      cursor: col-resize;
    }
    .split-divider-vertical {
      cursor: row-resize;
    }
    /* Orientation flip button — sits on the divider; its own click is
     * stopped from starting a drag (handled in Split.tsx). */
    .split-orient-btn {
      position: absolute;
      width: 18px;
      height: 18px;
      padding: 0;
      border: 1px solid var(--border);
      border-radius: 4px;
      background: var(--pane);
      color: var(--muted);
      font-size: 11px;
      line-height: 1;
      cursor: pointer;
      display: grid;
      place-items: center;
      opacity: 0;
      transition: opacity 0.12s ease, color 0.12s ease;
    }
    .split:hover .split-orient-btn,
    .split-divider:hover .split-orient-btn {
      opacity: 1;
    }
    .split-orient-btn:hover {
      color: var(--fg);
      background: var(--hover);
    }

    .split-preview>iframe {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      border: 0;
      display: block;
    }

    .pdf-source-split {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
      grid-template-rows: auto minmax(0, 1fr);
      height: 100%;
      overflow: hidden;
      min-width: 0;
      min-height: 0;
      background: var(--bg);
    }

    .pdf-source-split > .pdf-failure-banner {
      grid-column: 1 / -1;
      grid-row: 1;
      position: relative;
      max-width: none;
    }

    .pdf-derived-pane,
    .pdf-original-pane {
      position: relative;
      overflow: hidden;
      min-width: 0;
      min-height: 0;
      background: var(--bg);
      grid-row: 2;
    }

    .pdf-derived-pane { grid-column: 1; }

    .pdf-source-divider {
      background: var(--border);
      grid-column: 2;
      grid-row: 2;
    }

    .pdf-original-pane { grid-column: 3; }

    .pdf-original-pane .pdf-preview {
      padding-top: 8px;
    }

    .pdf-derived-empty {
      height: 100%;
      padding: 56px 28px 28px;
      box-sizing: border-box;
      color: var(--muted);
      font-size: 13px;
      line-height: 1.5;
      background: var(--bg);
    }

    .pdf-derived-empty strong {
      display: block;
      color: var(--fg);
      font-weight: 500;
      margin-bottom: 4px;
    }

    .viewer-shell {
      position: relative;
      width: 100%;
      height: 100%;
      overflow: hidden;
      background: #fff;
      min-width: 0;
      min-height: 0;
    }

    /* Cap the viewer column at 1100px on wide screens — keeps HTML
     * imports (arxiv / Wikipedia snapshots) from stretching edge-to-edge
     * on 2K/4K monitors, and visually aligns them with MD's narrower
     * 820px reading column (which is enforced inside the MD iframe's
     * own body styles, so this cap is functionally a no-op for MD). */
    .viewer-shell>iframe {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 50%;
      transform: translateX(-50%);
      width: 100%;
      max-width: 1100px;
      height: 100%;
      border: 0;
      display: block;
      background: #fff;
    }

    /* PdfPreview ------------------------------------------------------ */
    .pdf-preview {
      position: relative;
      width: 100%;
      height: 100%;
      /* Light surface keeps continuity with the rest of the app —
       * the white PDF page + box-shadow gives enough "paper on a
       * desk" contrast without a heavy dark backdrop. */
      background: var(--pane, #fafafa);
      overflow: auto;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding-top: 44px; /* clear the breadcrumb / chrome row */
    }
    /* ImagePreview ---------------------------------------------------- */
    .image-preview {
      position: relative;
      width: 100%;
      height: 100%;
      background: var(--pane, #fafafa);
      display: flex;
      flex-direction: column;
      padding-top: 44px; /* clear the breadcrumb / chrome row */
      box-sizing: border-box;
      overflow: hidden;
    }
    /* The scroll viewport. Defaults to actual-size content, so a large
     * image scrolls here rather than being squeezed to fit. */
    .image-preview-scroll {
      flex: 1;
      min-height: 0;
      overflow: auto;
    }
    /* Grows to at least the viewport so a smaller-than-pane image stays
     * centered, while a larger one expands the stage and the parent
     * scrolls to every edge (the flex-center-on-an-overflowing-child
     * clipping trap is avoided by centering the *stage*, not the img). */
    .image-preview-stage {
      min-width: 100%;
      min-height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 24px;
      box-sizing: border-box;
    }
    .image-preview-img {
      display: block;
      flex: 0 0 auto;
      height: auto;
      border-radius: 4px;
      box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
    }
    /* Floating zoom controls, pinned to the pane (outside the scroll area
     * so they don't move with the image). */
    .image-zoom-bar {
      position: absolute;
      bottom: 16px;
      left: 50%;
      transform: translateX(-50%);
      display: flex;
      align-items: center;
      gap: 2px;
      padding: 3px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
    }
    .image-zoom-bar button {
      appearance: none;
      border: 0;
      background: transparent;
      color: var(--fg);
      font: inherit;
      font-size: 13px;
      line-height: 1;
      padding: 5px 9px;
      border-radius: 5px;
      cursor: pointer;
      min-width: 28px;
    }
    .image-zoom-bar button:hover {
      background: var(--hover);
    }
    .image-zoom-bar .image-zoom-pct {
      min-width: 48px;
      font-variant-numeric: tabular-nums;
      color: var(--muted);
    }

    /* PDF zoom + page-count chrome, portalled into MainPane's
     * floating-actions row so it sits next to back/forward instead
     * of taking its own row. */
    .pdf-chrome {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;
      color: var(--fg);
    }
    .pdf-chrome .icon-btn {
      width: 26px;
      height: 26px;
      font-size: 15px;
      line-height: 1;
      background: transparent;
      border: 1px solid transparent;
      border-radius: 4px;
      cursor: pointer;
      color: inherit;
    }
    .pdf-chrome .icon-btn:hover { background: rgba(0,0,0,0.06); }
    .pdf-zoom {
      min-width: 38px;
      text-align: center;
      font-variant-numeric: tabular-nums;
    }
    .pdf-pageinfo {
      margin-left: 6px;
      opacity: 0.6;
    }
    .pdf-pages {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
      padding: 14px 0 40px;
      width: 100%;
    }
    .pdf-page-wrap {
      position: relative;
      background: #fff;
      box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    }
    .pdf-page-canvas {
      display: block;
    }
    .pdf-page-highlight-layer {
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 2;
    }
    .pdf-page-highlight {
      position: absolute;
      border-radius: 3px;
      background: rgba(46, 116, 230, 0.18);
      box-shadow: 0 0 0 2px rgba(46, 116, 230, 0.42);
      animation: pdf-hit-pulse 1.6s ease-out 1;
    }
    @keyframes pdf-hit-pulse {
      0% { background: rgba(46, 116, 230, 0.34); box-shadow: 0 0 0 3px rgba(46, 116, 230, 0.56); }
      100% { background: rgba(46, 116, 230, 0.18); box-shadow: 0 0 0 2px rgba(46, 116, 230, 0.42); }
    }
    .pdf-page-placeholder {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 600px;
      min-height: 800px;
      color: var(--muted);
      font-size: 12px;
    }
    .pdf-loading, .pdf-error {
      padding: 16px;
      color: var(--muted);
      font-size: 13px;
    }
    .pdf-error { color: #c83a3a; }
    .pdf-failure-banner {
      position: sticky;
      top: 0;
      z-index: 5;
      width: 100%;
      max-width: 1100px;
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 8px 14px;
      background: #fff4e0;
      border-bottom: 1px solid #f0c060;
      color: #5a3b00;
      font-size: 12px;
    }
    .pdf-failure-text {
      flex: 1;
      min-width: 0;
      max-height: 4.5em;
      overflow: auto;
      overflow-wrap: anywhere;
    }
    .pdf-failure-retry {
      flex: 0 0 auto;
      padding: 4px 10px;
      border: 1px solid #d4a233;
      background: #fff;
      color: #5a3b00;
      border-radius: 4px;
      cursor: pointer;
      font-size: 12px;
    }
    .pdf-failure-retry:disabled { opacity: 0.55; cursor: progress; }
    .pdf-failure-retry:hover:not(:disabled) { background: #fef0c5; }

    /* Inline rename — wrapper looks like one field, but only the
     basename is editable. The extension lives in a muted span pinned
     to the right so the user can't accidentally turn an .md note into
     something the rest of the pipeline doesn't know how to handle. */
    .rename-wrap {
      flex: 1;
      min-width: 0;
      display: flex;
      align-items: center;
      background: var(--card);
      border: 1px solid var(--accent);
      border-radius: 4px;
      font-size: 13px;
    }

    .rename-wrap .rename-input {
      flex: 1;
      min-width: 0;
      border: 0;
      outline: none;
      background: transparent;
      padding: 2px 0 2px 6px;
      font: inherit;
      color: var(--fg);
      text-align: left;
    }

    .rename-wrap .rename-ext {
      padding: 2px 6px 2px 0;
      color: var(--muted);
      white-space: nowrap;
      user-select: none;
    }

    /* Save status flows inline next to the doc title (centered cluster)
     so it doesn't collide with the absolutely-positioned format badge
     + edit toggle on the right edge. */
    .save-status {
      font-size: 12px;
      color: var(--muted);
      transition: opacity .3s;
    }

    .save-status:empty {
      display: none;
    }

    /* "Saved" / "Renaming…" share the default muted grey — green felt
     * too celebratory for a routine autosave tick. Errors stay red so
     * they break the visual rhythm. */
    .save-status.saved {
      color: var(--muted);
    }

    .save-status.error {
      color: #dc2626;
    }

    /* Content host for every viewer (iframe preview / split editor).
     Single-cell grid because a Chromium quirk: when an iframe with
     `position: absolute; inset: 0` sits inside a flex child, its
     internal initial-containing-block resolves to 0×0 — the iframe
     ELEMENT renders at full size but everything inside it (`<html>`,
     `<body>`, the user's content) lays out at zero. Grid cells give
     children a definite size unambiguously, sidestepping that bug. */
    .main-body {
      flex: 1;
      overflow: hidden;
      display: grid;
      grid-template: 1fr / 1fr;
      min-height: 0;
      min-width: 0;
      /* Reserve room for the absolute-positioned chrome row
       * (nav-actions / breadcrumb / floating-actions, all at top:44px,
       * height ~28px) so editor / preview content doesn't render
       * underneath it. */
      padding-top: 36px;
    }

    .main.no-file .main-body {
      padding-top: 0;
    }

    /* Tab strip — sits at the top of the main pane above the back/forward
     * + breadcrumb row. Layout is a horizontal flex row of chips. */
    .tab-strip {
      flex: 0 0 auto;
      background: var(--pane);
      padding: 6px 8px 0;
    }
    .tab-strip-inner {
      display: flex;
      align-items: flex-end;
      gap: 2px;
      /* Never wrap — VS Code-style single-row strip. When too many
       * tabs to fit at their natural width each one shrinks (see the
       * `flex: 1 1 0` on `.tab` below); when even shrunk-to-min tabs
       * don't fit, a horizontal scrollbar appears. Beats jumping to a
       * second row, which makes the document area resize and breaks
       * the "tabs are a strip" mental model. */
      flex-wrap: nowrap;
      overflow-x: auto;
      overflow-y: visible;
      scrollbar-width: thin;
      min-width: 0;
    }
    .tab {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 6px 8px 6px 10px;
      /* `flex: 1 1 0` makes every tab take an equal share of the
       * available width up to `max-width`; under pressure they shrink
       * down to `min-width` (just enough for a couple of chars + the
       * close button). */
      flex: 1 1 0;
      max-width: 200px;
      min-width: 60px;
      border: 1px solid transparent;
      border-bottom: none;
      border-top-left-radius: 6px;
      border-top-right-radius: 6px;
      background: transparent;
      color: var(--muted);
      cursor: pointer;
      font-size: 13px;
      user-select: none;
    }
    .tab:hover {
      background: var(--hover);
      color: var(--fg);
    }
    .tab.active {
      background: var(--bg);
      color: var(--fg);
      border-color: var(--border);
    }
    .tab-label {
      flex: 1;
      min-width: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    /* StashBase logo shown before a tab's label while the file is still
     * stashing (being converted into searchable content). Placeholder
     * for the eventual animated mark — the breathing pulse + reduced-
     * motion fallback live with the other stashing styles in
     * sidebar.css. */
    .tab-stashing-logo {
      width: 14px;
      height: 14px;
    }
    /* VS Code-style preview tabs: italic label is the visual cue that
     * the tab is "tentative" and the next single-click in the sidebar
     * will replace its content. Promoted to pinned (regular text) by
     * double-clicking either the sidebar file or the tab title. */
    .tab.preview .tab-label {
      font-style: italic;
    }

    /* Drag-reorder (HTML5 DnD, mirrors FileTree's drop-indicator
     * approach). The tab being dragged dims; the drop target paints an
     * inset accent edge on the side the dragged tab would land. */
    .tab.dragging {
      opacity: 0.4;
    }
    .tab.drop-before {
      box-shadow: inset 2px 0 0 0 var(--accent, #4a8cff);
    }
    .tab.drop-after {
      box-shadow: inset -2px 0 0 0 var(--accent, #4a8cff);
    }

    .tab-close {
      width: 18px;
      height: 18px;
      border: 0;
      background: transparent;
      color: var(--muted);
      font-size: 14px;
      line-height: 1;
      border-radius: 4px;
      cursor: pointer;
      padding: 0;
      display: grid;
      place-items: center;
      flex-shrink: 0;
    }
    .tab-close:hover {
      background: var(--border);
      color: var(--fg);
    }
    .tab-new {
      width: 28px;
      height: 28px;
      /* Pin to the right of the visible row even when tabs scroll —
       * never grows or shrinks with them. */
      flex: 0 0 28px;
      border: 0;
      background: transparent;
      color: var(--muted);
      font-size: 18px;
      line-height: 1;
      border-radius: 4px;
      cursor: pointer;
      padding: 0;
      margin-left: 2px;
      display: grid;
      place-items: center;
    }
    .tab-new:hover {
      background: var(--hover);
      color: var(--fg);
    }

    .doc {
      max-width: 760px;
      margin: 0 auto;
      padding: 0 32px;
      font-size: 15px;
      line-height: 1.7;
    }

    .empty-doc {
      height: 100%;
      display: grid;
      place-items: center;
      color: var(--muted);
      font-size: 13px;
      text-align: center;
      padding: 40px;
    }

    /* Calm "processing" state for a stashing file opened before its
     * content exists (a just-stopped recording). Sits in the single
     * .main-body grid cell and centers; the logo reuses the shared
     * `stashing-pulse` breathing (defined in sidebar.css). */
    .stashing-placeholder {
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 10px;
      padding: 40px;
      text-align: center;
      color: var(--muted);
      user-select: none;
    }
    .stashing-placeholder-logo {
      width: 40px;
      height: 40px;
    }
    @keyframes text-shimmer {
      0%   { background-position:  200% center; }
      100% { background-position: -200% center; }
    }
    .stashing-placeholder-title {
      font-size: 14px;
      font-weight: 500;
      color: transparent;
      background: linear-gradient(90deg, var(--muted) 25%, var(--fg) 50%, var(--muted) 75%);
      background-size: 300% 100%;
      -webkit-background-clip: text;
      background-clip: text;
      animation: text-shimmer 6s ease-in-out infinite;
    }
    @media (prefers-reduced-motion: reduce) {
      .stashing-placeholder-title { color: var(--fg); background: none; animation: none; }
    }

    /* Obsidian-style "new tab" landing — three stacked shortcut links
     * centered in the document area. Sits where the document content
     * would, so the back/forward + breadcrumb chrome above it still
     * reads as "this tab" rather than "nothing open". */
    .empty-tab-landing {
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 22px;
      padding: 40px;
    }
    .empty-tab-action {
      background: none;
      border: 0;
      padding: 4px 10px;
      color: var(--accent);
      cursor: pointer;
      font: inherit;
      font-size: 15px;
      font-weight: 500;
      border-radius: 6px;
      display: inline-flex;
      align-items: center;
      gap: 10px;
    }
    .empty-tab-action:hover {
      background: var(--hover);
    }
    .empty-tab-action kbd {
      font-family: inherit;
      color: var(--muted);
      font-size: 13px;
      font-weight: 400;
      letter-spacing: 0.5px;
    }
    .empty-tab-action.subtle {
      color: var(--muted);
    }
    .empty-tab-action.subtle:hover {
      color: var(--fg);
    }

    /* Empty-tab breadcrumb has no clickable parents — just the
     * "Untitled" placeholder in the same slot the path would occupy. */
    .main-breadcrumb.empty .seg {
      cursor: default;
    }
    .main-breadcrumb.empty .seg:hover {
      background: transparent;
      color: var(--muted);
    }

    /* Typora-ish markdown */
    .doc h1,
    .doc h2,
    .doc h3,
    .doc h4 {
      font-weight: 600;
      line-height: 1.25;
      margin: 1.8em 0 .6em;
    }

    .doc h1 {
      font-size: 28px;
    }

    .doc h2 {
      font-size: 22px;
    }

    .doc h3 {
      font-size: 18px;
    }

    .doc h4 {
      font-size: 15px;
    }

    .doc p {
      margin: .8em 0;
    }

    .doc a {
      color: var(--accent);
      text-decoration: none;
    }

    .doc a:hover {
      text-decoration: underline;
    }

    .doc code {
      background: var(--pane);
      border-radius: 3px;
      padding: 1px 5px;
      font: 12.5px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    }

    .doc pre {
      background: var(--pane);
      border-radius: 6px;
      padding: 14px 16px;
      overflow-x: auto;
      margin: 1em 0;
    }

    .doc pre code {
      background: none;
      padding: 0;
      font-size: 12.5px;
      line-height: 1.55;
    }

    .doc blockquote {
      border-left: 3px solid var(--border);
      padding-left: 14px;
      color: var(--muted);
      margin: 1em 0;
    }

    .doc ul,
    .doc ol {
      padding-left: 1.6em;
    }

    .doc li {
      margin: .25em 0;
    }

    .doc hr {
      border: 0;
      border-top: 1px solid var(--border);
      margin: 2em 0;
    }

    .doc table {
      border-collapse: collapse;
      margin: 1em 0;
    }

    .doc th,
    .doc td {
      border: 1px solid var(--border);
      padding: 6px 10px;
    }

    .doc img {
      max-width: 100%;
    }

    .drop-veil {
      position: fixed;
      inset: 0;
      background: rgba(37, 99, 235, .06);
      border: 2px dashed var(--accent);
      pointer-events: none;
      display: none;
      align-items: center;
      justify-content: center;
      color: var(--accent);
      font-size: 16px;
      z-index: 100;
    }

    .drop-veil.hot {
      display: flex;
    }


    /* Viewers sit in the single grid cell of .main-body and fill it with
     definite dimensions. HTML uses .viewer-shell so read-only preview
     matches the stable iframe geometry used by split edit preview.
     Markdown preview still mounts an iframe directly under .main-body. */
    .main-body>.html-viewer {
      width: 100%;
      height: 100%;
      border: 0;
      display: block;
      background: #fff;
    }

    .image-lightbox {
      position: fixed;
      inset: 0;
      z-index: 90;
      display: flex;
      flex-direction: column;
      background: rgba(18, 18, 20, 0.92);
      color: #fff;
    }

    .image-lightbox-toolbar {
      height: 44px;
      flex: 0 0 auto;
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 7px 12px 7px 78px;
      background: rgba(18, 18, 20, 0.96);
      border-bottom: 1px solid rgba(255, 255, 255, 0.12);
      -webkit-app-region: drag;
    }

    .image-lightbox-title {
      min-width: 0;
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 12.5px;
      color: rgba(255, 255, 255, 0.82);
    }

    .image-lightbox-toolbar button {
      height: 28px;
      padding: 0 10px;
      border: 1px solid rgba(255, 255, 255, 0.16);
      border-radius: 6px;
      background: rgba(255, 255, 255, 0.08);
      color: #fff;
      font: inherit;
      font-size: 12.5px;
      cursor: pointer;
      -webkit-app-region: no-drag;
    }

    .image-lightbox-toolbar button:hover {
      background: rgba(255, 255, 255, 0.14);
    }

    .image-lightbox-scale {
      min-width: 44px;
      text-align: center;
      color: rgba(255, 255, 255, 0.72);
      font-size: 12px;
      font-variant-numeric: tabular-nums;
    }

    .image-lightbox-stage {
      flex: 1;
      min-height: 0;
      display: grid;
      place-items: center;
      overflow: hidden;
      touch-action: none;
      cursor: zoom-in;
    }

    .image-lightbox-stage.pannable {
      cursor: grab;
    }

    .image-lightbox-stage.pannable:active {
      cursor: grabbing;
    }

    .image-lightbox-stage img {
      max-width: calc(100vw - 64px);
      max-height: calc(100vh - 108px);
      object-fit: contain;
      user-select: none;
      transition: transform 0.08s ease-out;
      transform-origin: center center;
      box-shadow: 0 16px 60px rgba(0, 0, 0, 0.35);
    }

    /* Welcome screen — VSCode/Cursor-style first-run overlay shown when
     no space is open. Sits above .app via fixed positioning so we can
     simply toggle [hidden] and the underlying UI keeps its state. */
    .welcome {
      position: fixed;
      inset: 0;
      z-index: 50;
      background: #f6f7f9;
      display: flex;
      align-items: flex-start;
      justify-content: center;
      overflow: auto;
      color: #222;
      font-family: inherit;
    }

    .welcome[hidden] {
      display: none;
    }

    body.is-electron .welcome::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 32px;
      -webkit-app-region: drag;
    }

    body.is-electron .welcome-inner {
      padding-top: 56px;
    }

    .welcome-inner {
      width: min(620px, calc(100vw - 48px));
      padding: 32px 36px 28px;
      margin-top: 22vh;
    }

    .welcome-brand {
      margin-bottom: 28px;
      /* Row 1: logo + title side-by-side; row 2: sub on its own,
       * spanning both columns so it reads as a separate caption line. */
      display: grid;
      grid-template-columns: auto 1fr;
      column-gap: 4px;
      row-gap: 10px;
      align-items: center;
    }

    .welcome-logo {
      width: 42px;
      height: 42px;
      grid-column: 1;
      grid-row: 1;
    }

    .welcome-brand .welcome-title { grid-column: 2; grid-row: 1; }
    .welcome-brand .welcome-sub   { grid-column: 1 / -1; grid-row: 2; margin-top: 0; }

    .welcome-logo svg {
      width: 100%;
      height: 100%;
    }

    .welcome-title {
      font-size: 28px;
      font-weight: 600;
      letter-spacing: -0.01em;
    }

    .welcome-sub {
      color: #777;
      font-size: 13px;
      margin-top: 4px;
      line-height: 1.5;
    }

    .welcome-actions {
      display: flex;
      gap: 12px;
      margin-bottom: 14px;
    }

    .welcome-actions .welcome-action {
      flex: 1;
    }

    .welcome-action {
      display: flex;
      flex-direction: row;
      align-items: center;
      gap: 13px;
      padding: 18px 18px;
      border: 1px solid #e1e3e7;
      border-radius: 8px;
      background: #fff;
      color: #222;
      cursor: pointer;
      text-align: left;
      box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
      transition: border-color 0.12s, background 0.12s, box-shadow 0.12s,
        transform 0.12s;
    }

    .welcome-action:hover {
      border-color: #b9bdc4;
      background: #fafbfc;
      box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
      transform: translateY(-1px);
    }

    .welcome-action:active {
      transform: translateY(0);
      box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    }

    .welcome-action-icon {
      width: 38px;
      height: 38px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 8px;
      background: rgba(8, 145, 178, 0.08);
      color: var(--accent);
    }

    .welcome-action-icon svg {
      width: 22px;
      height: 22px;
    }

    .welcome-action-label {
      font-size: 14px;
      font-weight: 500;
    }

    .welcome-mcp {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 14px;
      padding: 14px 16px;
      margin-bottom: 24px;
      border: 1px solid rgba(8, 145, 178, 0.24);
      border-radius: 8px;
      background: rgba(8, 145, 178, 0.06);
      box-shadow: 0 1px 2px rgba(8, 145, 178, 0.05);
    }

    .welcome-mcp-text {
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 3px;
    }

    .welcome-mcp-title {
      font-size: 13.5px;
      font-weight: 600;
      color: #222;
    }

    .welcome-mcp-sub {
      font-size: 12.5px;
      line-height: 1.45;
      color: #6f757d;
    }

    .welcome-mcp-btn {
      flex-shrink: 0;
      border: 1px solid rgba(8, 145, 178, 0.35);
      background: #fff;
      color: var(--accent);
      border-radius: 6px;
      padding: 7px 12px;
      cursor: pointer;
      font: inherit;
      font-size: 12.5px;
      font-weight: 500;
      transition: background 0.12s, border-color 0.12s;
    }

    .welcome-mcp-btn:hover {
      background: rgba(8, 145, 178, 0.08);
      border-color: rgba(8, 145, 178, 0.5);
    }

    .welcome-recent {
      margin-top: 4px;
    }

    .welcome-recent-head {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: #888;
      font-weight: 600;
      margin-bottom: 8px;
      padding: 0 8px;
      display: flex;
      justify-content: space-between;
      align-items: baseline;
    }

    .welcome-recent-pills {
      display: flex;
      flex-wrap: wrap;
      gap: 6px 8px;
      padding: 0 8px;
    }

    .welcome-recent-pill {
      padding: 5px 12px;
      border-radius: 999px;
      border: 1px solid #d6d9dd;
      background: #f5f6f8;
      color: #1f1f1f;
      font-size: 12px;
      font-weight: 500;
      cursor: pointer;
      line-height: 1.4;
      max-width: 240px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      transition: background 0.08s ease, border-color 0.08s ease;
    }

    .welcome-recent-pill:hover {
      background: #e9ebef;
      border-color: #c1c5cb;
    }

    .welcome-recent-pill:active {
      background: #dde0e5;
    }

    .welcome-open-list {
      display: flex;
      flex-direction: column;
      max-height: 260px;
      overflow-y: auto;
      border: 1px solid #e1e3e6;
      border-radius: 8px;
      margin: 8px 0 12px;
    }

    .welcome-open-row {
      display: flex;
      align-items: center;
      gap: 10px;
      text-align: left;
      padding: 10px 14px;
      border: none;
      background: transparent;
      font-size: 13px;
      color: #1f1f1f;
      cursor: pointer;
      border-bottom: 1px solid #f1f2f4;
      transition: background 0.1s, color 0.1s;
    }

    .welcome-open-row-icon {
      width: 16px;
      height: 16px;
      flex-shrink: 0;
      color: #9ca3af;
      transition: color 0.1s;
    }

    .welcome-open-row-name {
      flex: 1;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .welcome-open-row::after {
      content: '›';
      font-size: 16px;
      line-height: 1;
      flex-shrink: 0;
      color: var(--accent);
      opacity: 0;
      transform: translateX(-4px);
      transition: opacity 0.12s, transform 0.12s;
    }

    .welcome-open-row:last-child {
      border-bottom: none;
    }

    .welcome-open-row:hover:not(:disabled),
    .welcome-open-row.active:not(:disabled) {
      background: rgba(8, 145, 178, 0.07);
    }

    .welcome-open-row:hover:not(:disabled)::after,
    .welcome-open-row.active:not(:disabled)::after {
      opacity: 1;
      transform: translateX(0);
    }

    .welcome-open-row:hover:not(:disabled) .welcome-open-row-icon,
    .welcome-open-row.active:not(:disabled) .welcome-open-row-icon {
      color: var(--accent);
    }

    .welcome-open-row:disabled {
      cursor: default;
      opacity: 0.6;
    }

    .welcome-open-row:disabled::after {
      content: none;
    }

    .welcome-recent-more {
      padding: 0;
      background: none;
      border: none;
      color: #0891b2;
      font-size: 11px;
      font-weight: 400;
      letter-spacing: 0.04em;
      text-transform: uppercase;
      cursor: pointer;
    }

    .welcome-recent-more:hover {
      text-decoration: underline;
    }

    .welcome-err {
      margin-top: 14px;
      padding: 8px 12px;
      font-size: 12.5px;
      color: #b91c1c;
      background: #fef2f2;
      border: 1px solid #fecaca;
      border-radius: 6px;
    }

    .welcome-err[hidden] {
      display: none;
    }

    /* Unified Settings modal — left nav + right content. Wider than
     * the default modal-card so the MCP client list (the longest
     * panel) doesn't crowd. */
    .modal-card.settings-card {
      width: min(760px, 94vw);
      /* Fixed height — the modal must NOT resize when switching tabs.
       * Each panel scrolls inside .settings-content instead. */
      height: min(78vh, 640px);
      padding: 0;
      display: flex;
      flex-direction: column;
    }

    .settings-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
    }

    .settings-header h3 {
      margin: 0;
      font-size: 15px;
    }

    .settings-close {
      width: 28px;
      height: 28px;
      border: 0;
      background: transparent;
      color: var(--muted);
      font-size: 20px;
      line-height: 1;
      border-radius: 6px;
      cursor: pointer;
      transition: background 0.12s, color 0.12s;
    }

    .settings-close:hover {
      color: var(--fg);
      background: var(--hover);
    }

    .settings-close:disabled {
      cursor: default;
      opacity: 0.45;
    }

    .settings-body {
      display: grid;
      grid-template-columns: 180px 1fr;
      min-height: 0;
      flex: 1;
    }

    .settings-nav {
      display: flex;
      flex-direction: column;
      padding: 12px 8px;
      border-right: 1px solid var(--border);
      background: var(--pane);
      gap: 2px;
    }

    .settings-nav-item {
      text-align: left;
      padding: 7px 12px;
      border: 0;
      background: transparent;
      color: var(--fg);
      font: inherit;
      font-size: 13px;
      border-radius: 6px;
      cursor: pointer;
      transition: background 0.12s, color 0.12s;
    }

    .settings-nav-item:hover {
      background: var(--hover);
    }

    .settings-nav-item:disabled {
      cursor: default;
      opacity: 0.55;
    }

    .settings-nav-item:disabled:hover {
      background: transparent;
    }

    .settings-nav-item.current {
      background: rgba(8, 145, 178, 0.10);
      color: var(--accent);
      font-weight: 600;
    }

    .settings-content {
      padding: 20px 24px;
      overflow-y: auto;
      min-width: 0;
    }

    .settings-section + .settings-section {
      margin-top: 22px;
      padding-top: 18px;
      border-top: 1px solid var(--border);
    }

    .settings-section-title {
      font-size: 13px;
      font-weight: 600;
      color: var(--fg);
      margin-bottom: 4px;
    }

    .settings-section-hint {
      font-size: 12px;
      color: var(--muted);
      line-height: 1.5;
      margin-bottom: 10px;
    }

    .settings-section-hint code {
      font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
      font-size: 11.5px;
      color: var(--accent);
      white-space: nowrap;
    }


    .settings-actions-row {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    /* A hint that trails *below* the action row (secondary detail —
     * privacy note, storage location, …). Sits at the bottom. */
    .settings-hint-foot {
      margin-top: 14px;
      margin-bottom: 0;
    }

    /* KB-root migration: per-conflict resolver. One row per colliding
     * space name + a segmented Keep both / Skip / Overwrite control. */
    .migrate-conflict-list {
      display: flex;
      flex-direction: column;
      border: 1px solid var(--border);
      border-radius: 8px;
      overflow: hidden;
      margin: 4px 0;
      max-height: 320px;
      overflow-y: auto;
    }
    .migrate-conflict-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 10px 12px;
    }
    .migrate-conflict-row + .migrate-conflict-row {
      border-top: 1px solid var(--border);
    }
    .migrate-conflict-name {
      font-size: 13px;
      font-weight: 500;
      color: var(--fg);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .migrate-choices {
      display: inline-flex;
      flex-shrink: 0;
      border: 1px solid var(--border);
      border-radius: 6px;
      overflow: hidden;
    }
    .migrate-choice {
      border: 0;
      background: transparent;
      color: var(--muted);
      font: inherit;
      font-size: 12px;
      padding: 5px 10px;
      cursor: pointer;
      transition: background 0.1s, color 0.1s;
    }
    .migrate-choice + .migrate-choice {
      border-left: 1px solid var(--border);
    }
    .migrate-choice:hover {
      background: var(--hover);
      color: var(--fg);
    }
    .migrate-choice.active {
      background: rgba(8, 145, 178, 0.10);
      color: var(--accent);
      font-weight: 600;
    }
    .migrate-choice.overwrite.active {
      background: rgba(220, 38, 38, 0.10);
      color: #b91c1c;
    }

    .settings-panel {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    /* Screen-recording status — a coloured, bold state word leading an
     * otherwise-muted hint line (no heavy card; matches the flat style
     * of the other settings tabs). */
    .capture-state-ok { color: var(--accent); font-weight: 600; }
    .capture-state-warn { color: #b45309; font-weight: 600; }

    .settings-note,
    .settings-ok,
    .settings-error {
      font-size: 12px;
      line-height: 1.45;
      margin: 0;
    }

    .settings-note {
      color: var(--muted);
    }

    .settings-ok {
      color: #047857;
    }

    .settings-error {
      color: #b91c1c;
    }

    .settings-field-row {
      display: flex;
      gap: 8px;
      align-items: center;
      min-width: 0;
    }

    .settings-text-input {
      flex: 1;
      min-width: 0;
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 8px 10px;
      font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace;
      color: var(--fg);
      background: #fff;
    }

    .settings-primary-btn,
    .settings-secondary-btn {
      height: 32px;
      border-radius: 6px;
      padding: 0 12px;
      font: inherit;
      font-size: 12px;
      cursor: pointer;
      white-space: nowrap;
      transition: background 0.12s, border-color 0.12s, filter 0.12s;
    }

    .settings-primary-btn {
      border: 1px solid var(--accent);
      background: var(--accent);
      color: #fff;
    }
    .settings-primary-btn:hover:not(:disabled) {
      filter: brightness(0.96);
    }

    .settings-secondary-btn {
      border: 1px solid var(--border);
      background: #fff;
      color: var(--fg);
    }
    .settings-secondary-btn:hover:not(:disabled) {
      background: var(--hover);
      border-color: #b9bdc4;
    }

    /* Destructive secondary (e.g. Remove key) — red text/border, red
     * wash on hover. Matches the accent/red palette used elsewhere. */
    .settings-secondary-btn.danger {
      color: #b91c1c;
      border-color: rgba(220, 38, 38, 0.3);
    }
    .settings-secondary-btn.danger:hover:not(:disabled) {
      background: rgba(220, 38, 38, 0.06);
      border-color: rgba(220, 38, 38, 0.45);
    }

    .settings-primary-btn:disabled,
    .settings-secondary-btn:disabled,
    .settings-text-input:disabled {
      opacity: 0.6;
      cursor: default;
    }

    .modal-btn.danger {
      color: #b91c1c;
      border-color: rgba(220, 38, 38, 0.3);
    }
    .modal-btn.danger:hover:not(:disabled) {
      background: rgba(220, 38, 38, 0.06);
    }

    .settings-panel-loading {
      color: var(--muted);
      font-size: 13px;
      padding: 12px 0;
    }

    /* Bottom-right stack of toast notifications. `fixed` so the stack
     * floats over scroll containers without being clipped; column-
     * reverse so the newest toast pops in below the existing ones
     * (less disruptive than pushing everything down). Pointer events
     * forwarded only to the actual toast cards so the stack itself
     * doesn't block clicks on the underlying UI. */
    .toast-stack {
      position: fixed;
      right: 16px;
      bottom: 16px;
      display: flex;
      flex-direction: column;
      gap: 8px;
      max-width: min(360px, calc(100vw - 32px));
      z-index: 9000;
      pointer-events: none;
    }

    .toast {
      pointer-events: auto;
      display: flex;
      align-items: flex-start;
      gap: 8px;
      padding: 10px 12px;
      border-radius: 8px;
      background: var(--bg);
      color: var(--fg);
      border: 1px solid var(--border);
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
      font-size: 12.5px;
      line-height: 1.4;
      animation: toast-in 160ms ease-out;
    }

    @keyframes toast-in {
      from { opacity: 0; transform: translateY(6px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    /* Level-specific accents — a 3px left bar carries the colour
     * cue; the body stays on the neutral surface so the message
     * itself reads clearly. */
    .toast.toast-info    { border-left: 3px solid var(--accent); }
    .toast.toast-success { border-left: 3px solid #047857; }
    .toast.toast-warning { border-left: 3px solid #d97706; }
    .toast.toast-error   { border-left: 3px solid #b91c1c; }

    .toast-msg {
      flex: 1 1 auto;
      min-width: 0;
      word-break: break-word;
    }

    .toast-action {
      appearance: none;
      flex: 0 0 auto;
      border: 1px solid var(--border);
      background: var(--bg);
      color: var(--fg);
      font: inherit;
      font-size: 12px;
      font-weight: 600;
      padding: 2px 8px;
      border-radius: 4px;
      cursor: pointer;
    }
    .toast-action:hover {
      background: var(--hover);
    }

    .toast-close {
      appearance: none;
      flex: 0 0 auto;
      border: 0;
      background: transparent;
      color: var(--muted);
      font-size: 16px;
      line-height: 1;
      padding: 0 4px;
      cursor: pointer;
    }
    .toast-close:hover {
      color: var(--fg);
    }
