/* mnemo UI - modern dark theme, generous spacing, designed for clarity. */

:root {
  --bg:           #0b0d10;
  --panel:        #14171c;
  --panel-2:      #1b1f25;
  --border:       #262b33;
  --border-soft:  #1f242c;
  --fg:           #e6edf3;
  --fg-muted:     #a0a8b3;
  --fg-dim:       #6b727c;

  --accent:       #7ee7e0;
  --accent-hover: #a5f0eb;
  --accent-soft:  rgba(126, 231, 224, 0.12);

  --ok:    #56d364;
  --warn:  #d97757;
  --info:  #6cb6ff;

  --type-feedback:  #f0a47c;
  --type-user:      #b6e88c;
  --type-project:   #8db6f0;
  --type-reference: #d790f0;
  --type-doc:       #f0d990;
  --type-plan:      #9396f0;

  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 0 rgba(255,255,255,0.02), 0 4px 12px rgba(0,0,0,0.25);
  --transition: 120ms ease;

  /* C1 page-shell + primitive tokens (v4.0) -- a value lives here once. */
  --topbar-h:       65px;     /* topbar height; calc(100vh - var(--topbar-h)) */
  --content-max:    1600px;   /* centered-page content cap */
  --page-pad:       2rem;     /* centered-page horizontal padding */
  --radius-pill:    999px;    /* pill / capsule radius */
  --accent-fg:      #06201e;  /* text on --accent fills */
  --warn-fg:        #1a0f0c;  /* text on --warn fills */
  --measure:        46rem;    /* canonical reading measure for centered prose */
  --measure-wide:   40rem;    /* token-track width */
  --measure-prose:  30rem;    /* welcome copy width */
  --measure-narrow: 28rem;    /* examples column width */

  /* C1.R breakpoint scale (responsive contract, v4.4) -- a breakpoint
     lives here once. CSS @media can't take var(); the rem literal in
     every width media query IS the single-source contract, enforced by
     tests/unit/test_responsive_contract.py. The 15 ad-hoc literals
     (1100/980/1080/800/900/1000px) consolidated to --bp-md (the natural
     800-1100px cluster point); desktop pixel-parity at 1280/1440 holds
     (every max-width stays inactive, every min-width stays active there
     exactly as before). rem so the scale tracks the user's font. */
  --bp-sm: 40rem;   /* ~640px @ 16px root -- tight / mobile            */
  --bp-md: 60rem;   /* ~960px @ 16px root -- primary collapse point    */
  --bp-lg: 80rem;   /* ~1280px @ 16px root -- wide desktop             */

  --mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

/* v5.1.1: themed custom cursor.
   Two SVG assets in cursors/ — the default carries a soft teal halo
   that matches the C1 --accent, and the pointer variant brightens for
   interactive targets. Relative URL (cursors/...) resolves the same
   way from /static/app.css in the daemon AND from /app.css in the
   demo Pages build (the build copies the cursors dir alongside). The
   ``, auto`` / ``, pointer`` fallback keeps the platform default if
   a UA refuses the SVG cursor for any reason.
   Hot spot is the center (16, 16) — see the SVG headers. */
body {
  cursor: url("cursors/mnem-cursor.svg") 16 16, auto;
}
a, button, [role="button"], summary, label,
input[type="submit"], input[type="button"], input[type="checkbox"],
input[type="radio"], select,
.mc-architect, .mc-copy, .mc-copy-prompt,
.mc-tab, .demo-chip, .clickable {
  cursor: url("cursors/mnem-cursor-pointer.svg") 16 16, pointer;
}
/* Restore the OS text I-beam for typing surfaces — the custom
   cursor would obscure caret placement otherwise. */
input[type="text"], input[type="password"], input[type="email"],
input[type="search"], input:not([type]), textarea {
  cursor: text;
}

/* --- Scrollbar (custom, cross-browser) --------------------------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
  border: 2px solid var(--bg);
  transition: background-color var(--transition);
}
*::-webkit-scrollbar-thumb:hover { background: var(--accent); }
*::-webkit-scrollbar-corner { background: transparent; }
/* Inside dark panels, blend the track edge with the panel. */
.card *::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb,
.detail-body pre::-webkit-scrollbar-thumb,
.detail-panel::-webkit-scrollbar-thumb { border-color: var(--panel); }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* --- Topbar -------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.85rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  color: var(--accent);
  transition: var(--transition);
}
.brand:hover { color: var(--accent-hover); }
/* v3.1: the Mnem mark replaces the old "M" pseudo-badge. */
.brand-mark {
  display: block;
  filter: drop-shadow(0 1px 4px rgba(126, 231, 224, 0.25));
}

.topbar nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}
.topbar nav a {
  color: var(--fg-muted);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.92rem;
  position: relative;
  transition: color var(--transition), background var(--transition);
}
.topbar nav a:hover {
  color: var(--fg);
  background: var(--panel-2);
}
.topbar nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
}
.topbar nav a.active::after {
  content: "";
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: -0.85rem;
  width: 22px; height: 2px;
  background: var(--accent);
  border-radius: 2px;
  animation: nav-underline 200ms ease-out;
}
@keyframes nav-underline {
  from { transform: translateX(-50%) scaleX(0); }
  to   { transform: translateX(-50%) scaleX(1); }
}

.topbar .help {
  font-size: 0.85rem;
  color: var(--fg-dim);
}

/* --- C1.R adaptive nav drawer (v4.4) -------------------------------
   >= --bp-md: .nav-drawer is display:contents, so nav + workspace-
   switcher + bell + help stay direct .topbar flex items -- pixel-
   identical to pre-v4.4 (the Task-1 desktop-parity discipline). The
   hamburger is display:none. < --bp-md: the toggle appears and the
   drawer becomes a fixed off-canvas panel with a scrim (a11y:
   aria-expanded on the toggle, Escape + scrim close, focus return --
   navDrawer()). Themed 100% from C1 tokens. */
.nav-drawer {
  display: contents;
}
/* v4.4.1: workspace-switcher + notification bell live here (NOT in
   the drawer) -- always right-aligned + directly clickable on every
   screen size (the user's explicit IA). >= --bp-md the contents-
   drawer's nav has flex:1 so this group sits at the right exactly as
   before; < --bp-md the drawer is out of flow so margin-left:auto
   right-aligns it (the topbar is then [hamburger][brand]...[actions]). */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px; /* C1.R polish: >= 44px touch target */
  height: 44px;
  padding: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  cursor: pointer;
  transition: var(--transition);
}
.nav-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.nav-scrim {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 55;
  border: 0;
}
@media (min-width: 60rem) {
  /* --bp-md: the scrim must never paint on desktop, even if the
     persisted open state is stale from a narrow session. */
  .nav-scrim {
    display: none !important;
  }
}
@media (max-width: 60rem) {
  /* --bp-md: collapse the topbar into the off-canvas drawer. The
     hamburger is leftmost (no margin-left:auto); the workspace+bell
     actions group right-aligns instead (always visible, not drawered). */
  .nav-toggle {
    display: inline-flex;
  }
  /* v4.4.1: the 2rem desktop gap + 1.5rem padding overflow a 375
     row once toggle+brand+actions all show. Tighten on mobile. AND
     drop backdrop-filter < --bp-md: it makes .topbar the containing
     block for its position:fixed children (.nav-drawer / .nav-scrim),
     so the drawer resolved against the 63px topbar box -> a broken
     32px strip on click. Without it they resolve against the viewport
     -> a real full-height side panel + a full-screen scrim. (Desktop
     keeps the glass blur; there the drawer is display:contents, not
     fixed, so no CB trap.) */
  .topbar {
    gap: 0.55rem;
    padding: 0.55rem 0.85rem;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .topbar-actions {
    margin-left: auto;
    gap: 0.45rem;
  }
  .topbar-actions .workspace-switcher-label {
    max-width: 7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* v4.4.1: a real full-height side panel anchored LEFT (the
     hamburger is leftmost -> the menu sticks to the left; a left
     trigger opening a right panel was disorienting). display:none
     when closed (zero footprint, never extends scrollWidth); when
     open it's a fixed panel pinned top:--topbar-h / left:0 / bottom:0,
     full height now that .topbar drops backdrop-filter < --bp-md so
     this resolves against the viewport (not the 63px topbar). */
  .nav-drawer {
    display: none;
    position: fixed;
    inset: var(--topbar-h) auto 0 0;
    width: min(82vw, 320px);
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    padding: 1rem;
    background: var(--panel);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow-y: auto;
    z-index: 60;
  }
  .nav-drawer.open {
    display: flex;
  }
  .nav-drawer nav {
    flex-direction: column;
    flex: none;
    gap: 0.15rem;
  }
  .nav-drawer nav a {
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
  }
  .nav-drawer nav a.active::after {
    display: none;
  }
  .nav-drawer .help {
    padding: 0.5rem 0.25rem;
  }
}

/* --- Main layout --------------------------------------------------- */

main {
  max-width: var(--content-max);
  margin: 2rem auto;
  padding: 0 var(--page-pad) 4rem;  /* bottom breathing room */
  animation: page-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1.0);
}
@media (max-width: 60rem) { /* --bp-md (was 1100px) */
  main { padding: 0 1.25rem 3rem; }
}

main.full {
  max-width: none;
  margin: 0;
  padding: 0;
  animation: page-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1.0);
}

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

/* Reduce motion for users who prefer it. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; margin: 0; }
h2 { font-size: 1.15rem; margin-top: 1.5rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.0rem; margin-top: 1.25rem; margin-bottom: 0.5rem; color: var(--fg-muted); }

p { margin: 0.5rem 0; color: var(--fg); }
.hint { color: var(--fg-muted); font-size: 0.9rem; }

/* --- Forms / inputs ------------------------------------------------ */

input, textarea, button, select {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  font: inherit;
  font-family: var(--sans);
  transition: var(--transition);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* --- Custom checkbox: themed dark-mode checkbox using only CSS.
   Works on every checkbox in the app; graph + nodes filters and any
   future ones inherit automatically. Native browser checkbox is hidden
   via `appearance: none` and we draw the box + checkmark ourselves. ---
*/
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
input[type="checkbox"]:hover {
  border-color: var(--accent);
}
input[type="checkbox"]::before {
  content: "";
  width: 9px; height: 9px;
  transform: scale(0);
  transition: transform 100ms ease-out;
  background: var(--bg);
  /* Two-line check mark drawn as a clipped square via clip-path. */
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
  background: var(--accent);
}
input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked::before {
  transform: scale(1);
  background: var(--bg);
}
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: url("cursors/mnem-cursor-not-allowed.svg") 16 16, not-allowed;
}

/* --- Custom select: themed dropdown trigger. We strip the native
   chrome and draw our own caret. The popped-open option list is still
   browser-rendered (can't fully theme in CSS), but the closed state
   matches the rest of the dark UI.

   The caret is a URL-encoded inline SVG (literal `<` and `>` in a data:
   URI break Firefox -- always %-encode them). ---
*/
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237ee7e0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  /* Tell Chromium/Firefox to render the option popup with dark theme
     when the user's browser supports color-scheme. */
  color-scheme: dark;
}
select:hover {
  border-color: var(--accent);
}
/* Tighter compact selects (nodes filter, audit pagination) keep the
   custom caret but use less padding. */
.filters select {
  padding: 0.4rem 2rem 0.4rem 0.65rem;
  font-size: 0.85rem;
  background-position: right 0.6rem center;
}
select option {
  background: var(--panel);
  color: var(--fg);
}
select:disabled {
  opacity: 0.5;
  cursor: url("cursors/mnem-cursor-not-allowed.svg") 16 16, not-allowed;
}
input[type="search"] {
  font-family: var(--mono);
  font-size: 0.95rem;
}
textarea { font-family: var(--mono); font-size: 0.9rem; }

button {
  cursor: pointer;
  font-weight: 500;
}
button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
button:disabled { opacity: 0.5; cursor: url("cursors/mnem-cursor-progress.svg") 16 16, progress; }
button.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg);
}

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

/* --- C1.R no-overflow primitives (v4.4) ---------------------------
   The v4.3.1 audit-overflow lesson, generalized + single-sourced. A
   long string must fit its box: .u-truncate clips to one line with an
   ellipsis; .u-clamp clips to var(--u-clamp) lines (default 3) for
   descriptions / previews. Both set min-width:0 -- an un-shrinkable
   box makes the clip inert (the v4.3.1 root cause; the ancestor
   grid/flex track must also allow shrink via minmax(0,...)/min-width:0).
   The line count is a token so a surface tunes it without redefining
   the primitive. Forbidden to redefine in any page template
   (test_responsive_contract is the teeth). */
.u-truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.u-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--u-clamp, 3);
  line-clamp: var(--u-clamp, 3);
  min-width: 0;
  overflow: hidden;
}
/* Wide non-responsive content (a data <table>) scrolls WITHIN its own
   box instead of forcing a document scrollbar. Wrap any table that
   can exceed the viewport in <div class="table-scroll">. */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

/* --- C1 shared chat primitives (v4.0) ------------------------------
   Single canonical home. Pre-v4.0 these were duplicated + divergent
   in chat.html (page) and base.html (dock); the dock copies were 5px
   dots / no @keyframes off /chat. Canonical = the page variant; the
   dock now matches it (intended de-divergence). The C1 guard test
   forbids re-defining these in any page template. */
.mnem-working { display: inline-flex; gap: .3rem; align-items: center;
  padding: .15rem 0; min-height: 1.1rem; }
.mnem-working span { width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); opacity: .35;
  animation: mnem-bob 1.1s ease-in-out infinite; }
.mnem-working span:nth-child(2) { animation-delay: .15s; }
.mnem-working span:nth-child(3) { animation-delay: .3s; }
@keyframes mnem-bob {
  0%,80%,100% { opacity: .3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) {
  .mnem-working span { animation: none; opacity: .6; } }

.load-older { min-height: 6px; display: flex; justify-content: center; }
.load-older.on { padding: .35rem 0 .2rem; }
.lo-pill { display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--mono); font-size: .7rem; color: var(--fg-dim);
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill); padding: .25rem .7rem; }
.lo-dot { width: 4px; height: 4px; border-radius: 50%;
  background: var(--fg-dim); animation: mnem-bob 1.2s ease-in-out infinite; }
.lo-dot:nth-child(2) { animation-delay: .15s; }
.lo-dot:nth-child(3) { animation-delay: .3s; }

/* Canonical link-styled button (was defined nowhere central pre-v4.0;
   sources.html keeps only its contextual .row-actions overrides). */
.link-button { background: none; border: 0; padding: 0; margin: 0;
  color: var(--accent); cursor: pointer; font: inherit;
  text-decoration: none; transition: color var(--transition); }
.link-button:hover { color: var(--accent-hover); }
.link-button:disabled { opacity: .5; cursor: url("cursors/mnem-cursor-progress.svg") 16 16, progress; }

