/* ─── @odla-ai/ui css/tokens.css ─── */
/* ══════════════════════════════════════════════════════════════
   @odla-ai/ui — token defaults
   Every block is wrapped in :where() so it has ZERO specificity:
   a theme's plain `:root { … }` definitions always win, regardless
   of stylesheet load order. Without a theme, these neutral values
   (grayscale + restrained blue) render sanely on their own.
   Contract data lives in js/tokens.js; themes map their palettes
   onto the required tier in themes/<name>/ui.css.
   ══════════════════════════════════════════════════════════════ */

:where(:root) {
  /* ─── Required tier: neutral fallbacks (themes override all of these) ─── */
  --ui-bg: #f7f7f5;
  --ui-surface: #ffffff;
  --ui-surface-2: #efefec;
  --ui-text: #24272b;
  --ui-text-muted: #64686e;
  --ui-text-faint: #9b9fa6;
  --ui-border: #dfe0dc;
  --ui-border-strong: #b9bbb5;
  --ui-accent: #3b5e8c;
  --ui-accent-strong: #2e4a70;
  --ui-accent-soft: rgba(59, 94, 140, 0.1);
  --ui-on-accent: #ffffff;
  --ui-good: #4a7c59;
  --ui-good-soft: rgba(74, 124, 89, 0.12);
  --ui-warn: #a07d2e;
  --ui-warn-soft: rgba(160, 125, 46, 0.12);
  --ui-danger: #a8433a;
  --ui-danger-soft: rgba(168, 67, 58, 0.1);
  --ui-code-bg: #efefec;
  --ui-code-text: #33363b;
  --ui-hl-keyword: #7c3aed;
  --ui-hl-string: #15803d;
  --ui-hl-comment: #6b7280;
  --ui-hl-number: #b45309;
  --ui-hl-title: #1f2937;
  --ui-hl-attr: #0369a1;
  --ui-hl-type: #0f766e;
  --ui-hl-meta: #a16207;
  --ui-hl-addition: #15803d;
  --ui-hl-deletion: #b91c1c;
  --ui-shadow: 0 1px 2px rgba(36, 39, 43, 0.04), 0 8px 24px rgba(36, 39, 43, 0.06);
  --ui-font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ui-font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ui-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ui-font-display: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* ─── Defaulted tier: universal scales ─── */
  /* Reading preferences. --ui-font-size-root defaults to 100% — a percentage,
     not a pixel value, so a reader who has raised their browser's default font
     size keeps that raise; hard-coding 16px would silently cancel it. Themes
     with their own body measure override it (the blog themes use 17px).
     --ui-font-scale is the reader's text-size multiplier and stays 1 until
     css/a11y.css turns it. Smoothing defaults to `auto` (subpixel on macOS):
     `antialiased` thins every stroke, which is the usual reason body copy
     reads too light — opt into it deliberately, per surface. */
  --ui-font-size-root: 100%;
  --ui-font-scale: 1;
  --ui-font-smoothing: auto;
  --ui-weight-body: 400;
  --ui-weight-medium: 500;
  --ui-weight-strong: 600;
  --ui-weight-heading: 700;
  /* Accent family extensions (derived; themes with richer palettes override).
     accent-2 collapses onto the single accent unless a theme separates them. */
  --ui-accent-glow: color-mix(in srgb, var(--ui-accent) 16%, transparent);
  --ui-accent-2: var(--ui-accent);
  --ui-accent-2-soft: color-mix(in srgb, var(--ui-accent-2) 10%, transparent);
  --ui-highlight: var(--ui-accent-strong);
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 24px;
  --ui-space-6: 32px;
  --ui-space-7: 48px;
  --ui-space-8: 64px;
  --ui-space-9: 80px;
  --ui-space-10: 96px;
  --ui-space-11: 120px;
  --ui-radius-sm: 4px;
  --ui-radius-md: 7px;
  --ui-radius-lg: 10px;
  --ui-radius-pill: 999px;
  --ui-text-xs: 11px;
  --ui-text-sm: 12px;
  --ui-text-md: 13px;
  --ui-text-lg: 15px;
  /* Marketing body scale — app UI text stays on xs..lg. */
  --ui-text-xl: 17px;
  --ui-text-2xl: 19px;
  --ui-text-3xl: 20px;
  --ui-text-4xl: 22px;
  --ui-tracking-caps: 0.06em;
  --ui-tracking-tight: -0.03em;
  --ui-tracking-snug: -0.02em;
  --ui-tracking-wide: 0.02em;
  --ui-tracking-widest: 0.14em;
  --ui-tracking-ultra: 0.22em;
  --ui-leading-none: 1;
  --ui-leading-tight: 1.1;
  --ui-leading-snug: 1.3;
  --ui-leading-normal: 1.55;
  --ui-leading-relaxed: 1.7;
  --ui-leading-loose: 1.8;
  --ui-focus: 0 0 0 3px var(--ui-accent-soft);
  /* Elevated tier for hero-scale panels; derives from --ui-shadow so every
     theme gets a sane value, and themes may override for deeper lift. */
  --ui-shadow-strong: var(--ui-shadow);
  --ui-rail-width: 64px;
  --ui-sidebar-width: 240px;
  --ui-bottom-bar-height: 42px;
  --ui-dock-card-width: 320px;
  --ui-master-detail-columns: minmax(280px, 0.38fr) minmax(0, 0.62fr);
  --ui-master-detail-min-height: 480px;
  --ui-layer-chrome: 50;
  --ui-layer-dock: 80;
  --ui-layer-toast: 110;
  --ui-layer-overlay: 1000;

  /* ─── Chart roles (derived; themes may override for richer palettes) ─── */
  --ui-chart-1: var(--ui-accent);
  --ui-chart-2: var(--ui-good);
  --ui-chart-3: var(--ui-warn);
  --ui-chart-4: var(--ui-danger);
  --ui-chart-5: color-mix(in srgb, var(--ui-accent) 45%, var(--ui-text));
  --ui-chart-6: var(--ui-text-faint);
  --ui-chart-grid: color-mix(in srgb, var(--ui-text) 8%, transparent);
  --ui-chart-grid-zero: color-mix(in srgb, var(--ui-text) 22%, transparent);
  --ui-chart-axis: var(--ui-text-muted);
  --ui-chart-axis-faint: var(--ui-text-faint);
  --ui-chart-band: color-mix(in srgb, var(--ui-accent) 10%, transparent);
  --ui-chart-band-strong: color-mix(in srgb, var(--ui-accent) 22%, transparent);
  --ui-chart-pos: var(--ui-good);
  --ui-chart-neg: var(--ui-danger);
  /* Tooltips are themed popovers, not inverted/code surfaces. Keeping these
     on the semantic surface/text pair preserves contrast across every palette
     and lets the component border + shadow provide separation from the plot. */
  --ui-chart-tip-bg: var(--ui-surface);
  --ui-chart-tip-text: var(--ui-text);
  --ui-chart-dot-stroke: var(--ui-bg);
  /* Temporal/geo viz roles (maps, flow arcs, activity glow, heat ramp).
     Intensity is expressed with globalAlpha/blur at draw time, never by
     interpolating these colors — values may be unresolved color-mix(). */
  --ui-chart-geo-fill: color-mix(in srgb, var(--ui-text) 7%, transparent);
  --ui-chart-geo-line: var(--ui-border);
  --ui-chart-flow: var(--ui-accent);
  --ui-chart-glow: var(--ui-accent-strong);
  --ui-chart-heat-lo: var(--ui-good);
  --ui-chart-heat-mid: var(--ui-warn);
  --ui-chart-heat-hi: var(--ui-danger);

  /* ─── Chat roles (derived) ─── */
  --ui-chat-user-bg: var(--ui-accent-soft);
  --ui-chat-user-text: var(--ui-text);
  --ui-chat-assistant-bg: var(--ui-surface);
  --ui-chat-thinking-bg: var(--ui-surface-2);
  --ui-chat-thinking-text: var(--ui-text-muted);
  --ui-chat-tool-accent: var(--ui-accent);

  /* ─── Marketing roles: display type, section rhythm, decor hooks ───
     Decor defaults are inert (no grain, empty watermark) — a theme opts in
     with literals in its ui.css (see themes/salt). */
  --ui-display-h6: clamp(20px, 2.8vw, 28px);
  --ui-display-h5: clamp(22px, 3vw, 32px);
  --ui-display-h4: clamp(26px, 3.5vw, 36px);
  --ui-display-h3: clamp(28px, 4vw, 42px);
  --ui-display-h2: clamp(36px, 5.5vw, 56px);
  --ui-display-h1: clamp(48px, 7vw, 72px);
  --ui-display-xl: clamp(52px, 8vw, 108px);
  --ui-section-pad-y: var(--ui-space-10);
  --ui-section-pad-x: var(--ui-space-7);
  --ui-content-width: 1100px;
  --ui-content-narrow: 620px;
  --ui-grain: none;
  --ui-watermark-glyph: "";
  --ui-watermark-ink: color-mix(in srgb, var(--ui-text) 4%, transparent);
  --ui-nav-veil: color-mix(in srgb, var(--ui-bg) 92%, transparent);
}

