/* ============================================================================
   Alexandria — Thesis Field · "Luminous Void"
   A near-black tinted field. The Tetra canvas paints the live graph + per-work
   glow underneath; everything here is the floating chrome above it.
   Committed, cinematic, depth-of-field, alive. OKLCH everywhere. No #000/#fff.
   ========================================================================== */

/* ---- Self-hosted faces (SIL OFL, variable, latin) ----------------------
   Editorial pairing: a text serif for the words the corpus produced, a
   grotesque for chrome/data, a mono for ids & keycaps. Self-hosted so the
   locally-served viewer renders identically with no network. font-display:
   swap → fallback stack paints instantly, swaps in when (if) loaded. */
@font-face {
  font-family: "Source Serif 4 Var";
  src: url("fonts/source-serif-4-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4 Var";
  src: url("fonts/source-serif-4-wght-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk Var";
  src: url("fonts/hanken-grotesk-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Spline Sans Mono Var";
  src: url("fonts/spline-sans-mono-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ---- Field & ink --------------------------------------------------- */
  --field-0: oklch(0.11 0.014 275);     /* deepest field */
  --field-1: oklch(0.15 0.016 275);     /* panel base behind glass */
  --ink:     oklch(0.96 0.005 275);
  --ink-dim: oklch(0.74 0.012 275);
  --ink-mute:oklch(0.55 0.014 275);
  --line:    oklch(0.85 0.02 275 / 0.14);   /* hairline */
  --accent:  oklch(0.80 0.13 255);          /* luminous cyan-violet */
  --accent-warm: oklch(0.83 0.11 85);       /* faint parchment-gold */

  /* ---- Kind colors (Agent B references these exact tokens) ----------- */
  --kind-analog:            oklch(0.74 0.15 155);
  --kind-contrast:          oklch(0.66 0.20 25);
  --kind-method_variant:    oklch(0.81 0.14 85);
  --kind-cluster_bridge:    oklch(0.71 0.16 290);
  --kind-definition_variant:oklch(0.75 0.13 220);

  /* ---- Glass --------------------------------------------------------- */
  --glass-tint:   oklch(0.20 0.02 275 / 0.50);
  --glass-stroke: oklch(0.92 0.02 275 / 0.16);

  /* ---- Shape & motion ------------------------------------------------ */
  --r-card: 16px;
  --r-pill: 999px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);    /* ease-out-expo, no bounce */
  --t-fast: 160ms;
  --t-med: 320ms;

  /* ---- Derived washes (composed from tokens, never raw colors) ------- */
  --wash-faint:  oklch(0.80 0.13 255 / 0.07);
  --wash-soft:   oklch(0.80 0.13 255 / 0.12);
  --wash-warm:   oklch(0.83 0.11 85 / 0.10);
  --on-accent:   oklch(0.15 0.02 255);      /* ink that sits on --accent */
  --shadow-long: 0 24px 60px -20px oklch(0.05 0.02 275 / 0.72),
                 0 4px 14px -8px oklch(0.05 0.02 275 / 0.55);
  --lip: inset 0 1px 0 0 oklch(0.97 0.02 275 / 0.14);

  /* ---- Type roles (offline fallbacks end every stack) ---------------- */
  --font-serif: "Source Serif 4 Var", Georgia, "Times New Roman", serif;
  --font-sans:  "Hanken Grotesk Var", system-ui, -apple-system,
                "Segoe UI Variable", "Segoe UI", sans-serif;
  --font-mono:  "Spline Sans Mono Var", ui-monospace, "SF Mono", Menlo,
                Consolas, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Deep fallback only on the root (paints behind everything). Body stays
   transparent so it never covers the z-index:-1 gravity-mesh canvas — if
   body also had a background it would paint OVER negative-z-index children. */
html { background: var(--field-0); }
body { overflow: hidden; background: transparent; }

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

::selection { background: var(--wash-soft); color: var(--ink); }

/* ---- Scrollbars: thin, tinted ------------------------------------------ */
* {
  scrollbar-width: thin;
  scrollbar-color: oklch(0.55 0.03 275 / 0.40) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: oklch(0.55 0.03 275 / 0.35);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: oklch(0.62 0.05 275 / 0.55); background-clip: padding-box; }

/* ============================================================================
   THE FIELD — canvas + depth haze
   ========================================================================== */

/* Gravity-mesh interactive WebGL background (vendor/gravity-mesh.js). Pinned
   behind everything; the graph canvas above is transparent so this shows. */
#gm-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: -1;
  background: var(--field-0);   /* flat fallback if WebGL fails */
  /* Recede it behind the graph: the graph is the subject (sharp, in front),
     this is soft, dim, low-chroma atmosphere. One set of knobs to taste —
     raise opacity / drop blur for more presence; the reverse to fade it.
     Pushed softer (0.26→0.15, blur 1→3px): the brighter contour-glow knots
     were reading as clickable orbs and stealing clicks from the real graph.
     Now it's unmistakably background haze, never a target. */
  opacity: 0.15;
  filter: blur(3px) brightness(0.62) saturate(0.72);
}
@media (prefers-reduced-motion: reduce) {
  #gm-bg { opacity: 0.12; filter: blur(3.5px) brightness(0.58) saturate(0.66); }
}

#graph-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;        /* dynamic vh: no jump as mobile URL bar shows/hides */
  display: block;
  z-index: 0;
  background: transparent;   /* let the gravity mesh show through */
}

/* Auxiliary glow overlay shown briefly while transition-fx.js morphs
   between corpora. The real transition is done inside the WebGL
   renderer (node lerps, camera dolly, ghost edges); this element only
   adds a soft radial tint so the swap reads even on near-empty graphs.
   Idle: opacity:0. */
#transitionFx {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(ellipse at center,
      rgba(122, 216, 255, 0.18) 0%,
      rgba(181, 156, 255, 0.12) 35%,
      transparent 75%);
}

/*
   #haze : the depth-of-field "void" the WASM can't paint. No grain — pure
   smooth gradient depth plus two large, soft, slowly drifting glow blobs that
   give the field a living, wavey atmosphere (an aurora/nebula, not static).
   All layers inert (pointer-events:none) and faint enough not to wash the
   graph rendered on the canvas below.
*/
#haze {
  /* Superseded by the gravity-mesh shader (vendor/gravity-mesh.js), which is
     the real living atmosphere this CSS layer used to approximate. Hidden
     rather than deleted so it's a one-line revert if the shader is dropped. */
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  background:
    /* top atmospheric glow — air behind the HUD */
    radial-gradient(120% 60% at 50% -8%,
      oklch(0.62 0.10 275 / 0.14) 0%,
      oklch(0.40 0.06 275 / 0.045) 40%,
      transparent 72%),
    /* center lift -> edge vignette — the planetarium dome */
    radial-gradient(120% 110% at 50% 46%,
      oklch(0.30 0.05 275 / 0.085) 0%,
      transparent 36%,
      oklch(0.06 0.012 275 / 0.40) 78%,
      oklch(0.035 0.010 275 / 0.64) 100%);
}
/* Two soft drifting glows — the "wavey" life. Heavily blurred so they read as
   smooth color movement, never edges. */
#haze::before,
#haze::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
}
#haze::before {
  width: 62vw;
  height: 62vw;
  left: -14vw;
  top: -18vh;
  background: radial-gradient(circle,
    oklch(0.58 0.13 280 / 0.16) 0%,
    oklch(0.50 0.10 275 / 0.05) 45%,
    transparent 70%);
}
#haze::after {
  width: 58vw;
  height: 58vw;
  right: -16vw;
  bottom: -20vh;
  background: radial-gradient(circle,
    oklch(0.60 0.11 235 / 0.13) 0%,
    oklch(0.48 0.08 255 / 0.04) 48%,
    transparent 72%);
}
@media (prefers-reduced-motion: no-preference) {
  #haze::before { animation: hazeDriftA 34s var(--ease) infinite alternate; }
  #haze::after  { animation: hazeDriftB 42s var(--ease) infinite alternate; }
}
@keyframes hazeDriftA {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(7vw, 5vh, 0) scale(1.12); }
}
@keyframes hazeDriftB {
  from { transform: translate3d(0, 0, 0) scale(1.08); }
  to   { transform: translate3d(-6vw, -4vh, 0) scale(1); }
}

