/* ==========================================================================
   Noctuary — AEM Owl skin
   Product: a night desk (leaf + plate + verso/recto). Not a dashboard.

   Tokens
   ------
   Color: indigo-ink + copper lamp. Copper is reserved for the one CTA.
   Dark: surfaces lift by luminance. Primaries desaturated ~15%.
   Type: Fraunces (display) + Figtree (UI). Perfect fourth 1.333 from 16.
   Space: 8pt only — 8 / 16 / 24 / 32 / 48 / 64. Leaf rules sit on 32.
   Motion: named durations + easings. Reduced-motion collapses to instant.
   Icons: 24 grid, 1.5 stroke, square caps. See /skins/owl/icons/
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Global tokens
   -------------------------------------------------------------------------- */
:root {
  /* Ink — cool indigo, not graphite */
  --ink-50: #f1f2f6;
  --ink-100: #e2e4ec;
  --ink-200: #c4c8d4;
  --ink-300: #9aa1b4;
  --ink-400: #737b91;
  --ink-500: #5a6278;
  --ink-600: #464d61;
  --ink-700: #353a4b;
  --ink-800: #242836;
  --ink-900: #171a24;
  --ink-950: #0b0d14;

  /* Copper — lamp. Used once as fill. */
  --cu-50: #fbf4ea;
  --cu-100: #f3e4cc;
  --cu-200: #e4c89a;
  --cu-300: #d4ab6e;
  --cu-400: #c4924a;
  --cu-500: #a87638;
  --cu-600: #8a5e2c;
  --cu-700: #6c4923;
  --cu-800: #4e341a;
  --cu-900: #352412;
  --cu-950: #1f150a;

  /* Info */
  --i-50: #e8eef6;
  --i-100: #cdd8ea;
  --i-200: #9bb2d4;
  --i-300: #6e8fb8;
  --i-400: #4a709c;
  --i-500: #38587c;
  --i-600: #2c4663;
  --i-700: #23364d;
  --i-800: #1a2738;
  --i-900: #121b28;

  /* Steady */
  --s-50: #e8f3ef;
  --s-100: #cde4db;
  --s-200: #9ac8b6;
  --s-300: #6aac93;
  --s-400: #458e74;
  --s-500: #34705b;
  --s-600: #285848;
  --s-700: #1f4438;
  --s-800: #163128;
  --s-900: #10231d;

  /* Caution */
  --w-50: #f7f0e4;
  --w-100: #ecdcc0;
  --w-200: #d8b87c;
  --w-300: #c49648;
  --w-400: #a87a30;
  --w-500: #866026;
  --w-600: #684b1e;
  --w-700: #503a18;
  --w-800: #382910;
  --w-900: #281c0c;

  /* Danger */
  --d-50: #f6eaea;
  --d-100: #e8cfd2;
  --d-200: #d09aa2;
  --d-300: #b46a74;
  --d-400: #964850;
  --d-500: #783840;
  --d-600: #5e2c32;
  --d-700: #482328;
  --d-800: #34191c;
  --d-900: #241214;

  /* Viz — colorblind-safer categorical (no red/green pair) */
  --viz-velocity: #7ba3c9;
  --viz-outreach: #c9a06a;
  --viz-worth: #9b8ec4;
  --viz-agency: #6ba89a;
  --viz-existential: #c4847a;
  --viz-neutral: #8a90a4;

  /* Type — perfect fourth */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-sans: "Figtree", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, "IBM Plex Mono", monospace;
  --fs-caption: 0.75rem;   /* 12 */
  --fs-sm: 0.875rem;       /* 14 */
  --fs-body: 1rem;         /* 16 */
  --fs-sub: 1.3125rem;     /* 21 */
  --fs-h3: 1.5rem;         /* 24 */
  --fs-h2: 2rem;           /* 32 */
  --fs-h1: 3rem;           /* 48 */
  --lh-tight: 1.2;
  --lh-body: 1.5;
  --lh-read: 1.75;
  --lh-rule: 32px;         /* leaf ruling — 8pt × 4 */
  --track-tight: -0.03em;
  --track-wide: 0.08em;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  /* 8pt spacing */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --space-6: 64px;

  /* Layout */
  --desk-max: 80rem;
  --gutter: 24px;
  --page-margin: 32px;

  /* Shape */
  --radius-sm: 2px;
  --radius-md: 4px;
  --focus-ring: 2px;
  --icon-size: 24px;
  --icon-stroke: 1.5px;

  /* Motion */
  --duration-instant: 50ms;
  --duration-fast: 100ms;
  --duration-normal: 200ms;
  --duration-moderate: 300ms;
  --duration-slow: 400ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0.2, 1);
  --ease-accelerate: cubic-bezier(0.3, 0, 1, 0.3);
  --z-nav: 80;
  --z-tooltip: 20;
  --z-scrim: 90;
  --z-drawer: 95;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-instant: 1ms;
    --duration-fast: 1ms;
    --duration-normal: 1ms;
    --duration-moderate: 1ms;
    --duration-slow: 1ms;
  }
}