/* ══════════════════════════════════════════════════════════════
   Scoped accent swap — [data-ui-accent="<name>"]
   Custom properties substitute var() at computed-value time ON THE
   DECLARING ELEMENT, so a scope that re-points --ui-accent must also
   re-declare every derived default that composes it — otherwise those
   composites keep the :root-computed values. Each declaration below is
   byte-identical to its :where(:root) twin (test-enforced) so the two
   can never drift. Themes ship the variant values themselves as plain
   [data-ui-accent="<name>"] blocks in ui.css (specificity 0,1,0 beats
   these zero-specificity re-derivations regardless of load order).
   ══════════════════════════════════════════════════════════════ */
:where([data-ui-accent]) {
  --ui-accent-glow: color-mix(in srgb, var(--ui-accent) 16%, transparent);
  --ui-accent-2: var(--ui-accent);
  --ui-accent-2-soft: color-mix(in srgb, var(--ui-accent-2) 10%, transparent);
  --ui-highlight: var(--ui-accent-strong);
  --ui-focus: 0 0 0 3px var(--ui-accent-soft);
  --ui-chart-1: var(--ui-accent);
  --ui-chart-5: color-mix(in srgb, var(--ui-accent) 45%, var(--ui-text));
  --ui-chart-band: color-mix(in srgb, var(--ui-accent) 10%, transparent);
  --ui-chart-band-strong: color-mix(in srgb, var(--ui-accent) 22%, transparent);
  --ui-chart-flow: var(--ui-accent);
  --ui-chart-glow: var(--ui-accent-strong);
  --ui-chat-user-bg: var(--ui-accent-soft);
  --ui-chat-tool-accent: var(--ui-accent);
}

/* ══════════════════════════════════════════════════════════════
   Inverted island — .ui-invert
   The subtree renders in the dark palette regardless of the global
   mode (inside global dark it is a no-op). Same substitution rule as
   above: the island must re-declare the dark values AND every
   var()-composing derived default so composites recompute against the
   island's palette on the island element. The neutral values mirror
   :where([data-theme="dark"]) byte-for-byte (test-enforced); themes
   layer their own palettes via the generated themes/<name>/invert.css.
   ══════════════════════════════════════════════════════════════ */
:where(.ui-invert) {
  color-scheme: dark;
  --ui-bg: #17181b;
  --ui-surface: #1f2125;
  --ui-surface-2: #26282d;
  --ui-text: #e6e6e3;
  --ui-text-muted: #a2a6ad;
  --ui-text-faint: #6f737a;
  --ui-border: #33363c;
  --ui-border-strong: #4a4e56;
  --ui-accent: #7ba1d4;
  --ui-accent-strong: #97b7e2;
  --ui-accent-soft: rgba(123, 161, 212, 0.14);
  --ui-on-accent: #14161a;
  --ui-good: #7fae8e;
  --ui-good-soft: rgba(127, 174, 142, 0.14);
  --ui-warn: #c5a75e;
  --ui-warn-soft: rgba(197, 167, 94, 0.14);
  --ui-danger: #cf7a72;
  --ui-danger-soft: rgba(207, 122, 114, 0.14);
  --ui-code-bg: #26282d;
  --ui-code-text: #d4d5d2;
  --ui-hl-keyword: #c4b5fd;
  --ui-hl-string: #86efac;
  --ui-hl-comment: #9199a5;
  --ui-hl-number: #fcd34d;
  --ui-hl-title: #e5e7eb;
  --ui-hl-attr: #7dd3fc;
  --ui-hl-type: #5eead4;
  --ui-hl-meta: #fbbf24;
  --ui-hl-addition: #86efac;
  --ui-hl-deletion: #fca5a5;
  --ui-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --ui-accent-glow: color-mix(in srgb, var(--ui-accent) 16%, transparent);
  --ui-accent-2: var(--ui-accent);
  --ui-accent-2-soft: color-mix(in srgb, var(--ui-accent-2) 10%, transparent);
  --ui-highlight: var(--ui-accent-strong);
  --ui-focus: 0 0 0 3px var(--ui-accent-soft);
  --ui-shadow-strong: var(--ui-shadow);
  --ui-chart-1: var(--ui-accent);
  --ui-chart-2: var(--ui-good);
  --ui-chart-3: var(--ui-warn);
  --ui-chart-4: var(--ui-danger);
  --ui-chart-5: color-mix(in srgb, var(--ui-accent) 45%, var(--ui-text));
  --ui-chart-6: var(--ui-text-faint);
  --ui-chart-grid: color-mix(in srgb, var(--ui-text) 8%, transparent);
  --ui-chart-grid-zero: color-mix(in srgb, var(--ui-text) 22%, transparent);
  --ui-chart-axis: var(--ui-text-muted);
  --ui-chart-axis-faint: var(--ui-text-faint);
  --ui-chart-band: color-mix(in srgb, var(--ui-accent) 10%, transparent);
  --ui-chart-band-strong: color-mix(in srgb, var(--ui-accent) 22%, transparent);
  --ui-chart-pos: var(--ui-good);
  --ui-chart-neg: var(--ui-danger);
  --ui-chart-tip-bg: var(--ui-surface);
  --ui-chart-tip-text: var(--ui-text);
  --ui-chart-dot-stroke: var(--ui-bg);
  --ui-chart-geo-fill: color-mix(in srgb, var(--ui-text) 7%, transparent);
  --ui-chart-geo-line: var(--ui-border);
  --ui-chart-flow: var(--ui-accent);
  --ui-chart-glow: var(--ui-accent-strong);
  --ui-chart-heat-lo: var(--ui-good);
  --ui-chart-heat-mid: var(--ui-warn);
  --ui-chart-heat-hi: var(--ui-danger);
  --ui-chat-user-bg: var(--ui-accent-soft);
  --ui-chat-user-text: var(--ui-text);
  --ui-chat-assistant-bg: var(--ui-surface);
  --ui-chat-thinking-bg: var(--ui-surface-2);
  --ui-chat-thinking-text: var(--ui-text-muted);
  --ui-chat-tool-accent: var(--ui-accent);
  --ui-section-pad-y: var(--ui-space-10);
  --ui-section-pad-x: var(--ui-space-7);
  --ui-watermark-ink: color-mix(in srgb, var(--ui-text) 4%, transparent);
  --ui-nav-veil: color-mix(in srgb, var(--ui-bg) 92%, transparent);
}

/* Neutral dark fallbacks — only the required tier changes; the derived
   tiers track it automatically via var()/color-mix(). Themes that define
   their own dark palettes override these the same zero-specificity way. */