#glass-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  /* NOT display:none — that breaks SVG filter referencing */
}

/* ============================================================================
   GLASS SURFACES
   ========================================================================== */

/* Liquid glass: dock + palette. Fallback / lg-fallback path is the default. */
.glass-liquid {
  position: relative;
  background: var(--glass-tint);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--glass-stroke);
  box-shadow: var(--shadow-long), var(--lip);
  isolation: isolate;
}
/* the glass lip: a 1px refracted highlight along the top inner edge */
.glass-liquid::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding-top: 1px;
  background: linear-gradient(
    to bottom,
    oklch(0.97 0.02 275 / 0.20),
    oklch(0.97 0.02 275 / 0) 18%);
  -webkit-mask: linear-gradient(oklch(0 0 0)) content-box,
                linear-gradient(oklch(0 0 0));
          mask: linear-gradient(#000) content-box, linear-gradient(#000);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 0;
}
.glass-liquid > * { position: relative; z-index: 1; }

/* Chromium-enhanced refractive path injected by vendor/liquid-glass.js */
@supports (backdrop-filter: url(#liquid-glass)) {
  html.lg-supported .glass-liquid {
    backdrop-filter: url(#liquid-glass);
    -webkit-backdrop-filter: url(#liquid-glass);
  }
}

/* Plain glass: the detail card. Blur-only — never the url() filter. */
.glass-plain {
  background: var(--glass-tint);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--glass-stroke);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-long), var(--lip);
}

/* ============================================================================
   HUD — top, transparent, floats over the field
   ========================================================================== */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  background: transparent;
  pointer-events: none;   /* let the field receive drags between controls */
}
#hud > * { pointer-events: auto; }

.hud-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ink);
  text-transform: uppercase;
}
.hud-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: 8px;
  flex: 1;
  min-width: 0;
}

/* Ghost controls — minimal, glass-less, quiet */
#corpusSel {
  font: inherit;
  font-size: 12px;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 5px 12px;
  max-width: 240px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
#corpusSel:hover { color: var(--ink); border-color: var(--glass-stroke); background: var(--wash-faint); }
#corpusSel:focus-visible { outline: none; border-color: var(--accent); color: var(--ink); }
#corpusSel option { background: var(--field-1); color: var(--ink); }

.hud-stats {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: var(--ink-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#locateBtn {
  font: inherit;
  font-size: 12px;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 5px 10px 5px 14px;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
#locateBtn:hover { color: var(--ink); border-color: var(--glass-stroke); background: var(--wash-faint); }
#locateBtn:focus-visible { outline: none; border-color: var(--accent); }

/* Settings gear + legend key — same quiet ghost language, icon-only */
#settingsBtn,
#legendBtn {
  font: inherit;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
#settingsBtn:hover, #legendBtn:hover { color: var(--ink); border-color: var(--glass-stroke); background: var(--wash-faint); }
#settingsBtn:focus-visible, #legendBtn:focus-visible { outline: none; border-color: var(--accent); color: var(--ink); }
#settingsBtn[aria-expanded="true"], #legendBtn[aria-expanded="true"] { color: var(--ink); border-color: var(--glass-stroke); background: var(--wash-soft); }
#settingsBtn svg, #legendBtn svg { display: block; }

/* "Reading the field" legend — anchored under the HUD, right side.
   Glass surface; rows use the same leading glow-dot grammar as kind pills,
   never a side-stripe or a nested box. */
#legendPop {
  position: fixed;
  top: 56px;
  right: 22px;
  z-index: 19;
  width: 320px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 76px);
  overflow-y: auto;
  padding: 18px 20px 20px;
}
#legendPop[hidden] { display: none; }
.legendIntro {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-dim);
  margin: 0 0 16px;
}
.legendSection + .legendSection { margin-top: 18px; }
.legendHead {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  margin: 0 0 10px;
}
.legendRow {
  display: flex;
  align-items: baseline;
  gap: 11px;
  margin: 9px 0;
}
.legendDot {
  flex: none;
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 9px -1px var(--c);
}
.legendDot.isBand {
  width: 44px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg,
    hsl(200 72% 62%), hsl(255 72% 62%), hsl(330 72% 62%));
  box-shadow: none;
}
.legendDot.isSize {
  background: var(--ink-dim);
  box-shadow: 0 0 0 3px var(--wash-soft);
}
.legendName { color: var(--ink); font-size: 12.5px; font-weight: 500; line-height: 1.35; }
.legendGloss { color: var(--ink-mute); font-size: 11.5px; line-height: 1.45; margin-top: 2px; }
@media (prefers-reduced-motion: no-preference) {
  #legendPop:not([hidden]) {
    animation: legendIn var(--t-fast) var(--ease);
  }
  @keyframes legendIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
  }
}
@media (max-width: 720px) {
  #legendPop { top: 52px; right: 14px; left: 14px; width: auto; }
}
kbd { font-family: var(--font-mono); }
#locateBtn kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--ink-mute);
  background: oklch(0.30 0.02 275 / 0.45);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  line-height: 1;
}

/* ============================================================================
   DETAIL CARD — plain glass, top-left, overlaid
   ========================================================================== */

#detailCard {
  position: fixed;
  top: 64px;
  left: 20px;
  width: min(380px, calc(100vw - 40px));
  max-width: 380px;
  max-height: 70vh;
  overflow: auto;
  z-index: 6;
  padding: 26px 26px 30px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--t-med) var(--ease),
              transform var(--t-med) var(--ease);
}
#detailCard[hidden] {
  display: block;          /* keep it laid out for the transition... */
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  visibility: hidden;      /* ...but inert + unreachable */
}

#detailClose {
  position: sticky;
  top: 0;
  float: right;
  margin: -8px -8px 4px 12px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  color: var(--ink-mute);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  cursor: pointer;
  z-index: 2;
  transition: color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
#detailClose:hover { color: var(--ink); background: var(--wash-soft); }
#detailClose:focus-visible { outline: none; border-color: var(--accent); }

/* Back: mirror of the close affordance, anchored top-left. Shown only when
   the detail nav stack has depth (the user clicked through ≥2 entities). */
#detailBack {
  position: sticky;
  top: 0;
  float: left;
  margin: -8px 12px 4px -8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-mute);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  cursor: pointer;
  z-index: 2;
  transition: color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
#detailBack[hidden] { display: none; }
#detailBack:hover { color: var(--ink); background: var(--wash-soft); }
#detailBack:focus-visible { outline: none; border-color: var(--accent); }

/* ============================================================================
   DETAIL BODY — five distinct information objects, one shared grammar.
   Type is legible at a glance via a per-kind eyebrow signature (color +
   label), not a left stripe. Hierarchy via type scale + weight; section
   separation via space + hairline, never nested boxes.
   ========================================================================== */
.detail { color: var(--ink-dim); max-width: 68ch; }
.detail > *:first-child { margin-top: 0; }
.detail p { margin: 8px 0; line-height: 1.62; }
.detail .hint { color: var(--ink-mute); font-style: italic; font-size: 12.5px; }

/* ---- Eyebrow: the kind signature. Color keys to the view. ------------- */
.eyebrow {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 12px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}
.eyebrowKind {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  white-space: nowrap;
}
.eyebrowMeta {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.01em;
  margin-left: auto;
  text-align: right;
}
.dot { margin: 0 6px; opacity: 0.55; color: var(--ink-mute); }

/* Per-view accent on the eyebrow kind word — the restrained signature. */
.detail[data-view="thesis"]   .eyebrowKind { color: var(--kind-cluster_bridge); }
.detail[data-view="work"]     .eyebrowKind { color: var(--kind-definition_variant); }
.detail[data-view="cluster"]  .eyebrowKind { color: var(--kind-method_variant); }
.detail[data-view="edge"]     .eyebrowKind { color: var(--ink-dim); }
.detail[data-view="findings"] .eyebrowKind { color: var(--accent); }
.detail[data-view="section"]  .eyebrowKind { color: var(--accent); }