/* Pill-shape base for future convergence of send/mc-send/chat-jump/
   msg-copy/tool-chip (shape only; no element opts in during v4.0). */
.btn-pill { display: inline-flex; align-items: center;
  justify-content: center; border-radius: var(--radius-pill);
  cursor: pointer; transition: var(--transition); }

/* C4 (v4.2): the shared settings cross-route tab strip. One source
   here (not a per-page <style>) -- both /settings and /settings/chat
   include _settings_tabs.html. */
.settings-tabs { display: flex; gap: .4rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--border-soft);
  margin: 1rem 0 1.25rem; }
.settings-tabs a { padding: .55rem 1rem; color: var(--fg-muted);
  text-decoration: none; border-bottom: 2px solid transparent;
  transition: color var(--transition); }
.settings-tabs a:hover { color: var(--fg); }
.settings-tabs a.active { color: var(--fg);
  border-bottom-color: var(--accent); }

/* C3 (v4.3): the SHARED chat rail's dock variant. The dock renders
   off /chat where chat.html's <style> (.chat-rail page styling) is
   absent, so .rail--dock is self-sufficient: a compact, bounded,
   scrollable conversation switcher (the switch/back capability the
   dock silently lacked pre-v4.3). The page variant keeps chat.html's
   .chat-rail rules untouched. */
.rail--dock { flex: 0 0 auto; max-height: 32vh; overflow-y: auto;
  border-bottom: 1px solid var(--border-soft);
  padding: .3rem .5rem .4rem; font-size: .8rem; }
.rail--dock .rail-group-label { font-size: .66rem; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: .04em; margin: .4rem 0 .15rem; }
.rail--dock ul { list-style: none; margin: 0; padding: 0; }
.rail--dock li { display: flex; align-items: center; gap: .4rem;
  padding: .3rem .4rem; border-radius: var(--radius); cursor: pointer; }
.rail--dock li:hover { background: var(--panel-2); }
.rail--dock li.active { background: var(--accent-soft); color: var(--accent); }
.rail--dock .cv-name { flex: 1; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.rail--dock .cv-time { font-size: .64rem; color: var(--fg-dim); flex: 0 0 auto; }
.rail--dock .cv-del { background: none; border: 0; color: var(--fg-dim);
  cursor: pointer; padding: .12rem; display: inline-flex; }
.rail--dock .cv-del:hover { color: var(--warn); }
.rail--dock .cv-ren { background: none; border: 0; color: var(--fg-dim);
  cursor: pointer; padding: .12rem; display: inline-flex; }
.rail--dock .cv-ren:hover { color: var(--accent); }
.rail--dock .cv-rename { flex: 1; min-width: 0; font-size: .78rem;
  padding: .15rem .3rem; background: var(--bg);
  border: 1px solid var(--accent); border-radius: var(--radius);
  color: var(--fg); }

/* C3 (v4.3): dock bookmark UI (shared _chat_bookmarks partial). Dock-
   scoped + self-sufficient (renders off /chat where chat.html's bm CSS
   is absent). The dock strip is a compact horizontal tick row at the
   thread top (the page uses a vertical left-gutter minimap). */
.mnem-chat .bm-strip { display: flex; flex-wrap: wrap; gap: 3px;
  padding: .3rem .5rem; border-bottom: 1px solid var(--border-soft); }
.mnem-chat .bm-tick { height: 6px; width: 18px; flex: 0 0 auto;
  padding: 0; border: 0; border-radius: 3px; cursor: pointer;
  background: var(--accent); opacity: .4;
  transition: opacity .15s ease, transform .15s ease; }
.mnem-chat .bm-tick:hover { opacity: 1; transform: scaleY(1.5); }
.mc-turn-meta { display: flex; justify-content: flex-end;
  min-height: .9rem; margin-top: -.2rem; }
.mnem-chat .bm-star { background: none; border: 0; cursor: pointer;
  padding: 0 .15rem; color: var(--fg-dim); font-size: .85rem;
  line-height: 1; opacity: .55;
  transition: opacity .15s ease, color .15s ease; }
.mnem-chat .mc-turn:hover .bm-star, .mnem-chat .bm-star.on { opacity: 1; }
.mnem-chat .bm-star.on, .mnem-chat .bm-star:hover { color: var(--accent); }

/* v5 phase 4: dock-only prompt-architect toggle. Lives left of the
   textarea in .mc-composer; OFF = quiet outlined pill, ON = accent
   surface so the mode flip is unmistakable. The textarea placeholder
   also changes so a keyboard user without the toggle in view still
   sees that they're in architect mode. */
.mc-architect { display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .5rem; font-size: .72rem; line-height: 1;
  background: transparent; color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  cursor: pointer; transition: background var(--transition),
  color var(--transition), border-color var(--transition); }
.mc-architect:hover { color: var(--fg); border-color: var(--accent); }
.mc-architect.on { background: var(--accent); color: var(--accent-fg);
  border-color: var(--accent); }
.mc-architect svg { flex: 0 0 auto; }

/* v5 phase 5: pre-emit local-only warning banner. Sits above the
   composer in the dock. Amber (not red) -- a hint, not an error.
   The dismiss control is a plain "x" so screen readers announce
   "Dismiss" via aria-label. */
.mc-localonly-warn { display: flex; align-items: center; gap: .4rem;
  padding: .35rem .55rem; margin: .2rem .25rem .4rem;
  font-size: .76rem; color: var(--warn);
  background: rgba(217, 119, 87, 0.08);
  border: 1px solid rgba(217, 119, 87, 0.3);
  border-radius: var(--radius); }
.mc-localonly-warn svg { flex: 0 0 auto; }
.mc-localonly-warn span { flex: 1 1 auto; line-height: 1.35; }
.mc-localonly-warn button { background: transparent; border: 0;
  color: var(--warn); cursor: pointer; font-size: 1rem; padding: 0 .15rem;
  line-height: 1; }
.mc-localonly-warn button:hover { color: var(--fg); }

/* C3 (v4.3): dock welcome + suggested-questions (shared
   _chat_examples partial). Dock-scoped + self-sufficient (renders off
   /chat where chat.html's .welcome CSS is absent); compact for the
   narrow dock. The page keeps chat.html's .welcome rules unchanged. */
.welcome--dock { text-align: center; margin: auto; padding: 1.4rem 1rem;
  display: flex; flex-direction: column; align-items: center; }
.welcome--dock .welcome-mark { border-radius: 50%; margin-bottom: .6rem; }
.welcome--dock h1 { font-size: 1rem; margin: 0 0 .3rem; }
.welcome--dock p { color: var(--fg-muted); font-size: .82rem;
  max-width: 22rem; margin: 0 auto 1rem; line-height: 1.5; }
.welcome--dock .examples { display: flex; flex-direction: column;
  gap: .4rem; width: 100%; }
.welcome--dock .example { text-align: left; padding: .5rem .7rem;
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); color: var(--fg-muted);
  font-size: .8rem; cursor: pointer; transition: var(--transition); }
.welcome--dock .example:hover { border-color: var(--accent);
  color: var(--fg); }
.rail--dock .rail-empty { color: var(--fg-dim); font-size: .76rem;
  padding: .4rem; margin: 0; }

/* C1.R (v4.4): shared rail-collapse toggle (page + dock, one
   component). The dock starts collapsed so a growing session list is
   bounded and never eats the bubble; the page starts expanded
   (behaviour unchanged). Themed 100% from C1 tokens. */
.rail-collapse {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 44px; /* C1.R polish: >= 44px touch target */
  padding: 0.4rem 0.55rem;
  background: none;
  border: 0;
  border-radius: var(--radius);
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}
.rail-collapse:hover {
  color: var(--fg);
  background: var(--panel-2);
}
.rail-collapse:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.rail-collapse-caret {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--fg-dim);
  transition: transform var(--transition);
}
.rail-collapse-caret.open {
  transform: rotate(90deg);
}
.rail-collapse-label {
  flex: 1;
  text-align: left;
}
.rail-collapse-count {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--fg-dim);
  background: var(--panel-2);
  border-radius: var(--radius-pill);
  padding: 0.05rem 0.45rem;
}

code, pre { font-family: var(--mono); font-size: 0.85em; }
pre {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  overflow-x: auto;
  margin: 0.5rem 0;
}

/* --- Cards / tables ----------------------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  transition: var(--transition);
}
.card:hover {
  border-color: var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--fg-dim);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--panel-2);
}
tr:hover td { background: var(--panel); }

/* --- Type badges --------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fg-dim);
}
/* Single rule, palette-driven. Templates emit
   ``style="--type-color: <hex>"`` on every .badge.type-* element (see
   daemon/mnemo/ui/palette.py for the source-of-truth dict). When a
   node type is missing from the palette, the fallback keeps the chip
   readable instead of dropping it to the muted-grey default. */
.badge[class*="type-"] {
  color: var(--type-color, var(--fg-muted));
  border-color: color-mix(in srgb, var(--type-color, var(--border)) 30%, transparent);
}
.badge[class*="type-"]::before {
  background: var(--type-color, var(--fg-dim));
}
/* BASE flag: knowledge that applies across all projects.
   Distinct visual from type badges -- gold for "universal". */
.badge.base-badge {
  background: rgba(240, 217, 144, 0.16);
  color: #f0d990;
  border-color: rgba(240, 217, 144, 0.4);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.badge.base-badge::before { background: #f0d990; }

/* Inline toggle for BASE flag in node detail page hero. */
.base-toggle {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-family: var(--mono);
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.base-toggle:hover { border-color: #f0d990; color: #f0d990; }
.base-toggle:has(input:checked) {
  background: rgba(240, 217, 144, 0.16);
  border-color: rgba(240, 217, 144, 0.45);
  color: #f0d990;
}
.base-toggle input { margin: 0; }

.badges { list-style: none; padding: 0; margin: 0.5rem 0; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.badges li { background: none; padding: 0; margin: 0; border: 0; }

/* --- Search page --------------------------------------------------- */

.hero {
  text-align: center;
  padding: 1rem 0 2rem;
}
.hero h1 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--fg), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p { color: var(--fg-muted); font-size: 1rem; }

.search-box {
  position: relative;
  max-width: 720px;
  margin: 0 auto 1.5rem;
}
.search-box input[type="search"] {
  width: 100%;
  padding: 0.85rem 1.1rem 0.85rem 2.85rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
  background: var(--panel);
}
.search-box::before {
  content: "";
  position: absolute;
  left: 1.1rem; top: 50%;
  width: 1rem; height: 1rem;
  transform: translateY(-50%);
  background: var(--fg-dim);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E") no-repeat center / contain;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E") no-repeat center / contain;
}

.search-meta {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin: 0.5rem 0 1rem;
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.search-meta strong { color: var(--fg); font-weight: 500; }

.search-empty {
  text-align: center;
  color: var(--fg-muted);
  padding: 2rem 1rem;
}
.search-empty .examples {
  display: inline-flex; flex-direction: column; gap: 0.5rem;
  margin-top: 1rem;
}
.search-empty .examples a {
  font-family: var(--mono); font-size: 0.85rem;
  background: var(--panel); padding: 0.4rem 0.85rem; border-radius: var(--radius);
  border: 1px solid var(--border-soft);
}

/* --- Hit cards (search results) ----------------------------------- */

.hits {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 0.75rem;
}
.hit {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  transition: var(--transition);
}
.hit:hover {
  border-color: var(--accent);
  background: var(--panel-2);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}
.hit > a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}
.hit > a:hover .name { color: var(--accent); }
.hit .name { color: var(--fg); transition: var(--transition); }
.hit .score {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  min-width: 3.5rem;
  text-align: center;
}
.hit .desc {
  margin-top: 0.5rem;
  color: var(--fg-muted);
  font-size: 0.92rem;
}
.hit .body {
  margin-top: 0.65rem;
}
.hit .body summary {
  cursor: pointer;
  color: var(--fg-dim);
  font-size: 0.82rem;
  user-select: none;
}
.hit .body summary:hover { color: var(--accent); }
.hit .body pre {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
}
.hit .cite {
  font-size: 0.75rem;
  color: var(--fg-dim);
  font-family: var(--mono);
}

/* v1.2 phase 3: thumb-up/down feedback per hit. */
.hit-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.6rem;
}
.hit-feedback {
  display: inline-flex;
  gap: 0.25rem;
}
.thumb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--fg-dim);
  cursor: pointer;
  transition: var(--transition);
}
.thumb-btn:hover {
  color: var(--fg);
  border-color: var(--accent);
}
.thumb-btn.active.thumb-up {
  color: var(--type-feedback, #b6e88c);
  border-color: var(--type-feedback, #b6e88c);
  background: rgba(182, 232, 140, 0.12);
}
.thumb-btn.active.thumb-down {
  color: var(--warn, #e88a6a);
  border-color: var(--warn, #e88a6a);
  background: rgba(232, 138, 106, 0.12);
}
.thumb-btn.busy {
  opacity: 0.6;
  cursor: url("cursors/mnem-cursor-progress.svg") 16 16, progress;
}
.thumb-btn:disabled {
  cursor: url("cursors/mnem-cursor-not-allowed.svg") 16 16, not-allowed;
}

/* --- Autocomplete primitive --------------------------------------- */
/*
 * Used by:
 *   - Topbar active-project switcher (base.html, fs path suggest)
 *   - Sources page "Add source" path + project_key inputs
 *
 * Markup:
 *   <div class="ac-wrap">
 *     <input ...>
 *     <div class="ac-pop">
 *       <button class="ac-item active?">
 *         <span class="ac-item-kind ac-kind-<recent|fs|known>">...</span>
 *         <span class="ac-item-value">...</span>
 *         <span class="ac-item-meta">...</span>  -- optional
 *       </button>
 *     </div>
 *   </div>
 *
 * ``.ac-field`` is a row layout used inside the Sources modal so the
 * label, input, and hint stack consistently. Other surfaces (the
 * topbar popover) skip ``ac-field`` and place ``ac-wrap`` directly.
 */
.ac-field { margin-top: 0.85rem; }
.ac-field > label { display: block; font-size: 0.85rem; color: var(--fg-muted); margin-bottom: 0.35rem; }
.ac-field > label > .hint { font-size: 0.72rem; margin-left: 0.35rem; }
.ac-field > input,
.ac-field > select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.88rem;
}
.ac-field .ac-hint { margin: 0.35rem 0 0; font-size: 0.75rem; }

.ac-wrap { position: relative; }
.ac-wrap input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.88rem;
}
.ac-pop {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-height: 280px;
  overflow-y: auto;
  z-index: 220;  /* above modal-backdrop AND above the active-project popover */
  display: flex; flex-direction: column;
  padding: 0.25rem;
}
.ac-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: var(--transition);
}
.ac-item:hover, .ac-item.active {
  background: var(--panel-2);
}
.ac-item-kind {
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-pill);
  text-align: center;
  white-space: nowrap;
}
.ac-kind-recent { background: var(--accent-soft); color: var(--accent); }
.ac-kind-fs     { background: rgba(141, 182, 240, 0.16); color: var(--type-project); }
.ac-kind-known  { background: rgba(182, 232, 140, 0.16); color: var(--type-user); }
.ac-item-value {
  font-family: var(--mono);
  font-size: 0.85rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ac-item-meta {
  font-size: 0.72rem;
  color: var(--fg-dim);
  white-space: nowrap;
}

/* --- Recent / lists ----------------------------------------------- */

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin: 1.5rem 0 0.75rem;
}
.section-head h2 { margin: 0; }