/* --------------------------------------------------------------------------
   2. Semantic aliases — night (default)
   Surfaces elevate by getting lighter. Copper stays the only warm fill.
   Body text vs canvas ≥ 4.5:1.
   -------------------------------------------------------------------------- */
:root,
:root[data-theme="night"] {
  color-scheme: dark;

  --bg: var(--ink-950);
  --surface-1: var(--ink-900);
  --surface-2: var(--ink-800);
  --surface-3: var(--ink-700);

  --text: var(--ink-100);          /* #E2E4EC on #0B0D14 ≈ 14:1 */
  --text-secondary: #b8bdc8;       /* ≈ 8.4:1 */
  --text-tertiary: #969cad;        /* ≈ 5.8:1 captions */

  --border: rgba(226, 228, 236, 0.1);
  --border-strong: rgba(226, 228, 236, 0.18);
  --rule: rgba(226, 228, 236, 0.08);

  --action-bg: var(--cu-300);
  --action-fg: var(--cu-950);
  --action-hover: var(--cu-200);

  --focus: var(--cu-300);

  --info-bg: #141c28;
  --info-fg: #b7c8dc;
  --info-border: #2a3d54;
  --info-icon: var(--i-300);

  --ok-bg: #13241e;
  --ok-fg: #b3d4c6;
  --ok-border: #2a4e42;
  --ok-icon: var(--s-300);

  --warn-bg: #241c10;
  --warn-fg: #e2c48a;
  --warn-border: #5e4a20;
  --warn-icon: var(--w-300);

  --err-bg: #241416;
  --err-fg: #e0b4ba;
  --err-border: #5e3036;
  --err-icon: var(--d-300);

  --scrim: rgba(6, 7, 10, 0.64);
  --plate-well: #07080d;
  --leaf-well: #10131a;
  --shadow: none;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="night"]) {
    color-scheme: light;

    --bg: #eef0f4;
    --surface-1: #f7f8fa;
    --surface-2: #ffffff;
    --surface-3: var(--ink-100);

    --text: var(--ink-900);
    --text-secondary: var(--ink-600);
    --text-tertiary: #3d4454;

    --border: rgba(23, 26, 36, 0.1);
    --border-strong: rgba(23, 26, 36, 0.18);
    --rule: rgba(23, 26, 36, 0.08);

    --action-bg: var(--cu-700);
    --action-fg: var(--cu-50);
    --action-hover: var(--cu-600);

    --focus: var(--cu-600);

    --info-bg: var(--i-50);
    --info-fg: var(--i-800);
    --info-border: var(--i-200);
    --info-icon: var(--i-600);

    --ok-bg: var(--s-50);
    --ok-fg: var(--s-800);
    --ok-border: var(--s-200);
    --ok-icon: var(--s-600);

    --warn-bg: var(--w-50);
    --warn-fg: var(--w-800);
    --warn-border: var(--w-200);
    --warn-icon: var(--w-600);

    --err-bg: var(--d-50);
    --err-fg: var(--d-800);
    --err-border: var(--d-200);
    --err-icon: var(--d-600);

    --scrim: rgba(11, 13, 20, 0.4);
    --plate-well: var(--ink-100);
    --leaf-well: #ffffff;
    --shadow: 0 8px 24px rgba(11, 13, 20, 0.08);
  }
}