/* ---- Entity head — sized to what matters for the type ----------------- */
.detail .entityHead {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.34;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin: 0 0 8px;
}
.detail .workTitle { font-size: 21px; letter-spacing: -0.01em; }
.detail .edgeConcept { font-size: 20px; }

/* ---- Section label — quiet eyebrow, not a heading box ----------------- */
.sectionLabel {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  margin: 30px 0 12px;
}
.sectionLabel::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.sectionLabel .labelCount {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: oklch(0.30 0.02 275 / 0.42);
  flex: none;
}

/* ---- Tokens — quiet, not pill soup ------------------------------------ */
.token, .detail .pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: oklch(0.27 0.018 275 / 0.40);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: 11px;
}
.aliasRow, .termRow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 0;
}

/* ---- Quote / evidence — hanging hairline, not a tinted box ------------- */
.detail .quote {
  padding: 4px 0 4px 16px;
  margin: 12px 0;
  border-left: 1px solid var(--line);
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-dim);
  line-height: 1.6;
  font-size: 14px;
}
.detail .quote .pill { font-style: normal; margin-left: 6px; vertical-align: 1px; }
.detail .quote.citeOnly { font-style: normal; }
.detail .quote.citeOnly a { color: var(--accent); }
.thesisEvidence { margin-top: 16px; }
.sectionText {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 14px 0 0;
  padding: 0;
  color: var(--ink-dim);
  font: inherit;
  line-height: 1.62;
}

/* ---- kind-pill: leading glow dot, NO side-stripe ---------------------- */
.detail .kind-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 10.5px;
  padding: 2px 10px 2px 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  color: var(--ink);
  background: oklch(0.24 0.02 275 / 0.40);
  white-space: nowrap;
}
.detail .kind-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px -1px currentColor;
  flex: none;
}
.kind-pill.analog            { color: var(--kind-analog); }
.kind-pill.contrast          { color: var(--kind-contrast); }
.kind-pill.method_variant    { color: var(--kind-method_variant); }
.kind-pill.cluster_bridge    { color: var(--kind-cluster_bridge); }
.kind-pill.definition_variant{ color: var(--kind-definition_variant); }

/* ============================================================================
   THESIS VIEW — the idea is the hero
   ========================================================================== */
.thesisStatement {
  font-size: 17px;
  line-height: 1.5;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  margin: 2px 0 12px;
}
.thesisAttribution {
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.01em;
}
.thesisAttribution[data-kind] { cursor: pointer; transition: color var(--t-fast) var(--ease); }
.thesisAttribution[data-kind]:hover { color: var(--ink-dim); }
.thesisAttribution[data-kind]:hover .dot { color: var(--ink-dim); }

/* threads from this idea — pullable edges */
ul.threadEdges { list-style: none; margin: 0; padding: 0; }
li.threadEdge {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 8px 11px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-radius: 8px;
  transition: background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
li.threadEdge:last-child { border-bottom: none; }
li.threadEdge:hover { background: var(--wash-faint); transform: translateX(3px); }
.threadEdge .kind-pill { margin-top: 1px; flex: none; }
.threadEdgeBody { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.teName { color: var(--ink); font-size: 13px; font-weight: 500; line-height: 1.4; }
.teWork { color: var(--ink-mute); font-size: 11px; }

/* ============================================================================
   WORK VIEW — a source masthead + a navigable thesis index
   ========================================================================== */
.workMeta {
  font-size: 12.5px;
  color: var(--ink-dim);
  letter-spacing: 0.01em;
  margin: 0 0 4px;
}
.workArgument {
  font-size: 13.5px;
  line-height: 1.66;
  color: var(--ink-dim);
  margin: 12px 0 0;
}
.purchaseLinks {
  margin: 14px 0 4px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.purchaseLink {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  padding: 7px 12px;
  border-radius: var(--r-pill);
  background: var(--wash-warm);
  border: 1px solid oklch(0.83 0.11 85 / 0.28);
  color: var(--accent-warm);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.purchaseLink:hover {
  color: var(--ink);
  background: oklch(0.83 0.11 85 / 0.16);
  border-color: oklch(0.83 0.11 85 / 0.42);
  transform: translateY(-1px);
}
.purchaseLink:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--field-0), 0 0 0 4px var(--accent-warm);
}
.purchaseLabel {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.purchaseSource {
  color: var(--ink-mute);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.purchaseDisclosure {
  margin: 7px 0 0;
  color: var(--ink-mute);
  font-size: 10.5px;
  line-height: 1.45;
}
ol.thesisIndex { list-style: none; margin: 0; padding: 0; counter-reset: ix; }
li.indexRow {
  counter-increment: ix;
  position: relative;
  padding: 12px 8px 12px 34px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-radius: 8px;
  transition: background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
li.indexRow:last-child { border-bottom: none; }
li.indexRow::before {
  content: counter(ix, decimal-leading-zero);
  position: absolute;
  left: 4px;
  top: 13px;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
}
li.indexRow:hover { background: var(--wash-faint); transform: translateX(3px); }
li.indexRow:hover::before { color: var(--accent); }
.ixName { display: block; color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.4; }
.ixStatement { display: block; font-family: var(--font-serif); color: var(--ink-mute); font-size: 13px; line-height: 1.48; margin-top: 3px; }

/* ============================================================================
   CLUSTER VIEW — a constellation: who converges / strains / adjacent
   ========================================================================== */
.constellation { display: flex; flex-direction: column; gap: 4px; }
.constGroup { padding: 4px 0 8px; }
.constSource {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  text-align: left;
  font: inherit;
  background: none;
  border: none;
  padding: 6px 6px 6px 4px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  transition: background var(--t-fast) var(--ease);
}
.constSource:hover { background: var(--wash-faint); }
.constSource .srcName { font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.constSource .srcCount {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: oklch(0.30 0.02 275 / 0.42);
  flex: none;
}
ul.threadList { list-style: none; margin: 2px 0 0; padding: 0 0 0 4px; }
li.thread {
  padding: 6px 8px 6px 16px;
  position: relative;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-dim);
  border-radius: 7px;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
li.thread::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 13px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-mute);
  transition: background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
li.thread:hover {
  background: var(--wash-faint);
  color: var(--ink);
  transform: translateX(3px);
}
li.thread:hover::before { background: var(--accent); box-shadow: 0 0 8px -1px var(--accent); }

/* where it strains */
.strainList { display: flex; flex-direction: column; }

/* adjacent constellations — jump targets */
ul.adjacentList { list-style: none; margin: 0; padding: 0; }
li.adjacent {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 8px 10px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-radius: 8px;
  transition: background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
li.adjacent:last-child { border-bottom: none; }
li.adjacent:hover { background: var(--wash-faint); transform: translateX(3px); }
.adjLabel { color: var(--accent); font-size: 13px; font-weight: 500; line-height: 1.4; }
li.adjacent:hover .adjLabel { color: var(--ink); }
.adjSim {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  flex: none;
}

/* ============================================================================
   EDGE VIEW — the relationship IS the subject; A↔B endpoints
   ========================================================================== */
.edgeRationale {
  font-size: 13.5px;
  line-height: 1.64;
  color: var(--ink-dim);
  margin: 8px 0 0;
}
.edgeContext {
  display: inline-block;
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--ink-mute);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease);
}
.edgeContext .ctxLabel { color: var(--ink-dim); font-weight: 500; }
.edgeContext:hover { color: var(--ink-dim); }
.edgeContext:hover .ctxLabel { color: var(--accent); }

.endpoints { display: flex; flex-direction: column; }
.endpoint {
  position: relative;
  padding: 14px 8px 16px 4px;
  cursor: pointer;
  border-radius: 8px;
  transition: background var(--t-fast) var(--ease);
}
.endpoint:hover { background: var(--wash-faint); }
.endpoint--missing { cursor: default; }
.endpoint--missing:hover { background: none; }
.endSide {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
}
.endWork { color: var(--ink-mute); font-size: 11px; margin-top: 3px; }
.endName { font-family: var(--font-serif); color: var(--ink); font-weight: 600; font-size: 14.5px; margin: 4px 0 6px; line-height: 1.36; }
.endStatement { font-family: var(--font-serif); color: var(--ink-dim); font-size: 13.5px; line-height: 1.52; }
.endpoint .quote { margin: 10px 0 0; font-size: 12px; }

/* the pivot — a quiet kind-keyed connector between A and B */
.edgePivot {
  display: flex;
  align-items: center;
  gap: 0;
  height: 22px;
  margin: 2px 0;
  padding-left: 4px;
}
.edgePivot::before, .edgePivot::after {
  content: "";
  height: 1px;
  background: var(--line);
}
.edgePivot::before { width: 18px; }
.edgePivot::after { flex: 1; }
.pivotMark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink-mute);
  flex: none;
  margin: 0 8px;
}
.detail[data-view="edge"][data-edge-kind="analog"]             .pivotMark { background: var(--kind-analog); box-shadow: 0 0 10px -2px var(--kind-analog); }
.detail[data-view="edge"][data-edge-kind="contrast"]           .pivotMark { background: var(--kind-contrast); box-shadow: 0 0 10px -2px var(--kind-contrast); }
.detail[data-view="edge"][data-edge-kind="method_variant"]     .pivotMark { background: var(--kind-method_variant); box-shadow: 0 0 10px -2px var(--kind-method_variant); }
.detail[data-view="edge"][data-edge-kind="cluster_bridge"]     .pivotMark { background: var(--kind-cluster_bridge); box-shadow: 0 0 10px -2px var(--kind-cluster_bridge); }
.detail[data-view="edge"][data-edge-kind="definition_variant"] .pivotMark { background: var(--kind-definition_variant); box-shadow: 0 0 10px -2px var(--kind-definition_variant); }

/* ---- Strain row (edge-as-card inside cluster) ------------------------- */
.detail .edgeCard {
  padding: 13px 6px 15px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  border-radius: 8px;
  transition: background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.detail .edgeCard:hover { background: var(--wash-faint); transform: translateX(3px); }
.detail .edgeCard:last-child { border-bottom: none; }
.edgeCard .strainTop { display: flex; align-items: center; gap: 9px; }
.edgeCard .strainConcept { color: var(--ink-dim); font-size: 12px; font-weight: 500; }
.edgeCard .strainEnds {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.4;
}
.edgeCard .strainEnd { flex: 1; }
.edgeCard .strainWork { display: block; color: var(--ink-mute); font-size: 10.5px; margin-top: 2px; }
.edgeCard .strainVs { color: var(--ink-mute); flex: none; font-size: 12px; }
.edgeCard .rationale { color: var(--ink-dim); font-size: 11.5px; margin-top: 9px; line-height: 1.55; }

/* ============================================================================
   AGENT FINDINGS — a response, not an entity row
   ========================================================================== */
.detail[data-view="findings"] .findingsQuery {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink);
  margin: 2px 0 4px;
}
.detail[data-view="findings"] .findingsQuery::before {
  content: "“";
  color: var(--ink-mute);
}
.detail[data-view="findings"] .findingsQuery::after {
  content: "”";
  color: var(--ink-mute);
}

/* ============================================================================
   COMMAND PALETTE — scrim + liquid glass
   ========================================================================== */

#paletteScrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: start center;
  padding-top: 18vh;
  background: oklch(0.11 0.014 275 / 0.40);
  -webkit-backdrop-filter: blur(2px);
          backdrop-filter: blur(2px);
}
#paletteScrim[hidden] { display: none; }

#palette {
  width: min(620px, calc(100vw - 32px));
  max-height: 64vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-card);
  padding: 8px;
  overflow: hidden;
}