:where([data-theme="dark"]) {
  --ui-bg: #17181b;
  --ui-surface: #1f2125;
  --ui-surface-2: #26282d;
  --ui-text: #e6e6e3;
  --ui-text-muted: #a2a6ad;
  --ui-text-faint: #6f737a;
  --ui-border: #33363c;
  --ui-border-strong: #4a4e56;
  --ui-accent: #7ba1d4;
  --ui-accent-strong: #97b7e2;
  --ui-accent-soft: rgba(123, 161, 212, 0.14);
  --ui-on-accent: #14161a;
  --ui-good: #7fae8e;
  --ui-good-soft: rgba(127, 174, 142, 0.14);
  --ui-warn: #c5a75e;
  --ui-warn-soft: rgba(197, 167, 94, 0.14);
  --ui-danger: #cf7a72;
  --ui-danger-soft: rgba(207, 122, 114, 0.14);
  --ui-code-bg: #26282d;
  --ui-code-text: #d4d5d2;
  --ui-hl-keyword: #c4b5fd;
  --ui-hl-string: #86efac;
  --ui-hl-comment: #9199a5;
  --ui-hl-number: #fcd34d;
  --ui-hl-title: #e5e7eb;
  --ui-hl-attr: #7dd3fc;
  --ui-hl-type: #5eead4;
  --ui-hl-meta: #fbbf24;
  --ui-hl-addition: #86efac;
  --ui-hl-deletion: #fca5a5;
  --ui-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme="light"])) {
    --ui-bg: #17181b;
    --ui-surface: #1f2125;
    --ui-surface-2: #26282d;
    --ui-text: #e6e6e3;
    --ui-text-muted: #a2a6ad;
    --ui-text-faint: #6f737a;
    --ui-border: #33363c;
    --ui-border-strong: #4a4e56;
    --ui-accent: #7ba1d4;
    --ui-accent-strong: #97b7e2;
    --ui-accent-soft: rgba(123, 161, 212, 0.14);
    --ui-on-accent: #14161a;
    --ui-good: #7fae8e;
    --ui-good-soft: rgba(127, 174, 142, 0.14);
    --ui-warn: #c5a75e;
    --ui-warn-soft: rgba(197, 167, 94, 0.14);
    --ui-danger: #cf7a72;
    --ui-danger-soft: rgba(207, 122, 114, 0.14);
    --ui-code-bg: #26282d;
    --ui-code-text: #d4d5d2;
    --ui-hl-keyword: #c4b5fd;
    --ui-hl-string: #86efac;
    --ui-hl-comment: #9199a5;
    --ui-hl-number: #fcd34d;
    --ui-hl-title: #e5e7eb;
    --ui-hl-attr: #7dd3fc;
    --ui-hl-type: #5eead4;
    --ui-hl-meta: #fbbf24;
    --ui-hl-addition: #86efac;
    --ui-hl-deletion: #fca5a5;
    --ui-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

/* ─── @odla-ai/ui css/a11y.css ─── */
/* ══════════════════════════════════════════════════════════════
   @odla-ai/ui — reading preferences
   Four axes a reader can set independently, each an attribute on
   <html>, each composing with the existing `data-theme` mode:

     data-ui-text    md | lg | xl        text size
     data-ui-weight  normal | medium | bold
     data-ui-motion  system | reduce | allow
     data-ui-palette default | mono | contrast   (css/palettes/*)

   Absent attribute == the default, so a page that never sets one
   renders exactly as it did before this sheet existed.

   js/prefs.js owns the model: it persists the choices and stamps
   the attributes before first paint. The axis names/values there
   and the selectors here are one contract — test-enforced.
   ══════════════════════════════════════════════════════════════ */

/* Base wiring, at ZERO specificity so any theme or app rule still wins a
   tie. A surface that sets its own `html { font-size }` opts out of the
   text-size axis entirely — the documented adoption step is to express that
   rule through these two custom properties instead. */
:where(html) {
  font-size: calc(var(--ui-font-size-root) * var(--ui-font-scale));
  font-weight: var(--ui-weight-body);
  -webkit-font-smoothing: var(--ui-font-smoothing);
}

/* ─── Text size ───────────────────────────────────────────────
   Two mechanisms, one axis, because odla surfaces size text two ways.
   Long-form content (the blog themes) is rem-based off the root font
   size, so --ui-font-scale carries it. App chrome reads the fixed
   --ui-text-* rungs, which no root-size change can reach — so each step
   also restates the ladder. Rungs are the base scale multiplied and
   rounded to whole pixels, never fractional: half-pixel type renders
   blurry at 1x. --ui-text-md is the body rung. */
html[data-ui-text="lg"] {
  --ui-font-scale: 1.125;
  --ui-text-xs: 12px;
  --ui-text-sm: 13px;
  --ui-text-md: 15px;
  --ui-text-lg: 17px;
  --ui-text-xl: 19px;
  --ui-text-2xl: 21px;
  --ui-text-3xl: 23px;
  --ui-text-4xl: 25px;
}

html[data-ui-text="xl"] {
  --ui-font-scale: 1.25;
  --ui-text-xs: 13px;
  --ui-text-sm: 15px;
  --ui-text-md: 16px;
  --ui-text-lg: 19px;
  --ui-text-xl: 21px;
  --ui-text-2xl: 24px;
  --ui-text-3xl: 25px;
  --ui-text-4xl: 28px;
}

/* ─── Text weight ─────────────────────────────────────────────
   The rungs stay ordered (body < medium <= strong <= heading) at every
   step so emphasis never inverts, and none exceeds 700: a step that asks
   for a weight the loaded font lacks gets a synthesized fake-bold, which
   looks worse than the weight it replaced. Themes that load a variable
   font, or static faces beyond 700, may extend these. */
html[data-ui-weight="medium"] {
  --ui-weight-body: 500;
  --ui-weight-medium: 600;
  --ui-weight-strong: 700;
  --ui-weight-heading: 700;
}

html[data-ui-weight="bold"] {
  --ui-weight-body: 600;
  --ui-weight-medium: 700;
  --ui-weight-strong: 700;
  --ui-weight-heading: 700;
}

/* ─── Motion ──────────────────────────────────────────────────
   The OS preference is honoured by default; "allow" is the reader's
   explicit opt-back-in, and "reduce" turns motion off on a machine that
   never asked the OS. Durations go to a hair above zero rather than
   zero so `transitionend`/`animationend` handlers still fire — a chain
   that waits on one would otherwise stall forever. */
@media (prefers-reduced-motion: reduce) {
  html:not([data-ui-motion="allow"]) *,
  html:not([data-ui-motion="allow"]) *::before,
  html:not([data-ui-motion="allow"]) *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

html[data-ui-motion="reduce"] *,
html[data-ui-motion="reduce"] *::before,
html[data-ui-motion="reduce"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* ─── Local colour scopes yield to an accessibility palette ───
   A reader who asked for monochrome or high contrast asked for the WHOLE
   page, and both of the ui's local-colour mechanisms would otherwise punch
   holes in it: `[data-ui-accent]` swaps the accent family inside a subtree,
   and `.ui-invert` renders a band in the dark palette regardless of mode.
   Both win by tree proximity, not specificity, so no amount of weight on the
   root reaches them — the scope element itself has to give the roles back.

   `inherit` on a custom property means "take the parent's computed value",
   which is precisely the palette in force one level up. Only the LITERAL
   declarations need cancelling: a derived role like --ui-surface-2, declared
   on the scope as a color-mix() of --ui-text, recomputes on its own once the
   ink it references is the inherited one. Keyed on any non-default palette so
   this sheet never has to know their names. */
html[data-ui-palette]:not([data-ui-palette="default"]) [data-ui-accent],
html[data-ui-palette]:not([data-ui-palette="default"]) .ui-invert {
  --ui-bg: inherit;
  --ui-surface: inherit;
  --ui-surface-2: inherit;
  --ui-text: inherit;
  --ui-text-muted: inherit;
  --ui-text-faint: inherit;
  --ui-border: inherit;
  --ui-border-strong: inherit;
  --ui-accent: inherit;
  --ui-accent-strong: inherit;
  --ui-accent-soft: inherit;
  --ui-accent-glow: inherit;
  --ui-accent-2: inherit;
  --ui-accent-2-soft: inherit;
  --ui-highlight: inherit;
  --ui-on-accent: inherit;
  --ui-good: inherit;
  --ui-good-soft: inherit;
  --ui-warn: inherit;
  --ui-warn-soft: inherit;
  --ui-danger: inherit;
  --ui-danger-soft: inherit;
  --ui-code-bg: inherit;
  --ui-code-text: inherit;
  --ui-shadow: inherit;
  --ui-hl-keyword: inherit;
  --ui-hl-string: inherit;
  --ui-hl-comment: inherit;
  --ui-hl-number: inherit;
  --ui-hl-title: inherit;
  --ui-hl-attr: inherit;
  --ui-hl-type: inherit;
  --ui-hl-meta: inherit;
  --ui-hl-addition: inherit;
  --ui-hl-deletion: inherit;
}

html[data-ui-palette]:not([data-ui-palette="default"]) .ui-invert {
  color-scheme: inherit;
}

/* ─── @odla-ai/ui css/palettes/mono.css ─── */
/* ══════════════════════════════════════════════════════════════
   @odla-ai/ui — monochrome palette   html[data-ui-palette="mono"]
   Every colour role collapses onto one neutral ink over one neutral
   ground. Layers over ANY theme rather than replacing it: only the
   colour roles move, so type, spacing, radii and layout stay the
   theme's own.

   Specificity is the whole trick. `html[data-ui-palette="mono"]` is
   (0,1,1), which outranks a theme's `:root` and its generated
   `[data-ui-theme="…"]` scope (both 0,1,0) no matter which stylesheet
   loads last. The dark twins carry one more attribute (0,2,1) so they
   also outrank a theme's `[data-ui-theme][data-theme="dark"]` (0,2,0).

   The dark blocks restate only the ink and the ground. Custom
   properties substitute var() on the DECLARING element, and every
   block here declares on <html>, so the derived roles below recompute
   against whichever ink won the cascade — no second copy needed.
   ══════════════════════════════════════════════════════════════ */

html[data-ui-palette="mono"] {
  color-scheme: light;
  --ui-bg: #ffffff;
  --ui-text: #111111;

  /* Surfaces separate by hairline, not by fill — with hue gone, a tinted
     panel and its page read as the same value anyway. */
  --ui-surface: var(--ui-bg);
  --ui-surface-2: color-mix(in srgb, var(--ui-text) 7%, var(--ui-bg));
  --ui-text-muted: color-mix(in srgb, var(--ui-text) 68%, var(--ui-bg));
  --ui-text-faint: color-mix(in srgb, var(--ui-text) 45%, var(--ui-bg));
  --ui-border: color-mix(in srgb, var(--ui-text) 22%, var(--ui-bg));
  --ui-border-strong: color-mix(in srgb, var(--ui-text) 45%, var(--ui-bg));

  --ui-accent: var(--ui-text);
  --ui-accent-strong: var(--ui-text);
  --ui-accent-soft: color-mix(in srgb, var(--ui-text) 10%, transparent);
  --ui-on-accent: var(--ui-bg);

  /* Status keeps a value ladder — danger is full ink, warn the lightest —
     so the three stay tellable apart. It is a ladder, not a language:
     monochrome is exactly the case that proves colour alone was never
     enough, so status must also carry an icon, a label, or a shape. */
  --ui-danger: var(--ui-text);
  --ui-danger-soft: color-mix(in srgb, var(--ui-text) 12%, transparent);
  --ui-good: color-mix(in srgb, var(--ui-text) 78%, var(--ui-bg));
  --ui-good-soft: color-mix(in srgb, var(--ui-text) 9%, transparent);
  --ui-warn: color-mix(in srgb, var(--ui-text) 58%, var(--ui-bg));
  --ui-warn-soft: color-mix(in srgb, var(--ui-text) 7%, transparent);

  --ui-code-bg: color-mix(in srgb, var(--ui-text) 6%, var(--ui-bg));
  --ui-code-text: var(--ui-text);
  --ui-shadow: 0 1px 2px color-mix(in srgb, var(--ui-text) 10%, transparent);

  /* Syntax highlighting: token classes that survive as weight/value
     differences instead of hues. Comments recede, titles hold full ink. */
  --ui-hl-keyword: var(--ui-text);
  --ui-hl-title: var(--ui-text);
  --ui-hl-string: color-mix(in srgb, var(--ui-text) 78%, var(--ui-code-bg));
  --ui-hl-number: color-mix(in srgb, var(--ui-text) 78%, var(--ui-code-bg));
  --ui-hl-type: color-mix(in srgb, var(--ui-text) 66%, var(--ui-code-bg));
  --ui-hl-attr: color-mix(in srgb, var(--ui-text) 66%, var(--ui-code-bg));
  --ui-hl-meta: color-mix(in srgb, var(--ui-text) 55%, var(--ui-code-bg));
  --ui-hl-comment: color-mix(in srgb, var(--ui-text) 48%, var(--ui-code-bg));
  --ui-hl-addition: color-mix(in srgb, var(--ui-text) 82%, var(--ui-code-bg));
  --ui-hl-deletion: color-mix(in srgb, var(--ui-text) 62%, var(--ui-code-bg));

  /* Series default to accent/good/warn/danger, which have just collapsed
     onto one ink — a mono chart needs its own ramp or every line is the
     same line. Six evenly-spaced steps; pair with dash/marker variation. */
  --ui-chart-1: color-mix(in srgb, var(--ui-text) 100%, var(--ui-bg));
  --ui-chart-2: color-mix(in srgb, var(--ui-text) 84%, var(--ui-bg));
  --ui-chart-3: color-mix(in srgb, var(--ui-text) 68%, var(--ui-bg));
  --ui-chart-4: color-mix(in srgb, var(--ui-text) 54%, var(--ui-bg));
  --ui-chart-5: color-mix(in srgb, var(--ui-text) 41%, var(--ui-bg));
  --ui-chart-6: color-mix(in srgb, var(--ui-text) 29%, var(--ui-bg));
  --ui-chart-pos: var(--ui-text);
  --ui-chart-neg: color-mix(in srgb, var(--ui-text) 55%, var(--ui-bg));
  --ui-chart-heat-lo: color-mix(in srgb, var(--ui-text) 30%, var(--ui-bg));
  --ui-chart-heat-mid: color-mix(in srgb, var(--ui-text) 62%, var(--ui-bg));
  --ui-chart-heat-hi: var(--ui-text);
}

html[data-ui-palette="mono"][data-theme="dark"] {
  color-scheme: dark;
  --ui-bg: #0b0b0b;
  --ui-text: #f0f0f0;
}

@media (prefers-color-scheme: dark) {
  html[data-ui-palette="mono"]:not([data-theme="light"]) {
    color-scheme: dark;
    --ui-bg: #0b0b0b;
    --ui-text: #f0f0f0;
  }
}

/* ─── @odla-ai/ui css/palettes/contrast.css ─── */
/* ══════════════════════════════════════════════════════════════
   @odla-ai/ui — high contrast   html[data-ui-palette="contrast"]
   SHARPENS the theme; it does not replace it. Every declaration here
   is a var() reference to a role the theme already owns, so the page
   keeps its own colours — a reader who chose high contrast on the
   green theme still gets the green theme.

   Three habits of a normal palette are inverted on purpose:
     · surfaces stop tinting and separate by border instead, because a
       wash light enough to sit under body text carries no contrast of
       its own to begin with;
     · muted text stops being muted — dimming is the exact thing a
       reader asking for contrast is asking us to stop doing;
     · shadows go away. Depth drawn in blurred alpha is invisible at
       this end of the scale and only softens the edges that aren't.

   What this sheet CANNOT do is move a hue. `--ui-accent: <something
   derived from --ui-accent>` on the same element is a self-reference,
   which CSS resolves as a cycle, so a theme whose accent sits at
   4:1 has to deepen it itself: each theme ships its own
   `html[data-ui-palette="contrast"]` block in ui.css, the same way it
   ships a dark block, with the hue held and only the lightness moved.
   test/palette-contrast.test.js measures every theme and fails the
   build if a role lands under 7:1 — the AAA claim is enforced per
   theme, not asserted here.

   No dark twin: every value is a reference, so the whole sheet tracks
   whatever mode the theme is in.
   ══════════════════════════════════════════════════════════════ */

html[data-ui-palette="contrast"] {
  --ui-text-muted: var(--ui-text);
  --ui-text-faint: var(--ui-text);

  --ui-surface: var(--ui-bg);
  --ui-surface-2: var(--ui-bg);
  --ui-border: var(--ui-text);
  --ui-border-strong: var(--ui-text);
  --ui-code-bg: var(--ui-bg);
  --ui-code-text: var(--ui-text);

  --ui-shadow: none;
  --ui-shadow-strong: none;

  /* Tone washes mark a region; they never carry the contrast. Mixed toward
     the page rather than toward transparent so full-ink text still clears
     7:1 on top of one whatever sits behind it. */
  --ui-accent-soft: color-mix(in srgb, var(--ui-accent) 14%, var(--ui-bg));
  --ui-accent-2-soft: color-mix(in srgb, var(--ui-accent-2) 14%, var(--ui-bg));
  --ui-good-soft: color-mix(in srgb, var(--ui-good) 14%, var(--ui-bg));
  --ui-warn-soft: color-mix(in srgb, var(--ui-warn) 14%, var(--ui-bg));
  --ui-danger-soft: color-mix(in srgb, var(--ui-danger) 14%, var(--ui-bg));

  /* A focus ring that cannot be lost against either ground: an inner band in
     the page colour, an outer band in full ink. */
  --ui-focus: 0 0 0 3px var(--ui-bg), 0 0 0 6px var(--ui-text);

  /* Grid and axes come up off the usual whisper-alpha so the frame of a
     chart is legible too, not just the series drawn on it. */
  --ui-chart-grid: color-mix(in srgb, var(--ui-text) 35%, var(--ui-bg));
  --ui-chart-grid-zero: var(--ui-text);
  --ui-chart-axis: var(--ui-text);
  --ui-chart-axis-faint: var(--ui-text);
  --ui-chart-tip-bg: var(--ui-bg);
  --ui-chart-tip-text: var(--ui-text);
}

/* ─── @odla-ai/ui css/components/prefs.css ─── */
/* @odla-ai/ui — reading-preferences popover
   Built from the design system's own parts rather than a private look: the
   panel is the `.card` contract (surface, hairline, radius-lg, shadow), each
   axis is a `.segmented` pill track, and the axis captions are the same
   uppercase micro-label `.card h4` uses. Nothing here invents a control — a
   new look belongs in a theme, not in this sheet.

   The disclosure is a native <details>. That matters more here than anywhere
   else in the system: this is what a reader reaches for when the defaults are
   failing them, and it is the last thing that should wait on a script.
   js/prefs.js only adds persistence.

   Sizing is in px and --ui-space-*, deliberately NOT rem: this is chrome, and
   chrome must not grow when the reader turns the text-size axis up. */

.ui-prefs {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.ui-prefs-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  background: transparent;
  color: var(--ui-text-muted);
  cursor: pointer;
  /* Kill the disclosure triangle in every engine: `display` for WebKit's
     pseudo-element, `list-style` for the modern marker. */
  list-style: none;
}
.ui-prefs-trigger::-webkit-details-marker {
  display: none;
}
.ui-prefs-trigger:hover {
  color: var(--ui-text);
  border-color: var(--ui-border-strong);
}
.ui-prefs-trigger:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus);
}
.ui-prefs[open] > .ui-prefs-trigger {
  color: var(--ui-text);
  border-color: var(--ui-border-strong);
}

/* Sliders glyph in currentColor: tracks the trigger's state, costs no request. */
.ui-prefs-icon {
  width: 15px;
  height: 15px;
  background-image:
    linear-gradient(currentColor, currentColor),
    linear-gradient(currentColor, currentColor),
    radial-gradient(circle 2.5px at center, currentColor 98%, transparent 100%),
    radial-gradient(circle 2.5px at center, currentColor 98%, transparent 100%);
  background-size: 13px 1.5px, 13px 1.5px, 5px 5px, 5px 5px;
  background-position: 1px 4.25px, 1px 9.75px, 2.5px 2px, 7.5px 7.5px;
  background-repeat: no-repeat;
}

.ui-prefs-panel {
  position: absolute;
  top: calc(100% + var(--ui-space-2));
  right: 0;
  z-index: var(--ui-layer-overlay);
  /* Sized by its widest pill track, floored so short axes do not look ragged
     and capped so it never scrolls the page sideways from the right edge. */
  width: max-content;
  min-width: 240px;
  max-width: min(340px, calc(100vw - var(--ui-space-5)));
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
  padding: var(--ui-space-4);
  text-align: left;
  font-family: var(--ui-font-sans);
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-strong);
  /* The trigger lives in a top bar, and bars are routinely set in tracked
     uppercase — which the panel would inherit, turning "High contrast" into a
     label half again as wide and pushing every row into wrapping. A popover
     speaks in its own voice. */
  text-transform: none;
  letter-spacing: normal;
  font-weight: var(--ui-weight-body);
  font-style: normal;
}