.node-list { list-style: none; padding: 0; margin: 0; display: grid;
  /* explicit minmax(0,1fr): an implicit `auto` grid track sizes to
     max-content, so a long nowrap node .name blows the list (and the
     page) width and the .u-truncate ellipsis never engages -- the
     exact v4.3.1 .query-log bug class, systematized (C1.R). */
  grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
.node-list li {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  transition: var(--transition);
  min-width: 0; /* grid item shrinks into the minmax(0,1fr) cell (v4.3.1) */
}
.node-list li:hover { border-color: var(--border); background: var(--panel-2); }
.node-list a { display: flex; align-items: center; gap: 0.75rem; color: var(--fg); min-width: 0; }
.node-list .name { font-weight: 500; min-width: 0; }
.node-list .proj { color: var(--fg-dim); font-size: 0.78rem; margin-left: auto; }
.node-list .desc { font-size: 0.85rem; color: var(--fg-muted); margin: 0.25rem 0 0; }

/* --- Graph page --------------------------------------------------- */

.graph-pane {
  position: relative;
  height: calc(100vh - var(--topbar-h));
  width: 100%;
  background: radial-gradient(ellipse at center, #11151b 0%, #0b0d10 100%);
}
#cy {
  width: 100%; height: 100%;
  background: transparent;
}

.graph-controls {
  position: absolute; top: 1rem; left: 1rem;
  background: rgba(20, 23, 28, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  backdrop-filter: blur(8px);
  max-width: 280px;
  box-shadow: var(--shadow);
}
.graph-controls h3 { margin-top: 0; color: var(--fg); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.6px; }
.graph-controls .filter { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; cursor: pointer; user-select: none; font-size: 0.85rem; }
.graph-controls .filter input { width: 14px; height: 14px; margin: 0; }
.graph-controls .swatch { width: 10px; height: 10px; border-radius: 50%; }
.graph-controls .layout-row { margin-top: 0.75rem; display: flex; gap: 0.4rem; }
.graph-controls .layout-row button { padding: 0.3rem 0.6rem; font-size: 0.78rem; }

.graph-legend {
  position: absolute; bottom: 1rem; left: 1rem;
  background: rgba(20, 23, 28, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  font-size: 0.78rem;
  color: var(--fg-muted);
  backdrop-filter: blur(8px);
}
.graph-legend strong { color: var(--fg); display: block; margin-bottom: 0.3rem; font-size: 0.78rem; }

.graph-help {
  position: absolute; top: 1rem; right: 1rem;
  background: rgba(20, 23, 28, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  font-size: 0.78rem;
  color: var(--fg-muted);
  backdrop-filter: blur(8px);
  max-width: 250px;
}
.graph-help kbd {
  display: inline-block; padding: 0 0.3rem; border-radius: 3px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.72rem; color: var(--fg);
}

.side {
  position: absolute; top: 1rem; right: 1rem;
  width: 320px; padding: 1.25rem;
  background: rgba(20, 23, 28, 0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  z-index: 5;
}
.side .close {
  float: right; padding: 0.15rem 0.5rem; font-size: 0.85rem;
  background: transparent; border: 0; color: var(--fg-dim); cursor: pointer;
}
.side h3 { margin-top: 0.25rem; }
.side .open {
  display: inline-block; margin-top: 0.85rem;
  padding: 0.4rem 0.85rem; background: var(--accent); color: var(--bg);
  border-radius: var(--radius); font-weight: 500; font-size: 0.85rem;
}
.side .open:hover { background: var(--accent-hover); color: var(--bg); }

/* --- Node-edit page ----------------------------------------------- */

.node-edit { max-width: 880px; }
.node-head {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.node-head h2 { margin: 0; font-size: 1.4rem; }
.node-head code {
  background: var(--panel-2); padding: 0.15rem 0.5rem; border-radius: 4px;
  color: var(--fg-dim); font-size: 0.78rem;
}

dl.meta {
  /* minmax(0,1fr): a long nowrap <code> id/path in <dd> otherwise
     forces the value column to max-content and blows the page width
     (v4.3.1 bug class, systematized C1.R). */
  display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 0.4rem 1rem;
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 1rem; margin: 1rem 0;
  font-size: 0.85rem;
}
dl.meta dt { color: var(--fg-dim); font-weight: 500; }
dl.meta dd { margin: 0; color: var(--fg); min-width: 0; overflow-wrap: anywhere; }

.node-edit form label {
  display: block; margin: 1.25rem 0 0.45rem;
  color: var(--fg-muted); font-size: 0.85rem; font-weight: 500;
}
.node-edit form input, .node-edit form textarea { width: 100%; }
.node-edit .actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1.25rem; }
.ok  { color: var(--ok);   font-size: 0.85rem; }
.err { color: var(--warn); font-size: 0.85rem; }

.edges { margin-top: 2rem; }
.edges ul { list-style: none; padding: 0; margin: 0.5rem 0; display: grid; gap: 0.4rem; }
.edges li {
  background: var(--panel); border: 1px solid var(--border-soft);
  padding: 0.5rem 0.85rem; border-radius: var(--radius); font-size: 0.85rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.edges code {
  background: var(--accent-soft); color: var(--accent);
  padding: 0.05rem 0.4rem; border-radius: 3px; font-size: 0.78rem;
}
.edges .weight, .edges .src { color: var(--fg-dim); font-size: 0.78rem; }

/* --- Sources page ------------------------------------------------- */

.sources header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.sources header h2 { margin: 0; flex: 1; }
.sources .msg { color: var(--fg-muted); font-size: 0.85rem; font-family: var(--mono); }

/* v2.2 phase 3 streaming reindex progress.
   The block uses the palette-driven .bar-fill primitive -- inline
   ``style="--type-color: ..."`` on the row sets accent (in progress)
   or red (errors). When ``progress.done`` flips true, ``.reindex-done``
   tweens the panel toward muted so the user reads "I'm finished" at
   a glance. */
.reindex-progress {
  margin: 0.75rem 0 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  transition: opacity 220ms ease-out, border-color 220ms ease-out;
}
.reindex-progress.reindex-done {
  border-color: var(--border);
}
.reindex-progress-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.5rem;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.reindex-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--fg);
  font-weight: 600;
  min-width: 6em;
}
.reindex-counter .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.reindex-progress:not(.reindex-done) .reindex-counter .dot.pulse {
  animation: mnemo-pulse 1.1s ease-in-out infinite;
}
@keyframes mnemo-pulse {
  0%, 100% { opacity: 0.4; transform: scale(1.0); }
  50%      { opacity: 1.0; transform: scale(1.25); }
}
.reindex-current {
  flex: 1;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.reindex-progress .bar-track {
  height: 4px;
}
.reindex-summary {
  margin: 0.55rem 0 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg-muted);
}
.reindex-summary .err { color: var(--warn); }

/* prefers-reduced-motion: stop the pulse, keep everything readable. */
@media (prefers-reduced-motion: reduce) {
  .reindex-progress .reindex-counter .dot.pulse { animation: none; }
  .reindex-progress { transition: none; }
}

/* --- Audit page --------------------------------------------------- */

.audit { /* full-width: drives split-2 dash-row + summary aside */ }
/* Drop the default <ul> margin so queries-left and summary-right
   share the same first-row baseline inside the audit dash-row. */
.audit .query-log { margin: 0; }
/* v4.3.1: minmax(0,1fr) -- an implicit `auto` track sizes to
   max-content, so a long white-space:nowrap .hit-desc propagated up
   this grid and blew the page width horizontally. minmax(0,...) lets
   the track shrink below max-content so the .hit-desc ellipsis
   truncates to fit. */
.query-log { list-style: none; padding: 0; margin: 1rem 0;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.6rem; }
.query {
  min-width: 0;  /* v4.3.1: grid item must shrink below min-content */
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.1rem;
  transition: var(--transition);
}
.query:hover { border-color: var(--border); }
.query header {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.query .ts {
  color: var(--fg-dim); font-size: 0.78rem; font-family: var(--mono);
}
.query .tag {
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: var(--radius-pill);
  font-family: var(--mono);
}
.query .prompt {
  font-size: 0.95rem; color: var(--fg);
  font-family: var(--mono);
  margin: 0.25rem 0 0.4rem;
}
.query details summary {
  font-size: 0.82rem; color: var(--fg-muted); cursor: pointer; user-select: none;
}
.query details summary:hover { color: var(--accent); }
.query details ul.hits {
  margin-top: 0.5rem; padding: 0; list-style: none;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.3rem;
  font-size: 0.82rem;
}
.query details ul.hits li {
  display: flex; gap: 0.5rem; padding: 0.3rem 0.5rem;
  background: var(--bg); border: 1px solid var(--border-soft); border-radius: 4px;
}
.query details ul.hits .score {
  font-family: var(--mono); color: var(--ok); min-width: 3rem; text-align: right;
}

/* v2.6.0 polish: each audit hit row now carries name + type badge +
   description + truncated ID. align cleanly across rows.            */
.query details ul.hits li.hit-row {
  min-width: 0;  /* v4.3.1: grid item must shrink so .hit-desc clips */
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 0.6rem;
}
.hit-row .hit-name {
  color: var(--fg);
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
}
.hit-row .hit-name:hover { color: var(--accent); }
.hit-row .hit-type {
  font-size: 0.7rem;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  background: color-mix(in srgb, var(--type-color) 18%, transparent);
  color: var(--type-color, var(--accent));
  border: 1px solid color-mix(in srgb, var(--type-color) 35%, transparent);
  white-space: nowrap;
}
.hit-row .hit-desc {
  /* 1-line clip is delegated to the .u-truncate primitive on the span
     (C1.R single-source); this rule only carries the audit-row-
     specific colour/size + the 12rem flex floor. The v4.3.1 fix is
     intact: .hit-row has min-width:0 and .query-log uses minmax(0,1fr)
     so the row shrinks and .u-truncate's ellipsis engages. */
  color: var(--fg-muted);
  font-size: 0.78rem;
  flex: 1 1 0;
  min-width: 12rem;
}
.hit-row .hit-id {
  font-family: var(--mono);
  color: var(--fg-dim);
  font-size: 0.7rem;
  white-space: nowrap;
}
.hit-row .hit-removed {
  color: var(--fg-dim);
  font-style: italic;
  font-size: 0.78rem;
  text-decoration: line-through;
}

.empty {
  background: var(--panel); border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem; text-align: center; color: var(--fg-muted);
}

/* --- Settings page ------------------------------------------------ */

.settings table { background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.settings tr td:first-child { color: var(--fg-muted); width: 30%; }
.settings tr td:last-child { font-family: var(--mono); }

/* --- Counts grid -------------------------------------------------- */

.counts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.count-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.count-card .num { font-size: 1.4rem; font-weight: 600; color: var(--fg); font-family: var(--mono); }
.count-card .label { font-size: 0.78rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.6px; }

/* --- Dashboard --------------------------------------------------- */

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin: 1.5rem 0;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  text-decoration: none;
  display: block;
  transition: var(--transition);
}
.stat-card:hover {
  border-color: var(--accent);
  background: var(--panel-2);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}
.stat-card .stat-num {
  font-family: var(--mono);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.1;
}
.stat-card .stat-label {
  color: var(--fg-muted);
  font-size: 0.82rem;
  margin-top: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dash-row {
  display: grid;
  /* minmax(0,...) so a long nowrap child (node .name) can't force the
     track to max-content and blow the page width (v4.3.1 rule,
     systematized -- C1.R). */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  margin: 1rem 0;
}
@media (max-width: 60rem) { /* --bp-md (was 800px) */ .dash-row { grid-template-columns: minmax(0, 1fr); } }
.dash-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin: 1rem 0;
  min-width: 0; /* grid item must shrink below max-content (v4.3.1) */
}
.dash-card-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 0.85rem;
}
.dash-card h2 { margin: 0; font-size: 1rem; }

.type-bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.type-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.25rem; font-size: 0.85rem;
}
.type-num { color: var(--fg-muted); font-family: var(--mono); }
.bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  /* Defensive: width + height only apply to block / inline-block /
     flex-item elements. The dashboard markup uses <div> which is
     already block, but other call sites use <span> -- forcing
     ``display: block`` here so the rule paints regardless of the
     element type the template chose. */
  display: block;
  height: 100%;
  border-radius: 4px;
  transition: width 300ms ease-out;
  /* Palette-driven: dashboard.html stamps each <div class="bar-fill ...">
     with ``style="--type-color: <hex>"`` so this rule covers EVERY
     type (including any new ones added to palette.py). Without the
     inline custom property we fall back to a readable accent so a
     new type at least shows a visible bar instead of vanishing. */
  background: var(--type-color, var(--accent));
}

.search-box.compact input[type="search"] { padding-left: 1.1rem; font-size: 0.9rem; }
.search-box.compact::before { display: none; }

.node-list.compact li { padding: 0.5rem 0.75rem; }
.node-list.compact .name { font-size: 0.88rem; }

.query-mini { list-style: none; padding: 0; margin: 0; display: grid;
  /* minmax(0,1fr): implicit `auto` track = max-content; the .prompt's
     own nowrap+ellipsis never engages and the page overflows -- the
     v4.3.1 .query-log bug class, 3rd instance, systematized (C1.R). */
  grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
.query-mini li {
  min-width: 0; /* grid item shrinks into the minmax(0,1fr) cell */
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}
.query-mini .prompt {
  display: block; color: var(--fg);
  font-family: var(--mono); font-size: 0.82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.query-mini .meta { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.3rem; }
.hero.compact { padding: 0.5rem 0 1rem; }
.hero.compact h1 { font-size: 1.3rem; }

/* --- Filters + pagination --------------------------------------- */

.filters {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
}

/* v5.4.0: mobile layout for the section-head + filters row. Below
   --bp-md the H2 and the two-select filter form were sitting on
   one row (.section-head is flex/space-between), which squeezed
   the selects into a narrow strip on the right and made them
   wrap awkwardly under the H2. Stack vertically + let the filters
   span full width + let each select breathe. */
@media (max-width: 60rem) {
  .section-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .section-head .filters {
    width: 100%;
    flex-wrap: nowrap;
    gap: 0.4rem;
  }
  .section-head .filters select {
    flex: 1 1 0;
    min-width: 0;
  }
  .section-head .filter-clear {
    flex: 0 0 auto;
  }
}
/* .filters select is defined globally above (with the themed caret).
   Don't redefine background here -- the shorthand would wipe the SVG. */

/* Always-visible clear button. Disabled state stays visible (greyed
   + non-interactive) instead of mounting/unmounting on every filter
   toggle, which used to flash the layout. */
.filter-clear {
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  transition: var(--transition);
}
.filter-clear:hover { background: var(--accent-soft); }
.filter-clear.is-disabled {
  color: var(--fg-dim);
  cursor: url("cursors/mnem-cursor-not-allowed.svg") 16 16, not-allowed;
  pointer-events: none;
  opacity: 0.6;
}

.pagination-summary { margin: 0.5rem 0 1rem; }

.pager {
  display: flex; gap: 0.6rem; align-items: center; justify-content: center;
  margin: 1.5rem 0 0.5rem;
  font-size: 0.85rem;
}
.page-btn {
  padding: 0.45rem 0.95rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  transition: var(--transition);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.disabled {
  color: var(--fg-dim);
  cursor: url("cursors/mnem-cursor-not-allowed.svg") 16 16, not-allowed;
  border-color: var(--border-soft);
}
.page-info {
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 0.82rem;
}

/* --- Active-project switcher (topbar pill + popover, v1.1) -------- */

.active-proj { position: relative; }
.active-proj-pill {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
  max-width: 280px;
}
.active-proj-pill:hover {
  border-color: var(--accent);
  color: var(--fg);
}
.active-proj-pill.is-set {
  border-color: var(--accent);
  color: var(--accent);
}
.active-proj-pill.is-set .active-proj-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(126, 231, 224, 0.18);
}
.active-proj-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--fg-dim);
  flex-shrink: 0;
}
.active-proj-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.active-proj-pop {
  position: absolute; top: 110%; right: 0;
  width: 360px; max-width: calc(100vw - 1.5rem);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 60;
  animation: bell-pop 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.active-proj-pop > header {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-soft);
}
.active-proj-pop > header strong { font-size: 0.88rem; color: var(--fg); }
.active-proj-pop .body {
  padding: 0.85rem 1rem 1rem;
}
.active-proj-pop p.hint code {
  font-size: 0.78rem;
  background: var(--bg);
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  word-break: break-all;
}
.active-proj-pop label {
  display: block;
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin: 0.85rem 0 0;
}
.active-proj-pop label input {
  width: 100%; margin-top: 0.35rem;
  padding: 0.5rem 0.7rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.active-proj-actions {
  display: flex; gap: 0.5rem;
  margin-top: 0.85rem;
}
.active-proj-actions button { padding: 0.45rem 0.85rem; font-size: 0.85rem; }

/* --- v2.6: Workspace switcher (topbar pill + dropdown) ----------- */
/* Visual feel mirrors the active-project pill -- shared variables, same
   panel + radius + spacing -- so the two read as siblings in the bar.
   The dropdown opens left-anchored since it lives next to the brand
   rather than the right edge.                                       */

.workspace-switcher { position: relative; }
.workspace-switcher-pill {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
  max-width: 280px;
}
.workspace-switcher-pill:hover {
  border-color: var(--accent);
  color: var(--fg);
}
.workspace-switcher-pill.is-set {
  border-color: var(--accent);
  color: var(--accent);
}
.workspace-switcher-pill.is-set .workspace-switcher-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(126, 231, 224, 0.18);
}
.workspace-switcher-pill.is-base-only .workspace-switcher-dot {
  background: var(--fg-dim);
}
.workspace-switcher-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--fg-dim);
  flex-shrink: 0;
}
.workspace-switcher-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.workspace-switcher-caret { font-size: 0.7rem; color: var(--fg-dim); }
.workspace-switcher-cap {
  display: inline-grid; place-items: center;
  width: 16px; height: 16px;
  background: var(--warn); color: var(--bg);
  border-radius: 50%;
  font-size: 0.7rem; font-weight: 700;
}