#paletteInput {
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 14px 16px 16px;
  outline: none;
}
#paletteInput::placeholder { color: var(--ink-mute); }
#paletteInput::-webkit-search-cancel-button { -webkit-appearance: none; }

#paletteScopes {
  display: flex;
  gap: 4px;
  padding: 12px 8px 10px;
}
#paletteScopes button {
  font: inherit;
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--ink-mute);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 4px 14px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
#paletteScopes button:hover { color: var(--ink-dim); background: var(--wash-faint); }
#paletteScopes button.is-active {
  color: var(--accent);
  background: var(--wash-soft);
  border-color: var(--glass-stroke);
}
#paletteScopes button:focus-visible { outline: none; border-color: var(--accent); }

#paletteResults {
  overflow-y: auto;
  padding: 6px 4px 8px;
  display: flex;
  flex-direction: column;
}
/* result rows: quiet, hairline-separated, hover wash + pad-shift, NO stripe */
#paletteResults > * {
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
  transition: background var(--t-fast) var(--ease),
              padding-left var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}
#paletteResults > *:last-child { border-bottom: none; }
#paletteResults > *:hover {
  background: var(--wash-soft);
  color: var(--ink);
  padding-left: 20px;
}
#paletteResults > *.is-active {
  background: var(--wash-soft);
  color: var(--ink);
  padding-left: 20px;
  box-shadow: var(--lip);
}

/* ============================================================================
   FIELD SETTINGS — modal, same liquid-glass language as the ⌘K palette
   ========================================================================== */

#settingsScrim {
  position: fixed;
  inset: 0;
  z-index: 22;
  display: grid;
  place-items: start center;
  padding: 12vh 16px 6vh;
  overflow-y: auto;
  background: oklch(0.11 0.014 275 / 0.40);
  -webkit-backdrop-filter: blur(2px);
          backdrop-filter: blur(2px);
}
#settingsScrim[hidden] { display: none; }

#settingsModal {
  width: min(560px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  border-radius: var(--r-card);
  overflow: hidden;
}

.set-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.set-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.set-head .card-close { position: static; }

.set-body {
  padding: 6px 20px 4px;
  max-height: 60vh;
  overflow-y: auto;
}

/* a settings group: an eyebrow label + a quiet stack of rows */
.set-group { padding: 16px 0; border-bottom: 1px solid var(--line); }
.set-group:last-child { border-bottom: none; }
.set-group > .set-glabel {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 12px;
}

/* a row: label on the left, control on the right, baseline-calm */
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 32px;
  padding: 5px 0;
}
.set-row > .set-label {
  font-size: 12.5px;
  color: var(--ink-dim);
  flex: 1;
  min-width: 0;
}
.set-row > .set-label .set-sub {
  display: block;
  font-size: 10.5px;
  color: var(--ink-mute);
  margin-top: 1px;
}
.set-ctl {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* range slider — thin, accent thumb, tabular value */
.set-ctl input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 150px;
  height: 3px;
  border-radius: var(--r-pill);
  background: oklch(0.55 0.03 275 / 0.30);
  cursor: pointer;
}
.set-ctl input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 7px -1px var(--accent);
  border: none;
}
.set-ctl input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
}
.set-ctl input[type="range"]:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }
.set-val {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
  min-width: 34px;
  text-align: right;
}

/* segmented control — quiet pill group, accent the selected */
.set-seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.set-seg button {
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  padding: 5px 11px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.set-seg button:last-child { border-right: none; }
.set-seg button:hover { color: var(--ink-dim); background: var(--wash-faint); }
.set-seg button.is-active { color: var(--accent); background: var(--wash-soft); }
.set-seg button:focus-visible { outline: none; color: var(--ink); background: var(--wash-soft); }

/* select — native control, void-tinted to match the segmented rows */
.set-select {
  font: inherit;
  font-size: 12px;
  color: var(--ink);
  background: var(--wash-faint);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 5px 26px 5px 11px;
  max-width: 220px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%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='%238b8fa3' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.set-select:hover { color: var(--ink); border-color: var(--ink-mute); }
.set-select:focus-visible { outline: none; border-color: var(--accent); }
.set-select option { background: var(--field-1); color: var(--ink); }

/* toggle — minimal switch */
.set-switch {
  position: relative;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: oklch(0.30 0.02 275 / 0.45);
  cursor: pointer;
  padding: 0;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.set-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--ink-dim);
  transition: transform var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.set-switch[aria-checked="true"] {
  background: var(--wash-soft);
  border-color: var(--glass-stroke);
}
.set-switch[aria-checked="true"]::after {
  transform: translateX(17px);
  background: var(--accent);
}
.set-switch:focus-visible { outline: none; border-color: var(--accent); }

/* compact 2D angle gizmo — drag to set pitch/yaw */
.set-gizmo {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 50%,
      oklch(0.30 0.05 275 / 0.30) 0%,
      oklch(0.16 0.02 275 / 0.30) 70%,
      transparent 100%);
  position: relative;
  cursor: grab;
  touch-action: none;
}
.set-gizmo:active { cursor: grabbing; }
.set-gizmo:focus-visible { outline: none; border-color: var(--accent); }
.set-gizmo .set-gizmo-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px -1px var(--accent);
  pointer-events: none;
}