.ui-prefs-group {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

/* The `.card h4` micro-label: uppercase, tracked, muted. */
.ui-prefs-legend {
  padding: 0 0 var(--ui-space-2);
  font-size: var(--ui-text-xs);
  font-weight: var(--ui-weight-strong);
  text-transform: uppercase;
  letter-spacing: var(--ui-tracking-caps);
  color: var(--ui-text-muted);
}

/* The `.segmented-track` contract, re-declared for labels rather than the
   buttons Segmented uses — the radios are the accessible control here, so the
   selected state hangs off `input:checked + span` instead of aria-checked.
   Values stay in step with css/components/segmented.css (test-enforced). */
.ui-prefs-options {
  /* flex, not Segmented's inline-flex: there the track sits inline beside a
     caption, here each axis owns its row and a content-width track leaves the
     panel looking ragged. */
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  max-width: 100%;
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-pill);
}

/* grow 1 / shrink 0 / basis auto. The shrink is load-bearing: left
   shrinkable, an over-long row does not wrap — the options squeeze below
   their own labels and the text spills across the neighbouring pill.
   Refusing to shrink pushes the option that does not fit onto a second line,
   where it then grows to fill it. */
.ui-prefs-option {
  flex: 1 0 auto;
  max-width: 100%;
  display: flex;
  cursor: pointer;
}