.workspace-switcher-pop {
  /* v2.6.0 polish: anchored to the right edge of the pill (matches
     the slot the legacy active-project popover used). The pill now
     lives right-of-nav so the dropdown unfolds toward the left,
     keeping it inside the viewport even on narrow windows. */
  position: absolute; top: 110%; right: 0;
  width: 340px; max-width: calc(100vw - 1.5rem);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 60;
  animation: bell-pop 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.workspace-switcher-pop > header {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-soft);
}
.workspace-switcher-pop > header strong { font-size: 0.88rem; color: var(--fg); }
.workspace-switcher-pop .body { padding: 0.6rem 0.5rem 0.7rem; }

.workspace-switcher-error,
.workspace-switcher-warn {
  margin: 0.4rem 0.5rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  border-radius: var(--radius);
}
.workspace-switcher-error {
  background: rgba(217, 119, 87, 0.12);
  color: var(--warn);
  border: 1px solid rgba(217, 119, 87, 0.3);
}
.workspace-switcher-warn {
  background: rgba(217, 119, 87, 0.10);
  color: var(--fg-muted);
  border: 1px solid rgba(217, 119, 87, 0.25);
}

.ws-section { padding: 0.45rem 0.5rem 0.5rem; }
.ws-section + .ws-section { border-top: 1px solid var(--border-soft); margin-top: 0.2rem; }
.ws-section-head {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  margin: 0 0.4rem 0.3rem;
}
.ws-item {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}
.ws-item:hover:not(:disabled) {
  background: var(--panel-2);
  border-color: var(--border-soft);
}
.ws-item.is-active {
  background: var(--accent-soft);
  border-color: rgba(126, 231, 224, 0.25);
  cursor: default;
}
.ws-item.is-active .ws-item-name { color: var(--accent); font-weight: 600; }
.ws-item.is-empty { color: var(--fg-muted); cursor: default; }
.ws-item-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.ws-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ws-item-meta { color: var(--fg-muted); font-size: 0.75rem; flex-shrink: 0; }

.ws-actions { display: flex; flex-direction: column; gap: 0.1rem; }
.ws-action {
  display: block; width: 100%;
  padding: 0.5rem 0.65rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 0.85rem;
  text-align: left;
  text-decoration: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}
.ws-action:hover { background: var(--panel-2); border-color: var(--border-soft); }
.ws-action-clear { color: var(--fg-muted); }

.ws-newform {
  padding: 0.6rem 0.7rem 0.7rem;
  margin: 0.4rem 0.5rem 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--panel-2);
}
.ws-newform label {
  display: block;
  color: var(--fg-muted);
  font-size: 0.78rem;
  margin: 0.5rem 0 0;
}
.ws-newform label:first-child { margin-top: 0; }
.ws-newform label input {
  width: 100%; margin-top: 0.25rem;
  padding: 0.4rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.ws-newform-actions {
  display: flex; gap: 0.5rem;
  margin-top: 0.7rem;
}
.ws-newform-actions button { padding: 0.4rem 0.8rem; font-size: 0.82rem; }

/* --- v2.6 phase 10.2: chip-based project_keys picker ------------ */

.ws-chips {
  position: relative;
  display: flex; flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.4rem 0.5rem;
  margin-top: 0.3rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  min-height: 2.25rem;
  align-items: center;
}
.ws-chips:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.ws-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.45rem;
  background: var(--accent-soft);
  border: 1px solid rgba(126, 231, 224, 0.3);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.78rem;
  border-radius: var(--radius-pill);
  max-width: 100%;
}
.ws-chip-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
  max-width: 220px;
}
.ws-chip-remove {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.7;
  transition: var(--transition);
}
.ws-chip-remove:hover { opacity: 1; background: rgba(126, 231, 224, 0.18); }

.ws-chip-input {
  flex: 1 1 8rem;
  min-width: 8rem;
  background: transparent;
  border: none;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.15rem 0.2rem;
  outline: none;
}