.set-foot {
  display: flex;
  justify-content: flex-end;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
}
.set-reset {
  font: inherit;
  font-size: 12px;
  color: var(--ink-mute);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 6px 16px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.set-reset:hover { color: var(--ink); border-color: var(--glass-stroke); background: var(--wash-faint); }
.set-reset:focus-visible { outline: none; border-color: var(--accent); }

/* ============================================================================
   REPLAY CAPTION — pinned near the spotlit node
   ========================================================================== */

#caption {
  position: fixed;
  left: 50%;
  top: 70%;
  transform: translate(-50%, 0);
  z-index: 8;
  pointer-events: none;
  width: min(640px, 86vw);
  text-align: center;
  opacity: 1;
  transition: opacity var(--t-med) var(--ease),
              transform var(--t-med) var(--ease);
}
#caption[hidden] {
  display: block;
  opacity: 0;
  transform: translate(-50%, 8px);
}
.replay-caption .line {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  text-shadow: 0 1px 14px oklch(0.08 0.02 275 / 0.85);
}
.replay-caption .rationale {
  font-size: 12.5px;
  color: var(--ink-dim);
  margin-top: 6px;
  line-height: 1.5;
  text-shadow: 0 1px 10px oklch(0.08 0.02 275 / 0.8);
}
.replay-caption .meter {
  width: 132px;
  height: 3px;
  margin: 12px auto 0;
  border-radius: var(--r-pill);
  background: oklch(0.55 0.03 275 / 0.30);
  overflow: hidden;
}
.replay-caption .meter > i {
  display: block;
  height: 100%;
  width: 0;        /* JS sets inline width */
  border-radius: var(--r-pill);
  background: var(--accent);
  box-shadow: 0 0 8px -1px var(--accent);
  transition: width var(--t-med) var(--ease);
}

/* ============================================================================
   AGENT DOCK — bottom-center, liquid glass
   ========================================================================== */

#agentDock {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(680px, 92vw);
  z-index: 7;
  border-radius: var(--r-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* minimise affordance — hidden until the agent has been used (JS toggles
   [hidden]); collapses the dock to a small chevron pill so the graph is
   fully explorable. */
.dock-min {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 3;
  width: 26px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-mute);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.dock-min[hidden] { display: none; }
.dock-min:hover { color: var(--ink); background: var(--wash-faint); }
.dock-min:focus-visible {
  outline: none;
  color: var(--ink);
  box-shadow: 0 0 0 2px var(--field-0), 0 0 0 4px var(--accent);
}
.dock-min .chev {
  font-size: 13px;
  line-height: 1;
  display: inline-block;
  transition: transform var(--t-med) var(--ease);
}
#agentDock.is-min { width: auto; }
#agentDock.is-min .dock-stream {
  max-height: 0 !important;
  padding: 0 !important;
  border-bottom: 0 !important;
}
#agentDock.is-min .dock-form { display: none; }
#agentDock.is-min .dock-min { position: static; width: 40px; height: 30px; }
#agentDock.is-min .dock-min .chev { transform: rotate(180deg); }

/* dock stream: collapsed at rest, grows when #agentDock.is-open */
.dock-stream {
  max-height: 0;
  overflow: hidden;
  padding: 0 18px;
  transition: max-height var(--t-med) var(--ease),
              padding var(--t-med) var(--ease);
}
#agentDock.is-open .dock-stream {
  max-height: 46vh;
  overflow-y: auto;
  padding: 16px 18px 6px;
  border-bottom: 1px solid var(--line);
}

/* ---- dock form: single row at rest ------------------------------------ */
.dock-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 10px 16px;
}


#chatInput {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: transparent;   /* the dock IS the box */
  border: none;
  outline: none;
  resize: none;
  max-height: 120px;
  padding: 8px 4px;
  line-height: 1.45;
}
#chatInput::placeholder { color: var(--ink-mute); }

.dock-skip,
.dock-reset {
  font: inherit;
  font-size: 11px;
  color: var(--ink-mute);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 5px 10px;
  flex: none;
  align-self: center;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.dock-skip:hover,
.dock-reset:hover { color: var(--ink); background: var(--wash-faint); }
.dock-skip[hidden] { display: none; }
.dock-skip:focus-visible,
.dock-reset:focus-visible { outline: none; border-color: var(--accent); }

.dock-send {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 8px 18px;
  flex: none;
  align-self: center;
  cursor: pointer;
  transition: filter var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.dock-send:hover { filter: brightness(1.08); }
.dock-send:active { transform: scale(0.97); }
.dock-send:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--field-0), 0 0 0 4px var(--accent); }

.dock-form button:disabled,
.dock-send:disabled { opacity: 0.5; cursor: not-allowed; }
.dock-send:disabled:hover { filter: none; }

/* ---- conversation messages -------------------------------------------- */
.msg {
  margin: 8px 0;
  padding: 9px 13px;
  border-radius: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  font-size: 13px;
  max-width: 70ch;
}
.msg.user {
  background: var(--wash-soft);
  border: 1px solid var(--glass-stroke);
  color: var(--ink);
  margin-left: auto;
}
.msg.assistant {
  background: oklch(0.22 0.018 275 / 0.42);
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
/* Rendered-markdown answer: quiet, well-spaced, dock-scale typography. */
.msg.assistant > :first-child { margin-top: 0; }
.msg.assistant > :last-child { margin-bottom: 0; }
.msg.assistant p { margin: 0 0 0.6em; }
.msg.assistant strong { color: var(--ink); font-weight: 600; }
.msg.assistant em { color: var(--ink); font-style: italic; }
.msg.assistant a { color: var(--accent); text-decoration: underline;
  text-decoration-color: oklch(0.80 0.13 255 / 0.4); text-underline-offset: 2px; }
.msg.assistant a:hover { color: var(--ink); text-decoration-color: var(--accent); }
/* Inline citations: a quiet link with a leading kind-keyed glow dot. The
   dot carries the type signal so the text stays readable prose. */
.msg.assistant a.cite {
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid oklch(0.80 0.13 255 / 0.35);
  transition: border-color 140ms var(--ease), color 140ms var(--ease);
}
.msg.assistant a.cite::before {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-right: 0.34em;
  border-radius: 50%;
  vertical-align: 0.1em;
  background: var(--accent);
  box-shadow: 0 0 6px -1px var(--accent);
}
.msg.assistant a.cite-work::before {
  background: var(--kind-definition_variant);
  box-shadow: 0 0 6px -1px var(--kind-definition_variant);
}
.msg.assistant a.cite-thesis::before {
  background: var(--kind-cluster_bridge);
  box-shadow: 0 0 6px -1px var(--kind-cluster_bridge);
}
.msg.assistant a.cite em { font-style: italic; }
.msg.assistant a.cite:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.msg.assistant a.cite:focus-visible {
  outline: none;
  border-radius: 3px;
  box-shadow: 0 0 0 2px var(--field-0), 0 0 0 4px var(--accent);
}
.msg.assistant h4, .msg.assistant h5, .msg.assistant h6 {
  margin: 0.9em 0 0.35em; color: var(--ink);
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase;
}
.msg.assistant ul, .msg.assistant ol { margin: 0 0 0.6em; padding-left: 1.25em; }
.msg.assistant li { margin: 0.15em 0; }
.msg.assistant li::marker { color: var(--ink-mute); }
.msg.assistant code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.86em; padding: 0.08em 0.36em; border-radius: 4px;
  background: var(--wash-faint); color: var(--ink);
}
.msg.assistant pre {
  margin: 0 0 0.6em; padding: 9px 11px; border-radius: 8px;
  background: oklch(0.16 0.016 275 / 0.7); border: 1px solid var(--line);
  overflow-x: auto;
}
.msg.assistant pre code { padding: 0; background: none; font-size: 12px;
  color: var(--ink-dim); white-space: pre; }