/* The radio stays in the accessibility tree — clipped, never `display: none`,
   which would drop it from tab order and from the group semantics. All of the
   selected/focused styling therefore hangs off the adjacent <span>, via plain
   sibling combinators rather than :has(), so the control is never one
   unsupported selector away from having no visible selection at all. */
.ui-prefs-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.ui-prefs-option span {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  font-size: var(--ui-text-sm);
  line-height: var(--ui-leading-snug);
  color: var(--ui-text-muted);
  border-radius: var(--ui-radius-pill);
  text-align: center;
  white-space: nowrap;
}
.ui-prefs-option:hover span {
  color: var(--ui-text);
}
.ui-prefs-option input:checked + span {
  color: var(--ui-on-accent);
  background: var(--ui-accent);
  font-weight: var(--ui-weight-strong);
}
.ui-prefs-option input:focus-visible + span {
  outline: none;
  box-shadow: var(--ui-focus);
}

/* ══════════════════════════════════════════════════════════════
   CORY.NEWS — broadsheet on survey-grid paper
   odla-brand palette · IBM Plex Sans body · IBM Plex Mono chrome
   Light: mineral paper, growth-green accent, faint survey grid.
   Dark: night instrument panel, brightened green.
   Layout: newspaper chrome (issue bar, masthead, ruled nav),
   front-page feature with drop cap, "Previously" ledger.
   ══════════════════════════════════════════════════════════════ */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&display=swap");