.ws-chip-suggest {
  position: absolute; left: 0; right: 0; top: 100%;
  margin-top: 0.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow-y: auto;
  z-index: 70;
}
.ws-chip-suggest-item {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0.6rem;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}
.ws-chip-suggest-item:hover,
.ws-chip-suggest-item.active {
  background: var(--panel-2);
  color: var(--accent);
}
.ws-chip-suggest-kind {
  display: inline-block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  color: var(--fg-dim);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  flex-shrink: 0;
  min-width: 3.2rem;
  text-align: center;
}
.ws-chip-suggest-kind.kind-project { color: var(--accent); border-color: rgba(126, 231, 224, 0.3); }
.ws-chip-suggest-kind.kind-fs      { color: var(--info);   border-color: rgba(108, 182, 255, 0.3); }
.ws-chip-suggest-value {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.ws-chip-suggest-meta {
  color: var(--fg-muted);
  font-size: 0.72rem;
  flex-shrink: 0;
}

/* --- /workspaces management page -------------------------------- */

.workspaces-page { max-width: 1200px; }
.workspaces-error {
  margin: 0.7rem 0;
  padding: 0.6rem 0.9rem;
  background: rgba(217, 119, 87, 0.12);
  border: 1px solid rgba(217, 119, 87, 0.3);
  border-radius: var(--radius);
  color: var(--warn);
  font-size: 0.88rem;
}

.workspaces-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

/* v2.6.0 polish: equalize card height + bottom-pin the actions row.
   Grid auto-rows used to leave the actions floating mid-card on the
   workspace whose chip strip was empty; the dash-card body now lays
   out as a flex column so the actions row pushes to the bottom. The
   .dash-card-head's heading also picks up an extra top-shift so the
   default 1.25rem dash-card padding doesn't feel oversized for the
   compact ws-card shape.                                            */
.ws-card {
  position: relative;
  padding-top: 0.85rem;       /* was 1.25rem via .dash-card */
  display: flex;
  flex-direction: column;
}
.ws-card .dash-card-head { margin-bottom: 0.5rem; }
.ws-card .dash-card-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}
.ws-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}
.ws-card-active-chip {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
}
.ws-card-projects {
  display: flex; flex-wrap: wrap; gap: 0.3rem;
  margin: 0.25rem 0 0.65rem;
  min-height: 1.8rem;          /* hold a row's worth of space even when empty */
  align-items: center;
}
.ws-card-empty {
  color: var(--fg-muted);
  font-size: 0.82rem;
  font-style: italic;
}
.ws-card-meta {
  display: flex; flex-direction: column; gap: 0.2rem;
  margin: 0 0 0.7rem;
  font-size: 0.8rem;
  color: var(--fg-muted);
}
.ws-card-meta-label { color: var(--fg-dim); margin-right: 0.4rem; }
.ws-card-actions {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin-top: auto;            /* push actions to the bottom of the body */
  padding-top: 0.5rem;
}
.ws-card-actions button { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.ws-card-actions .danger {
  border-color: rgba(217, 119, 87, 0.4);
  color: var(--warn);
}
.ws-card-actions .danger:hover {
  background: rgba(217, 119, 87, 0.1);
}

.ws-new-card { margin-top: 0.8rem; }
.ws-new-card label {
  display: block;
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin: 0.7rem 0 0;
}
.ws-new-card label:first-child { margin-top: 0; }
.ws-new-card label input {
  width: 100%; margin-top: 0.3rem;
  padding: 0.5rem 0.7rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.ws-empty-state {
  grid-column: 1 / -1;
  padding: 2.5rem;
  text-align: center;
  color: var(--fg-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

/* --- v2.6 phase 9: reindex report modal ------------------------- */

.reindex-report-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 80;
  display: grid; place-items: center;
  padding: 1.5rem;
  animation: bell-pop 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.reindex-report-modal {
  width: min(880px, 100%);
  max-height: calc(100vh - 3rem);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.reindex-report-modal > .dash-card-head {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
}

.report-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.6rem 1rem 1rem;
}
.report-section {
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border-soft);
}
.report-section:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.report-section h4 {
  font-size: 0.92rem;
  margin: 0 0 0.25rem;
  color: var(--fg);
}
.report-list {
  list-style: none;
  padding: 0; margin: 0.5rem 0 0;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.report-list li {
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: 0.4rem 0.6rem;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  font-size: 0.84rem;
}
.report-list li code {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg);
  word-break: break-all;
}
.report-reason {
  color: var(--fg-muted);
  font-size: 0.76rem;
  font-family: var(--mono);
}
.report-heuristic { color: var(--fg-dim); font-size: 0.76rem; }

.report-decision-row {
  flex-direction: row !important;
  align-items: center;
  gap: 0.6rem;
}
.report-decision-meta {
  flex: 1 1 auto;
  display: flex; flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.report-decision-meta code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-decision-buttons {
  display: flex; gap: 0.35rem;
  flex-shrink: 0;
}
.report-decision-buttons button {
  padding: 0.3rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}
.report-decision-buttons button:hover {
  border-color: var(--accent);
  color: var(--fg);
}
.report-decision-buttons button.is-picked {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.report-modal-actions {
  display: flex; gap: 0.5rem; justify-content: flex-end;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--border-soft);
}
.report-modal-actions button { padding: 0.5rem 1rem; font-size: 0.85rem; }

@media (prefers-reduced-motion: reduce) {
  .reindex-report-modal-backdrop { animation: none; }
}

/* --- Notification bell ------------------------------------------ */

.bell-wrap { position: relative; }
.bell {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-muted);
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: grid; place-items: center;
  cursor: pointer; padding: 0;
  position: relative;
  transition: var(--transition);
}
.bell:hover { color: var(--fg); background: var(--panel-2); }
.bell.has-unread { color: var(--accent); }
.bell-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--warn); color: var(--bg);
  border-radius: var(--radius-pill);
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}
.bell-dropdown {
  position: absolute; top: 110%; right: 0;
  width: 340px; max-width: calc(100vw - 1.5rem);
  max-height: 480px; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  z-index: 60;
  animation: bell-pop 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bell-dropdown header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--border-soft);
}
.bell-dropdown header strong { font-size: 0.88rem; color: var(--fg); }
.bell-dropdown ul { list-style: none; padding: 0.5rem 0; margin: 0; }
.bell-empty { padding: 1.2rem; color: var(--fg-muted); text-align: center; font-size: 0.85rem; }
.bell-item {
  display: flex; gap: 0.65rem; padding: 0.55rem 1rem;
  border-left: 2px solid transparent;
}
.bell-item:hover { background: var(--panel-2); }
.bell-success { border-left-color: var(--ok); }
.bell-error   { border-left-color: var(--warn); }
.bell-warn    { border-left-color: #e2c763; }
.bell-info    { border-left-color: var(--accent); }
.bell-icon {
  width: 18px; height: 18px;
  border-radius: var(--radius-pill);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 0.7rem; font-weight: 700;
  flex-shrink: 0; margin-top: 2px;
}
.bell-success .bell-icon { background: rgba(86,211,100,0.15); color: var(--ok); }
.bell-error   .bell-icon { background: rgba(217,119,87,0.15); color: var(--warn); }
.bell-warn    .bell-icon { background: rgba(226,199,99,0.15); color: #e2c763; }
.bell-info    .bell-icon { background: var(--accent-soft); color: var(--accent); }
.bell-msg { color: var(--fg); font-size: 0.85rem; line-height: 1.35; }
.bell-time { color: var(--fg-dim); font-size: 0.72rem; margin-top: 2px; }

@keyframes bell-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Node detail edge list -------------------------------------- */

.back-row { margin-bottom: 0.85rem; }
.edge-list { list-style: none; padding: 0; margin: 0.5rem 0; display: grid;
  /* minmax(0,1fr): implicit auto track = max-content; a long node
     .name otherwise blows the connections list -> page width
     (v4.3.1 bug class, systematized C1.R). */
  grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
.edge-list li {
  min-width: 0;
  background: var(--panel-2); border: 1px solid var(--border-soft);
  padding: 0.5rem 0.85rem; border-radius: var(--radius);
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.edge-list .rel {
  background: var(--accent-soft); color: var(--accent);
  padding: 0.05rem 0.45rem; border-radius: 3px; font-size: 0.78rem;
}
.edge-list .arrow { color: var(--fg-dim); }
.edge-target {
  display: flex; gap: 0.5rem; align-items: center;
  text-decoration: none;
  /* take the remaining row space + clip, so the .name u-truncate
     ellipsis actually engages (a nowrap child needs a bounded,
     clipping flex parent -- the systematized v4.3.1 rule). */
  flex: 1 1 8rem; min-width: 0; overflow: hidden;
}
.edge-target:hover .name { color: var(--accent); }
.edge-target .name { color: var(--fg); }
.edge-list .weight, .edge-list .src { color: var(--fg-dim); font-size: 0.78rem; margin-left: auto; }
.node-head .cite { color: var(--fg-dim); font-size: 0.8rem; }

/* --- Toast notifications ----------------------------------------- */

.toast-stack {
  position: fixed;
  top: 4.5rem; right: 1.25rem;
  display: flex; flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
  pointer-events: none;
  max-width: calc(100vw - 2.5rem);
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 0.95rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.04);
  font-size: 0.88rem;
  min-width: 240px; max-width: 380px;
  animation: toast-in 180ms ease-out;
  cursor: default;
}
.toast-success { border-left-color: var(--ok); }
.toast-error   { border-left-color: var(--warn); }
.toast-warn    { border-left-color: #e2c763; }
.toast-info    { border-left-color: var(--accent); }
.toast-icon {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: var(--radius-pill);
  font-family: var(--mono); font-size: 0.78rem; font-weight: 700;
  flex-shrink: 0;
}
.toast-success .toast-icon { background: rgba(86, 211, 100, 0.15); color: var(--ok); }
.toast-error   .toast-icon { background: rgba(217, 119, 87, 0.15); color: var(--warn); }
.toast-warn    .toast-icon { background: rgba(226, 199, 99, 0.15); color: #e2c763; }
.toast-info    .toast-icon { background: var(--accent-soft); color: var(--accent); }
.toast-msg { flex: 1; color: var(--fg); }
.toast-close {
  background: transparent; border: 0; padding: 0;
  color: var(--fg-dim); cursor: pointer; font-size: 1.1rem; line-height: 1;
  width: 22px; height: 22px;
}
.toast-close:hover { color: var(--fg); }

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

/* --- Modal (replaces window.alert / window.confirm) -------------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 10, 13, 0.72);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  z-index: 200;
  animation: modal-fade 140ms ease-out;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  width: min(440px, calc(100vw - 2rem));
  padding: 1.5rem 1.5rem 1.25rem;
  animation: modal-pop 160ms cubic-bezier(0.2, 0.8, 0.2, 1.05);
}
.modal h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: var(--fg);
}
.modal p {
  color: var(--fg-muted);
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
}
.modal-actions {
  display: flex; justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.modal-actions button {
  min-width: 96px;
  padding: 0.5rem 1rem;
}
.modal-actions .danger {
  background: var(--warn);
  color: var(--bg);
  border-color: var(--warn);
  font-weight: 600;
}
.modal-actions .danger:hover {
  background: #e88a6a;
  border-color: #e88a6a;
  color: var(--bg);
}
@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Markdown body styling --------------------------------------- */
/* Shared between the node detail page and the graph side panel. */
.md-body {
  color: var(--fg);
  font-size: 0.9rem;
  line-height: 1.6;
  word-wrap: break-word;
}
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  margin: 1.1rem 0 0.5rem; line-height: 1.3;
  color: var(--fg);
}
.md-body h1 { font-size: 1.15rem; }
.md-body h2 { font-size: 1.0rem; color: var(--accent); }
.md-body h3 { font-size: 0.92rem; color: var(--fg-muted); text-transform: none; }
.md-body h4 { font-size: 0.85rem; color: var(--fg-muted); }
.md-body p { margin: 0.55rem 0; color: var(--fg); }
.md-body ul, .md-body ol { padding-left: 1.4rem; margin: 0.55rem 0; }
.md-body li { margin: 0.2rem 0; }
.md-body code {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-size: 0.82em;
  color: var(--accent);
}
.md-body pre {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.75rem 0.95rem;
  overflow-x: auto;
  margin: 0.65rem 0;
}
.md-body pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--fg);
  font-size: 0.82rem;
}
.md-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.05rem 0 0.05rem 0.85rem;
  margin: 0.65rem 0;
  color: var(--fg-muted);
  background: var(--panel-2);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.md-body a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.md-body a:hover { color: var(--accent-hover); }
.md-body table {
  border-collapse: collapse;
  margin: 0.65rem 0;
  font-size: 0.85rem;
  width: 100%;
}
.md-body th, .md-body td {
  border: 1px solid var(--border-soft);
  padding: 0.4rem 0.65rem;
  text-align: left;
}
.md-body th { background: var(--panel-2); color: var(--fg-muted); font-weight: 500; }
.md-body hr {
  border: 0;
  border-top: 1px solid var(--border-soft);
  margin: 1rem 0;
}
.md-body strong { color: var(--fg); font-weight: 600; }
.md-body em { color: var(--fg); font-style: italic; }
.md-fallback {
  white-space: pre-wrap; word-break: break-word;
  font-size: 0.82rem; color: var(--fg-muted);
}

/* --- Code-typed body preview (Prism-highlighted) ----------------- */
/* When a code_* node is rendered in the Preview tab or the search
   popover, mnemoRenderBody writes <pre class="mnemo-code language-X">.
   The Prism Tomorrow-Night theme paints token colors; we layer the
   mnemo palette (panel + border) on top so the block matches the
   rest of the UI. */
.mnemo-code {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin: 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
}
.mnemo-code code {
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  white-space: pre;
}
/* When the Preview tab is showing a code body, drop the markdown
   typography (margins, headings) -- the <pre> stands on its own. */
.node-md-preview.is-code {
  background: transparent;
  border: 0;
  padding: 0;
}
.node-md-preview.is-code > .mnemo-code {
  /* The wrapper already paints the panel; keep the inner pre flush. */
  margin: 0;
}
/* Tiny status hint under the preview area ("rendered as code") so
   the user knows which path was picked. */
.preview-mode-hint {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: var(--fg-muted);
}
.preview-mode-hint code {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
  font-size: 0.95em;
  color: var(--accent);
}

/* Search-results body details: the toggle on each hit opens a
   live-rendered preview. Keep the slot tight so the body doesn't
   dwarf the rest of the hit card. */
.hit-body summary {
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 0.78rem;
  padding: 0.15rem 0;
}
.hit-body summary:hover { color: var(--accent); }
.hit-body-render {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  max-height: 26rem;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  background: var(--panel);
}
.hit-body-render .mnemo-code {
  /* The render slot already has its own border + padding -- inset
     the code block so the two borders don't double up. */
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 0.76rem;
}

/* --- Plain-text body preview (commit nodes etc.) ----------------- */
.mnemo-plain {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--fg);
}

/* --- Full-dive page hero (audit/settings/node) -------------------- */
.page-hero {
  display: flex;
  /* v4.4.1: flex-start, not center -- center floated the actions
     (BASE / cite / Copy citation) at the vertical MIDDLE of a tall
     description, disconnected and awkward (the v4.4.0 live-review
     screenshot). Top-aligned reads as a proper header. */
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  padding: 1.5rem 0 1.75rem;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 1.75rem;
}
.page-hero .hero-text { flex: 1 1 360px; min-width: 0; }
.page-hero .hero-text h1 {
  font-size: 1.85rem;
  margin: 0 0 0.4rem;
  background: linear-gradient(135deg, var(--fg), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-hero .hero-text p {
  color: var(--fg-muted);
  margin: 0;
  font-size: 1rem;
  max-width: 720px;
}
.page-hero .hero-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}
.page-hero .hero-actions button,
.page-hero .hero-actions .button {
  height: 40px;
  padding: 0 1.1rem;
  font-size: 0.92rem;
}
.page-hero .hint {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
  color: var(--fg-muted);
}

/* --- Wider 2-column dash layout for big content pages ------------- */
.dash-row.split-2 {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}
@media (max-width: 60rem) { /* --bp-md (was 980px) */
  .dash-row.split-2 { grid-template-columns: minmax(0, 1fr); }
}
.dash-row.split-3 {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr);
}
@media (max-width: 60rem) { /* --bp-md (was 1080px) */
  .dash-row.split-3 { grid-template-columns: minmax(0, 1fr); }
}

/* Stat-card variant when used as compact pill (no link, no hover lift). */
.stat-card.flat {
  cursor: default;
}
.stat-card.flat:hover {
  border-color: var(--border-soft);
  background: var(--panel);
  transform: none;
  box-shadow: none;
}

/* --- Aligned action row (used by graph side panel + node page) ---- */
.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.btn-row > * {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--fg);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1;
  box-sizing: border-box;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  font-family: inherit;
}
.btn-row > .primary,
.btn-row > a.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.btn-row > .primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg);
}
.btn-row > button:hover,
.btn-row > a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Node-detail page layout -------------------------------------- */
.node-edit { max-width: none; }
.node-detail-grid {
  display: grid;
  /* v4.4.1: minmax(0,...) -- a long nowrap <code> path/id in dl.meta
     otherwise grows the 1fr/2fr track to max-content and blows the
     page width at < --bp-md (the v4.3.1 bug class; the v4.4.0 Task-6
     dl.meta fix was insufficient while the SHELL track stayed bare
     1fr). Systematized. */
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}
.node-detail-main {
  min-width: 0; /* grid item must shrink so dl.meta/code can wrap */
}
@media (max-width: 60rem) { /* --bp-md (was 980px) */
  .node-detail-grid { grid-template-columns: minmax(0, 1fr); }
}
.node-detail-side {
  position: sticky;
  top: 5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.node-edit-tabs {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 0.2rem;
  margin: 0.5rem 0 0.85rem;
}
.node-edit-tab {
  padding: 0.3rem 0.85rem;
  border-radius: var(--radius-pill);
  background: transparent;
  border: 0;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 0.82rem;
  transition: var(--transition);
}
.node-edit-tab.active {
  background: var(--panel);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--border);
}
.node-edit-tab:hover { color: var(--fg); }
.node-md-preview {
  min-height: 220px;
  padding: 1rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* --- Settings page layout ----------------------------------------- */
.settings-formula {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}
.settings-formula code {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.85rem;
}

/* --- Audit summary aside ------------------------------------------ */
.audit-summary {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  font-size: 0.88rem;
}
.audit-summary h3 {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-dim);
}
.audit-summary dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  margin: 0;
}
.audit-summary dt { color: var(--fg-muted); }
.audit-summary dd {
  margin: 0;
  font-family: var(--mono);
  color: var(--accent);
}
.audit-summary .tag-cloud {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
}
.audit-summary .tag-cloud .tag {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  font-family: var(--mono);
}
.audit .query .ts {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg-muted);
}
.audit .query time {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg-muted);
}

/* --- v2.0 phase 2: auto-router preview panel --------------------- */

.preview-panel {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  margin: 0.5rem 0 0.85rem;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.preview-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.preview-by-ext .preview-ext {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.1rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--fg-muted);
}
.preview-by-ext .preview-ext code {
  background: none;
  padding: 0;
  color: var(--fg);
}
.preview-use {
  margin-left: auto;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
}
.preview-use:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.preview-warn {
  margin-top: 0.4rem;
  padding: 0.55rem 0.65rem;
  background: rgba(240, 164, 124, 0.08);
  border: 1px solid rgba(240, 164, 124, 0.4);
  border-radius: var(--radius);
  font-size: 0.82rem;
}
.preview-warn p {
  margin: 0 0 0.4rem;
  color: var(--fg-muted);
}
.preview-warn strong {
  color: var(--warn);
}

/* --- v2.1 /code landing redesign ----------------------------- */

.code-hero {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
}