:root[data-theme="lamp"] {
  color-scheme: light;

  --bg: #eef0f4;
  --surface-1: #f7f8fa;
  --surface-2: #ffffff;
  --surface-3: var(--ink-100);

  --text: var(--ink-900);
  --text-secondary: var(--ink-600);
  --text-tertiary: #3d4454;

  --border: rgba(23, 26, 36, 0.1);
  --border-strong: rgba(23, 26, 36, 0.18);
  --rule: rgba(23, 26, 36, 0.08);

  --action-bg: var(--cu-700);
  --action-fg: var(--cu-50);
  --action-hover: var(--cu-600);

  --focus: var(--cu-600);

  --info-bg: var(--i-50);
  --info-fg: var(--i-800);
  --info-border: var(--i-200);
  --info-icon: var(--i-600);

  --ok-bg: var(--s-50);
  --ok-fg: var(--s-800);
  --ok-border: var(--s-200);
  --ok-icon: var(--s-600);

  --warn-bg: var(--w-50);
  --warn-fg: var(--w-800);
  --warn-border: var(--w-200);
  --warn-icon: var(--w-600);

  --err-bg: var(--d-50);
  --err-fg: var(--d-800);
  --err-border: var(--d-200);
  --err-icon: var(--d-600);

  --scrim: rgba(11, 13, 20, 0.4);
  --plate-well: var(--ink-100);
  --leaf-well: #ffffff;
  --shadow: 0 8px 24px rgba(11, 13, 20, 0.08);
}

/* --------------------------------------------------------------------------
   3. Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -48px;
  z-index: 100;
  padding: var(--space-1) var(--space-2);
  background: var(--action-bg);
  color: var(--action-fg);
  font-family: var(--font-sans);
  text-decoration: none;
}

.skip-link:focus { top: var(--space-2); }

body.skin-owl {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  min-height: 100vh;
  transition:
    background-color var(--duration-moderate) var(--ease-standard),
    color var(--duration-moderate) var(--ease-standard);
}

body.skin-owl :focus-visible {
  outline: var(--focus-ring) solid var(--focus);
  outline-offset: 2px;
}

.icon {
  width: var(--icon-size);
  height: var(--icon-size);
  display: block;
  flex-shrink: 0;
}

.icon-lg { width: 32px; height: 32px; }
.icon-xl { width: 48px; height: 48px; }

/* --------------------------------------------------------------------------
   4. Skin bar — ground
   -------------------------------------------------------------------------- */
.skin-owl .skin-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: var(--space-1) var(--page-margin);
  gap: var(--space-1);
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
}

.skin-owl .skin-bar a {
  color: var(--text-tertiary);
  padding: var(--space-1);
}

.skin-owl .skin-bar a:hover { color: var(--text); }

.skin-owl .skin-bar a[aria-current="page"] {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--cu-400);
}

.skin-owl .theme-toggle { margin-left: auto; }

/* --------------------------------------------------------------------------
   5. Desk — page frame
   -------------------------------------------------------------------------- */
.desk {
  max-width: var(--desk-max);
  margin-inline: auto;
  padding: var(--space-5) var(--page-margin) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

@media (max-width: 767px) {
  :root {
    --page-margin: 16px;
    --gutter: 16px;
    --fs-h1: 2rem;
    --fs-h2: 1.5rem;
  }
  .desk { padding-block: var(--space-3) var(--space-5); gap: var(--space-3); }
}

/* --------------------------------------------------------------------------
   6. Type
   -------------------------------------------------------------------------- */
.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0 0 var(--space-1);
}

h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  font-weight: 700;
  font-optical-sizing: auto;
  line-height: var(--lh-tight);
  letter-spacing: var(--track-tight);
  margin: 0;
}

h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: var(--track-tight);
  margin: 0;
}

h3 {
  font-family: var(--font-display);
  font-size: var(--fs-sub);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: var(--track-tight);
  margin: 0;
}

.lede {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-secondary);
  margin: var(--space-1) 0 0;
  max-width: 42em;
}

.meta, .hint, .plate-caption, .colophon {
  font-size: var(--fs-caption);
  color: var(--text-tertiary);
}

/* --------------------------------------------------------------------------
   7. Identity — one chunk (proximity)
   -------------------------------------------------------------------------- */
.identity {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  column-gap: var(--space-2);
  align-items: start;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.identity-mark {
  color: var(--cu-400);
  margin-top: 8px;
}

.identity-session {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-1);
}

@media (max-width: 767px) {
  .identity { grid-template-columns: 32px 1fr; }
  .identity-session {
    grid-column: 1 / -1;
    justify-content: flex-start;
    margin-top: var(--space-2);
  }
}

#statusBadge {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  color: var(--text-tertiary);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  background: var(--surface-1);
}

/* --------------------------------------------------------------------------
   8. Atelier — leaf | plate (common region, not stacked cards)
   -------------------------------------------------------------------------- */
.atelier {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--gutter);
  align-items: start;
}

@media (max-width: 1023px) {
  .atelier { grid-template-columns: 1fr; }
}

.leaf,
.plate,
.folio {
  background: var(--surface-1);
  border: 1px solid var(--border);
  padding: var(--space-3);
}

.leaf-head,
.plate-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.leaf-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.field-label { display: block; margin-bottom: var(--space-1); }