/* blockquote: indent + muted + hairline-left (1px, not an accent stripe) */
.msg.assistant blockquote {
  margin: 0 0 0.6em; padding: 0.1em 0 0.1em 0.9em;
  border-left: 1px solid var(--line);
  color: var(--ink-mute); font-style: italic;
}
.msg.assistant .tableWrap {
  margin: 0 0 0.7em; overflow-x: auto;
  border: 1px solid var(--line); border-radius: 8px;
}
.msg.assistant table {
  border-collapse: collapse; width: 100%;
  font-size: 12.5px; line-height: 1.45;
}
.msg.assistant th, .msg.assistant td {
  padding: 0.4em 0.7em; text-align: left;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  vertical-align: top;
}
.msg.assistant th:last-child, .msg.assistant td:last-child { border-right: 0; }
.msg.assistant tbody tr:last-child td { border-bottom: 0; }
.msg.assistant thead th {
  background: var(--wash-soft, oklch(0.22 0.018 275 / 0.38));
  color: var(--ink); font-weight: 600;
  white-space: nowrap;
}
.msg.assistant tbody tr:hover td { background: var(--wash-soft, oklch(0.22 0.018 275 / 0.25)); }

.msg.tool {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--ink-mute);
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", monospace;
}
.msg.error {
  background: oklch(0.30 0.10 25 / 0.30);
  border: 1px solid oklch(0.66 0.20 25 / 0.45);
  color: oklch(0.86 0.10 25);
}
/* Live status line: ONE assistant bubble whose text is replaced per step
   ("Reading a thesis…"), with a soft sweeping sheen. The sheen is an overlay
   (not background-clip:text) so it respects the gradient-text ban. */
.msg.is-thinking {
  position: relative;
  overflow: hidden;
  color: var(--ink-dim);
  letter-spacing: 0.01em;
}
@media (prefers-reduced-motion: no-preference) {
  .msg.is-thinking::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg,
      transparent 35%, var(--wash-soft) 50%, transparent 65%);
    transform: translateX(-100%);
    animation: thinkShimmer 1.7s var(--ease) infinite;
    pointer-events: none;
  }
}
@keyframes thinkShimmer { to { transform: translateX(100%); } }

/* ============================================================================
   DEBUG: raw tool_trace dump (gear → Debug: tool calls)
   ========================================================================== */
details.debug-trace {
  margin: 4px 0 12px;
  border: 1px dashed var(--line);
  border-radius: var(--r-card);
  background: oklch(0.80 0.13 255 / 0.035);
}
details.debug-trace > summary {
  list-style: none;
  cursor: pointer;
  padding: 7px 12px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
details.debug-trace > summary::-webkit-details-marker { display: none; }
details.debug-trace > summary:hover { color: var(--accent); }
details.debug-trace[open] > summary { border-bottom: 1px dashed var(--line); }

.dbg-call { border-top: 1px solid var(--line); }
.dbg-call:first-of-type { border-top: none; }
.dbg-call > summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 12px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11.5px;
  color: var(--ink-dim);
}
.dbg-call > summary::-webkit-details-marker { display: none; }
.dbg-call > summary:hover { color: var(--ink); background: var(--wash-faint); }
.dbg-call.is-error > summary { color: oklch(0.70 0.17 25); }

.dbg-label {
  padding: 6px 12px 2px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.dbg-json {
  margin: 0 12px 10px;
  padding: 9px 11px;
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: oklch(0.18 0.02 275 / 0.55);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre;
  tab-size: 2;
}

/* ============================================================================
   CHAT CITATIONS  (details.citations)
   ========================================================================== */

details.citations { margin: -2px 0 12px; padding: 0; font-size: 11.5px; color: var(--ink-dim); }
details.citations summary {
  list-style: none;
  cursor: pointer;
  padding: 4px 12px;
  display: inline-block;
  color: var(--ink-mute);
  user-select: none;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
details.citations summary::-webkit-details-marker { display: none; }
details.citations summary:hover { color: var(--accent); background: var(--wash-faint); }
details.citations summary .chev {
  display: inline-block;
  margin-left: 4px;
  transition: transform var(--t-fast) var(--ease);
}
details.citations[open] summary .chev { transform: rotate(180deg); }

ul.citationList {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
li.citation {
  background: oklch(0.22 0.018 275 / 0.38);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  line-height: 1.45;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
li.citation:hover { background: var(--wash-soft); border-color: var(--glass-stroke); }
li.citation strong { color: var(--ink); font-weight: 600; margin-left: 7px; }
li.citation.is-disabled { cursor: not-allowed; opacity: 0.55; }
li.citation.is-disabled:hover { background: oklch(0.22 0.018 275 / 0.38); border-color: var(--line); }
.citationMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 7px 0 0;
}
.citationMetaLink {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: oklch(0.27 0.018 275 / 0.38);
  color: var(--ink-dim);
  cursor: pointer;
  font: inherit;
  font-size: 10.5px;
  line-height: 1.2;
  padding: 2px 8px;
}
.citationMetaLink:hover {
  color: var(--accent);
  background: var(--wash-faint);
  border-color: var(--glass-stroke);
}

/* citation quote: leading hairline + indent, NOT a side-stripe accent */
li.citation .quote {
  margin-top: 7px;
  padding: 6px 0 6px 12px;
  border-left: 1px solid var(--line);   /* neutral hairline rule, not accent */
  font-family: var(--font-serif);
  color: var(--ink-dim);
  font-style: italic;
  font-size: 12.5px;
  line-height: 1.52;
}
li.citation .quote.citeOnly { font-style: normal; }

/* kind-tag — quiet token chips, color via dot not fill */
.kind-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  padding: 1px 8px 1px 7px;
  border-radius: var(--r-pill);
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: oklch(0.26 0.02 275 / 0.45);
  border: 1px solid var(--line);
  vertical-align: baseline;
}
.kind-tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px -1px currentColor;
  flex: none;
}
.kind-tag.work    { color: var(--kind-definition_variant); }
.kind-tag.thesis  { color: var(--kind-cluster_bridge); }
.kind-tag.cluster { color: var(--kind-method_variant); }
.kind-tag.section { color: var(--ink-mute); }

/* ============================================================================
   TERRAIN MAP  (details.terrain)
   ========================================================================== */

details.terrain { margin: 6px 0 8px; padding: 0; font-size: 12px; }
details.terrain summary {
  list-style: none;
  cursor: pointer;
  padding: 4px 12px;
  display: inline-block;
  color: var(--ink-mute);
  user-select: none;
  border-radius: var(--r-pill);
  border: 1px dashed var(--line);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
details.terrain summary::-webkit-details-marker { display: none; }
details.terrain summary:hover { color: var(--accent); background: var(--wash-faint); }
details.terrain summary .chev {
  display: inline-block;
  margin-right: 4px;
  transition: transform var(--t-fast) var(--ease);
}
details.terrain[open] summary .chev { transform: rotate(90deg); }
details.terrain .terrain-counts { color: var(--ink-mute); font-size: 11px; }

/* terrain-section: quiet hairline block, not a boxed nested card */
.terrain-section {
  margin: 12px 0 4px;
  padding: 12px 0 14px;
  border-top: 1px solid var(--line);
}
.terrain-section:first-of-type { border-top: none; }
.terrain-heading {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-mute);
  margin-bottom: 8px;
}
.terrain-pill-row { display: flex; flex-wrap: wrap; gap: 6px; }

.facet-pill,
.action-pill {
  font: inherit;
  font-size: 11px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: oklch(0.26 0.02 275 / 0.45);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.facet-pill:hover,
.action-pill:hover { color: var(--ink); background: var(--wash-soft); border-color: var(--glass-stroke); }
.facet-pill:disabled { cursor: default; opacity: 0.6; }
.facet-pill:disabled:hover { color: var(--ink-dim); background: oklch(0.26 0.02 275 / 0.45); border-color: var(--line); }

/* action-pill is the lit affordance */
.action-pill {
  color: var(--on-accent);
  background: var(--accent);
  border-color: transparent;
}
.action-pill:hover { color: var(--on-accent); background: var(--accent); filter: brightness(1.08); }

/* work-row — leading dot on hover, no side-stripe */
.work-row {
  position: relative;
  padding: 7px 8px 7px 16px;
  margin: 3px 0;
  line-height: 1.45;
  border-radius: 8px;
  transition: background var(--t-fast) var(--ease);
}
.work-row::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 12px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-mute);
  transition: background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.work-row.is-clickable { cursor: pointer; }
.work-row.is-clickable:hover { background: var(--wash-faint); }
.work-row.is-clickable:hover::before { background: var(--accent); box-shadow: 0 0 8px -1px var(--accent); }
.work-row-author { color: var(--ink-mute); font-size: 11px; }
.work-row-title { color: var(--ink); font-weight: 600; }
.work-row-note { color: var(--ink-dim); font-size: 11px; margin-top: 3px; line-height: 1.5; }

.tension-row { padding: 4px 8px; font-size: 11.5px; line-height: 1.45; }
.tension-side { color: var(--ink); font-weight: 600; }
.tension-arrow { color: var(--kind-contrast); margin: 0 6px; }
.tension-concept { color: var(--ink-mute); }

/* ============================================================================
   TRAVERSAL TRAIL PANEL
   ========================================================================== */

.traversalTrailPanel {
  border-bottom: 1px solid var(--line);
  background: oklch(0.18 0.016 275 / 0.40);
  max-height: 220px;
  overflow-y: auto;
}
.traversalTrailPanel header {
  padding: 9px 14px 4px;
  font-size: 10px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.trailSteps {
  padding: 2px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* trailStep — leading glow dot timeline, NOT a left border-stripe */
.trailStep {
  position: relative;
  padding: 7px 10px 7px 18px;
  background: oklch(0.24 0.02 275 / 0.38);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.trailStep::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 12px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 7px -1px var(--accent);
}
.trailStep p { margin: 3px 0 0; color: var(--ink-dim); font-size: 11px; line-height: 1.45; }
.trailAction,
.trailConfidence {
  font-size: 10px;
  color: var(--ink-mute);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  margin-right: 6px;
}
.trailRejected { color: var(--ink-mute); font-size: 11px; opacity: 0.8; }
.trailRejected.trailStep::before { background: var(--ink-mute); box-shadow: none; }

.voiceBadge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--wash-warm);
  border: 1px solid oklch(0.83 0.11 85 / 0.32);
  color: var(--accent-warm);
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ============================================================================
   DOMAIN JOURNEY CHIPS
   ========================================================================== */

.domainJourneyChips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.domainJourneyChips button {
  font: inherit;
  font-size: 11px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-dim);
  background: oklch(0.26 0.02 275 / 0.45);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 4px 12px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.domainJourneyChips button:hover {
  color: var(--ink);
  background: var(--wash-soft);
  border-color: var(--glass-stroke);
}

/* ============================================================================
   BOOT NOTICE — the planetarium powering on
   ========================================================================== */

#bootNotice {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-shadow: 0 0 24px oklch(0.62 0.10 275 / 0.5);
  pointer-events: none;
}
#bootNotice[hidden] { display: none; }

/* ============================================================================
   LOADING VEIL — heavy-corpus swap overlay
   z-index 25 deliberately sits ABOVE palette (20), settings (22), and the
   HUD bar (5) so it can't be hidden behind a modal that lingered into a
   swap. Only bootNotice (30) outranks it — bootNotice owns the initial
   boot and the veil suppresses itself while it is visible. pointer-events:
   none so it never steals input; the 4 s freeze it covers is uninteractive
   anyway. Shown immediately for heavy corpora (preserves user feedback
   through the void load_graph block) and on a 250 ms grace timer otherwise.
   ========================================================================== */

#loadingVeil {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(
    ellipse at center,
    oklch(0.18 0.04 275 / 0.30) 0%,
    oklch(0.10 0.02 275 / 0.55) 65%,
    oklch(0.06 0.01 275 / 0.78) 100%
  );
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 280ms ease;
  pointer-events: none;
}
#loadingVeil.is-visible { opacity: 1; }
#loadingVeil[hidden] { display: none; }