.code-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 500px 250px at 50% 0%, rgba(192, 132, 252, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 400px 200px at 50% 100%, rgba(34, 211, 238, 0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.code-hero h2 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  background: linear-gradient(135deg, #7ee7e0, #c084fc 60%, #e879f9);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
  position: relative;
  z-index: 1;
}

.code-hero-sub {
  max-width: 640px;
  margin: 0 auto;
  color: var(--fg-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  position: relative;
  z-index: 1;
}

.code-project-grid {
  display: grid;
  /* auto-fit so a single project card expands to fill the row.
     auto-fill leaves phantom tracks at 360px and pins the card to
     that width; auto-fit collapses empty tracks. min(420px,100%) so
     the 420px floor can't exceed a narrow viewport (< --bp-md the
     card would otherwise force a horizontal scrollbar) -- the
     canonical responsive-grid clamp, single-source, no media query
     (C1.R). */
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.code-project-card {
  position: relative;
  background: linear-gradient(135deg, rgba(15, 19, 28, 0.85), rgba(11, 14, 22, 0.95));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition:
    transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 300ms cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.code-project-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 0%, rgba(126, 231, 224, 0.08), transparent 50%);
  opacity: 0;
  transition: opacity 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

.code-project-card:hover {
  transform: translateY(-2px);
  border-color: rgba(126, 231, 224, 0.4);
  box-shadow:
    0 12px 32px -12px rgba(126, 231, 224, 0.25),
    0 0 0 1px rgba(126, 231, 224, 0.1);
}

.code-project-card:hover::before { opacity: 1; }

.code-project-card-link {
  display: block;
  padding: 1.1rem 1.2rem 0.9rem;
  text-decoration: none;
  color: var(--fg);
  position: relative;
  z-index: 1;
}

.code-project-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.code-project-card-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
  font-family: var(--mono);
  word-break: break-all;
}

.code-project-card-total {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(126, 231, 224, 0.12);
  padding: 0.15rem 0.7rem;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.code-project-card-bars {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0 0 0.85rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 12px 80px 1fr 32px;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
}

.bar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.bar-label {
  color: var(--fg-muted);
  font-family: var(--mono);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

/* /code project card has its own thinner / softer bar styling.
   Scoped under .code-project-card-bars so it doesn't shadow the
   palette-driven .bar-fill rule the dashboard "Memory by type"
   panel relies on. Previously these rules were unscoped, so the
   later definition won and the dashboard bars went transparent
   while the /code bars themselves had NO background at all. */
.code-project-card-bars .bar-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.code-project-card-bars .bar-fill {
  /* The /code template renders the bar with <span> elements
     (vs the dashboard's <div>). A <span> is display:inline by
     default and inline elements IGNORE width + height per the CSS
     spec -- so the explicit ``style="width: 8.7%"`` and the
     ``height: 100%`` below were both being ignored, leaving the
     bar at 0x0 (invisible but DOM-present + colored). Forcing
     ``display: block`` makes the box-model apply. */
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--type-color, var(--accent));
  transition: width 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bar-count {
  font-family: var(--mono);
  color: var(--fg);
  font-size: 0.72rem;
  text-align: right;
}

.code-project-card-path {
  margin: 0 0 0.85rem;
  font-size: 0.7rem;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
}

.code-project-card-path code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

.code-project-card-foot {
  display: flex;
  align-items: center;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.code-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.code-card-cta svg {
  transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.code-project-card:hover .code-card-cta svg {
  transform: translateX(4px);
}

.code-project-card-summary {
  position: absolute;
  bottom: 1rem;
  right: 1.2rem;
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-decoration: none;
  z-index: 2;
  transition: color 200ms ease;
}

.code-project-card-summary:hover {
  color: var(--accent);
}

/* Endpoint section */
.endpoint-section {
  margin-top: 2rem;
}

.endpoint-section-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap; /* C1.R: filter wraps to its own line < --bp-md */
}

.endpoint-section-head h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--fg);
}

.endpoint-section-count {
  font-family: var(--mono);
  color: var(--accent);
  background: rgba(126, 231, 224, 0.12);
  padding: 0.1rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
}

.endpoint-section-hint {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin: 0 0 1rem;
  max-width: 720px;
}

.endpoint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.6rem;
}

.endpoint-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  background: rgba(15, 19, 28, 0.7);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg);
  transition:
    transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    background 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.endpoint-card:hover {
  transform: translateX(2px);
  background: rgba(20, 26, 38, 0.85);
}

.endpoint-method {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius);
  text-transform: uppercase;
}

.endpoint-method-get    { color: #4ade80; background: rgba(74, 222, 128, 0.14); }
.endpoint-method-post   { color: #38bdf8; background: rgba(56, 189, 248, 0.14); }
.endpoint-method-put    { color: #fb923c; background: rgba(251, 146, 60, 0.14); }
.endpoint-method-patch  { color: #c084fc; background: rgba(192, 132, 252, 0.14); }
.endpoint-method-delete { color: #f43f5e; background: rgba(244, 63, 94, 0.14); }
.endpoint-method-head   { color: #94a3b8; background: rgba(148, 163, 184, 0.14); }
.endpoint-method-options { color: #94a3b8; background: rgba(148, 163, 184, 0.14); }

.endpoint-card.endpoint-method-get    { border-left-color: #4ade80; }
.endpoint-card.endpoint-method-post   { border-left-color: #38bdf8; }
.endpoint-card.endpoint-method-put    { border-left-color: #fb923c; }
.endpoint-card.endpoint-method-patch  { border-left-color: #c084fc; }
.endpoint-card.endpoint-method-delete { border-left-color: #f43f5e; }
.endpoint-card.endpoint-method-head,
.endpoint-card.endpoint-method-options { border-left-color: #94a3b8; }

.endpoint-path {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--fg);
  background: none;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.endpoint-fanout {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
}

.endpoint-fanout span {
  font-size: 0.6rem;
  color: var(--fg-muted);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.endpoint-filter {
  margin-left: auto;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0.6rem;
  color: var(--fg);
  font-size: 0.8rem;
  font-family: var(--mono);
  /* C1.R: a hard min-width:220 made this input force a horizontal
     scrollbar < --bp-md (margin-left:auto in a non-wrapping flex
     header). width gives the desktop size; min-width:0 + max-width
     lets it shrink, and .endpoint-section-head now wraps it to its
     own full-width line on narrow. */
  width: 14rem;
  min-width: 0;
  max-width: 100%;
  transition: border-color 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.endpoint-filter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(126, 231, 224, 0.15);
}

.endpoint-expand-row {
  display: flex;
  justify-content: center;
  margin-top: 0.85rem;
}

.expand-toggle {
  background: rgba(126, 231, 224, 0.08);
  border: 1px solid rgba(126, 231, 224, 0.3);
  border-radius: var(--radius-pill);
  color: var(--accent);
  padding: 0.4rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition:
    background 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.expand-toggle:hover {
  background: rgba(126, 231, 224, 0.18);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.rail-card .expand-toggle {
  margin-top: 0.55rem;
  width: 100%;
  font-size: 0.72rem;
  padding: 0.3rem 0.6rem;
}

/* --- v2.0 phases 11-13: /code UI family ------------------------- */

.code-landing {
  /* v2.1: full-page width for the Code landing -- no constrained
     reading column. The project grid expands to fill available
     space so a single project doesn't look isolated. */
  width: 100%;
  margin: 0;
  padding: 1.25rem 1.5rem 3rem;
}

.code-project,
.code-function {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.code-landing .page-header,
.code-project .page-header,
.code-function .page-header {
  margin-bottom: 1.25rem;
}

.code-landing .page-header h2,
.code-project .page-header h2,
.code-function .page-header h2 {
  margin: 0.25rem 0 0.35rem;
  font-size: 1.45rem;
  color: var(--fg);
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin: 0 0 0.3rem;
}

.breadcrumb a {
  color: var(--fg-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--accent);
}

.code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}

.code-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
  color: var(--fg);
  text-decoration: none;
  transition: border-color 120ms ease, transform 120ms ease;
}

.code-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.code-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.code-card-head h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--fg);
  word-break: break-all;
}

.code-card-counts {
  list-style: none;
  padding: 0;
  margin: 0 0 0.45rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem 0.5rem;
  font-size: 0.78rem;
}

.code-card-counts li {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.code-card-counts li span {
  color: var(--fg-muted);
}

.code-card-counts li strong {
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.9rem;
}

.code-card-path {
  margin: 0;
  font-size: 0.72rem;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-card-path code {
  background: none;
  padding: 0;
}

.code-card-foot {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--accent);
}

.code-card-summary {
  margin-left: auto;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.72rem;
}

.code-card-summary:hover {
  color: var(--accent);
}

.code-section {
  margin-top: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem 1rem;
}

.code-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--fg);
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.code-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.code-list li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.25rem 0;
  border-bottom: 1px dashed transparent;
}

.code-list li a {
  text-decoration: none;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.code-list li a:hover {
  color: var(--accent);
}

.code-list li .hint {
  font-size: 0.72rem;
  color: var(--fg-muted);
}

.code-list-files li {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
}

.endpoint-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.endpoint-list li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.2rem 0;
}

.endpoint-list li a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--fg);
}

.endpoint-list li a:hover {
  color: var(--accent);
}

.http-method {
  font-family: var(--mono);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.code-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.code-stats strong {
  color: var(--fg);
  font-family: var(--mono);
}

.code-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 60rem) { /* --bp-md (was 900px) */
  .code-columns {
    grid-template-columns: 1.4fr 1fr;
  }
  .code-columns .code-section.lessons {
    grid-column: 1 / -1;
  }
}

.code-snippet {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  margin: 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
}

.code-function-body details {
  margin-bottom: 1rem;
}

.code-function-body summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-bottom: 0.4rem;
}

.ego-network {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 60rem) { /* --bp-md (was 900px) */
  .ego-network {
    grid-template-columns: 1fr 1fr;
  }
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--fg-muted);
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state h3 {
  color: var(--fg);
  margin: 0 0 0.5rem;
}

.lead {
  color: var(--fg-muted);
  margin: 0.4rem 0;
}

.sitemap-link {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
}

.sitemap-link:hover {
  text-decoration: underline;
}

.sitemap-table {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.85rem;
}

.sitemap-row {
  display: grid;
  grid-template-columns: 1.3fr 1.2fr 1.2fr 1.2fr;
  gap: 0.85rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

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

.sitemap-header-row {
  background: rgba(255, 255, 255, 0.04);
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sitemap-endpoint a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--fg);
}

.sitemap-endpoint a:hover {
  color: var(--accent);
}

.sitemap-row a {
  color: var(--fg);
  text-decoration: none;
}

.sitemap-row a:hover {
  color: var(--accent);
}

/* --- v2.1 /code project view polish --------------------------------- */

.project-header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.25rem 0 0.85rem;
}

.project-header-row h2 {
  margin: 0;
  font-size: 1.55rem;
  color: var(--fg);
  word-break: break-all;
}

.project-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: linear-gradient(135deg, rgba(126, 231, 224, 0.18), rgba(126, 231, 224, 0.06));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  transition: transform 120ms ease, background 120ms ease;
}

.primary-action:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(126, 231, 224, 0.3), rgba(126, 231, 224, 0.12));
}

.primary-action .action-arrow {
  transition: transform 120ms ease;
}

.primary-action:hover .action-arrow {
  transform: translateX(3px);
}

.ghost-action {
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.ghost-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.project-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.5rem;
  margin: 0.5rem 0 0.4rem;
}

.project-stats .stat-cell {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
}

.project-stats .stat-cell strong {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.1;
}

.project-stats .stat-cell span {
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.project-prefix {
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin: 0.45rem 0 0;
}

.project-prefix code {
  background: rgba(255, 255, 255, 0.04);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius);
  font-size: 0.72rem;
}

.project-toolbar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0.85rem 0;
}

.project-toolbar input[type="search"] {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.7rem;
  color: var(--fg);
  font-size: 0.88rem;
  font-family: var(--mono);
}

.project-toolbar input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(126, 231, 224, 0.15);
}

.project-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 60rem) { /* --bp-md (was 1000px) */
  .project-columns {
    grid-template-columns: 1fr 300px;
  }
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin: 0 0 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.section-title .section-count {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  background: rgba(126, 231, 224, 0.12);
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.65rem;
}

.module-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
  transition: border-color 120ms ease, transform 120ms ease;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.module-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.module-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed var(--border);
}

.module-card-title {
  flex: 1;
  text-decoration: none;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-card-title:hover {
  color: var(--accent);
}

.module-card-title code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 0.8rem;
}

.module-card-count {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--fg-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-pill);
}

.decl-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.decl-group-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}

.decl-group .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.decl-list {
  list-style: none;
  padding: 0 0 0 0.85rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.decl-list li {
  overflow: hidden;
}

.decl-list li a {
  display: block;
  color: var(--fg-muted);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.74rem;
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.decl-list li a:hover {
  color: var(--accent);
  background: rgba(126, 231, 224, 0.08);
}

.decl-list li a code {
  background: none;
  padding: 0;
  color: inherit;
}

.project-rail {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.rail-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
}

.hot-list {
  list-style: decimal inside;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.hot-list li {
  font-size: 0.78rem;
  color: var(--fg-muted);
  overflow: hidden;
}

.hot-list li::marker {
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.hot-list li a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--fg);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius);
  max-width: 100%;
  overflow: hidden;
}

.hot-list li a:hover {
  color: var(--accent);
  background: rgba(126, 231, 224, 0.08);
}

.hot-list .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.hot-list code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 0.76rem;
  /* Truncate long names with ellipsis. Full name appears on hover
     via the title attribute the template now sets. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.lessons-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.lessons-list li a {
  text-decoration: none;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.lessons-list li a:hover {
  color: var(--accent);
}

.lessons-list li code {
  background: none;
  padding: 0;
  color: inherit;
}

.lessons-list .hint {
  margin: 0.2rem 0 0;
  font-size: 0.72rem;
  color: var(--fg-muted);
  line-height: 1.45;
}

/* --- v2.1 Nebula graph theme ---------------------------------------- */
/*
   Three-panel resizable shell:
     +---------+----------------+----------+
     |  TREE   |   CANVAS       |  DETAIL  |
     +---------+----------------+----------+
     |              FILTER BAR             |
     +-------------------------------------+
   Panels persist their widths to localStorage. Dragging the gutters
   resizes the adjacent panels.
*/

.nebula-shell {
  display: grid;
  grid-template-columns: var(--nebula-left, 240px) 4px 1fr 4px var(--nebula-right, 320px);
  grid-template-rows: 1fr auto;
  height: calc(100vh - var(--topbar-h));
  background:
    /* faint starfield: 2 layered radial dot patterns at different scales */
    radial-gradient(1px 1px at 20% 30%, rgba(192, 132, 252, 0.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 75% 60%, rgba(34, 211, 238, 0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 45% 80%, rgba(251, 146, 60, 0.3) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 15%, rgba(192, 132, 252, 0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 12% 75%, rgba(74, 222, 128, 0.3) 50%, transparent 51%),
    /* soft nebula gradient -- deep purple bloom upper-left, teal lower-right */
    radial-gradient(circle at 25% 15%, rgba(76, 50, 130, 0.35) 0%, transparent 55%),
    radial-gradient(circle at 80% 85%, rgba(20, 90, 110, 0.35) 0%, transparent 55%),
    /* base */
    linear-gradient(180deg, #07090f 0%, #0b0e18 100%);
  background-size:
    220px 220px,
    180px 180px,
    260px 260px,
    200px 200px,
    240px 240px,
    100% 100%,
    100% 100%,
    100% 100%;
  position: relative;
  overflow: hidden;
}

.nebula-tree {
  grid-row: 1 / 2;
  grid-column: 1 / 2;
  overflow-y: auto;
  background: rgba(8, 11, 19, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid rgba(126, 231, 224, 0.08);
  padding: 0.85rem 0.5rem 0.85rem 0.85rem;
  font-size: 0.82rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(126, 231, 224, 0.3) transparent;
  scroll-behavior: smooth;
}

.nebula-tree::-webkit-scrollbar { width: 6px; }
.nebula-tree::-webkit-scrollbar-track { background: transparent; }
.nebula-tree::-webkit-scrollbar-thumb {
  background: rgba(126, 231, 224, 0.2);
  border-radius: 3px;
  transition: background 200ms ease;
}
.nebula-tree::-webkit-scrollbar-thumb:hover { background: rgba(126, 231, 224, 0.4); }

.nebula-canvas {
  grid-row: 1 / 2;
  grid-column: 3 / 4;
  position: relative;
  overflow: hidden;
  /* v4.6: a plain OPAQUE C1 deep-space base (#07090f). The v4.6
     renderer (nebula-gl.js) clears its own GL canvas to this exact
     colour, so there is NO transparent-canvas + CSS-atmosphere
     coupling anymore -- that coupling was the v4.5.x failure source
     (the "white background / lag" reports). This is just the
     fallback paint behind the two absolutely-filling canvases. */
  background: #07090f;
}

/* v4.6: the two stacked canvases fill .nebula-canvas exactly.
   #nebula-gl is the WebGL graph (z:1); #nebula-labels is the 2D
   label overlay the renderer's LabelProvider draws onto -- it sits
   on top (z:2) and is click-through so all input lands on the GL
   canvas. #cy-nebula is an inert hidden legacy node. */
#nebula-gl,
#nebula-labels {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#nebula-gl {
  z-index: 1;
  background: transparent;
}
#nebula-labels {
  z-index: 2;
  pointer-events: none;
}
#cy-nebula {
  display: none;
}

.nebula-detail {
  grid-row: 1 / 2;
  grid-column: 5 / 6;
  overflow-y: auto;
  background: rgba(8, 11, 19, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid rgba(126, 231, 224, 0.08);
  padding: 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(126, 231, 224, 0.3) transparent;
  scroll-behavior: smooth;
}

.nebula-detail::-webkit-scrollbar { width: 6px; }
.nebula-detail::-webkit-scrollbar-track { background: transparent; }
.nebula-detail::-webkit-scrollbar-thumb {
  background: rgba(126, 231, 224, 0.2);
  border-radius: 3px;
}
.nebula-detail::-webkit-scrollbar-thumb:hover { background: rgba(126, 231, 224, 0.4); }

/* C1.R (v4.4): adaptive full-window shell. < --bp-md the 5-col
   .nebula-shell collapses to a single full-width canvas (no 277px-
   sliver pathology) and the tree/detail panels become reachable
   off-canvas drawers via display:none<->block (NOT translateX -- the
   Task-3 lesson: a translated fixed panel extends scrollWidth). The
   shell carries mp-tree / mp-detail (nebula().mPanel); a scrim closes
   it. Desktop (>= --bp-md) 3-panel layout is untouched. */
@media (max-width: 60rem) {
  /* display:flex (NOT grid). With grid + 1 explicit column the in-grid
     children (canvas grid-column:3/4, filterbar 1/6, the two resize
     gutters at cols 2 & 4) keep auto-generating IMPLICIT columns -- the
     graph stayed a 247px sliver through 4 grid tweaks. flex makes every
     grid-column / grid-row inert: no tracks, no slivers, deterministic
     (feedback_three_failed_fixes_architecture). The canvas flexes to
     full width/height; the filterbar stacks under it; the gutters are
     useless on a single-pane mobile view. */
  .nebula-shell {
    display: flex;
    flex-direction: column;
  }
  .nebula-canvas {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
  }
  .nebula-filterbar {
    flex: 0 0 auto;
    width: 100%;
  }
  .nebula-gutter {
    display: none;
  }
  .nebula-tree,
  .nebula-detail {
    display: none;
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    width: min(86vw, 320px);
    z-index: 60;
    box-shadow: var(--shadow);
  }
  .nebula-tree {
    left: 0;
  }
  .nebula-detail {
    right: 0;
  }
  .nebula-shell.mp-tree .nebula-tree {
    display: block;
  }
  .nebula-shell.mp-detail .nebula-detail {
    display: block;
  }
}

/* C1.R shared mobile-panel affordances (both full-window shells,
   single-source). The toggle bar + scrim only exist < --bp-md; the
   desktop 3-panel layouts never see them. */
/* v4.4.1: a refined SEGMENTED CONTROL, not two floating bordered
   pills with a stray inconsistent glyph (the v4.4.0 review found
   "Chats / Cite" + "Tree / Detail" weird). One inset track, the
   active segment filled with --accent-soft. C1-token, dark-theme,
   single-source for BOTH shells (chat #6 + nebula #8). */
.mpanel-bar {
  display: none;
}
.mpanel-toggle {
  display: inline-flex;
  flex: 1; /* v4.4.1: full-width 50/50 segments (the user's pick) */
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 0.95rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition);
}
.mpanel-toggle:hover {
  color: var(--fg);
}
.mpanel-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.mpanel-toggle.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.mpanel-scrim {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 55;
  border: 0;
}
@media (min-width: 60rem) {
  .mpanel-bar,
  .mpanel-scrim {
    display: none !important;
  }
}
@media (max-width: 60rem) {
  /* v4.4.1: a FULL-WIDTH 50/50 segmented control (the user rejected
     the compact left pill as unprofessional). The track spans the
     pane; the two .mpanel-toggle segments each flex:1. */
  .mpanel-bar {
    display: flex;
    width: 100%;
    gap: 3px;
    margin: 0.6rem 0 0.45rem;
    padding: 3px;
    background: var(--panel-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
  }
}

/* Silky fade-in for the detail content when a node is selected.
   Triggered by Alpine's x-if mounting the inner div. ``.nebula-body``
   is the v2.2.7 generic body container (replaces the old hardcoded
   ``<pre>``; mnemoRenderBody now picks code vs markdown). */
.nebula-detail h3,
.nebula-detail .ntype,
.nebula-detail .nsource,
.nebula-detail .ndesc,
.nebula-detail .nebula-body,
.nebula-detail pre,
.nebula-detail h4,
.nebula-detail .nlist,
.nebula-detail .nactions {
  animation: nebula-fade-in 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.nebula-detail .nlist li {
  animation: nebula-fade-in 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

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

.nebula-filterbar {
  grid-row: 2 / 3;
  grid-column: 1 / 6;
  background: rgba(15, 19, 28, 0.95);
  border-top: 1px solid var(--border);
  padding: 0.5rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  backdrop-filter: blur(10px);
  font-size: 0.82rem;
}

.nebula-gutter {
  grid-row: 1 / 2;
  background: linear-gradient(180deg, transparent 0%, rgba(126, 231, 224, 0.12) 50%, transparent 100%);
  cursor: url("cursors/mnem-cursor-col-resize.svg") 16 16, col-resize;
  position: relative;
  transition: background 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nebula-gutter:hover,
.nebula-gutter.dragging {
  background: linear-gradient(180deg, transparent 0%, rgba(126, 231, 224, 0.45) 50%, transparent 100%);
}

.nebula-gutter::before {
  transition: height 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nebula-gutter:hover::before {
  height: 40px;
}

.nebula-gutter::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 24px;
  border-radius: 1px;
  background: rgba(126, 231, 224, 0.55);
}

.nebula-gutter-left  { grid-column: 2 / 3; }
.nebula-gutter-right { grid-column: 4 / 5; }

/* --- Tree --- */

.nebula-tree h3.tree-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  margin: 0 0 0.65rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nebula-tree h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin: 0 0 0.5rem;
}

.tree-title-icon {
  width: 14px;
  height: 14px;
  color: var(--accent);
  opacity: 0.7;
}

.tree-title-scope {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
  white-space: nowrap;
}

/* VSCode-style tree -- compact rows, colored corner-fold per ext */
.vscode-tree {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* v2.6.0 perf: skip layout + paint for off-screen rows. Modern
   browsers respect ``content-visibility: auto`` to defer rendering
   of elements outside the viewport; combined with
   ``contain-intrinsic-size`` (which gives a placeholder size) the
   tree scales to thousands of rows without browser jank. ``24px``
   is the actual per-row height in our compact style. */
.vscode-tree li {
  content-visibility: auto;
  contain-intrinsic-size: auto 24px;
}

.vscode-tree ul {
  list-style: none;
  padding-left: 0.85rem;
  margin: 0;
  position: relative;
}

.vscode-tree ul::before {
  content: "";
  position: absolute;
  left: 0.5rem;
  top: 0.15rem;
  bottom: 0.15rem;
  width: 1px;
  background: rgba(255, 255, 255, 0.05);
}

/* Hide EVERY browser's default details-disclosure marker.
   The spec only allows ``color``, ``content``, ``font-*``,
   ``white-space``, and ``text-*`` properties on ``::marker`` --
   ``display: none`` is ignored. We use the allowed levers
   (content + font-size + width + color) to make the marker
   invisible regardless of which UA rendered it. */
.vscode-tree summary,
.vscode-tree details summary {
  list-style: none !important;
  list-style-type: none !important;
}

/* Safari + old Chrome legacy marker */
.vscode-tree summary::-webkit-details-marker,
.vscode-tree details > summary::-webkit-details-marker {
  display: none !important;
}

/* Modern Chrome 128+ + Firefox unprefixed marker. ``display: none``
   is rejected here; ``content: ""`` + ``font-size: 0`` ARE allowed
   and combined make the marker take up zero space. */
.vscode-tree summary::marker,
.vscode-tree details > summary::marker {
  content: "" !important;
  font-size: 0 !important;
  color: transparent !important;
}

/* Chrome 128+ reserves a phantom slot for the disclosure widget
   inside any flex/grid summary -- 12-18px wide, invisible (with our
   marker hide) but still claiming flex slot 0. The cure is to leave
   the summary itself as a plain block and put our children inside
   an inner flex wrapper, which gets a clean flex context. */
.vscode-tree details summary.vscode-dir {
  display: block;
  list-style: none;
  cursor: pointer;
  padding: 0.18rem 0.35rem;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  transition: background 200ms ease;
}

.vscode-tree details summary.vscode-dir:hover {
  background: rgba(126, 231, 224, 0.07);
}

/* Inner flex row for summary contents. Lives INSIDE the summary so
   the disclosure-widget phantom slot (Chrome 128+) doesn't claim
   flex slot 0 -- we get a fresh flex context here. */
.vscode-tree .vscode-dir-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* The chev rotation needs to follow the new selector path
   (summary > .vscode-dir-row > .vscode-chev). The old rule that
   targeted summary > .vscode-chev no longer matches after the
   structural change. */
.vscode-tree details[open] > summary > .vscode-dir-row > .vscode-chev {
  transform: rotate(90deg);
}

/* Pseudo-element chevron -- sharper than a 10px SVG. Right-pointing
   when collapsed; rotates 90deg to point down when open. */
.vscode-chev {
  width: 10px;
  height: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--fg-muted);
  transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.vscode-chev::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
}

/* v2.6.0 polish: flat-tree chevron rotates when the dir is expanded. */
.vscode-chev.is-open {
  transform: rotate(90deg);
}

/* v2.6.0 polish: flat-tree dir is now a <button> not a <details/summary>.
   Match the existing summary styles so the visual stays identical. */
.vscode-tree .vscode-dir-button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.18rem 0.35rem;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  transition: background 200ms ease;
}
.vscode-tree .vscode-dir-button:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* File-count badge next to a dir name -- shows "1234" if the dir
   contains 1234 modules deep. */
.vscode-tree .vscode-dir-count {
  margin-left: auto;
  color: var(--fg-dim);
  font-size: 0.65rem;
  font-family: var(--mono);
}

.vscode-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.vscode-dir-label {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vscode-file {
  display: flex !important;
  align-items: center;
  gap: 0.4rem;
  padding: 0.18rem 0.35rem 0.18rem 0.85rem;
  text-decoration: none;
  color: var(--fg-dim);
  font-family: var(--mono);
  font-size: 0.72rem;
  border-radius: var(--radius);
  white-space: nowrap;
  overflow: hidden;
  transition:
    background 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    color 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.vscode-file:hover {
  background: rgba(126, 231, 224, 0.08);
  color: var(--fg);
}

.vscode-file.active {
  background: linear-gradient(90deg, rgba(126, 231, 224, 0.18), rgba(126, 231, 224, 0.04));
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}

.vscode-file-icon {
  display: inline-flex;
  flex-shrink: 0;
}

.vscode-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.vscode-file-meta {
  font-size: 0.6rem;
  color: var(--fg-muted);
  font-family: var(--mono);
  flex-shrink: 0;
  margin-left: auto;
}

.nebula-tree details {
  margin-left: 0;
}

/* Generic nebula-tree summary base (used by non-vscode trees, if any).
   The Unicode-arrow ::before that used to live here drew a SECOND
   chevron on top of the .vscode-chev one -- removed. Display is now
   ``block`` so summary doesn't reserve a phantom flex slot for the
   disclosure widget; inner content uses .vscode-dir-row for flex. */
.nebula-tree details > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.18rem 0.35rem;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg);
  display: block;
}

.nebula-tree details > summary::-webkit-details-marker { display: none; }

.nebula-tree summary:hover {
  background: rgba(126, 231, 224, 0.08);
}

.nebula-tree .tree-file {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.4rem 0.22rem 1.15rem;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--fg-dim);
  cursor: pointer;
  text-decoration: none;
  transition:
    background 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    color 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nebula-tree .tree-file:hover {
  background: rgba(126, 231, 224, 0.1);
  color: var(--fg);
  transform: translateX(2px);
}

.nebula-tree .tree-file.active {
  background: linear-gradient(90deg, rgba(126, 231, 224, 0.22), rgba(126, 231, 224, 0.08));
  color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}

.nebula-tree .tree-file-meta {
  margin-left: auto;
  font-size: 0.65rem;
  color: var(--fg-muted);
}

/* --- Detail panel --- */

.detail-close {
  position: absolute;
  top: 0.5rem;
  right: 0.7rem;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  /* the &times; glyph sits optically high; a slightly smaller size +
     flex centering + zeroed box reads as truly centred in the circle
     (live-review: "close button not centered"). */
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
  text-align: center;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  transition:
    background 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    color 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 5;
}

.detail-close:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.4);
  color: #f43f5e;
}

.nebula-detail {
  position: relative;
}

.nebula-detail .empty-detail {
  color: var(--fg-muted);
  font-size: 0.85rem;
  padding: 2rem 0.5rem;
  text-align: center;
}

.nebula-detail h3 {
  font-size: 1rem;
  margin: 0.3rem 0;
  color: var(--fg);
  word-break: break-word;
}

.nebula-detail .ntype {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  margin-bottom: 0.5rem;
}

.nebula-detail .nsource {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--fg-muted);
  margin: 0 0 0.5rem;
  word-break: break-all;
}

.nebula-detail .ndesc {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin: 0.4rem 0;
}

.nebula-detail pre,
.nebula-detail pre[class*="language-"] {
  background: #0a0d14 !important;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  margin: 0.5rem 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.55;
  max-height: 320px;
  overflow: auto;
  color: #e6edf3;
  /* Silky scrollbar inside the code block */
  scrollbar-width: thin;
  scrollbar-color: rgba(126, 231, 224, 0.3) transparent;
}

.nebula-detail pre code {
  font-family: var(--mono);
  font-size: inherit;
  line-height: inherit;
  background: none !important;
  padding: 0;
}

.nebula-detail pre::-webkit-scrollbar { height: 6px; width: 6px; }
.nebula-detail pre::-webkit-scrollbar-thumb {
  background: rgba(126, 231, 224, 0.25);
  border-radius: 3px;
}

/* Prism token color overrides to harmonize with the Nebula palette */
.nebula-detail .token.comment,
.nebula-detail .token.prolog,
.nebula-detail .token.doctype,
.nebula-detail .token.cdata { color: #6b7280; font-style: italic; }
.nebula-detail .token.punctuation { color: #94a3b8; }
.nebula-detail .token.keyword,
.nebula-detail .token.tag,
.nebula-detail .token.operator { color: #c084fc; }
.nebula-detail .token.string,
.nebula-detail .token.attr-value { color: #4ade80; }
.nebula-detail .token.number,
.nebula-detail .token.boolean,
.nebula-detail .token.constant { color: #fb923c; }
.nebula-detail .token.function,
.nebula-detail .token.method { color: #22d3ee; }
.nebula-detail .token.class-name,
.nebula-detail .token.maybe-class-name { color: #e879f9; }
.nebula-detail .token.builtin { color: #38bdf8; }
.nebula-detail .token.decorator,
.nebula-detail .token.atrule,
.nebula-detail .token.attr-name { color: #fbbf24; }

.nebula-detail h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin: 1rem 0 0.4rem;
}

.nebula-detail .nlist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nebula-detail .nlist li button {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.65rem;
  font-size: 0.78rem;
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition:
    border-color 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    background 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nebula-detail .nlist li button:hover {
  border-color: var(--accent);
  background: rgba(126, 231, 224, 0.1);
  transform: translateX(3px);
  box-shadow: -2px 0 0 var(--accent);
}

.nebula-detail .nlist .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nebula-detail .nlist .label {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.74rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nebula-detail .nlist .rel {
  font-size: 0.65rem;
  color: var(--fg-muted);
}

.nebula-detail .nactions {
  display: flex;
  gap: 0.4rem;
  margin: 0.85rem 0 0;
}

.nebula-detail .nactions a,
.nebula-detail .nactions button {
  flex: 1;
  font-size: 0.78rem;
  padding: 0.4rem 0.6rem;
  text-align: center;
  text-decoration: none;
}

/* --- Filter bar --- */

.nebula-filterbar input[type="search"] {
  flex: 1 1 220px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.6rem;
  color: var(--fg);
  font-size: 0.82rem;
}

.nebula-filterbar input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(126, 231, 224, 0.15);
}

.nebula-chips {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.nebula-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.72rem;
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
  /* silky toggle: opacity + transform + border all easing together */
  transition:
    opacity 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    border-color 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    background 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: opacity, transform;
}

.nebula-chip:hover {
  transform: translateY(-1px);
}

.nebula-chip.on {
  color: var(--fg);
  border-color: currentColor;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 1px transparent, 0 4px 10px -4px rgba(126, 231, 224, 0.25);
}

.nebula-chip.off {
  opacity: 0.32;
  transform: scale(0.95);
}

.nebula-chip .swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.nebula-slider {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--fg-muted);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
}

.nebula-slider .slider-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.65rem;
  color: var(--fg-muted);
}

.nebula-slider .slider-wrap {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  width: 160px;
  padding-bottom: 0.65rem;
}

.nebula-slider input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: linear-gradient(
    90deg,
    rgba(126, 231, 224, 0.55) 0%,
    rgba(126, 231, 224, 0.25) 70%,
    rgba(126, 231, 224, 0.15) 100%
  );
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.nebula-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent), 0 0 8px rgba(126, 231, 224, 0.5);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.nebula-slider input[type="range"]::-webkit-slider-thumb:hover,
.nebula-slider input[type="range"]:focus::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(126, 231, 224, 0.8);
}

.nebula-slider input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent), 0 0 8px rgba(126, 231, 224, 0.5);
  cursor: pointer;
}

.nebula-slider .slider-marks {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0.6rem;
  pointer-events: none;
}

.nebula-slider .slider-marks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--fg-muted);
  font-family: var(--mono);
  opacity: 0.65;
}

.nebula-slider .slider-marks span[data-pct="0"]   { left: 0%; }
.nebula-slider .slider-marks span[data-pct="50"]  { left: 50%; }
.nebula-slider .slider-marks span[data-pct="70"]  { left: 70%; }
.nebula-slider .slider-marks span[data-pct="90"]  { left: 90%; }
.nebula-slider .slider-marks span[data-pct="100"] { left: 100%; }

.nebula-slider .slider-value {
  min-width: 2.4rem;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg);
  font-weight: 600;
}

.nebula-slider .slider-reset {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  background: rgba(126, 231, 224, 0.15);
  border: 1px solid rgba(126, 231, 224, 0.4);
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nebula-slider .slider-reset:hover {
  background: rgba(126, 231, 224, 0.3);
}

.nebula-hops {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--fg-muted);
}

.nebula-hops select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.2rem 0.4rem;
  color: var(--fg);
  font-size: 0.78rem;
}

.nebula-layout-buttons {
  display: inline-flex;
  gap: 0.25rem;
}

.nebula-layout-buttons button {
  padding: 0.25rem 0.55rem;
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  border-radius: var(--radius);
  cursor: pointer;
}

.nebula-layout-buttons button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.nebula-layout-buttons button.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(126, 231, 224, 0.12);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

/* v2.2.3: edge + label visibility toggles. Match the layout-buttons
   palette (border, color) but pair with a leading dot that fills
   when ON and outlines when OFF -- gives a quick visual scan of
   what's enabled across the filter bar. */
.nebula-toggle-buttons {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.45rem;
}
.nebula-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--fg);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition),
              background var(--transition);
}
.nebula-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.nebula-toggle .nebula-toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent);
  transition: background var(--transition), box-shadow var(--transition);
}
.nebula-toggle.off {
  color: var(--fg-muted);
  background: transparent;
}
.nebula-toggle.off .nebula-toggle-dot {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--fg-dim);
}