/* Ruled leaf — figure on a notebook ground */
.leaf-well {
  background-color: var(--leaf-well);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 31px,
    var(--rule) 31px,
    var(--rule) 32px
  );
  border: 1px solid var(--border-strong);
  padding: 0 var(--space-2);
}

#thoughtInput {
  display: block;
  width: 100%;
  min-height: 256px;
  resize: vertical;
  background: transparent;
  color: var(--text);
  border: 0;
  padding: var(--space-2) 0;
  font-family: var(--font-display);
  font-size: var(--fs-body);
  font-optical-sizing: auto;
  line-height: var(--lh-rule);
}

#thoughtInput::placeholder { color: var(--text-tertiary); }

.leaf-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* Von Restorff: the lamp is the only filled control */
.btn-lamp,
#btnProcess {
  appearance: none;
  border: 0;
  background: var(--action-bg);
  color: var(--action-fg);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.btn-lamp:hover,
#btnProcess:hover:not(:disabled) { background: var(--action-hover); }

.btn-lamp:disabled,
#btnProcess:disabled,
#btnProcess.is-busy {
  opacity: 0.72;
  cursor: wait;
}

/* All other actions stay quiet so the lamp can isolate */
.btn-quiet,
.filter-btn,
.drawer-head button,
.drawer-footer button,
.first-lines button {
  appearance: none;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 40px;
}

.btn-quiet:hover,
.filter-btn:hover,
.drawer-head button:hover,
.drawer-footer button:hover,
.first-lines button:hover {
  background: var(--surface-2);
}

/* Hick: first lines stay closed until asked */
.disclosure {
  margin-top: var(--space-3);
  border-top: 1px solid var(--border);
  padding-top: var(--space-2);
}

.disclosure summary {
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
  cursor: pointer;
  list-style: none;
}

.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::after { content: " +"; }
.disclosure[open] summary::after { content: " –"; }
.disclosure[open] summary { margin-bottom: var(--space-2); }

.first-lines {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: line;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.first-lines li { counter-increment: line; }

.first-lines button {
  width: 100%;
  text-align: left;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-style: italic;
  line-height: var(--lh-body);
  min-height: 0;
  padding: var(--space-1) var(--space-2);
}

.first-lines button::before {
  content: counter(line, decimal-leading-zero);
  font-family: var(--font-sans);
  font-style: normal;
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  color: var(--text-tertiary);
  margin-right: var(--space-2);
}

/* --------------------------------------------------------------------------
   9. Listening state — one lamp, not a generic bar
   -------------------------------------------------------------------------- */
.pipeline-progress,
#pipelineProgress {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--leaf-well);
  border: 1px solid var(--border);
}

.listen-lamp {
  height: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.listen-lamp span {
  display: block;
  height: 100%;
  width: 8%;
  background: var(--cu-400);
  animation: listen-advance 3.2s var(--ease-standard) forwards;
}

.listen-beats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.listen-beats li {
  font-size: var(--fs-caption);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding-top: var(--space-1);
  border-top: 2px solid var(--border-strong);
}

#pipelineStepText {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

@keyframes listen-advance {
  0%   { width: 8%; }
  32%  { width: 36%; }
  68%  { width: 68%; }
  100% { width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .listen-lamp span { animation: none; width: 68%; }
}

/* --------------------------------------------------------------------------
   10. Safety
   -------------------------------------------------------------------------- */
.safety-banner,
#safetyBanner { display: none; }

.safety-banner.caution,
#safetyBanner.caution {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid var(--warn-border);
}

.safe-badge {
  font-size: var(--fs-caption);
  color: var(--ok-fg);
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  padding: var(--space-1);
}

.safety-alert {
  font-size: var(--fs-caption);
  color: var(--warn-fg);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  padding: var(--space-1);
}

#safetyIndicator { font-size: var(--fs-caption); }

/* --------------------------------------------------------------------------
   11. Plate — designed viz, not a widget
   -------------------------------------------------------------------------- */
.plate-tools {
  display: flex;
  gap: var(--space-1);
}

.plate-legend,
#categoryFilters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

.filter-btn {
  border-color: transparent;
  padding-inline: var(--space-1);
}

.filter-btn > *,
.btn-quiet > *,
.btn-lamp > *,
#btnProcess > *,
.first-lines button::before {
  pointer-events: none;
}

.filter-btn .tick,
.filter-btn .icon { color: var(--viz-neutral); }

.filter-btn[data-family="velocity"] .icon { color: var(--viz-velocity); }
.filter-btn[data-family="outreach"] .icon { color: var(--viz-outreach); }
.filter-btn[data-family="worth"] .icon { color: var(--viz-worth); }
.filter-btn[data-family="agency"] .icon { color: var(--viz-agency); }
.filter-btn[data-family="existential"] .icon { color: var(--viz-existential); }

.filter-btn .tick {
  display: block;
  width: 8px;
  height: 8px;
  background: var(--viz-neutral);
}

.filter-btn.active {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.canvas-wrapper,
#canvasWrapper {
  position: relative;
  width: 100%;
  min-height: 420px;
  height: 46vh;
  overflow: hidden;
  background: var(--plate-well);
  border: 1px solid var(--border);
}

#graphCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.plate-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  text-align: center;
  color: var(--text-tertiary);
  pointer-events: none;
}