.loading-veil-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 28px 40px;
  color: var(--ink-dim, oklch(0.78 0.04 275));
  text-align: center;
}

/* ── Horizontal progress bar. transform: scaleX lives on the compositor
   thread so it keeps advancing during the WASM freeze. The keyframes
   ramp 0 → 0.94 with a hand-tuned curve that decelerates near the end
   so the bar never lands at 100 % falsely. The JS-applied .lv-done
   class snaps the final 6 % home when load_graph actually returns. */
.loading-veil-progress {
  width: 260px;
  height: 3px;
  border-radius: 3px;
  background: oklch(0.25 0.04 280 / 0.55);
  overflow: hidden;
}
.lv-progress-fill {
  height: 100%;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(
    90deg,
    oklch(0.62 0.18 280 / 0.85) 0%,
    oklch(0.86 0.16 280) 60%,
    oklch(0.92 0.10 280) 100%
  );
  box-shadow: 0 0 12px oklch(0.78 0.18 280 / 0.55);
  will-change: transform;
}
@keyframes lv-progress-creep {
  0%   { transform: scaleX(0.00); }
  20%  { transform: scaleX(0.28); }
  45%  { transform: scaleX(0.55); }
  70%  { transform: scaleX(0.76); }
  88%  { transform: scaleX(0.88); }
  100% { transform: scaleX(0.94); }
}
#loadingVeil.lv-done .lv-progress-fill {
  animation: none;
  transform: scaleX(1);
  transition: transform 180ms ease-out;
}
.loading-veil-eyebrow {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: oklch(0.62 0.06 275);
  margin-top: 4px;
}
.loading-veil-corpus {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: oklch(0.92 0.05 275);
  text-shadow: 0 0 24px oklch(0.62 0.12 275 / 0.55);
  font-variant: small-caps;
  margin-top: -8px;        /* tighten under the eyebrow */
  min-height: 1em;
  text-align: center;
  word-break: break-word;
  max-width: 22ch;
}
.loading-veil-stats {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: oklch(0.65 0.05 275);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.lv-num {
  color: oklch(0.90 0.08 280);
  font-weight: 600;
  text-shadow: 0 0 12px oklch(0.62 0.16 280 / 0.40);
}
.lv-stat-sep {
  color: oklch(0.45 0.04 275);
  opacity: 0.6;
}
.loading-veil-phase {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.20em;
  color: oklch(0.78 0.08 280);
  min-height: 1em;
  margin-top: 8px;
  position: relative;
  font-style: italic;
  opacity: 0.85;
}
.loading-veil-phase::before {
  content: "·  ";
  color: oklch(0.50 0.06 280);
  font-style: normal;
}
.loading-veil-phase::after {
  content: "  ·";
  color: oklch(0.50 0.06 280);
  font-style: normal;
}

@media (prefers-reduced-motion: reduce) {
  .lv-progress-fill { animation: none !important; }
}

/* ============================================================================
   RESPONSIVE — laptop down to phone
   ========================================================================== */

@media (max-width: 720px) {
  #hud {
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 12px 16px;
  }
  .hud-controls { order: 3; flex-basis: 100%; margin-left: 0; }
  #locateBtn { margin-left: auto; }

  #detailCard {
    top: auto;
    left: 0;
    right: 0;
    bottom: auto;
    width: 100%;
    max-width: none;
    border-radius: 0 0 var(--r-card) var(--r-card);
    max-height: 62vh;
    padding: 64px 18px 24px;
  }

  #agentDock {
    left: 8px;
    right: 8px;
    transform: none;
    width: auto;
    bottom: 10px;
  }
  #agentDock.is-open .dock-stream { max-height: 52vh; }

  #palette { width: calc(100vw - 20px); max-height: 70vh; }
  #paletteScrim { padding-top: 10vh; }

  #settingsModal { width: calc(100vw - 20px); }
  #settingsScrim { padding-top: 8vh; }
  .set-ctl input[type="range"] { width: 110px; }

  .msg { max-width: 100%; }

  /* Touch targets ≥ 40px so the chrome is usable with a thumb. */
  #locateBtn, #settingsBtn, #detailClose, #dockMin,
  .dock-send, .dock-reset, .dock-skip,
  #paletteScopes button, .set-foot button {
    min-height: 40px;
  }
  #settingsBtn, #detailClose, #dockMin { min-width: 40px; }

  /* iOS zooms the page when focusing an input < 16px. Pin to 16px. */
  #chatInput, #paletteInput, #corpusSel { font-size: 16px; }

  /* Keep the dock clear of the iOS home indicator. */
  #agentDock { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }

  /* Modals scroll instead of overflowing a short screen. */
  #settingsModal { max-height: 86vh; display: flex; flex-direction: column; }
  .set-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #palette { display: flex; flex-direction: column; }
  #paletteResults { overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* The two big blurred haze blobs are GPU-costly on phones — lighten. */
  #haze::before, #haze::after { filter: blur(55px); }
}