.nebula-stats {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--fg-muted);
  font-family: var(--mono);
}

/* --- Canvas overlays --- */

/* v4.6: the v2.2.4 DOM-overlay pulse ring + its @keyframes are gone.
   The v4.6 renderer (nebula-gl.js) lights the selected node and its
   incident filaments in-GL (gl.select), so there is no DOM pulse
   element and no CSS pulse animation anymore -- a net simplification.
   The v4.5.x CSS "atmosphere" (drift / twinkle / parallax) is removed
   for the same reason: the WebGL canvas is opaque and self-contained,
   that transparent-canvas coupling was the documented failure source. */

/* --- Layout-change veil (v2.2.6) ---------------------------------
   When the user picks a different layout (rings / tree / grid /
   force) we snap node positions synchronously and animate only
   the camera. The veil hides the snap behind a translucent
   overlay that CSS-fades in -> opaque, holds while the snap
   happens, then fades back to transparent.

   The PRIOR implementation cross-faded by calling
   ``cy.elements().animate({ style: { opacity: 0.3 -> 1.0 } })``
   which writes an INLINE BYPASS on every node. The bypass at
   opacity:1.0 then overrode the .dim class's stylesheet
   ``opacity: 0.12`` -- so changing layout while a node was
   selected silently killed the blur-others focus effect. The
   user reported "the focus on related nodes disappears and
   also the blur-others effect" (2026-05-14). Pipeline 18:
   move the visual to a DOM overlay so cytoscape's style cascade
   keeps owning .hl / .dim opacity. ----------------------------- */