.plate-empty[hidden] { display: none; }

.plate-empty p {
  margin: 0;
  max-width: 36em;
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-sm);
  line-height: var(--lh-body);
}

.canvas-tooltip,
#canvasTooltip {
  display: none;
  position: absolute;
  z-index: var(--z-tooltip);
  max-width: 280px;
  pointer-events: none;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: var(--space-2);
  box-shadow: var(--shadow);
}

#tooltipTitle {
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

#tooltipMeta {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  color: var(--text-secondary);
}

#tooltipSnippet {
  margin-top: var(--space-1);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

.tooltip-mark {
  font-family: var(--font-display);
  margin-right: var(--space-1);
}

.graph-hud,
#graphHud {
  position: absolute;
  left: var(--space-2);
  bottom: var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--fs-caption);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  min-width: 48px;
}

.hud-stat b {
  font-weight: var(--fw-medium);
  font-size: var(--fs-sm);
  color: var(--text);
}

.hud-stat[data-series="fears"] b { color: var(--viz-velocity); }
.hud-stat[data-series="edges"] b { color: var(--viz-agency); }
.hud-stat[data-series="theme"] b { color: var(--viz-worth); }

.plate-caption {
  margin: var(--space-2) 0 0;
  max-width: 62em;
}

/* --------------------------------------------------------------------------
   12. Facing pages — peak / end
   -------------------------------------------------------------------------- */
.folios {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gutter);
}

@media (max-width: 767px) {
  .folios { grid-template-columns: 1fr; }
}

.folio-kicker {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.verso .eyebrow,
.verso .icon { color: var(--info-icon); }

.recto .eyebrow,
.recto .icon { color: var(--ok-icon); }

.card-body {
  margin: var(--space-2) 0;
  min-height: 128px;
  line-height: var(--lh-read);
  max-width: 40em;
  font-family: var(--font-display);
  font-optical-sizing: auto;
}

.placeholder-text { color: var(--text-tertiary); font-style: italic; }

.card-body:not(.placeholder-text) {
  color: var(--text);
  animation: arrive var(--duration-moderate) var(--ease-decelerate);
}

@keyframes arrive {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .card-body:not(.placeholder-text) { animation: none; }
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

#btnAudioSpeak.loading { opacity: 0.7; }
#btnAudioSpeak.playing { border-color: var(--cu-400); }

/* --------------------------------------------------------------------------
   13. Folio drawer — figure over receding ground
   -------------------------------------------------------------------------- */
.history-backdrop {
  background: var(--scrim);
}

.history-drawer {
  background: var(--surface-2);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform var(--duration-moderate) var(--ease-decelerate);
}

.history-drawer.open { transform: translateX(0); }

.drawer-head,
.drawer-footer {
  padding: var(--space-2) var(--space-3);
  border-color: var(--border);
}

.drawer-head { border-bottom: 1px solid var(--border); }
.drawer-footer { border-top: 1px solid var(--border); }

.drawer-head strong {
  font-family: var(--font-display);
  font-size: var(--fs-sub);
  font-weight: 600;
}

.drawer-footer button:last-child {
  color: var(--err-fg);
  border-color: var(--err-border);
  margin-left: auto;
}

.history-item {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.history-item:hover { background: var(--surface-3); }

.history-item-time {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  color: var(--text-tertiary);
}

.history-item-preview {
  margin-top: var(--space-1);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-family: var(--font-display);
}

.history-item-del { color: var(--text-tertiary); }

.history-empty {
  padding: var(--space-5) var(--space-3);
  color: var(--text-tertiary);
  font-family: var(--font-display);
  font-style: italic;
  text-align: center;
}

/* --------------------------------------------------------------------------
   14. Footer
   -------------------------------------------------------------------------- */
.colophon {
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
}