/* Small phones: tighten chrome, drop nonessential hints. */
@media (max-width: 480px) {
  #hud { padding: 10px 12px; }
  .hud-brand { font-size: 14px; }
  #locateBtn kbd { display: none; }
  #detailCard { max-height: 70vh; padding: 58px 14px 20px; }
  #agentDock.is-open .dock-stream { max-height: 46vh; }
  #palette, #settingsModal { width: calc(100vw - 12px); }
  .dock-form { gap: 6px; padding: 8px 8px 8px 12px; }
}

/* ============================================================================
   MOTION — non-essential animation, reduced-motion guarded
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
  @keyframes voidBreath {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 1; }
  }
  #bootNotice:not([hidden]) {
    animation: voidBreath 2.6s var(--ease) infinite;
  }

  @keyframes captionRise {
    from { opacity: 0; transform: translate(-50%, 14px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
  }
  #caption:not([hidden]) {
    animation: captionRise var(--t-med) var(--ease);
  }

  @keyframes dockSettle {
    from { opacity: 0; transform: translateX(-50%) translateY(16px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
  }
  #agentDock { animation: dockSettle 520ms var(--ease) both; }

  @keyframes modalRise {
    from { opacity: 0; transform: translateY(12px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
  #settingsScrim:not([hidden]) #settingsModal {
    animation: modalRise var(--t-med) var(--ease);
  }
}

/* hard guard — last rule wins; kills all non-essential motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition-duration: 1ms !important;
  }
}

/* Mobile correction (must be LAST). dockSettle's keyframes bake in
   translateX(-50%) with fill-mode `both` for desktop centering; that filled
   transform overrides the mobile dock's `transform:none` and shoves the
   full-width dock half off-screen. Neutralise the centering animation on
   small screens. Equal specificity, latest source order, so it wins over
   the prefers-reduced-motion:no-preference dockSettle rule above. */
@media (max-width: 720px) {
  #agentDock { animation: none; transform: none; }
}

/* ============================================================================
   RESEARCH WORKBENCH — non-modal aside (right), pin/dossier/export.
   Composed only from existing tokens + the .glass-plain / quiet-ghost-button
   vocabulary. Stacking: z-index 7 sits above #detailCard (z6) so the two can
   coexist (detail left, workbench right). It is deliberately BELOW the
   transient overlays — #legendPop (z19), settings scrim (z20+), palette
   (z22) — which are dismissed first; this matches the non-modal Esc order.
   ========================================================================== */
#workbenchBtn {
  position: relative;
  font: inherit;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
#workbenchBtn:hover { color: var(--ink); border-color: var(--glass-stroke); background: var(--wash-faint); }
#workbenchBtn:focus-visible { outline: none; border-color: var(--accent); color: var(--ink); }
#workbenchBtn[aria-expanded="true"] { color: var(--ink); border-color: var(--glass-stroke); background: var(--wash-soft); }
#workbenchBtn svg { display: block; }
#workbenchCount {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: var(--r-pill);
}
#workbenchCount[hidden] { display: none; }

#workbenchPanel {
  position: fixed;
  top: 64px;
  right: 20px;
  width: min(400px, calc(100vw - 40px));
  max-width: 400px;
  max-height: 78vh;
  overflow: auto;
  z-index: 7;
  padding: 0 22px 22px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--t-med) var(--ease),
              transform var(--t-med) var(--ease);
}
#workbenchPanel[hidden] {
  display: block;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  visibility: hidden;
}
.wb-bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 10px;
  background: var(--glass-tint);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  z-index: 2;
}
.wb-bar-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.wb-head { margin: 6px 0 14px; }
.wb-title,
.wb-dnote,
.wb-note {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  margin-bottom: 8px;
  resize: vertical;
}
.wb-title { font-size: 15px; }
.wb-note { font-size: 12px; color: var(--ink-dim); min-height: 30px; }
.wb-title:focus,
.wb-dnote:focus,
.wb-note:focus { outline: none; border-color: var(--accent); }
.wb-title::placeholder,
.wb-dnote::placeholder,
.wb-note::placeholder { color: var(--ink-mute); }

.wb-empty {
  color: var(--ink-mute);
  font-size: 13px;
  line-height: 1.5;
  padding: 14px 0 18px;
}

.wb-list { list-style: none; margin: 0; padding: 0; }
.wb-item {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.wb-item:first-child { border-top: none; }
.wb-item-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.wb-kind {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.wb-item-title {
  flex: 1;
  font-size: 14px;
  color: var(--ink);
}
.wb-clabel {
  font-size: 10px;
  color: var(--ink-mute);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 1px 7px;
}
.wb-quote {
  margin: 6px 0;
  font-size: 12px;
  color: var(--ink-dim);
  font-style: italic;
  line-height: 1.45;
}
.wb-stale .wb-item-title { color: var(--ink-mute); }
.wb-stale-note {
  margin: 4px 0;
  font-size: 11px;
  color: var(--accent-warm);
}
.wb-item-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}
.wb-item-actions button,
.wb-actions button {
  font: inherit;
  font-size: 11px;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.wb-item-actions button:hover,
.wb-actions button:hover { color: var(--ink); border-color: var(--glass-stroke); background: var(--wash-faint); }
.wb-item-actions button:focus-visible,
.wb-actions button:focus-visible { outline: none; border-color: var(--accent); }
.wb-item-actions button:disabled { opacity: 0.35; cursor: default; }
.wb-move { min-width: 28px; }
.wb-remove { margin-left: auto; }

.wb-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.wb-actions .wb-copy { color: var(--ink); border-color: var(--glass-stroke); background: var(--wash-soft); }

/* Pin / copy-citation affordances injected at render time into the detail
   card + per-anchor evidence rows. Same quiet ghost language. */
.wb-detail-actions { margin-top: 18px; }
.anchor-actions {
  display: flex;
  gap: 6px;
  margin: 4px 0 12px;
}
.pin-btn,
.copy-cite-btn {
  font: inherit;
  font-size: 11px;
  color: var(--ink-mute);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 3px 9px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.pin-btn:hover,
.copy-cite-btn:hover { color: var(--ink); border-color: var(--glass-stroke); background: var(--wash-faint); }
.pin-btn:focus-visible,
.copy-cite-btn:focus-visible { outline: none; border-color: var(--accent); }
.pin-btn[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--accent);
  background: var(--wash-soft);
}

/* "Pin answer" affordance under each agent answer in the dock. */
.qa-pin-row { margin: 2px 0 6px; padding: 0; background: none; }
.pin-qa-btn {
  font: inherit;
  font-size: 11px;
  color: var(--ink-mute);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 3px 10px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.pin-qa-btn:hover { color: var(--ink); border-color: var(--glass-stroke); background: var(--wash-faint); }
.pin-qa-btn:focus-visible { outline: none; border-color: var(--accent); }
.pin-qa-btn:disabled { color: var(--ink); border-color: var(--accent); background: var(--wash-soft); cursor: default; }

.wb-toast {
  position: sticky;
  bottom: 0;
  margin-top: 12px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--ink);
  background: var(--wash-soft);
  border: 1px solid var(--glass-stroke);
  border-radius: 10px;
  text-align: center;
}
.wb-toast[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  #workbenchPanel { transition: none; }
}
@media (max-width: 720px) {
  #workbenchPanel { max-height: 70vh; right: 14px; padding: 0 14px 18px; }
}