.nebula-layout-veil {
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  z-index: 5;  /* above the #nebula-gl / #nebula-labels canvases */
  transition: opacity 140ms ease-in-out;
}
.nebula-layout-veil.on {
  opacity: 0.55;
}
@media (prefers-reduced-motion: reduce) {
  .nebula-layout-veil { transition: none; }
  .nebula-layout-veil.on { opacity: 0; }
}

.nebula-hint {
  position: absolute;
  top: 0.7rem;
  left: 0.85rem;
  /* v2.6.5: above the .nebula-labels DOM overlay (z-index 5) and
     the cosmos canvas, with a near-opaque background so the chip
     stays legible over the perpetually-drifting bright nebula
     (the old 0.85-alpha let moving nodes bleed through). */
  z-index: 20;
  background: rgba(8, 11, 18, 0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem;
  font-size: 0.72rem;
  color: var(--fg-muted);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

/* v2.6.3: DOM label overlay for the Cosmograph canvas (cosmos.gl
   renders no text). Spans are absolutely positioned at each point's
   screen coords (recomputed every frame). The layer never eats
   pointer events so canvas drag / click still work through it. */
.nebula-labels {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
}
.nebula-label {
  position: absolute;
  transform: translate(-50%, -160%);
  white-space: nowrap;
  font-size: 0.66rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 500;
  color: #e6edf3;
  background: rgba(10, 13, 20, 0.72);
  border: 1px solid color-mix(in srgb, var(--label-color, #7ee7e0) 45%, transparent);
  border-left: 2px solid var(--label-color, #7ee7e0);
  border-radius: 4px;
  padding: 1px 5px;
  text-shadow: 0 1px 2px #000;
  backdrop-filter: blur(2px);
}
.nebula-label.is-selected {
  font-weight: 700;
  font-size: 0.72rem;
  color: #fff;
  background: rgba(10, 13, 20, 0.9);
  border-color: var(--label-color, #7ee7e0);
  z-index: 2;
}

.nebula-context {
  position: absolute;
  top: 0.7rem;
  right: 0.85rem;
  /* v2.6.5: top layer + near-opaque (see .nebula-hint note). */
  z-index: 20;
  background: rgba(8, 11, 18, 0.96);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem;
  font-size: 0.72rem;
  color: var(--fg);
  backdrop-filter: blur(8px);
  font-family: var(--mono);
}

.nebula-context a {
  color: var(--accent);
  text-decoration: none;
  margin-left: 0.4rem;
}

/* v2.6.0 polish: status chip in the lower-right of the canvas.
   Replaces the top-center truncation banner that overlapped the
   pan/zoom hint + the scope chip. Now there's always-on visibility
   of "X nodes · workspace-name" without competing with the other
   top-row affordances. */
.nebula-status {
  position: absolute;
  right: 0.85rem;
  bottom: 0.85rem;
  /* v2.6.5: was z-index 5 (TIED with the .nebula-labels overlay ->
     workspace name bled under drifting labels). Lift above it +
     near-opaque background. */
  z-index: 20;
  background: rgba(8, 11, 18, 0.96);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  font-size: 0.72rem;
  font-family: var(--mono);
  backdrop-filter: blur(8px);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.nebula-status-count {
  color: var(--fg);
}
.nebula-status-ws {
  color: var(--accent);
}
.nebula-status-sep {
  color: var(--fg-dim);
}

/* --- Node-type badge colors used by chips + detail badge ---
   Palette-driven via ``--type-color``: templates stamp the color
   inline from palette.py (single source). Generic ``[class*=...]``
   selectors below cover every type (current + future). */

/* Nebula filter / breakdown swatches. The 50%-alpha glow uses the
   modern color-mix() function which Chrome 111+, Safari 16.4+, and
   Firefox 113+ all support natively. */
.swatch[class*="swatch-"] {
  background: var(--type-color, var(--accent));
  box-shadow: 0 0 6px color-mix(in srgb, var(--type-color, var(--accent)) 50%, transparent);
}

/* Pill chips that appear next to node titles inside the Nebula
   detail panel. 18%-alpha background + full-saturation text. */
[class*="ntype-"] {
  background: color-mix(in srgb, var(--type-color, var(--accent)) 18%, transparent);
  color: var(--type-color, var(--accent));
}

/* --- Mini-map overlay --- */
.nebula-minimap {
  position: absolute;
  bottom: 0.85rem;
  right: 0.85rem;
  width: 160px;
  height: 100px;
  background: rgba(11, 14, 22, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  pointer-events: none;
  overflow: hidden;
}

/* --- Progressive UX primitives (v2.2 phase 1) --------------------
   Three reveal classes used by daemon/mnemo/ui/static/app.js:

     .skeleton      paints a shimmering placeholder for any UI shape.
                    Sub-variants below (-list-row / -code-line / etc.)
                    tune the box geometry per kind.

     .reveal-item   the base class for items appended via
                    mnemoStaggeredReveal. Starts at opacity 0; when
                    the JS toggles .reveal-in on the next frame, the
                    CSS transition fades it in over 180ms.

     .fade-in       the per-chunk fade-in class used by Nebula's
                    chunked initial paint (phase 4). The class is
                    added to each chunk at insert time and removed
                    260ms later -- the transition runs only during
                    reveal, never during dim/un-dim (which is what
                    caused the deselect lag fixed in v2.1.2).

   ``prefers-reduced-motion: reduce`` short-circuits all animation
   below so the final state is visible instantly.
   ------------------------------------------------------------- */

/* Shimmer placeholder. The 1.3s sweep is gentle enough to avoid
   "loading flashing seizure" territory while still reading as
   "something is coming". */
.skeleton {
  position: relative;
  display: block;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 0%,
    rgba(255, 255, 255, 0.10) 50%,
    rgba(255, 255, 255, 0.04) 100%
  );
  background-size: 200% 100%;
  background-position: -100% 0;
  border-radius: 4px;
  animation: mnemo-shimmer 1.3s linear infinite;
}
@keyframes mnemo-shimmer {
  to { background-position: 200% 0; }
}

.skeleton-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 0;
}
.skeleton-list-row        { height: 1.8em; }
.skeleton-code-line       { height: 1.1em; }
.skeleton-paragraph-line  { height: 1.0em; }
.skeleton-graph           { min-height: 240px; border-radius: var(--radius); }

/* Staggered reveal item. The JS appends each item with
   .reveal-item (opacity 0), then on the next frame adds .reveal-in
   to trigger the transition to opacity 1. */
.reveal-item {
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}
.reveal-item.reveal-in {
  opacity: 1;
  transform: translateY(0);
}

/* Per-chunk Nebula fade-in. Applied to Cytoscape elements via
   .addClass('fade-in'); only the CSS-side reveal transition runs.
   Cytoscape's own opacity is controlled separately in graph.html. */
.fade-in {
  animation: mnemo-chunk-fade-in 220ms ease-out 1;
}
@keyframes mnemo-chunk-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Accessibility: honor prefers-reduced-motion. Skeletons stop
   shimmering; reveals snap; chunk fades end immediately. */
@media (prefers-reduced-motion: reduce) {
  .skeleton                    { animation: none; }
  .reveal-item,
  .reveal-item.reveal-in       { opacity: 1; transform: none; transition: none; }
  .fade-in                     { animation: none; }
}