/* ─── Tokens (palette: odla-ai/ui themes/odla-brand) ─── */
:root {
  --bg: #e9e4d8;
  --panel: #f8f4ea;
  --border: #b9b3a7;
  --border-strong: #7b827f;
  --text: #172229;
  --muted: #536168;
  --faint: #7d8788;
  --accent: #197a4e;
  --accent-strong: #0f5836;
  --accent-soft: rgba(25, 122, 78, 0.12);

  /* Derived from the ink rather than restated per mode: these follow whatever
     --text is in force, which is also what lets a reading palette reach them.
     Left as literals, the masthead rules would stay near-black on monochrome
     dark — a 4px double rule you cannot see. */
  --grid-line: color-mix(in srgb, var(--text) 4.5%, transparent);
  --rule: var(--text);

  --code-bg: #10191e;
  --code-text: #ece7da;
  --code-inline-bg: color-mix(in srgb, var(--text) 7%, transparent);
  --code-inline-text: var(--text);
  --hl-keyword: #37b47c;
  --hl-string: #65c6b9;
  --hl-comment: #8c9899;
  --hl-number: #e0b45a;
  --hl-title: #f5f0e4;
  --hl-attr: #8db8d0;
  --hl-type: #73c7ca;
  --hl-meta: #d89b73;
  --hl-addition: #79bd8e;
  --hl-deletion: #f07870;

  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Body measure. The reader's text-size axis scales it; see the html rule. */
  --font-size-root: 17px;

  /* Layout measures multiply the BASE size, not the scaled root: in rem they
     would ride --ui-font-scale, so the reader's text-size choice would widen
     the columns and the header rules too — which is page zoom, not a text
     setting. Pinned like this, larger text means fewer words per line. */
  --measure: calc(46 * var(--font-size-root));   /* reading column */
  --wide: calc(62 * var(--font-size-root));      /* ledger, archive */
  --chrome: calc(74 * var(--font-size-root));    /* header rules, footer */
}

[data-theme="dark"] {
  --bg: #0b1115;
  --panel: #121b20;
  --border: #304149;
  --border-strong: #566970;
  --text: #ece7da;
  --muted: #a5afac;
  --faint: #6d7b7e;
  --accent: #33b579;
  --accent-strong: #64d49c;
  --accent-soft: rgba(51, 181, 121, 0.16);

  --code-bg: #070c0f;
  --code-text: #ece7da;
  --hl-keyword: #64d49c;
  --hl-string: #65c6b9;
  --hl-comment: #738386;
  --hl-number: #e0b45a;
  --hl-title: #f5f0e4;
  --hl-attr: #8db8d0;
  --hl-type: #73c7ca;
  --hl-meta: #d89b73;
  --hl-addition: #79bd8e;
  --hl-deletion: #f07870;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1115;
    --panel: #121b20;
    --border: #304149;
    --border-strong: #566970;
    --text: #ece7da;
    --muted: #a5afac;
    --faint: #6d7b7e;
    --accent: #33b579;
    --accent-strong: #64d49c;
    --accent-soft: rgba(51, 181, 121, 0.16);

    --code-bg: #070c0f;
    --code-text: #ece7da;
    --hl-keyword: #64d49c;
    --hl-string: #65c6b9;
    --hl-comment: #738386;
    --hl-number: #e0b45a;
    --hl-title: #f5f0e4;
    --hl-attr: #8db8d0;
    --hl-type: #73c7ca;
    --hl-meta: #d89b73;
    --hl-addition: #79bd8e;
    --hl-deletion: #f07870;
  }
}

/* ─── Base ─── */
* {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  font-size: calc(var(--font-size-root) * var(--ui-font-scale, 1));
  font-weight: var(--ui-weight-body, 400);
  -webkit-font-smoothing: var(--ui-font-smoothing, auto);
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  transition: color 0.2s ease, background-color 0.2s ease;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
}

::selection {
  background: var(--accent-soft);
}

main {
  width: 100%;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
  flex: 1;
}

/* ─── Header: issue bar · masthead · ruled nav ─── */
.site-header {
  width: 100%;
  max-width: var(--chrome);
  margin: 0 auto;
  padding: 1.4rem 1.5rem 0;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 0.8rem;
  border-bottom: 3px solid var(--rule);
}

.topbar-issue,
.topbar-date,
.topbar-tools {
  flex: 1;
  white-space: nowrap;
}

.topbar-date {
  text-align: center;
}

.topbar-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.9rem;
}

.topbar-rss {
  color: var(--muted);
  text-decoration: none;
}

.topbar-rss:hover {
  color: var(--accent);
}

/* Reading-preferences menu. The panel and its pill tracks are the ui
   component layer as shipped; only the trigger is restyled, to keep the round
   hairline the old light/dark button wore in the issue bar. Sized in px, not
   rem — chrome must not grow when the reader turns the text size up. */
.ui-prefs-trigger {
  width: 26px;
  height: 26px;
  border-color: var(--border-strong);
  border-radius: 50%;
  color: var(--muted);
}

.ui-prefs-trigger:hover,
.ui-prefs[open] > .ui-prefs-trigger {
  border-color: var(--accent);
  color: var(--accent);
}

.ui-prefs-panel {
  right: -6px;
}

.masthead {
  text-align: center;
  padding: 2.2rem 0 1.6rem;
}

.site-title {
  font-family: var(--font-sans);
  font-size: 3.4rem;
  font-weight: var(--ui-weight-heading, 700);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
  text-decoration: none;
}

.site-title-accent {
  color: var(--accent);
}

.site-title:hover .site-title-accent {
  color: var(--accent-strong);
}

.site-tagline {
  font-style: italic;
  font-size: 1.02rem;
  color: var(--muted);
  margin: 0.9rem 0 0;
}

.site-nav {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem 2.4rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 4px double var(--rule);
}

.site-nav a {
  font-size: 0.78rem;
  font-weight: var(--ui-weight-strong, 600);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
}

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

/* ─── Scroll position indicator (fixed to viewport top) ─── */
.scroll-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 100;
  pointer-events: none;
}

.scroll-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
}

.scroll-dot {
  display: none;
}

[id] {
  scroll-margin-top: 2rem;
}

/* ─── Front-page feature ─── */
.feature {
  text-align: center;
  padding-top: 1.2rem;
}

.feature-kicker {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: var(--ui-weight-medium, 500);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1rem;
}

.feature-kicker .kicker-label {
  color: var(--accent);
  font-weight: var(--ui-weight-strong, 600);
}

/* Narrower than the reading column so the head wraps ahead of the body's
   measure — a headline that outruns its own text reads as a banner. */
.feature-title {
  font-size: 2.4rem;
  font-weight: var(--ui-weight-heading, 700);
  letter-spacing: -0.015em;
  line-height: 1.12;
  margin: 0 auto 2rem;
  max-width: 38rem;
  text-wrap: balance;
}

/* A deck belongs to the headline, so it sits tight; the deck's own bottom
   margin then carries the break into the body. */
.feature-title:has(+ .feature-deck) {
  margin-bottom: 1rem;
}

.feature-title a {
  color: var(--text);
  text-decoration: none;
}

.feature-title a:hover {
  color: var(--accent-strong);
}

.feature-deck {
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--muted);
  max-width: 38rem;
  margin: 0 auto 2.2rem;
  text-wrap: pretty;
}

.feature-body {
  max-width: var(--measure);
  margin: 0 auto;
  text-align: justify;
  hyphens: auto;
  font-size: 1.08rem;
  line-height: 1.75;
}

/* Headings, blockquotes, code — anything that isn't running text — read as
   centered mistakes inside justified copy, so pull them back to flush left. */
.feature-body :is(h2, h3, h4, blockquote, pre, figure, table, ul, ol) {
  text-align: left;
  hyphens: none;
}

.feature-body > p:first-child::first-letter {
  float: left;
  font-size: 3.55em;
  font-weight: var(--ui-weight-heading, 700);
  line-height: 0.8;
  padding: 0.08em 0.14em 0 0;
  color: var(--accent);
}

.feature-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin: 1.6rem 0 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
}

.feature-facts a {
  color: var(--muted);
  text-decoration: none;
}

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

.feature-read {
  font-weight: var(--ui-weight-strong, 600);
  color: var(--accent);
  text-decoration: none;
}

.feature-read:hover {
  color: var(--accent-strong);
}

/* ─── "Previously" ledger ─── */
.previously {
  margin-top: 4.5rem;
}

.previously-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: var(--ui-weight-medium, 500);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.7rem;
}

.previously-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--border-strong);
}

.previously-item {
  display: grid;
  grid-template-columns: 6.5rem 1fr auto;
  gap: 0.2rem 1.5rem;
  align-items: baseline;
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--border);
}

.previously-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.previously-headline {
  font-size: 1.3rem;
  font-weight: var(--ui-weight-heading, 700);
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
  text-decoration: none;
}

.previously-headline:hover {
  color: var(--accent-strong);
}

.previously-blurb {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.previously-tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  justify-self: end;
}

.previously-tag:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

/* ─── Single post / page ─── */
.post,
.page {
  max-width: var(--measure);
  margin: 0 auto;
}

.post > .post-header {
  text-align: center;
  margin-bottom: 2.4rem;
}

.post-kicker {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.2rem 0 1.3rem;
}

h1.post-title,
.page-title {
  font-size: 2.5rem;
  font-weight: var(--ui-weight-heading, 700);
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: var(--text);
  margin: 0 0 0.9rem;
}

.page-title {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

.post-deck {
  font-style: italic;
  font-size: 1.18rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
}

.post > .prose > p:first-child::first-letter {
  float: left;
  font-size: 3.3em;
  font-weight: var(--ui-weight-heading, 700);
  line-height: 0.8;
  padding: 0.08em 0.14em 0 0;
  color: var(--accent);
}

.post-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.3rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.post-tags {
  display: inline;
}

.post-tag {
  color: var(--accent);
  text-decoration: none;
}

.post-tag:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

/* ─── Prose ─── */
.prose {
  font-size: 1.02rem;
  line-height: 1.75;
  overflow-wrap: break-word;
  /* Contain legacy floated images (align="right" markup from the old site)
     so they can't bleed past the article and squeeze whatever follows. */
  display: flow-root;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  font-weight: var(--ui-weight-heading, 700);
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
  margin: 2.2rem 0 0.8rem;
}

.prose h1 { font-size: 1.55rem; }
.prose h2 { font-size: 1.4rem; }
.prose h3 { font-size: 1.2rem; }
.prose h4 { font-size: 1.05rem; }

.prose p {
  margin: 0 0 1.4rem;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

.prose a:hover {
  color: var(--accent-strong);
  text-decoration-thickness: 2px;
}

.prose ul,
.prose ol {
  margin: 0 0 1.4rem;
  padding-left: 1.6rem;
}

.prose li {
  margin-bottom: 0.45rem;
}

.prose li::marker {
  color: var(--accent);
}

.prose blockquote {
  margin: 2rem 0;
  padding-left: 1.4rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

.prose img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 2px;
}

.prose hr {
  border: none;
  border-top: 4px double var(--border-strong);
  margin: 3rem auto;
  width: 8rem;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.prose th {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: var(--ui-weight-strong, 600);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 2px solid var(--border-strong);
}

/* ─── Code ─── */
code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background-color: var(--code-inline-bg);
  color: var(--code-inline-text);
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

pre {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  background-color: var(--code-bg);
  color: var(--code-text);
  padding: 1.2rem 1.4rem;
  border-radius: 3px;
  overflow-x: auto;
  margin: 0 0 1.4rem;
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: 1em;
}

.hljs { color: var(--code-text); }
.hljs-keyword, .hljs-selector-tag, .hljs-tag { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp { color: var(--hl-string); }
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: var(--hl-number); }
.hljs-title, .hljs-section, .hljs-name { color: var(--hl-title); font-weight: var(--ui-weight-strong, 600); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-property { color: var(--hl-attr); }
.hljs-type, .hljs-built_in, .hljs-selector-class, .hljs-selector-id { color: var(--hl-type); }
.hljs-meta, .hljs-doctag { color: var(--hl-meta); }
.hljs-addition { color: var(--hl-addition); }
.hljs-deletion { color: var(--hl-deletion); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: var(--ui-weight-heading, 700); }

/* ─── Post lists on listTag pages (How I…, Sea Stories) ─── */
.post-list {
  display: flex;
  flex-direction: column;
  max-width: var(--measure);
  margin: 0 auto;
}

.page + .post-list,
.page .post-list {
  margin-top: 2rem;
}

.post-item {
  padding: 2.2rem 0;
  border-bottom: 1px solid var(--border);
}

.post-item:first-child {
  border-top: 2px solid var(--border-strong);
}

a.post-title {
  font-size: 1.55rem;
  font-weight: var(--ui-weight-heading, 700);
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
  text-decoration: none;
}

a.post-title:hover {
  color: var(--accent-strong);
}

.post-excerpt {
  margin-top: 0.9rem;
  font-size: 1rem;
}

.post-item .post-meta {
  margin-top: 0.8rem;
  padding-top: 0;
  border-top: none;
}

.read-more a {
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--accent);
  text-decoration: none;
}

.read-more a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

/* ─── Archive & tags ─── */
.archive-year {
  font-size: 1.7rem;
  font-weight: var(--ui-weight-heading, 700);
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 3rem 0 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border-strong);
}

.archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.archive-item {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.archive-item time {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 8.5rem;
}

.archive-item a {
  color: var(--text);
  font-weight: var(--ui-weight-medium, 500);
  text-decoration: none;
}

.archive-item a:hover {
  color: var(--accent-strong);
}

.tag-cloud {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.6rem;
  max-width: var(--measure);
}

.tag-cloud .post-tag {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--accent);
}

.tag-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--faint);
}

/* ─── Footnotes ─── */
.footnotes {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 4px double var(--border-strong);
  font-size: 0.88em;
  color: var(--muted);
}

.footnote-ref a,
.footnote-backref {
  text-decoration: none;
}

/* ─── Footer ─── */
.site-footer {
  width: 100%;
  max-width: var(--chrome);
  margin: 0 auto;
  padding: 1.3rem 1.5rem 2.2rem;
  text-align: center;
  border-top: 4px double var(--rule);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

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

.site-footer .copyright a {
  text-decoration: none;
}

.site-footer .copyright a:hover {
  text-decoration: underline;
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .site-title {
    font-size: 2.5rem;
  }

  .feature-title {
    font-size: 2.1rem;
  }

  .site-nav {
    gap: 0.4rem 1.4rem;
  }

  .topbar-date {
    display: none;
  }

  .topbar-issue,
  .topbar-tools {
    flex: none;
  }
}

@media (max-width: 640px) {
  html {
    font-size: 16px;
  }

  .site-title {
    font-size: 2.1rem;
  }

  .feature-title {
    font-size: 1.9rem;
  }

  .feature-deck {
    font-size: 1.1rem;
  }

  .feature-body {
    text-align: left;
    hyphens: none;
  }

  .previously-item {
    grid-template-columns: 1fr auto;
  }

  .previously-date {
    grid-column: 1;
    grid-row: 1;
  }

  .previously-tag {
    grid-column: 2;
    grid-row: 1;
  }

  .previously-main {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .archive-item {
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.7rem 0;
  }
}

/* ─── juniper/ui.css (odla-ui token aliases) ─── */
/* cory.news/ui.css — maps this site's palette onto the @odla-ai/ui token
   contract. Shadows the packaged juniper/ui.css, which had to be shadowed:
   theme/styles.css replaces juniper's palette wholesale, so juniper's aliases
   were reaching for token names (--surface, --text-secondary) that no longer
   exist here, leaving those --ui-* roles undefined.

   It also earns the reading palettes. The build inverts these aliases into a
   `html[data-ui-palette]:not([data-ui-palette="default"])` block, so under
   monochrome or high contrast the page tokens take their values from the
   palette instead of the other way round — which is what makes the article
   change, not just the buttons.

   Plain var() aliases track dark mode for free; any LITERAL that differs by
   mode must be restated identically in BOTH dark blocks. */
:root {
  --ui-bg: var(--bg);
  --ui-surface: var(--panel);
  --ui-surface-2: color-mix(in srgb, var(--text) 6%, var(--bg));
  --ui-text: var(--text);
  --ui-text-muted: var(--muted);
  --ui-text-faint: var(--faint);
  --ui-border: var(--border);
  --ui-border-strong: var(--border-strong);
  --ui-accent: var(--accent);
  --ui-accent-strong: var(--accent-strong);
  --ui-accent-soft: var(--accent-soft);
  --ui-on-accent: #ffffff;
  --ui-good: #1f7a4a;
  --ui-good-soft: color-mix(in srgb, var(--ui-good) 12%, transparent);
  --ui-warn: #8a6a1f;
  --ui-warn-soft: color-mix(in srgb, var(--ui-warn) 12%, transparent);
  --ui-danger: #a33a30;
  --ui-danger-soft: color-mix(in srgb, var(--ui-danger) 11%, transparent);
  --ui-code-bg: var(--code-bg);
  --ui-code-text: var(--code-text);
  --ui-hl-keyword: var(--hl-keyword);
  --ui-hl-string: var(--hl-string);
  --ui-hl-comment: var(--hl-comment);
  --ui-hl-number: var(--hl-number);
  --ui-hl-title: var(--hl-title);
  --ui-hl-attr: var(--hl-attr);
  --ui-hl-type: var(--hl-type);
  --ui-hl-meta: var(--hl-meta);
  --ui-hl-addition: var(--hl-addition);
  --ui-hl-deletion: var(--hl-deletion);
  --ui-shadow: 0 1px 2px color-mix(in srgb, var(--text) 8%, transparent);
  --ui-font-sans: var(--font-sans);
  --ui-font-serif: Georgia, "Iowan Old Style", Palatino, serif;
  --ui-font-mono: var(--font-mono);
  --ui-font-display: var(--font-sans);
  --ui-font-size-root: var(--font-size-root);
}

[data-theme="dark"] {
  --ui-on-accent: #07110c;
  --ui-good: #4cc487;
  --ui-warn: #d9b45e;
  --ui-danger: #ef8078;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ui-on-accent: #07110c;
    --ui-good: #4cc487;
    --ui-warn: #d9b45e;
    --ui-danger: #ef8078;
  }
}

/* High contrast — this site's own hues held, only the lightness moved, until
   each role clears WCAG AAA (7:1) on the mineral paper. The generic
   @odla-ai/ui contrast palette sharpens structure (no dimming, full-ink
   hairlines, flat surfaces, no shadow) but cannot move a hue: deriving
   --ui-accent from --ui-accent on one element is a cycle. The base block is
   unqualified, so it applies in dark too — every role is restated in both dark
   blocks, even the ones already past 7:1. Ratios are before → after. */
html[data-ui-palette="contrast"] {
  --ui-accent: #00532a;          /* 4.2 → 7.3 on #e9e4d8 */
  --ui-accent-strong: #065331;   /* 6.7 → 7.2 */
  --ui-good: #005326;            /* 4.2 → 7.3 */
  --ui-warn: #604200;            /* 4.0 → 7.3 */
  --ui-danger: #882019;          /* 5.2 → 7.3 */
}

html[data-ui-palette="contrast"][data-theme="dark"] {
  --ui-accent: #33b579;          /* already 7.3 on #0b1115 */
  --ui-accent-strong: #64d49c;   /* already 10.4 */
  --ui-good: #4cc487;            /* already 8.6 */
  --ui-warn: #d9b45e;            /* already 9.6 */
  --ui-danger: #ef8078;          /* already 7.3 */
}

@media (prefers-color-scheme: dark) {
  html[data-ui-palette="contrast"]:not([data-theme="light"]) {
    --ui-accent: #33b579;          /* already 7.3 on #0b1115 */
    --ui-accent-strong: #64d49c;   /* already 10.4 */
    --ui-good: #4cc487;            /* already 8.6 */
    --ui-warn: #d9b45e;            /* already 9.6 */
    --ui-danger: #ef8078;          /* already 7.3 */
  }
}

/* ─── accessibility palettes drive the theme's own page tokens ─── */
html[data-ui-palette="mono"]:not([data-ui-palette="default"]) {
  --bg: var(--ui-bg);
  --panel: var(--ui-surface);
  --text: var(--ui-text);
  --muted: var(--ui-text-muted);
  --faint: var(--ui-text-faint);
  --border: var(--ui-border);
  --border-strong: var(--ui-border-strong);
  --accent: var(--ui-accent);
  --accent-strong: var(--ui-accent-strong);
  --accent-soft: var(--ui-accent-soft);
  --code-bg: var(--ui-code-bg);
  --code-text: var(--ui-code-text);
  --hl-keyword: var(--ui-hl-keyword);
  --hl-string: var(--ui-hl-string);
  --hl-comment: var(--ui-hl-comment);
  --hl-number: var(--ui-hl-number);
  --hl-title: var(--ui-hl-title);
  --hl-attr: var(--ui-hl-attr);
  --hl-type: var(--ui-hl-type);
  --hl-meta: var(--ui-hl-meta);
  --hl-addition: var(--ui-hl-addition);
  --hl-deletion: var(--ui-hl-deletion);
}

html[data-ui-palette="contrast"]:not([data-ui-palette="default"]) {
  --panel: var(--ui-surface);
  --muted: var(--ui-text-muted);
  --faint: var(--ui-text-faint);
  --border: var(--ui-border);
  --border-strong: var(--ui-border-strong);
  --accent: var(--ui-accent);
  --accent-strong: var(--ui-accent-strong);
  --accent-soft: var(--ui-accent-soft);
  --code-bg: var(--ui-code-bg);
  --code-text: var(--ui-code-text);
}

/* ─── search ─── */
/* Search UI. Written entirely against the @odla-ai/ui --ui-* token contract,
   which every bundled theme's ui.css maps onto its own palette — so search
   inherits each theme's colours, fonts, and dark mode without any theme
   shipping search-specific CSS, and a custom theme gets it for free by
   defining the same tokens. Appended to assets/styles.css by the build. */

.site-search {
  position: relative;
  display: flex;
  align-items: center;
}

.site-search-input {
  font: inherit;
  font-family: var(--ui-font-sans);
  font-size: 0.9rem;
  color: var(--ui-text);
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  padding: 0.3em 0.9em;
  width: 9rem;
  transition: width 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.site-search-input::placeholder {
  color: var(--ui-text-faint);
}

.site-search-input:focus {
  outline: none;
  width: 14rem;
  border-color: var(--ui-accent);
  box-shadow: 0 0 0 3px var(--ui-accent-soft);
}

.site-search-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 50;
  width: min(28rem, calc(100vw - 2rem));
  max-height: min(28rem, calc(100vh - 6rem));
  overflow-y: auto;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 0.6rem;
  box-shadow: var(--ui-shadow);
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0.3rem;
}

.search-result {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 0.4rem;
  text-decoration: none;
  color: var(--ui-text);
}

.search-result.is-active,
.search-result:hover {
  background: var(--ui-accent-soft);
}

.search-result-title {
  display: block;
  font-family: var(--ui-font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}

.search-result-meta {
  display: block;
  font-family: var(--ui-font-sans);
  font-size: 0.75rem;
  color: var(--ui-text-faint);
  margin-top: 0.15rem;
}

.search-result-lead {
  display: block;
  font-family: var(--ui-font-sans);
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ui-text-muted);
  margin-top: 0.25rem;
  /* Two lines is enough to judge a hit; more turns the panel into a wall. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result mark {
  background: var(--ui-accent-soft);
  color: var(--ui-accent-strong);
  border-radius: 2px;
  padding: 0 1px;
}

.search-empty {
  margin: 0;
  padding: 0.9rem 1rem;
  font-family: var(--ui-font-sans);
  font-size: 0.85rem;
  color: var(--ui-text-muted);
}

@media (max-width: 34rem) {
  /* The input would crowd the nav on a phone; the results panel still works
     for anyone who focuses it via the keyboard. */
  .site-search-input {
    width: 6.5rem;
  }
  .site-search-input:focus {
    width: 9rem;
  }
}
