/* ══════════════════════════════════════════════════════════════════════════
   reset.css — flattens browser defaults so `theme.css` starts from one shape.

   Kept in its own file, and loadable on its own, because a reset is the one
   part of a design system a consumer might legitimately already have: an app
   that ships `normalize.css` or Tailwind's preflight links `theme.css` alone.

   Everything here removes or normalises. Nothing here decides what the UI
   looks like — that is `theme.css`'s job, and the split is what lets a
   consumer swap either half without touching the other.
   ══════════════════════════════════════════════════════════════════════════ */

/* Border-box everywhere, including pseudo-elements. Sizing an element by its
   border edge is what everyone means when they set a width, and inheriting it
   (rather than setting `*`) lets a subtree opt out if it ever must. */
html {
	box-sizing: border-box;
}
*,
*::before,
*::after {
	box-sizing: inherit;
}

/* The browser's default margins are a typographic opinion from 1996 that every
   stylesheet then has to argue with. `theme.css` re-applies rhythm deliberately. */
body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd,
pre, hr,
ol, ul {
	margin: 0;
	padding: 0;
}

/* Lists only look like lists when they carry a marker, and a list used for
   navigation is not one of those. `theme.css` restores markers for prose. */
ol, ul {
	list-style: none;
}

body {
	min-height: 100vh;
	/* `100dvh` where supported: on mobile the toolbar's show/hide changes the
	   viewport, and `vh` freezes at the larger value, leaving a scrollbar on a
	   page that fits. Declared second so browsers without `dvh` keep the first. */
	min-height: 100dvh;
	/* A UA normalisation, not a design decision: browsers ship `normal`, which
	   varies by font and is too tight for body copy. The theme's `body` rule
	   overrides this with `--ui-line-height` the moment `theme.css` loads. It
	   stays a literal deliberately — the reset must decide nothing about the
	   look and must not reach for a `--ui-*` token (`tokens.test.ts` enforces
	   both), so it cannot take this from the leading scale. */
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	/* Text should never zoom on landscape rotation in iOS Safari. */
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

/* Headings inherit the body's balance rather than the UA's tight default;
   `text-wrap: balance` keeps a two-line heading from stranding one word. */
h1, h2, h3, h4, h5, h6 {
	font-size: inherit;
	font-weight: inherit;
	text-wrap: balance;
}

/* Replaced elements are inline by default, which leaves a descender-sized gap
   under every image. Block removes it; `max-width` keeps them in their box. */
img, picture, video, canvas, svg, iframe, embed, object {
	display: block;
	max-width: 100%;
}
img, video {
	height: auto;
}

/* Form controls do not inherit typography from their ancestors — every browser
   substitutes its own system font — so say it explicitly. */
input, button, textarea, select, optgroup {
	font: inherit;
	color: inherit;
	letter-spacing: inherit;
}

/* A textarea that resizes horizontally escapes its layout; vertical is the
   only axis anyone actually wants. */
textarea {
	resize: vertical;
}

button {
	background: none;
	border: none;
	cursor: pointer;
}

/* A long unbroken token (a URL, a hash, an ID) must not push the page wider
   than the viewport. */
p, h1, h2, h3, h4, h5, h6, li, dd, dt, figcaption {
	overflow-wrap: break-word;
}

a {
	color: inherit;
	text-decoration: none;
}

table {
	border-collapse: collapse;
	border-spacing: 0;
}

/* `hidden` losing to a later `display` rule is a perennial source of elements
   that will not hide. */
[hidden] {
	display: none !important;
}

fieldset {
	margin: 0;
	padding: 0;
	border: none;
}
legend {
	padding: 0;
}

/* Safari renders a `<summary>` with a marker that cannot be styled; the theme
   draws its own. */
summary {
	display: list-item;
	cursor: pointer;
}

/* Respect the visitor's motion preference globally rather than per-animation.
   Not `animation: none` — an animation removed outright can leave an element
   stuck in its pre-animation state (a spinner that never appears, a panel that
   never opens). Collapsing the duration runs it to completion instantly. */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* ══════════════════════════════════════════════════════════════════════════
   theme.css — the shared look: tokens, element defaults, components, utilities.

   One file rather than four `@import`ed ones on purpose. `@import` chains are
   fetched serially, and the consumers here include static pages with no build
   step (paradigm-status, the forefront installer) where that would be three
   extra round trips before the first paint. Bundler consumers get the same
   file. Navigate it by the banner comments.

   Load order is `reset.css` then this file:

       <link rel="stylesheet" href=".../reset.css">
       <link rel="stylesheet" href=".../theme.css">

   or, from a bundler, `import "@hrayo/foundation-ui-theme/index.css"`.

   ── How to configure it ───────────────────────────────────────────────────
   Override the CONFIGURATION block below — nothing outside it. Every other
   token is derived from it with `calc()` / `color-mix()`, so setting
   `--ui-accent` once re-tints hovers, focus rings, links, selection and soft
   fills in both themes; setting `--ui-radius` once re-rounds every component.

   (Keep this example free of comment markers. CSS comments do not nest, so an
   inner close-marker ends this whole block and turns the prose below it into
   live CSS — which is a real thing that happened here, silently.)

       :root {
           --ui-accent: #0a908f;
           --ui-accent-contrast: #fff;
           --ui-radius: 0.375rem;
           --ui-body-background: var(--ui-surface-sunken);
       }

   `--ui-accent-contrast` is the ink drawn ON the accent; set it when the accent
   is pale enough that white text on it would not clear 4.5:1.

   A monochrome accent is a legitimate two-armed value —
   `--ui-accent: light-dark(#0f172a, #e7eaee)`. The derivation lifts a mid-tone
   accent for dark, which does nothing for a near-black one, so invert it
   yourself.

   Reaching past that — restyling `.ui-btn`, hardcoding a hex, adding an
   `!important` — is how a shared system stops being shared. If a token you
   need is missing, add it here rather than working around it locally.

   ── Light and dark ────────────────────────────────────────────────────────
   Both themes live in one declaration per token via `light-dark()`, which
   resolves against the element's used `color-scheme`. Following the OS is the
   default and needs no attribute; forcing a theme is a single attribute on
   `<html>`, which is what `setTheme()` in `src/index.ts` writes:

       <html>                      follows the operating system
       <html data-theme="light">   forced light
       <html data-theme="dark">    forced dark

   Because the switch is `color-scheme` rather than a class, native controls,
   scrollbars, and form widgets follow too — for free.
   ══════════════════════════════════════════════════════════════════════════ */


/* ══════════════════════════════════════════════════════════════════════════
   1. CONFIGURATION — the knobs. Override these; derive everything else.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
	/* Enables `light-dark()` below and tells the browser to render native
	   widgets in both themes. Do not remove. */
	color-scheme: light dark;

	/* ── Accent ────────────────────────────────────────────────────────────
	   One colour. Hover, active, links, rings, selection and soft fills are
	   mixed from it, in the right direction for each theme. */
	--ui-accent: #2f6fe4;
	/* Text and icons drawn ON a filled accent surface. White suits any accent
	   dark enough to carry white text; a pale accent (yellow, lime) should set
	   this to a dark ink. */
	--ui-accent-contrast: #ffffff;

	/* ── Shape ────────────────────────────────────────────────────────────
	   Corner roundness. 0 gives square corners throughout; every component
	   radius is a multiple of this. */
	--ui-radius: 0.375rem;

	/* ── Rhythm ───────────────────────────────────────────────────────────
	   The spacing unit. Padding, margins and gaps are all multiples, so
	   halving this compacts the entire UI. */
	--ui-space: 0.25rem;

	/* ── Type ─────────────────────────────────────────────────────────────
	   Base size (`--ui-text-md`); the rest of the scale is a ratio of it. */
	--ui-font-size: 1rem;
	--ui-line-height: 1.55;

	/* Platform-native first, degrading through the widest-installed faces to
	   the generic family. No webfont, so no network cost, no flash of
	   unstyled text, and no `font-src` entry in anyone's CSP. */
	--ui-font-sans:
		system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		"Helvetica Neue", "Noto Sans", Arial, sans-serif,
		"Apple Color Emoji", "Segoe UI Emoji";
	/* JetBrains Mono when the reader has it installed, then the platform's own
	   UI monospace, then the classics. */
	--ui-font-mono:
		"JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
		Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;

	/* ── Motion ───────────────────────────────────────────────────────────
	   `reset.css` already collapses these under `prefers-reduced-motion`. */
	--ui-transition: 140ms ease;

	/* Page background. Defaults to the plain surface; set it to
	   `var(--ui-surface-sunken)` for the "cards float on a recessed page" look
	   that a wizard or a dashboard usually wants. */
	--ui-body-background: var(--ui-surface);

	/* ── Layout ───────────────────────────────────────────────────────────*/
	--ui-container: 72rem;
	--ui-prose: 42rem;
}


/* ══════════════════════════════════════════════════════════════════════════
   2. DERIVED TOKENS — computed from the knobs above. Read these, don't set them.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
	/* ── Neutrals ─────────────────────────────────────────────────────────
	   A quiet, very slightly cool grey. `surface` is the page, `raised` sits
	   above it (cards, menus, modals), `sunken` below it (wells, code blocks,
	   table headers). Dark is not the light ramp inverted — it is compressed,
	   because pure black with pure white text is glare, not contrast. */
	--ui-surface:         light-dark(#ffffff, #16181c);
	--ui-surface-raised:  light-dark(#ffffff, #1c1f25);
	--ui-surface-sunken:  light-dark(#f5f6f8, #111318);
	--ui-surface-hover:   light-dark(#f1f3f5, #22262d);

	--ui-text:            light-dark(#16191d, #e7eaee);
	--ui-text-muted:      light-dark(#5b636e, #9aa2ae);
	--ui-text-subtle:     light-dark(#858d99, #6d7581);
	/* Text on an inverted surface (tooltips, toasts, dark badges). */
	--ui-text-inverse:    light-dark(#ffffff, #16191d);

	--ui-border:          light-dark(#e3e6ea, #292d35);
	--ui-border-strong:   light-dark(#c8cdd5, #3b414a);

	/* ── Accent, derived ──────────────────────────────────────────────────
	   Hover/active darken in light and lighten in dark, so the interaction
	   always moves *towards* the viewer rather than into the background. */
	--ui-accent-hover:    color-mix(in oklab, var(--ui-accent) 85%, light-dark(#000, #fff));
	--ui-accent-active:   color-mix(in oklab, var(--ui-accent) 72%, light-dark(#000, #fff));
	/* The accent used as a foreground — links, active tabs, selected icons.
	   Darkened in light and lifted in dark, so the ink always moves AWAY from
	   the surface behind it rather than towards it.

	   The two percentages are not taste, they are the contrast budget. This ink
	   is drawn on two different backgrounds: the plain surface, and — far more
	   often — its own `--ui-accent-soft` tint (every selected menu row, active
	   pill tab, accent badge, tag, banner, avatar and ghost-button hover). The
	   tint moves the background TOWARDS the ink, so a foreground that clears
	   4.5:1 on the page can sit at 4.0:1 on its own selected state; that is
	   exactly how the active pill tab shipped at ≈4.3:1 once the `-soft` tints
	   were repaired and started painting at all.

	   So the mix is sized to absorb the tint. Sweeping the whole sRGB accent
	   space (1,376 light / 3,431 dark accents that clear 4.5:1 on the plain
	   surface, tinted at the `-soft` alphas below and composited over surface,
	   surface-raised and surface-sunken in each scheme) the worst pair lands at
	   4.68:1 in light and 4.72:1 in dark — AA with a margin, for ANY accent a
	   product configures, not just ours. Loosening either percentage towards
	   the raw accent drops the worst case under 4.5:1 within two steps, so do
	   not "restore the brand colour" here without re-running that sweep;
	   `src/contrast.test.ts` recomputes the whole matrix from these very
	   declarations and will fail.

	   Note this is a CONDITIONAL guarantee: an accent that is already too pale
	   to read on white (a lemon yellow, a pastel lime) cannot be rescued by a
	   mix and is the product's own configuration bug. The contract is that a
	   qualifying accent stays qualifying once it lands on its own tint. */
	--ui-accent-text:     light-dark(color-mix(in oklab, var(--ui-accent) 88%, #000),
	                                 color-mix(in oklab, var(--ui-accent) 58%, #fff));
	/* Tinted fills: selected rows, soft badges, active nav items.
	   `light-dark()` wraps the two whole mixes, NOT the percentage — it is
	   defined to take two `<color>`s, so a percentage argument makes the
	   declaration invalid at computed-value time and the fill paints as
	   `transparent`, silently, in both schemes. Keep the mix inside it. */
	--ui-accent-soft:     light-dark(color-mix(in oklab, var(--ui-accent) 10%, transparent),
	                                 color-mix(in oklab, var(--ui-accent) 22%, transparent));
	--ui-accent-border:   color-mix(in oklab, var(--ui-accent) 45%, var(--ui-border));
	--ui-accent-ring:     light-dark(color-mix(in oklab, var(--ui-accent) 40%, transparent),
	                                 color-mix(in oklab, var(--ui-accent) 55%, transparent));

	/* ── Status ───────────────────────────────────────────────────────────
	   Four tones, each with a solid (dots, bars, filled buttons), a text
	   variant that clears 4.5:1 on the page surface AND on its own soft fill
	   (measured: 4.86–7.00, worst = warning on `-soft` over `surface-sunken`
	   in light), and that soft fill. Unlike the accent these are fixed hexes
	   the system owns, so they are tuned directly rather than derived — but
	   the same rule binds them, and the same test measures them. */
	--ui-success:         light-dark(#1a7f4b, #35c17c);
	--ui-success-text:    light-dark(#146b3e, #4ed295);
	--ui-success-soft:    light-dark(color-mix(in oklab, var(--ui-success) 10%, transparent),
	                                color-mix(in oklab, var(--ui-success) 20%, transparent));

	--ui-warning:         light-dark(#b26a00, #e0961f);
	--ui-warning-text:    light-dark(#8f5500, #f0b64c);
	--ui-warning-soft:    light-dark(color-mix(in oklab, var(--ui-warning) 12%, transparent),
	                                color-mix(in oklab, var(--ui-warning) 22%, transparent));

	--ui-danger:          light-dark(#c02525, #e5544f);
	--ui-danger-text:     light-dark(#a91d1d, #f77e79);
	--ui-danger-soft:     light-dark(color-mix(in oklab, var(--ui-danger) 10%, transparent),
	                                color-mix(in oklab, var(--ui-danger) 20%, transparent));
	/* The filled danger button's hover, derived like `--ui-accent-hover`:
	   darker in light, lighter in dark. A token rather than a `light-dark()`
	   written into the component rule, because every `light-dark()` in this
	   sheet is the value of a custom property — a consumer whose engine
	   ignores `color-scheme` can then restate the dark arms as plain token
	   overrides under `[data-theme="dark"]`, and nothing else. */
	--ui-danger-hover:    color-mix(in oklab, var(--ui-danger) 85%, light-dark(#000, #fff));

	--ui-info:            light-dark(#2563c9, #5b9bf5);
	--ui-info-text:       light-dark(#1f56ad, #7fb2f8);
	--ui-info-soft:       light-dark(color-mix(in oklab, var(--ui-info) 10%, transparent),
	                                color-mix(in oklab, var(--ui-info) 20%, transparent));

	/* ── Shape scale ──────────────────────────────────────────────────────*/
	--ui-radius-sm:   calc(var(--ui-radius) * 0.5);
	--ui-radius-md:   var(--ui-radius);
	--ui-radius-lg:   calc(var(--ui-radius) * 1.5);
	--ui-radius-xl:   calc(var(--ui-radius) * 2.5);
	--ui-radius-full: 9999px;

	/* ── Spacing scale ────────────────────────────────────────────────────*/
	--ui-space-1:  var(--ui-space);
	--ui-space-2:  calc(var(--ui-space) * 2);
	--ui-space-3:  calc(var(--ui-space) * 3);
	--ui-space-4:  calc(var(--ui-space) * 4);
	--ui-space-5:  calc(var(--ui-space) * 5);
	--ui-space-6:  calc(var(--ui-space) * 6);
	--ui-space-8:  calc(var(--ui-space) * 8);
	--ui-space-10: calc(var(--ui-space) * 10);
	--ui-space-12: calc(var(--ui-space) * 12);
	--ui-space-16: calc(var(--ui-space) * 16);
	--ui-space-20: calc(var(--ui-space) * 20);
	--ui-space-24: calc(var(--ui-space) * 24);

	/* ── Spacing, SEMANTIC — reach for these first ─────────────────────────
	   The numeric ladder above is raw material. What a call site should
	   normally say is how much room it wants, not how many units that is:

	       none    0            no gap — a welded control, a flush edge
	       small   0.5rem       INSIDE a thing — icon↔label, chip↔chip,
	                            a dense row's padding
	       normal  1rem         BETWEEN things — control↔control, cell
	                            padding, a card's inner padding
	       large   2rem         between SECTIONS — card↔card, a block break

	   Four stops on an 8-pt doubling ladder, which is the granularity a
	   layout decision actually has. `--ui-space-3` (0.75 rem) beside
	   `--ui-space-4` (1 rem) beside `--ui-space-5` (1.25 rem) is not three
	   decisions, it is three people rounding differently — the same failure
	   the type ladder was introduced to end.

	   The numeric stops stay for the two honest exceptions: an **optical**
	   nudge below the smallest semantic step (a 1–3 px hairline, a 4 px
	   `--ui-space-1` gap between welded chips) and the **outsized** page
	   rhythm above the largest (`--ui-space-12`+ hero padding). Anything in
	   between should be a semantic stop; if it looks wrong at one, the
	   component's density is the thing to fix, not the gap. */
	--ui-space-none:   0;
	--ui-space-small:  var(--ui-space-2);
	--ui-space-normal: var(--ui-space-4);
	--ui-space-large:  var(--ui-space-8);

	/* ── Icon size ────────────────────────────────────────────────────────
	   One icon scale for every product, so a "settings" glyph is the same
	   size in the app shell, the admin console and the marketing site.

	       small   1rem     (16 px) inside small text, or a dense table cell
	       normal  1.25rem  (20 px) THE DEFAULT — rows, buttons, fields, nav
	       large   1.5rem   (24 px) a standalone action, section header, a
	                        glyph that carries meaning on its own

	   `normal` is 20 px rather than the 13–16 px this codebase had drifted
	   to. The established floors all sit above that: Material's standard
	   icon is 24 dp, Apple's HIG toolbar glyphs are ~24 pt, and WCAG 2.2 SC
	   2.5.8 (Target Size, Minimum) wants a 24 × 24 CSS-px target. 20 px is
	   the dense-UI step below the 24 px standard — big enough to read a
	   glyph's silhouette at a glance, small enough for an analytics sidebar
	   — and the tappable BOX around it (`--ui-icon-btn-size`) is what
	   satisfies the target-size rule.

	   Sizes are `rem`, not `em`, on purpose: an icon is a fixed-size object,
	   and one riding `em` shrinks in every caption it happens to sit in,
	   which is how a system ends up with a dozen icon sizes nobody chose. */
	--ui-icon-small:  1rem;
	--ui-icon-normal: 1.25rem;
	--ui-icon-large:  1.5rem;

	/* ── Tap target ───────────────────────────────────────────────────────
	   The house figure for "big enough for a fingertip": 44 CSS px, Apple's
	   HIG minimum and WCAG 2.2 SC 2.5.5 (Target Size, Enhanced, AAA). The
	   AA-level SC 2.5.8 asks only 24 × 24, which `--ui-icon-btn-size`'s
	   1.75rem box already clears with padding to spare — so this token is the
	   COARSE-POINTER figure, not a floor every control has to meet.

	   It exists because the number was being restated: `.ui-icon-btn` opened
	   to a literal `2.75rem` on a coarse pointer, and `ui-dropdown`'s docblock
	   claimed "44px (the shared tap-target size)" for a trigger the stylesheet
	   sets to 2.25rem — a shared size stated in prose in two packages and
	   defined in none (DOC-013). Naming it does not move anything: the one
	   adopter below already shipped this exact value.

	   ADOPTION IS PER COMPONENT AND DELIBERATE. Applying it as a min-height to
	   a control that has shipped shorter is a VISIBLE change to every product,
	   so it is a decision with a before/after, not a token rename — see
	   DECISIONS.md § Design system. On a COARSE pointer it was taken: every
	   `.ui-btn` / `.ui-control` / `.ui-menu-item` / `.ui-option` /
	   `.ui-segmented-btn` is at least this tall there (§ Touch); nothing moved
	   for a mouse. `ui-dropdown`'s 2.25rem trigger has NOT adopted it. */
	--ui-tap-target: 2.75rem;

	/* ── Disabled ─────────────────────────────────────────────────────────
	   How far a disabled control fades. Named on the `--ui-tap-target`
	   precedent: the number was already shared, it was simply restated at
	   every call site, and `opacity` was not in the token vocabulary at all —
	   so the one property that says "you cannot use this" was the one property
	   with no house value.

	   It was drawn SEVEN ways in the file whose job is to stop exactly that:
	   `.ui-btn` 0.5, `.ui-icon-btn` 0.4, `.ui-control` 0.55, `.ui-switch` 0.6,
	   `.ui-menu-item` 0.5, `.ui-option` 0.35, `.ui-segmented-btn` 0.5. The
	   sharpest case is the last pair: § Menu argues that `.ui-option` IS
	   `.ui-menu-item` in a different context, and the two dimmed 0.15 apart.

	   0.5 is the plurality (four of the seven) and is what those four now
	   read. THE OTHER THREE ARE STILL LITERALS. Converging them is a VISIBLE
	   change to `.ui-icon-btn`, `.ui-control` and `.ui-switch` in every
	   product, so — exactly like `--ui-tap-target`'s adoption — it is a
	   decision with a before/after rather than a token rename, and each of the
	   three carries a comment saying so at its site. See DECISIONS.md
	   § Design system.

	   CURSOR IS SETTLED, THOUGH, AND IT WAS FREE: every disabled rule says
	   `cursor: not-allowed` now, where it used to say `not-allowed`, `default`
	   or nothing. Five of the seven also set `pointer-events: none`, which
	   makes the element invisible to hit-testing and the `cursor` declaration
	   inert — the pointer takes its shape from whatever is underneath — so
	   agreeing on the wording there changed nothing on screen. The two that do
	   NOT suppress pointer events (`.ui-switch`, `.ui-segmented-btn`) were
	   already `not-allowed`. */
	--ui-disabled-opacity: 0.5;

	/* ── The phone breakpoint — ONE PAIR, WRITTEN OUT ─────────────────────
	   THE ONLY two width queries this package may write, in either sheet:

	       @media (width <  48rem)   the phone half
	       @media (width >= 48rem)   everything wider

	   `48rem` is 768 px at a default-sized root. The pair is exhaustive and
	   disjoint by construction — every viewport matches exactly one arm — so
	   nothing falls in a hole between them and nothing matches both.

	   IT IS A LITERAL BECAUSE IT HAS TO BE. A custom property cannot be read
	   inside a media query: the query is evaluated before there is an element
	   whose cascade could supply a value. So there is no token to reach for
	   here and no way to make this DRY — repetition is the only implementation
	   available, and keeping the repetitions equal is therefore a TEST rather
	   than a token. `tokens.test.ts` § "one phone breakpoint, written one way"
	   reads every width query out of BOTH sheets and fails on anything that is
	   not this pair or an explicitly allowlisted breakpoint of its own.

	   That test exists because the number was written FOUR ways for one
	   breakpoint (BUG-034): `max-width: 47.99rem` swapped the navbar to its
	   hamburger, `max-width: 48rem` hid `.ui-hide-sm`, `min-width: 48.0625rem`
	   hid `.ui-show-sm`, and `site-chrome.css` — the OTHER half of that same
	   navbar — used `max-width: 767px` / `min-width: 768px`. The px/rem split
	   is the one that bites: a media query's `rem` resolves against the
	   BROWSER's default font size, not the page's, so a visitor who has set a
	   20 px default collapsed the navbar at ~959.8 px while `.navbar-actions`
	   kept its horizontal layout until 767 px — a ~190 px band in which the
	   hamburger panel is open and the action cluster inside it is still a row.
	   `site-chrome.js` says outright that it depends on the two sheets
	   agreeing about where that panel appears.

	   A component with a genuinely different threshold (`.ui-drawer` goes
	   full-bleed at `30rem`, which is "a phone in portrait" rather than
	   "narrow enough to collapse the nav") names it in the allowlist beside
	   the test. Do not add one to dodge a layout problem at 48rem. */

	/* ── Type scale ───────────────────────────────────────────────────────*/
	--ui-text-2xs: calc(var(--ui-font-size) * 0.7);
	--ui-text-xs:  calc(var(--ui-font-size) * 0.75);
	--ui-text-sm:  calc(var(--ui-font-size) * 0.875);
	--ui-text-md:  var(--ui-font-size);
	--ui-text-lg:  calc(var(--ui-font-size) * 1.125);
	--ui-text-xl:  calc(var(--ui-font-size) * 1.375);
	--ui-text-2xl: calc(var(--ui-font-size) * 1.75);
	--ui-text-3xl: calc(var(--ui-font-size) * 2.25);
	--ui-text-4xl: calc(var(--ui-font-size) * 3);
	--ui-text-5xl: calc(var(--ui-font-size) * 3.75);

	/* ── Relative type scale ──────────────────────────────────────────────
	   Sized against the *inherited* size rather than the root, so a caption
	   inside a card that already shrank shrinks with it. Same ladder names as
	   the absolute scale, same anchor (`md` is 1×). Reach for these — never a
	   bare `0.85em` — wherever a part must track its container. */
	--ui-text-rel-4xs: 0.7em;
	--ui-text-rel-3xs: 0.75em;
	--ui-text-rel-2xs: 0.8em;
	--ui-text-rel-xs:  0.85em;
	--ui-text-rel-sm:  0.9em;
	--ui-text-rel-md:  1em;
	--ui-text-rel-lg:  1.15em;
	--ui-text-rel-xl:  1.4em;
	--ui-text-rel-2xl: 1.7em;
	--ui-text-rel-3xl: 2em;
	--ui-text-rel-4xl: 3em;
	--ui-text-rel-5xl: 5em;

	/* Fractions of a display number. A KPI value and the caption beneath it are
	   one type object: the caption is sized as a ratio of the value, not of the
	   page, so it keeps its proportion as the tile grows. Reach for these only
	   inside such a pairing — everywhere else the ladder above is the answer. */
	--ui-text-ratio-half:  0.5em;
	--ui-text-ratio-third: 0.35em;

	/* ── Type, SEMANTIC — reach for these first ────────────────────────────
	   Body copy has exactly THREE sizes, named for what they are rather than
	   for where they sit on a ladder:

	       small    a caption, a hint, a meta line, a chip
	       normal   body copy, a control's label, a table cell — the default
	       large    a lead-in, a callout, the one line that should be read
	                before the ones around it

	   plus the heading levels below, which are the one sanctioned exception
	   (a document outline genuinely has levels, and `<h1>`–`<h4>` need to
	   differ from one another).

	   `-rel-` twins size against the INHERITED size, for a part that must
	   track a container that already shrank; everything in the app shell's
	   chrome is one of those. Same three names, same anchor.

	   The `2xs…5xl` ladders above remain — display type, hero numbers and
	   the rare in-between still need them — but a call site reaching past
	   these three for ordinary copy should have a reason it can state. Four
	   near-identical stops (`.8em`, `.85em`, `.9em`, `.92em`) is what the
	   ladder was meant to prevent and, once there were twelve rungs, is what
	   it quietly enabled instead. */
	--ui-text-small:  var(--ui-text-sm);
	--ui-text-normal: var(--ui-text-md);
	--ui-text-large:  var(--ui-text-lg);

	--ui-text-rel-small:  var(--ui-text-rel-xs);
	--ui-text-rel-normal: var(--ui-text-rel-md);
	--ui-text-rel-large:  var(--ui-text-rel-lg);

	/* Heading levels — the exception to "three sizes". A document outline
	   really does have levels, so `h1`–`h6` each get a name.

	   THE TOKEN IS WHAT THE ELEMENT SHIPS. § 3 sets every heading's
	   `font-size` FROM the token beside it — `h2 { font-size:
	   var(--ui-text-h2); }` — so a card title written `var(--ui-text-h2)` is
	   the same size as the `<h2>` next to it BY CONSTRUCTION. That is the
	   whole reason the semantic set exists, and it is not something the two
	   halves can be trusted to keep by hand: for the life of these tokens each
	   one was exactly ONE RUNG BELOW the element it is named for (`-h1` was
	   `2xl` against `h1`'s `3xl`, and so on down), while README and
	   COMPONENTS.md both presented them as the sanctioned way to size a
	   heading. Nothing in the workspace read one, so nothing noticed (BUG-033).
	   `tokens.test.ts` § "every heading token is the size its element ships"
	   now compares the two lists in both directions.

	   All SIX levels, not four. The earlier comment here claimed `h5`/`h6`
	   were "deliberately absent — below `h4` a heading is a `.ui-label`",
	   which was never true of the stylesheet: § 3 has styled `h5` and `h6`
	   since the file was written, so the missing tokens made those two levels
	   the only ones a consumer could not name. Removing the *rules* would have
	   been a visible change to every product's document copy; naming the sizes
	   they already ship is not.

	   The phone override lives on these tokens too — see § 5's
	   `width < 48rem` block, which reassigns `-h1`/`-h2` rather than
	   restyling the elements, so a consumer's heading-sized text shrinks with
	   the real headings instead of drifting past them below the breakpoint. */
	--ui-text-h1: var(--ui-text-3xl);
	--ui-text-h2: var(--ui-text-2xl);
	--ui-text-h3: var(--ui-text-xl);
	--ui-text-h4: var(--ui-text-lg);
	--ui-text-h5: var(--ui-text-md);
	--ui-text-h6: var(--ui-text-sm);

	/* ── Weight ladder ────────────────────────────────────────────────────
	   Five stops and no more. A sixth only lets two components disagree by
	   50 and call it a design. `strong` is the heaviest the system draws —
	   heavier than that is shout, not hierarchy. */
	--ui-weight-normal:   400;
	--ui-weight-medium:   500;
	--ui-weight-semibold: 550;
	--ui-weight-bold:     600;
	--ui-weight-strong:   650;

	/* ── Leading ──────────────────────────────────────────────────────────
	   `--ui-line-height` is body copy; these are the deliberate departures
	   from it — chrome and headings tighten, prose relaxes. */
	--ui-leading-none:    1;
	--ui-leading-tight:   1.2;
	--ui-leading-snug:    1.3;
	--ui-leading-normal:  1.4;
	--ui-leading-loose:   1.5;
	--ui-leading-body:    var(--ui-line-height);
	--ui-leading-relaxed: 1.6;
	/* Deliberately tall line box — inline chips wrapping inside a text field
	   need the room, and the row rhythm comes from the leading, not padding. */
	--ui-leading-double:  2;

	/* ── Tracking ─────────────────────────────────────────────────────────
	   Big type reads loose without negative tracking; small uppercase labels
	   read cramped without positive tracking. Everything else is `normal`. */
	--ui-tracking-tighter: -0.02em;
	--ui-tracking-tight:   -0.015em;
	--ui-tracking-snug:    -0.01em;
	--ui-tracking-normal:  0;
	--ui-tracking-wide:    0.04em;
	--ui-tracking-wider:   0.06em;
	--ui-tracking-widest:  0.08em;

	/* ── Elevation ────────────────────────────────────────────────────────
	   Restrained in light; in dark a shadow is nearly invisible, so the raised
	   surface colour and border carry the separation and the shadow only
	   deepens. */
	--ui-shadow-sm: 0 1px 2px light-dark(rgba(16, 24, 40, 0.06), rgba(0, 0, 0, 0.4));
	--ui-shadow-md: 0 2px 4px -1px light-dark(rgba(16, 24, 40, 0.06), rgba(0, 0, 0, 0.4)),
	                0 4px 12px -2px light-dark(rgba(16, 24, 40, 0.08), rgba(0, 0, 0, 0.5));
	--ui-shadow-lg: 0 8px 24px -4px light-dark(rgba(16, 24, 40, 0.10), rgba(0, 0, 0, 0.55)),
	                0 2px 6px -2px light-dark(rgba(16, 24, 40, 0.06), rgba(0, 0, 0, 0.4));

	/* One ring definition, so focus looks identical on every control. */
	--ui-ring: 0 0 0 3px var(--ui-accent-ring);

	/* ── Layering ─────────────────────────────────────────────────────────
	   A stacking ORDER, not four arbitrary numbers. The load-bearing rule is
	   `popover > overlay`: you routinely open a menu, a picker or a date
	   dropdown FROM inside a modal, and it has to land on top of the thing
	   that opened it. A single z-index cannot express that, which is how
	   products end up hand-incrementing `1001`, `1102`, `10000` per site and
	   still getting one wrong.

	       sticky    fixed chrome — navbar, sticky table headers
	       overlay   modal scrim + panel, full-screen blocking states
	       popover   menu / dropdown / picker — ALWAYS above an overlay
	       toast     transient acknowledgement — above everything

	   The gaps are wide so a product can slot its own layer between two of
	   these without renumbering. A full-screen state that must outrank even a
	   menu (an auth wall, a fatal error) is the one thing that belongs ABOVE
	   `--ui-z-popover`, and it should say so with a comment where it is set. */
	--ui-z-sticky:  100;
	--ui-z-overlay: 1000;
	--ui-z-popover: 2000;
	--ui-z-toast:   3000;

	/* NESTING is the second axis of the same problem, and it is the one that
	   used to be undefined: a dialog opened FROM a dialog — a confirm raised
	   over a details drawer, a drawer opened from a modal — has to land above
	   the one it came from, and DOM order is not a rule (a panel written into
	   the page body outranks one appended at open time, or does not, depending
	   on where the author happened to put it).

	   So an overlay's layer is `--ui-z-overlay` plus its DEPTH in the open
	   stack, one `--ui-z-overlay-step` per level. Depth 0 — the default, and
	   what every existing call site keeps — is exactly `--ui-z-overlay`, so
	   nothing moves until something nests. The step is deliberately small
	   against the 1000-wide gap to `--ui-z-popover`: a menu opened from inside
	   the DEEPEST realistic dialog is still above it.

	   `--ui-overlay-depth` is set by the behaviour that owns the stack
	   (`@hrayo/foundation-ui-drawer`), as a custom property through the CSSOM —
	   never a typed `z-index`, which is what hand-incrementing looks like when
	   a script does it. */
	--ui-z-overlay-step: 10;

	/* Overlay scrims. `--ui-scrim` is what a modal dims the page with;
	   `--ui-scrim-light` suits a popup that should not darken the whole screen.
	   Tokens rather than a literal inside `dialog::backdrop`, because an app
	   with its own overlay needs the same value and would otherwise invent one
	   that drifts. */
	--ui-scrim:       light-dark(rgba(16, 24, 40, 0.40), rgba(0, 0, 0, 0.60));
	--ui-scrim-light: light-dark(rgba(16, 24, 40, 0.12), rgba(0, 0, 0, 0.35));
}

/* Forcing a theme flips `color-scheme`, and every `light-dark()` above
   re-resolves. No token is repeated for dark. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* The two display sizes step down on a phone — the only tokens that are
   responsive, and the reason the heading levels are tokens at all.

   THIS REASSIGNS THE TOKEN, IT DOES NOT RESTYLE THE ELEMENT. § 5 used to carry
   `h1 { font-size: var(--ui-text-2xl); }` here instead, which made the phone a
   private repeat of BUG-033: below the breakpoint `<h1>` shrank a rung and
   `var(--ui-text-h1)` did not, so a card title sized from the token came out
   BIGGER than the real heading beside it. Sizing the token instead keeps the
   promise the semantic set is for — the token is the size the element ships,
   at every width — and carries it to the consumers too.

   It is also why this block is in § 2 and not in § 5 with the utility it
   replaced: a declaration in the tokens layer must be a custom property (a
   migrating app loads `tokens.css` beside its outgoing framework, and
   `layers.test.ts` enforces it), and `h1 { … }` was never one.

   The query is the house pair; see § 1, "The phone breakpoint". */
@media (width < 48rem) {
	:root {
		--ui-text-h1: var(--ui-text-2xl);
		--ui-text-h2: var(--ui-text-xl);
	}
}


/* ══════════════════════════════════════════════════════════════════════════
   3. BASE — plain HTML should already look right, with no classes at all.
   ══════════════════════════════════════════════════════════════════════════ */

html {
	/* Not a size — the deliberate refusal to pick one. `100%` is whatever the
	   reader set as their browser default, which `--ui-font-size` (1rem) then
	   inherits. A number here would override that and break zoom preferences,
	   so this stays literal; every other size in the sheet is a token. */
	font-size: 100%;
	-webkit-tap-highlight-color: transparent;
}

body {
	background: var(--ui-body-background);
	color: var(--ui-text);
	font-family: var(--ui-font-sans);
	font-size: var(--ui-text-md);
	line-height: var(--ui-line-height);
}

::selection {
	background: color-mix(in oklab, var(--ui-accent) 28%, transparent);
}

/* One focus treatment for the whole system. `:focus-visible` rather than
   `:focus` so a mouse click does not leave a ring behind, while keyboard and
   assistive navigation always do. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--ui-accent);
	outline-offset: 2px;
	border-radius: var(--ui-radius-sm);
}

/* ── Headings ─────────────────────────────────────────────────────────────
   A single scale, generous space above and tight below, so a heading binds to
   the text it introduces rather than floating between blocks.

   Every `font-size` here reads its `--ui-text-h*` token rather than a ladder
   rung, which is what makes the token an accurate description of the element
   instead of a parallel opinion about it (BUG-033). Only the SIZE is
   tokenised: the tracking and `h6`'s muted colour are treatments of the
   element, not of "heading-sized text", so a `.ui-card-title` opting into
   `var(--ui-text-h3)` gets the size and keeps its own colour. */
h1, h2, h3, h4, h5, h6 {
	font-weight: var(--ui-weight-strong);
	line-height: var(--ui-leading-tight);
	letter-spacing: var(--ui-tracking-snug);
	margin-block: var(--ui-space-8) var(--ui-space-3);
}
h1 { font-size: var(--ui-text-h1); letter-spacing: var(--ui-tracking-tighter); }
h2 { font-size: var(--ui-text-h2); letter-spacing: var(--ui-tracking-tight); }
h3 { font-size: var(--ui-text-h3); }
h4 { font-size: var(--ui-text-h4); }
h5 { font-size: var(--ui-text-h5); }
h6 { font-size: var(--ui-text-h6); letter-spacing: var(--ui-tracking-wider); color: var(--ui-text-muted); }

/* Nothing should push the first element of a container away from its top. */
:where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, pre, blockquote, table, figure):first-child {
	margin-block-start: 0;
}
:where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, pre, blockquote, table, figure):last-child {
	margin-block-end: 0;
}

/* ── Text ────────────────────────────────────────────────────────────────*/
p {
	margin-block: 0 var(--ui-space-4);
}

small { font-size: var(--ui-text-sm); }

strong, b { font-weight: var(--ui-weight-strong); }

/* Underlining a link is the browser's answer to "how do I know it is a link?".
   Ours is colour plus a hover underline: quieter in running text, and still
   discoverable. Links inside prose get the underline back (see `.ui-prose`),
   where colour alone would not be enough of a signal. */
a {
	color: var(--ui-accent-text);
	text-decoration: none;
	transition: color var(--ui-transition);
}
a:hover {
	color: var(--ui-accent-hover);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

abbr[title] {
	text-decoration: underline dotted;
	text-underline-offset: 0.2em;
	cursor: help;
}

mark {
	background: color-mix(in oklab, var(--ui-warning) 30%, transparent);
	color: inherit;
	padding: 0.05em 0.2em;
	border-radius: var(--ui-radius-sm);
}

del { color: var(--ui-text-muted); }
ins { text-decoration: none; background: var(--ui-success-soft); }

/* `line-height: 0` is not a leading value — it is the standard trick that stops
   a raised/lowered glyph from growing the line box it sits in. */
sub, sup { font-size: var(--ui-text-rel-3xs); line-height: 0; }

hr {
	border: none;
	border-top: 1px solid var(--ui-border);
	margin-block: var(--ui-space-8);
}

blockquote {
	margin-block: var(--ui-space-4);
	padding-inline-start: var(--ui-space-4);
	border-inline-start: 3px solid var(--ui-border-strong);
	color: var(--ui-text-muted);
}

address { font-style: normal; }

/* ── Lists ───────────────────────────────────────────────────────────────
   `reset.css` strips markers because most lists in an application are
   navigation. Restore them wherever a list carries prose. */
:where(ul, ol):not([class]) {
	list-style: revert;
	padding-inline-start: var(--ui-space-6);
	margin-block: 0 var(--ui-space-4);
}
:where(ul, ol):not([class]) li { margin-block: var(--ui-space-1); }
:where(ul, ol):not([class]) :where(ul, ol) { margin-block: var(--ui-space-1); }

dl { margin-block: 0 var(--ui-space-4); }
dt { font-weight: var(--ui-weight-strong); }
dd { margin-inline-start: var(--ui-space-6); margin-block-end: var(--ui-space-2); }

/* ── Code ────────────────────────────────────────────────────────────────*/
code, kbd, samp, pre {
	font-family: var(--ui-font-mono);
	/* Normalised so a code span does not change the line's height as the font
	   stack degrades — JetBrains Mono runs wider than the platform fallbacks. */
	font-size: var(--ui-text-rel-sm);
	/* Ligatures in code are a personal preference and a legibility risk in
	   identifiers (`!=` rendering as one glyph); off by default. */
	font-variant-ligatures: none;
}

code {
	background: var(--ui-surface-sunken);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-sm);
	padding: 0.1em 0.35em;
}

pre {
	background: var(--ui-surface-sunken);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-md);
	padding: var(--ui-space-4);
	margin-block: 0 var(--ui-space-4);
	overflow-x: auto;
	line-height: var(--ui-leading-loose);
}
/* A code span inside a block is already on the block's surface. */
pre code {
	background: none;
	border: none;
	padding: 0;
	font-size: var(--ui-text-sm);
}

kbd {
	background: var(--ui-surface-raised);
	border: 1px solid var(--ui-border-strong);
	border-bottom-width: 2px;
	border-radius: var(--ui-radius-sm);
	padding: 0.1em 0.4em;
	font-size: var(--ui-text-rel-xs);
	white-space: nowrap;
}

/* ── Tables ──────────────────────────────────────────────────────────────*/
table {
	width: 100%;
	margin-block: 0 var(--ui-space-4);
	font-size: var(--ui-text-sm);
}
/* A table is the one element that routinely outgrows its column, and the fix
   is a wrapper rather than `overflow` on the table itself: `overflow-x` needs
   `display: block`, which drops table layout — `width: 100%` stops filling and
   columns stop aligning. Wrap it instead.

       <div class="ui-table-scroll"><table>…</table></div> */
.ui-table-scroll {
	overflow-x: auto;
	margin-block: 0 var(--ui-space-4);
	scrollbar-width: thin;
}
.ui-table-scroll > table { margin-block: 0; }

caption {
	text-align: start;
	color: var(--ui-text-muted);
	font-size: var(--ui-text-sm);
	padding-block-end: var(--ui-space-2);
}

th, td {
	padding: var(--ui-space-2) var(--ui-space-3);
	text-align: start;
	border-bottom: 1px solid var(--ui-border);
	vertical-align: top;
}
thead th {
	background: var(--ui-surface-sunken);
	font-weight: var(--ui-weight-bold);
	color: var(--ui-text-muted);
	white-space: nowrap;
}
/* Opt-in, because a sticky header only makes sense when the table scrolls
   inside something — applied globally it pins the header to the viewport on
   ordinary page-length tables, which reads as a bug. */
 /* Within its own scroll container, not the page — so `z-index: 1`, not the
    sticky token. The background is not optional: a sticky cell paints over the
    rows passing under it only if it HAS one. */
.ui-table-sticky thead th { position: sticky; top: 0; z-index: 1; background: var(--ui-surface-hover); }
tbody tr:last-child > * { border-bottom: none; }
tfoot td { font-weight: var(--ui-weight-bold); }

/* ── Forms ───────────────────────────────────────────────────────────────
   Styled on the element, so a plain `<form>` with no classes already matches
   the rest of the system. `.ui-input` etc. exist for elements that cannot be
   the real tag (a contenteditable div, a custom control). */
label { display: inline-block; font-weight: var(--ui-weight-semibold); font-size: var(--ui-text-sm); }

/* Type is INHERITED, not anchored to the root (UX-033). A form control belongs
   to the same family as `.ui-control`, whose whole reason for existing is that
   it "sits in a column of `<select>`s and `<input>`s that it has to line up
   with to the pixel" — and that one says `font: inherit`. While this one said
   `--ui-text-md`, the two disagreed the moment they landed in a host that
   states its own type context (§ Scales: "a dense surface states its type
   context ONCE, on the container"): engeene's Explore sidebar painted its
   `<select>`s and `<input>`s at 16px beside 14px buttons, pickers and labels,
   and the products then papered over it with per-leaf `font-size` overrides.
   On a page whose controls sit at the document's own size this is a no-op —
   `inherit` from `body` IS `--ui-text-md`. */
input, textarea, select, .ui-input {
	background: var(--ui-surface);
	color: var(--ui-text);
	border: 1px solid var(--ui-border-strong);
	border-radius: var(--ui-radius-md);
	padding: var(--ui-space-2) var(--ui-space-3);
	font-family: inherit;
	font-size: inherit;
	line-height: var(--ui-leading-normal);
	width: 100%;
	max-width: 100%;
	transition: border-color var(--ui-transition), box-shadow var(--ui-transition);
}

/* Controls that are not text boxes must not be stretched to full width. */
input[type="checkbox"], input[type="radio"], input[type="range"],
input[type="color"], input[type="file"], input[type="image"],
input[type="button"], input[type="submit"], input[type="reset"] {
	width: auto;
}

input:focus, textarea:focus, select:focus, .ui-input:focus, .ui-input:focus-within {
	outline: none;
	border-color: var(--ui-accent);
	box-shadow: var(--ui-ring);
}

input::placeholder, textarea::placeholder { color: var(--ui-text-subtle); }

input:disabled, textarea:disabled, select:disabled,
input[readonly], textarea[readonly] {
	background: var(--ui-surface-sunken);
	color: var(--ui-text-muted);
	cursor: not-allowed;
}

/* A field the application has marked invalid. `:user-invalid` rather than
   `:invalid` so an empty required field is not red before it is ever typed in. */
input:user-invalid, textarea:user-invalid, select:user-invalid,
[aria-invalid="true"] {
	border-color: var(--ui-danger);
}
:where(input, textarea, select):user-invalid:focus, [aria-invalid="true"]:focus {
	box-shadow: 0 0 0 3px var(--ui-danger-soft);
}

textarea { min-height: var(--ui-space-20); }

select {
	/* The native arrow is drawn in the platform's own colour and ignores the
	   theme, so draw our own and leave room for it. */
	appearance: none;
	padding-inline-end: var(--ui-space-8);
	background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
	                  linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: right var(--ui-space-4) center, right calc(var(--ui-space-4) - 4px) center;
	background-size: 4px 4px, 4px 4px;
	background-repeat: no-repeat;
	cursor: pointer;
}
select[multiple], select[size]:not([size="1"]) {
	appearance: auto;
	background-image: none;
	padding-inline-end: var(--ui-space-3);
}

/* Native checkbox/radio, tinted by the accent. `accent-color` keeps the
   platform's own control — its focus behaviour, its high-contrast handling,
   its animation — which a hand-rolled replacement always loses. */
input[type="checkbox"], input[type="radio"] {
	accent-color: var(--ui-accent);
	width: 1em;
	height: 1em;
	cursor: pointer;
}
input[type="range"] { accent-color: var(--ui-accent); cursor: pointer; }
progress { accent-color: var(--ui-accent); }

input[type="file"] {
	padding: var(--ui-space-2);
	cursor: pointer;
}
input[type="file"]::file-selector-button {
	font: inherit;
	margin-inline-end: var(--ui-space-3);
	padding: var(--ui-space-1) var(--ui-space-3);
	border: 1px solid var(--ui-border-strong);
	border-radius: var(--ui-radius-sm);
	background: var(--ui-surface-raised);
	color: var(--ui-text);
	cursor: pointer;
}

fieldset { margin-block: 0 var(--ui-space-4); }
legend {
	font-weight: var(--ui-weight-strong);
	font-size: var(--ui-text-sm);
	color: var(--ui-text-muted);
	padding-block-end: var(--ui-space-2);
}

/* ── Details / summary ───────────────────────────────────────────────────*/
details {
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-md);
	padding: var(--ui-space-3) var(--ui-space-4);
	margin-block: 0 var(--ui-space-3);
	background: var(--ui-surface-raised);
}
summary {
	font-weight: var(--ui-weight-semibold);
	list-style: none;
	display: flex;
	align-items: center;
	gap: var(--ui-space-2);
}
summary::-webkit-details-marker { display: none; }
/* Our own marker, so it is the theme's colour and rotates on open. */
summary::before {
	content: "";
	width: 0;
	height: 0;
	border-inline-start: 5px solid currentColor;
	border-block: 4px solid transparent;
	color: var(--ui-text-subtle);
	transition: transform var(--ui-transition);
	flex: none;
}
details[open] > summary::before { transform: rotate(90deg); }
details[open] > summary { margin-block-end: var(--ui-space-3); }

/* ── Media ───────────────────────────────────────────────────────────────*/
figure { margin-block: 0 var(--ui-space-4); }
figcaption {
	color: var(--ui-text-muted);
	font-size: var(--ui-text-sm);
	padding-block-start: var(--ui-space-2);
}

/* An SVG used as an icon should follow the text it sits beside. */
svg { fill: currentColor; }

/* ── Dialog ──────────────────────────────────────────────────────────────
   The native element, so focus trapping, Escape, inertness and the top layer
   come from the browser instead of from a script. */
dialog {
	background: var(--ui-surface-raised);
	color: var(--ui-text);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-lg);
	box-shadow: var(--ui-shadow-lg);
	padding: var(--ui-space-6);
	max-width: min(32rem, calc(100vw - var(--ui-space-8)));
	/* `dvh`, not `vh`: on a phone `100vh` is the viewport WITHOUT the retracted
	   browser chrome, so a `vh`-capped dialog is taller than what is on screen and
	   its header/footer sit off it. `dvh` tracks the visible viewport. */
	max-height: calc(100dvh - var(--ui-space-16));
	overflow: auto;
}
dialog::backdrop {
	background: var(--ui-scrim);
	backdrop-filter: blur(2px);
}


/* ══════════════════════════════════════════════════════════════════════════
   4. COMPONENTS — one class each, composable, no framework required.

   ── No all-caps, anywhere ─────────────────────────────────────────────
   No component upper-cases TEXT, and a label must not reintroduce
   `text-transform: uppercase`. Three reasons, in order of weight:

     * It destroys information in the languages we ship. Our products are
       translated (engeene runs en + cs), and upper-casing is not a reversible
       or even well-defined transform everywhere — German ß, Turkish dotted/
       dotless i, and scripts with no case at all all come out wrong or
       unchanged-but-inconsistent.
     * A label is already legible AS a label from size, weight, letter-spacing
       and colour. The capitals add nothing those four do not.
     * ALL-CAPS text is measurably slower to read: it removes the word-shape
       cue readers use, and screen readers may spell it out letter by letter.

   engeene states this as a product rule and overrides its old CSS framework
   to enforce it; the shared system simply never creates the problem.

   The single exception is `.ui-avatar`, which upper-cases INITIALS — two
   letters standing in for a name, carrying no linguistic content and never
   translated. `layers.test.ts` allows that one and rejects any other.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Button ──────────────────────────────────────────────────────────────
   `.ui-btn` is the neutral (secondary) button. A variant class recolours it;
   nothing else about it changes, so the sizes and states are written once.

   A variant names its label colour through `--ui-btn-color` rather than
   declaring `color` itself, and every state resolves that one property. That
   is not indirection for its own sake — it is what makes the button survive
   being an ANCHOR. `<a class="ui-btn ui-btn-primary">` ("Get Started") is a
   button to a reader and a link to the cascade, and the document-level
   `a:hover` (specificity 0,1,1) outranks `.ui-btn-primary` (0,1,0): on hover
   the label was repainted in the accent, on a fill the same hover had just
   painted the accent, and the text vanished. With one `color` declaration on
   `.ui-btn:hover` (0,2,0) every variant keeps its own contrast, and a new
   variant gets that for free by setting the property — which is the failure
   mode worth designing out, since a variant that forgets to restate `color`
   at hover is unreadable rather than merely off-palette. `.ui-nav-link`,
   `.ui-tab`, `.ui-menu-item`, `.ui-option`, `.ui-navbar-brand`,
   `.ui-card-link` and `.ui-icon-btn` answer the same cascade by restating
   their colour at hover; the button has too many variants for that to stay
   true by hand. */
.ui-btn {
	--ui-btn-color: var(--ui-text);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--ui-space-2);
	padding: var(--ui-space-2) var(--ui-space-4);
	border: 1px solid var(--ui-border-strong);
	border-radius: var(--ui-radius-md);
	background: var(--ui-surface-raised);
	color: var(--ui-btn-color);
	font-family: inherit;
	font-size: var(--ui-text-sm);
	font-weight: var(--ui-weight-semibold);
	line-height: var(--ui-leading-normal);
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	user-select: none;
	transition: background var(--ui-transition), border-color var(--ui-transition),
	            color var(--ui-transition);
}
/* A button's hover is ACCENT-tinted, unlike a menu row's, which is neutral.
   That is not an inconsistency — it follows from the same rule. A menu row has a
   persistent SELECTED state (also accent), so its hover must be neutral or the
   two become one muddy state. A button has no selected state to collide with,
   so the accent is free, and it is the stronger "this is interactive" signal. */
.ui-btn:hover {
	background: var(--ui-accent-soft);
	border-color: var(--ui-accent-border);
	/* Re-asserting the variant's own colour at (0,2,0) — see the note above. */
	color: var(--ui-btn-color);
	text-decoration: none;
}
.ui-btn:active { background: var(--ui-surface-sunken); }
.ui-btn:disabled, .ui-btn[aria-disabled="true"] {
	opacity: var(--ui-disabled-opacity);
	cursor: not-allowed;
	pointer-events: none;
}
.ui-btn > svg { width: var(--ui-icon-small); height: var(--ui-icon-small); flex: none; }
.ui-btn > .ph { font-size: var(--ui-icon-small); line-height: var(--ui-leading-none); }
.ui-btn-lg > svg { width: var(--ui-icon-normal); height: var(--ui-icon-normal); }
.ui-btn-lg > .ph { font-size: var(--ui-icon-normal); }

.ui-btn-primary {
	--ui-btn-color: var(--ui-accent-contrast);
	background: var(--ui-accent);
	border-color: var(--ui-accent);
}
.ui-btn-primary:hover { background: var(--ui-accent-hover); border-color: var(--ui-accent-hover); }
.ui-btn-primary:active { background: var(--ui-accent-active); border-color: var(--ui-accent-active); }

.ui-btn-danger {
	--ui-btn-color: #fff;
	background: var(--ui-danger);
	border-color: var(--ui-danger);
}
.ui-btn-danger:hover { background: var(--ui-danger-hover); }

/* No border, no fill — for toolbars and icon rows where a box per action would
   be noise. */
.ui-btn-ghost {
	--ui-btn-color: var(--ui-text-muted);
	background: transparent;
	border-color: transparent;
}
.ui-btn-ghost:hover { --ui-btn-color: var(--ui-accent-text); background: var(--ui-accent-soft); border-color: transparent; }

/* Reads as a link, behaves as a button. */
.ui-btn-link {
	--ui-btn-color: var(--ui-accent-text);
	background: transparent;
	border-color: transparent;
	padding-inline: 0;
}
.ui-btn-link:hover { background: transparent; text-decoration: underline; text-underline-offset: 0.15em; }

.ui-btn-sm { padding: var(--ui-space-1) var(--ui-space-3); font-size: var(--ui-text-xs); }
.ui-btn-lg { padding: var(--ui-space-3) var(--ui-space-6); font-size: var(--ui-text-md); }

/* Square, for a single glyph. */
.ui-btn-icon { padding: var(--ui-space-2); aspect-ratio: 1; }
.ui-btn-icon.ui-btn-sm { padding: var(--ui-space-1); }

.ui-btn-block { display: flex; width: 100%; }

/* Buttons welded into one control. */
.ui-btn-group { display: inline-flex; }
.ui-btn-group > .ui-btn { border-radius: 0; margin-inline-start: -1px; }
.ui-btn-group > .ui-btn:first-child {
	border-start-start-radius: var(--ui-radius-md);
	border-end-start-radius: var(--ui-radius-md);
	margin-inline-start: 0;
}
.ui-btn-group > .ui-btn:last-child {
	border-start-end-radius: var(--ui-radius-md);
	border-end-end-radius: var(--ui-radius-md);
}
.ui-btn-group > .ui-btn:hover, .ui-btn-group > .ui-btn:focus-visible { z-index: 1; }

/* ── Icon button ─────────────────────────────────────────────────────────
   The small, chrome-less glyph action that lives INSIDE another thing — the
   trash on a list row, the pencil on a field, the "⋮" on a card, the × on a
   popup header. It is not `.ui-btn-icon`: that is a `.ui-btn` (a box with a
   border and a fill) constrained to a square, and a row carrying three of them
   reads as a row of boxes. This one has no box at all until it is pointed at.

       <button class="ui-icon-btn ui-icon-btn-danger" aria-label="Remove">
         <i class="ph ph-trash" aria-hidden="true"></i>
       </button>

   Every product had reinvented it — engeene's app shell alone carried THIRTEEN
   near-copies (remove / action / menu / filter / close / quick / category /
   property / description / saved-filter …), each re-typing the same six
   declarations and then disagreeing about the hover: some tinted accent, some
   danger, some only the text, some only the background. So the TONE is the
   variant and the geometry is a token:

     `-accent`  an ordinary action (open a menu, edit, sort)
     `-danger`  a destructive one (remove, delete) — the default is neutral
     `-quiet`   half-visible until pointed at, for a button that would be
                clutter at rest. A row that reveals its actions on ITS hover
                adds one rule at the call site (`.row:hover > .ui-icon-btn`),
                or uses `.ui-row-actions`, which already does exactly that.

   **The geometry is the component's, not the call site's.** `--ui-icon-btn-size`
   is the tappable BOX and `--ui-icon-btn-glyph` the glyph inside it, both
   defaulted here from the shared icon scale — a call site does not set a
   `font-size` on one. That is what the box was for: thirteen copies each
   picked their own 13/14/16 px glyph, so no two rows of actions lined up.

   The box is 1.75rem (28 px) against a 1.25rem (20 px) glyph, which clears
   WCAG 2.2 SC 2.5.8's 24 × 24 CSS-px minimum target with the padding to
   spare; on a COARSE pointer it opens to `--ui-tap-target` (2.75rem / 44 px,
   Apple's HIG minimum), since a fingertip is not a cursor. Nothing about the
   glyph changes — only the room around it. The rows and buttons follow it as a
   minimum height (§ Touch); this is the one that grows its WIDTH too.

   `-sm` (a 24 px box / 16 px glyph) exists for a genuinely dense row and is
   still at the accessibility floor; there is no smaller variant on purpose. */
.ui-icon-btn {
	--ui-icon-btn-size: 1.75rem;
	--ui-icon-btn-glyph: var(--ui-icon-normal);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: var(--ui-icon-btn-size);
	height: var(--ui-icon-btn-size);
	padding: 0;
	border: none;
	background: none;
	border-radius: var(--ui-radius-sm);
	color: var(--ui-text-muted);
	font-family: inherit;
	font-size: var(--ui-icon-btn-glyph);
	line-height: var(--ui-leading-none);
	cursor: pointer;
	transition: color var(--ui-transition), background var(--ui-transition),
	            opacity var(--ui-transition);
}
/* The glyph inherits the box's `font-size`; an `<svg>` has to be told. */
.ui-icon-btn > svg { width: 1em; height: 1em; flex: none; }
.ui-icon-btn-sm {
	--ui-icon-btn-size: 1.5rem;
	--ui-icon-btn-glyph: var(--ui-icon-small);
}
/* Last, so it beats `-sm`'s denser box above — a fingertip is not a cursor, and
   the dense variant is the one that most needs the room. */
@media (pointer: coarse) {
	.ui-icon-btn, .ui-icon-btn-sm { --ui-icon-btn-size: var(--ui-tap-target); }
}
.ui-icon-btn:hover { color: var(--ui-text); background: var(--ui-surface-hover); }
.ui-icon-btn-accent:hover { color: var(--ui-accent-text); background: var(--ui-accent-soft); }
.ui-icon-btn-danger:hover { color: var(--ui-danger-text); background: var(--ui-danger-soft); }
/* A LITERAL, and deliberately not `--ui-disabled-opacity` even though it is the
   same number: "quiet" is a resting state that hovers back to full, and the
   disabled token is free to move without dragging it along. */
.ui-icon-btn-quiet { opacity: 0.5; }
/* `:focus-visible` too, not only `:hover` — a half-visible button a keyboard
   user has landed on is the one case where "quiet" is wrong. */
.ui-icon-btn-quiet:hover, .ui-icon-btn-quiet:focus-visible { opacity: 1; }
/* DEVIANT OPACITY, LEFT AS A LITERAL ON PURPOSE (REF-089). The house figure is
   `--ui-disabled-opacity` (0.5); this fades further, to 0.4. An icon button is
   a bare glyph with no label and no fill to carry the state, so it was tuned
   deeper than a button with words in it. Adopting the token here is a VISIBLE
   change to every product's toolbars — a decision with a before/after, not a
   rename — so it stays until that decision is made. See DECISIONS.md
   § Design system. */
.ui-icon-btn:disabled, .ui-icon-btn[aria-disabled="true"] {
	opacity: 0.4;
	cursor: not-allowed;
	pointer-events: none;
}

/* ── Control ─────────────────────────────────────────────────────────────
   A button that must read as a FORM CONTROL rather than an action: the thing
   that opens a picker and then shows what was picked (a mode selector, a model
   or timezone combobox, a "colour: auto" toggle). It is deliberately not
   `.ui-btn` — a button is centred, shrink-to-fit and accent-tinted on hover,
   whereas this is full-width, start-aligned and sits in a column of `<select>`s
   and `<input>`s that it has to line up with to the pixel.

       <button class="ui-control" aria-expanded="false">
         <span>Aggregate</span><i class="ph ph-caret-down ui-control-caret"></i>
       </button>

   Six of these had been hand-built in one product (the sidebar mode picker, the
   model header inside three different pickers, the chart-type toggle, the
   timezone combobox), which is what promoted it. The hover raises the BORDER
   rather than tinting the fill — the same signal a focused input gives, because
   that is the family it belongs to.

   Height is deliberately NOT set here: a product states its own control density
   once (engeene pins `.ui-control` to its `--control-height` alongside `.ui-btn`
   and the bare form elements) and every control follows. */
.ui-control {
	display: flex;
	align-items: center;
	gap: var(--ui-space-2);
	width: 100%;
	box-sizing: border-box;
	padding-inline: var(--ui-space-3);
	text-align: start;
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-md);
	background: var(--ui-surface-raised);
	color: var(--ui-text);
	font: inherit;
	line-height: var(--ui-leading-tight);
	cursor: pointer;
	transition: border-color var(--ui-transition), background var(--ui-transition);
}
.ui-control:hover { border-color: var(--ui-accent-text); }
/* DEVIANT OPACITY, LEFT AS A LITERAL ON PURPOSE (REF-089). 0.55 against the
   house `--ui-disabled-opacity` of 0.5 — a control shows a VALUE somebody chose
   earlier, and that value still has to be readable when the control is locked,
   which a plain action button has no equivalent of. Adopting the token is a
   visible change; see DECISIONS.md § Design system. */
.ui-control:disabled, .ui-control[aria-disabled="true"] {
	opacity: 0.55;
	cursor: not-allowed;
	pointer-events: none;
}
/* Recessed variant, for a control sitting ON a raised surface (a toolbar, a
   sidebar header) where the default fill would disappear into it. */
.ui-control-sunken { background: var(--ui-surface-sunken); }
/* The trailing caret takes the slack, so the label never has to. It turns over
   from `aria-expanded`, so the glyph and what a screen reader hears cannot
   drift apart. */
.ui-control-caret {
	margin-inline-start: auto;
	flex: none;
	color: var(--ui-text-muted);
	font-size: var(--ui-icon-small);
	transition: transform var(--ui-transition);
}
.ui-control[aria-expanded="true"] .ui-control-caret { transform: rotate(180deg); }
/* A control's LEADING glyph is an icon, so the component owns its size the way
   `.ui-btn` and `.ui-icon-btn` own theirs. Both used to be left to inherit —
   i.e. sized off the TYPE scale, in `em` — which is how the same picker paints
   a 14px glyph in one product's sidebar and a 16px one in the next. */
.ui-control > .ph:not(.ui-control-caret) { font-size: var(--ui-icon-normal); }

/* ── Field ───────────────────────────────────────────────────────────────
   Label, control, hint and error as one block, so forms line up without every
   page inventing its own margins. */
.ui-field {
	display: flex;
	flex-direction: column;
	gap: var(--ui-space-1);
	margin-block-end: var(--ui-space-4);
}
.ui-field > label { color: var(--ui-text); }
.ui-hint { color: var(--ui-text-muted); font-size: var(--ui-text-sm); }

/* The muted paragraph that OPENS a dialog or a section and says what it is for
   — `.ui-hint`'s tone at block level, with the leading a paragraph needs and the
   space below it that separates it from the controls it introduces.

   It is here because it is the single most-repeated inline `style=` in a shell:
   engeene's app carried six copies (five typed out on the `<p>` itself, one under
   a private `.me-modal-intro`), which is a component nobody had got round to
   naming. `.ui-hint` is a field's one-line note and stays a `<span>`-scale thing;
   this is the paragraph above a form. */
.ui-intro {
	margin: 0 0 var(--ui-space-normal);
	color: var(--ui-text-muted);
	font-size: var(--ui-text-rel-small);
	line-height: var(--ui-leading-loose);
}
.ui-error { color: var(--ui-danger-text); font-size: var(--ui-text-sm); }
/* A required marker that does not depend on an asterisk in the copy. */
.ui-field-required > label::after {
	content: " *";
	color: var(--ui-danger-text);
}
/* Checkbox/radio rows read the other way round: control first, label beside. */
/* A HORIZONTAL label + control row, for a column of settings that has to line
   up: the label takes a fixed inline size (`--ui-field-row-label`, override it
   per panel) and the control takes the slack. `ui-field` is the vertical
   block — reach for that first; this is for an operator/settings panel where a
   stack of labels above their controls is twice as tall and reads worse.

       <div class="ui-field-row">
         <label for="cap">Cache size</label>
         <input id="cap" type="number">
         <span class="ui-field-row-hint">Applies on the next restart</span>
       </div> */
.ui-field-row {
	--ui-field-row-label: 8rem;
	display: flex;
	align-items: center;
	gap: var(--ui-space-2);
	flex-wrap: wrap;
}
.ui-field-row > label {
	min-width: var(--ui-field-row-label);
	color: var(--ui-text-muted);
	font-size: var(--ui-text-sm);
	font-weight: var(--ui-weight-medium);
}
.ui-field-row > input, .ui-field-row > select, .ui-field-row > textarea { flex: 1; min-width: 12rem; }
/* Hangs under the control, indented past the label column so it reads as
   belonging to the control rather than starting a new row. */
.ui-field-row-hint {
	width: 100%;
	margin-inline-start: calc(var(--ui-field-row-label) + var(--ui-space-2));
	font-size: var(--ui-text-xs);
	color: var(--ui-text-muted);
}

.ui-choice {
	display: flex;
	align-items: flex-start;
	gap: var(--ui-space-2);
	margin-block: var(--ui-space-2);
}
.ui-choice > input { margin-block-start: 0.25em; flex: none; }
.ui-choice > label { font-weight: var(--ui-weight-normal); font-size: var(--ui-text-md); }

/* ── Swatch ──────────────────────────────────────────────────────────────
   One filled thing's colours — background, border, text — as one control: a
   small rectangle drawn in those colours with a label inside, which opens a
   panel of pickers. A swatch row is the thing's name and one swatch per theme
   on one line. Markup from `swatchRow()` / `swatch()` in `./swatch`.

   The rectangle is painted through three custom properties the swatch script
   writes through the CSSOM (`--ui-swatch-bg`, `--ui-swatch-border`,
   `--ui-swatch-text`), because a server rendering under `style-src 'self'`
   cannot write a `style=` attribute. Before the script runs — or without it —
   they fall back to the theme's neutral surface, or the dark surface for a
   `data-mode="dark"` swatch, and every picker still works.

   It is a bare `<details>`, which the base layer draws as a bordered card with
   a rotating marker; both are taken off here — the rectangle IS the control. */
.ui-swatch-row {
	--ui-swatch-row-label: 12rem;
	flex-direction: row;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ui-space-2) var(--ui-space-3);
}
.ui-swatch-row-label { min-width: var(--ui-swatch-row-label); color: var(--ui-text); }
.ui-swatch-row > .ui-hint { flex-basis: 100%; margin: 0; }
.ui-swatch-set { display: flex; flex-wrap: wrap; gap: var(--ui-space-2); }
.ui-swatch {
	position: relative;
	border: none;
	padding: 0;
	margin: 0;
	background: none;
}
.ui-swatch-sample {
	--ui-swatch-bg: var(--ui-surface-hover);
	--ui-swatch-border: var(--ui-border-strong);
	--ui-swatch-text: var(--ui-text);
	min-width: 5.5rem;
	justify-content: center;
	padding: var(--ui-space-2) var(--ui-space-3);
	border: 1px solid var(--ui-swatch-border);
	border-radius: var(--ui-radius-md);
	background: var(--ui-swatch-bg);
	color: var(--ui-swatch-text);
	font-size: var(--ui-text-sm);
	font-weight: var(--ui-weight-medium);
	cursor: pointer;
}
.ui-swatch[data-mode="dark"] > .ui-swatch-sample {
	--ui-swatch-bg: var(--ui-text);
	--ui-swatch-border: var(--ui-text-muted);
	--ui-swatch-text: var(--ui-surface);
}
.ui-swatch-sample::before { display: none; }
.ui-swatch[open] > .ui-swatch-sample { margin: 0; }
.ui-swatch-sample:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.ui-swatch-panel {
	position: absolute;
	inset-block-start: calc(100% + var(--ui-space-1));
	inset-inline-start: 0;
	min-width: 15rem;
	padding: var(--ui-space-2) var(--ui-space-3);
	display: flex;
	flex-direction: column;
	gap: var(--ui-space-1);
}
.ui-swatch-part {
	display: grid;
	grid-template-columns: 1fr auto auto;
	align-items: center;
	gap: var(--ui-space-2);
}
.ui-swatch-part > label { font-size: var(--ui-text-sm); }
.ui-swatch-part > input[type="color"] { width: 2.5rem; height: 1.75rem; padding: 0; }
.ui-swatch-part > .ui-choice { margin: 0; }
.ui-swatch-part > .ui-choice > label { font-size: var(--ui-text-sm); }

/* ── Switch ──────────────────────────────────────────────────────────────
   A checkbox rendered as a slider — the "turn this on" control. Use it for a
   setting that takes effect immediately; a checkbox that is submitted with a
   form stays `.ui-choice`, because a slider promises an instant effect it does
   not have.

       <label class="ui-switch">
         <input type="checkbox"><span class="ui-switch-slider"></span>
         <span>Show totals</span>
       </label>

   The real `<input>` stays in the DOM — offscreen, NOT `display: none` — so it
   keeps its native focus, keyboard and form semantics, and the slider is
   decoration driven by `:checked` / `:focus-visible` on the sibling. That is the
   whole reason this is worth shipping centrally: every hand-rolled toggle we
   found had either dropped the input (losing keyboard access) or re-implemented
   focus with a `:focus` ring that a mouse click leaves behind.

   Geometry is three custom properties rather than fixed pixels, so a dense
   toolbar can shrink it without forking the component.

   The thumb slides on `transform`, NOT on `inset-inline-start`. Animating an
   inset is animating a layout property: every frame re-runs layout and paint on
   the main thread, and a page with two dozen toggles (engeene's app shell has
   about that many) pays it for each one. A `translate` is composited — the
   thumb is handed to the compositor once and the animation runs off the main
   thread. The thumb already carried `translateY(-50%)` to centre itself, so the
   composited form costs nothing extra: the same transform gains an X term.

   `transform` is physical, `inset-inline-start` is logical, so the X term has to
   flip itself in RTL — that is what `--ui-switch-direction` does. Configure the
   size through the three geometry properties; `--ui-switch-travel` and
   `-direction` are derived and are not knobs. */
.ui-switch {
	--ui-switch-width: 2.25rem;
	--ui-switch-height: 1.25rem;
	/* The thumb's inset from the track, doubled to give its diameter. */
	--ui-switch-inset: 0.1875rem;
	/* Derived: track width less the thumb's diameter-plus-insets (= the height). */
	--ui-switch-travel: calc(var(--ui-switch-width) - var(--ui-switch-height));
	--ui-switch-direction: 1;
	display: inline-flex;
	align-items: center;
	gap: var(--ui-space-2);
	position: relative;
	cursor: pointer;
	user-select: none;
	font-size: var(--ui-text-sm);
	color: var(--ui-text);
}
.ui-switch > input[type="checkbox"] {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	margin: 0;
}
.ui-switch-slider {
	position: relative;
	flex: none;
	width: var(--ui-switch-width);
	height: var(--ui-switch-height);
	border-radius: var(--ui-radius-full);
	background: var(--ui-border-strong);
	transition: background var(--ui-transition);
}
.ui-switch-slider::after {
	content: "";
	position: absolute;
	top: 50%;
	inset-inline-start: var(--ui-switch-inset);
	width: calc(var(--ui-switch-height) - var(--ui-switch-inset) * 2);
	height: calc(var(--ui-switch-height) - var(--ui-switch-inset) * 2);
	border-radius: var(--ui-radius-full);
	background: var(--ui-surface-raised);
	box-shadow: var(--ui-shadow-sm);
	transform: translate(0, -50%);
	transition: transform var(--ui-transition);
}
/* Physical transform, logical start edge: in RTL the thumb starts at the right
   and must travel LEFT, which `translate()` will not do on its own. */
.ui-switch:dir(rtl) { --ui-switch-direction: -1; }
/* The compact size, for a switch in a dense row (a toolbar, a sidebar option, a
   picker popup): the same three geometry knobs, never `transform: scale()`, which
   would shrink the focus ring with it. Promoted from engeene, which wore it on
   fifteen call sites (REF-1298). */
.ui-switch-compact {
	--ui-switch-width: 1.8rem;
	--ui-switch-height: 1rem;
	--ui-switch-inset: 0.15rem;
}
.ui-switch > input[type="checkbox"]:checked + .ui-switch-slider { background: var(--ui-accent); }
.ui-switch > input[type="checkbox"]:checked + .ui-switch-slider::after {
	transform: translate(calc(var(--ui-switch-travel) * var(--ui-switch-direction)), -50%);
}
/* `:focus-visible`, not `:focus` — a mouse click must not leave a ring behind. */
.ui-switch > input[type="checkbox"]:focus-visible + .ui-switch-slider {
	outline: 2px solid var(--ui-accent);
	outline-offset: 2px;
}
/* DEVIANT OPACITY, LEFT AS A LITERAL ON PURPOSE (REF-089). 0.6 against the
   house `--ui-disabled-opacity` of 0.5 — the whole affordance here is a
   filled track and a knob, and the ON/OFF reading has to survive the fade,
   which is not true of a control whose state is written in words. Adopting
   the token is a visible change; see DECISIONS.md § Design system. */
.ui-switch > input[type="checkbox"]:disabled + .ui-switch-slider { opacity: 0.6; }
.ui-switch:has(> input[type="checkbox"]:disabled) { cursor: not-allowed; }

/* Text or an icon fused to an input (a prefix, a unit, a search glyph). */
.ui-input-group { display: flex; align-items: stretch; }
.ui-input-group > :not(:first-child) { border-start-start-radius: 0; border-end-start-radius: 0; margin-inline-start: -1px; }
.ui-input-group > :not(:last-child) { border-start-end-radius: 0; border-end-end-radius: 0; }
.ui-input-group > :focus-within, .ui-input-group > :focus { z-index: 1; }
.ui-input-addon {
	display: flex;
	align-items: center;
	padding-inline: var(--ui-space-3);
	background: var(--ui-surface-sunken);
	border: 1px solid var(--ui-border-strong);
	border-radius: var(--ui-radius-md);
	color: var(--ui-text-muted);
	font-size: var(--ui-text-sm);
	white-space: nowrap;
}

/* ── Copy field ──────────────────────────────────────────────────────────
   A value the user is meant to take away — a token, an embed snippet, a
   callback URL — shown read-only with the copy control docked inside the
   field rather than beside it.

       <label class="ui-copy-field">
         <input class="ui-copy-field-input" readonly value="…">
         <button class="ui-copy-field-btn">Copy</button>
       </label>

   Inside, not beside, because a copy button in the next column drifts away
   from its value as soon as the layout changes, and because the field is the
   thing the user is looking at. The input reserves room on the trailing edge
   so the button never covers the end of the value; `--ui-copy-field-inset`
   retunes that when the button carries a longer label. Works on a
   `<textarea>` too — an embed snippet is several lines.

   The button is a full-height target, not a chip around its glyph: it fills
   the field's first line edge to edge inside the border, at least a tap target
   wide, so an icon-only copy button is a rectangle the height of a one-line
   field rather than a 12px icon to aim at. On an `<input>` it stretches to the
   field, so it follows whatever control height the product states. On a
   `<textarea>` it is one line tall — the line box (`--ui-copy-field-leading`,
   at the field's inherited size) plus the field's own block padding — so a
   snippet that grows keeps the button on its first line. A product that
   restyles the textarea's type states it on the `.ui-copy-field` (font-size)
   and through `--ui-copy-field-leading`, never on the textarea alone, so the
   two stay the same height. */
.ui-copy-field {
	--ui-copy-field-inset: 5rem;
	--ui-copy-field-leading: var(--ui-leading-normal);
	position: relative;
	display: block;
	width: 100%;
}
.ui-copy-field-input {
	/* Block, so the wrapper is exactly the field's height — an inline control
	   sits on a line box and leaves a strut below it the button would stretch
	   into. */
	display: block;
	width: 100%;
	box-sizing: border-box;
	padding-inline-end: var(--ui-copy-field-inset);
	font-family: var(--ui-font-mono);
	line-height: var(--ui-copy-field-leading);
}
.ui-copy-field-btn {
	position: absolute;
	/* Inside the field's 1px border, flush with it on three sides. */
	inset-block: 1px;
	inset-inline-end: 1px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--ui-space-1);
	min-inline-size: var(--ui-tap-target);
	padding: 0 var(--ui-space-2);
	background: transparent;
	border: none;
	border-radius: calc(var(--ui-radius-md) - 1px);
	color: var(--ui-text-muted);
	font-size: var(--ui-text-xs);
	cursor: pointer;
}
.ui-copy-field-btn > i, .ui-copy-field-btn > svg { font-size: var(--ui-icon-small); }
/* One line of a multi-line field: the same line box and block padding as the
   textarea, computed at the field's inherited size (`1em` here is that size,
   since the button inherits it for this calculation). */
.ui-copy-field > textarea + .ui-copy-field-btn {
	inset-block-end: auto;
	font-size: inherit;
	block-size: calc(var(--ui-copy-field-leading) * 1em + 2 * var(--ui-space-2));
}
.ui-copy-field-btn:hover { background: var(--ui-surface-hover); color: var(--ui-text); }
/* The acknowledgement, when the button stays put instead of a chip appearing.
   In place, never a corner toast — § Conventions. */
.ui-copy-field-btn.is-copied { color: var(--ui-accent-text); }

/* A block of machine text with nowhere to break: a generated token, a hash, a
   diagnostic dump. Bare `<pre>`/`<code>` are already styled — this is for the
   case where the value is not code and must WRAP rather than scroll, because
   the user has to see all of it to copy it by hand. */
.ui-code-block {
	padding: var(--ui-space-2);
	background: var(--ui-surface-hover);
	border-radius: var(--ui-radius-md);
	color: var(--ui-text);
	font-family: var(--ui-font-mono);
	font-size: var(--ui-text-xs);
	overflow-wrap: anywhere;
	word-break: break-all;
}

/* ── Card ────────────────────────────────────────────────────────────────*/
.ui-card {
	background: var(--ui-surface-raised);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-lg);
	padding: var(--ui-space-5);
}
.ui-card-raised { box-shadow: var(--ui-shadow-md); }
/* Header/footer bleed to the card's edge and carry the sunken tone. */
.ui-card-header, .ui-card-footer {
	margin-inline: calc(var(--ui-space-5) * -1);
	padding: var(--ui-space-3) var(--ui-space-5);
	background: var(--ui-surface-sunken);
}
.ui-card-header {
	margin-block-start: calc(var(--ui-space-5) * -1);
	margin-block-end: var(--ui-space-4);
	border-block-end: 1px solid var(--ui-border);
	border-start-start-radius: var(--ui-radius-lg);
	border-start-end-radius: var(--ui-radius-lg);
	font-weight: var(--ui-weight-strong);
}
.ui-card-footer {
	margin-block-start: var(--ui-space-4);
	margin-block-end: calc(var(--ui-space-5) * -1);
	border-block-start: 1px solid var(--ui-border);
	border-end-start-radius: var(--ui-radius-lg);
	border-end-end-radius: var(--ui-radius-lg);
}
/* A card that is a link to something. */
.ui-card-link { display: block; color: inherit; transition: border-color var(--ui-transition), background var(--ui-transition); }

/* ── Dashed affordance ───────────────────────────────────────────────────
   A dashed outline means "nothing here yet, and you can put something here":
   the add button at the end of a list, the empty tile in a grid, the slot a
   dragged item will land in. It is deliberately ONE look for all three — the
   dashes are the signal, and three different dashed boxes on one screen read
   as three different mechanisms.

       <button class="ui-dashed">＋ Add a metric</button>
       <div class="ui-dashed ui-dashed-active">Drop here</div>

   Size it at the call site; this brings no padding of its own, because the
   add button in a sidebar row and the drop target across a grid have nothing
   in common but the border. */
.ui-dashed {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--ui-space-2);
	background: none;
	border: 1px dashed var(--ui-border);
	border-radius: var(--ui-radius-md);
	color: var(--ui-text-muted);
	font-size: var(--ui-text-sm);
	cursor: pointer;
	box-sizing: border-box;
	transition: border-color var(--ui-transition), color var(--ui-transition), background var(--ui-transition);
}
.ui-dashed:hover { border-color: var(--ui-accent-border); color: var(--ui-accent-text); text-decoration: none; }
/* The leading "+" is an icon: sized from the icon scale, like `.ui-btn`'s. */
.ui-dashed > .ph { font-size: var(--ui-icon-small); }
/* The live drop target: already accepting, so it is tinted and not clickable. */
.ui-dashed-active {
	border-width: 2px;
	border-color: var(--ui-accent-border);
	background: var(--ui-accent-soft);
	color: var(--ui-accent-text);
	cursor: default;
}
.ui-card-link:hover { border-color: var(--ui-accent-border); background: var(--ui-surface-hover); text-decoration: none; color: inherit; }

/* ── Badge ───────────────────────────────────────────────────────────────*/
.ui-badge {
	display: inline-flex;
	align-items: center;
	gap: var(--ui-space-1);
	padding: 0.1em var(--ui-space-2);
	border-radius: var(--ui-radius-full);
	background: var(--ui-surface-sunken);
	border: 1px solid var(--ui-border);
	color: var(--ui-text-muted);
	font-size: var(--ui-text-xs);
	font-weight: var(--ui-weight-bold);
	line-height: var(--ui-leading-loose);
	white-space: nowrap;
}
.ui-badge-accent  { background: var(--ui-accent-soft);  border-color: var(--ui-accent-border); color: var(--ui-accent-text); }
.ui-badge-success { background: var(--ui-success-soft); border-color: transparent; color: var(--ui-success-text); }
.ui-badge-warning { background: var(--ui-warning-soft); border-color: transparent; color: var(--ui-warning-text); }
.ui-badge-danger  { background: var(--ui-danger-soft);  border-color: transparent; color: var(--ui-danger-text); }
.ui-badge-info    { background: var(--ui-info-soft);    border-color: transparent; color: var(--ui-info-text); }
/* The environment moniker — "Beta", "Preview", "Staging" — set beside a brand in
   a navbar. It is a badge with a leading gap and a touch of tracking, so all it
   adds is placement; pair it with a colour variant (`ui-badge-accent`).

   Three products were each carrying a private ~12-line `.brand-moniker` block for
   this, and they had drifted: two hand-rolled the pill (hardcoding the accent as a
   FOREGROUND, which is the shade that fails contrast — `--ui-accent-text` is the
   lifted one `.ui-badge-accent` uses) while the third already composed the badge.

   Deliberately no `text-transform`: see the no-all-caps note at the top of this
   file. A moniker is authored capitalised ("Beta") and stays that way. */
.ui-badge-moniker {
	margin-inline-start: var(--ui-space-2);
	letter-spacing: var(--ui-tracking-wider);
	vertical-align: middle;
}

/* ── Tag ─────────────────────────────────────────────────────────────────
   An applied, REMOVABLE selection — an active filter, a chosen recipient, a
   facet. A badge states a fact about something else ("Active", "Beta"); a tag
   is a thing the user added and can take back, which is why it is accent-tinted
   and carries a dismiss button.

       <span class="ui-tag">Confirmed
         <button class="ui-tag-remove" aria-label="Remove Confirmed">&times;</button>
       </span>

   The dismiss control must be a real `<button>` with an accessible name — a
   bare "×" glyph on a `<span>` is unreachable by keyboard and announces
   nothing. */
.ui-tag {
	display: inline-flex;
	align-items: center;
	gap: var(--ui-space-1);
	padding: 0.1em var(--ui-space-1) 0.1em var(--ui-space-2);
	border-radius: var(--ui-radius-full);
	background: var(--ui-accent-soft);
	border: 1px solid var(--ui-accent-border);
	color: var(--ui-accent-text);
	font-size: var(--ui-text-xs);
	font-weight: var(--ui-weight-bold);
	line-height: var(--ui-leading-loose);
	white-space: nowrap;
}
/* No colour of its own: it inherits the tag's, so a variant tints both at once. */
.ui-tag-remove {
	padding: 0 var(--ui-space-1);
	border: none;
	background: none;
	color: inherit;
	font: inherit;
	font-size: var(--ui-text-rel-lg);
	line-height: var(--ui-leading-none);
	opacity: 0.65;
	cursor: pointer;
}
.ui-tag-remove:hover { opacity: 1; }
/* A tag whose criterion cannot be applied here — kept visible and explained
   rather than dropped silently, which is the rule for an unenforceable filter. */
.ui-tag-muted {
	background: var(--ui-surface-sunken);
	border-color: var(--ui-border);
	color: var(--ui-text-muted);
}

/* ── Status dot ──────────────────────────────────────────────────────────
   A coloured dot is decorative; it must always be paired with a text label,
   because colour alone is not a status for a colour-blind reader. */
.ui-dot {
	display: inline-block;
	width: 0.625em;
	height: 0.625em;
	border-radius: var(--ui-radius-full);
	background: var(--ui-text-subtle);
	flex: none;
}
.ui-dot-lg { width: 0.875em; height: 0.875em; }
.ui-dot-success { background: var(--ui-success); }
.ui-dot-warning { background: var(--ui-warning); }
.ui-dot-danger  { background: var(--ui-danger); }
.ui-dot-info    { background: var(--ui-info); }
.ui-dot-accent  { background: var(--ui-accent); }
/* Draws the eye to the one thing that is wrong. */
.ui-dot-pulse { animation: ui-pulse 2s ease-in-out infinite; }
@keyframes ui-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ── Alert ───────────────────────────────────────────────────────────────*/
.ui-alert {
	display: flex;
	gap: var(--ui-space-3);
	padding: var(--ui-space-3) var(--ui-space-4);
	border: 1px solid var(--ui-border);
	border-inline-start: 3px solid var(--ui-border-strong);
	border-radius: var(--ui-radius-md);
	background: var(--ui-surface-sunken);
	margin-block-end: var(--ui-space-4);
	font-size: var(--ui-text-sm);
}
.ui-alert-success { background: var(--ui-success-soft); border-color: transparent; border-inline-start-color: var(--ui-success); }
.ui-alert-warning { background: var(--ui-warning-soft); border-color: transparent; border-inline-start-color: var(--ui-warning); }
.ui-alert-danger  { background: var(--ui-danger-soft);  border-color: transparent; border-inline-start-color: var(--ui-danger); }
.ui-alert-info    { background: var(--ui-info-soft);    border-color: transparent; border-inline-start-color: var(--ui-info); }
.ui-alert-title { font-weight: var(--ui-weight-strong); display: block; margin-block-end: var(--ui-space-1); }

/* ── Banner ──────────────────────────────────────────────────────────────
   An app-shell strip: full width, pinned in the shell's vertical stack above
   the content, saying something about the SESSION rather than about the
   content ("you are offline", "this workspace is still loading", "trial ends
   Friday").

   `ui-alert` is the in-flow sibling — it sits inside a page, next to what it
   is about, and wraps to its content. A banner spends a FIXED height
   (`--ui-banner-height`) precisely so showing or hiding one never shifts the
   layout underneath it, which is the whole reason an app shell cannot use an
   alert here. Visibility stays the product's: nothing sets `display`, so your
   own `.is-visible` / `hidden` still decides. */
.ui-banner {
	--ui-banner-height: 3rem;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--ui-space-2);
	flex: none;
	height: var(--ui-banner-height);
	padding-inline: var(--ui-space-5);
	background: var(--ui-surface-raised);
	border-block-end: 1px solid var(--ui-border);
	color: var(--ui-text);
	font-size: var(--ui-text-sm);
	font-weight: var(--ui-weight-medium);
	text-align: center;
}
.ui-banner-accent  { background: var(--ui-accent-soft);  border-block-end-color: var(--ui-accent-border); color: var(--ui-accent-text); }
.ui-banner-success { background: var(--ui-success-soft); border-block-end-color: var(--ui-success); color: var(--ui-success-text); }
.ui-banner-warning { background: var(--ui-warning-soft); border-block-end-color: var(--ui-warning); color: var(--ui-warning-text); }
.ui-banner-danger  { background: var(--ui-danger-soft);  border-block-end-color: var(--ui-danger);  color: var(--ui-danger-text); }
/* A link in a banner inherits the tone — a blue link inside an amber strip
   reads as a second message. */
.ui-banner a { color: inherit; text-decoration: underline; }

/* ── Navbar ──────────────────────────────────────────────────────────────*/
.ui-navbar {
	/* `auto` on a content-sized marketing bar; an APP shell sets a fixed height
	   so the chrome never reflows — and so a banner that replaces the bar
	   (offline, loading, parked) can read the same value instead of repeating
	   the literal, which is how those get out of step and the page jumps. */
	--ui-navbar-height: auto;
	display: flex;
	align-items: center;
	gap: var(--ui-space-4);
	height: var(--ui-navbar-height);
	flex-shrink: 0;
	padding: var(--ui-space-3) var(--ui-space-5);
	background: var(--ui-surface-raised);
	border-block-end: 1px solid var(--ui-border);
}
/* A navbar that centres its contents on a `.ui-container` would otherwise be
   padded twice — once by the bar, once by the container. The bar yields. */
.ui-navbar:has(> .ui-container) { padding-inline: 0; }
/* Opt-in, because a bar pinned to the viewport is a page-layout decision. */
.ui-navbar-sticky { position: sticky; top: 0; z-index: var(--ui-z-sticky); }
.ui-navbar-brand {
	display: inline-flex;
	align-items: center;
	gap: var(--ui-space-2);
	font-weight: var(--ui-weight-strong);
	font-size: var(--ui-text-lg);
	color: var(--ui-text);
	letter-spacing: var(--ui-tracking-tight);
}
.ui-navbar-brand:hover { color: var(--ui-text); text-decoration: none; }
.ui-navbar-brand img, .ui-navbar-brand svg { width: 1.5em; height: 1.5em; }
/* Pushes everything after it to the far end. `.ui-spacer` in § 5 is the same
   rule for non-navbar rows; this alias exists because "navbar spacer" is what
   people search for. */
.ui-navbar-spacer { flex: 1; }

/* ── Collapsing navbar (small screens) ───────────────────────────────────
   A bar that folds its links behind a hamburger below `--ui-nav-collapse`.
   Every site rebuilds this — a marketing header, a documentation shell — and
   each one picks its own breakpoint, its own toggle animation and its own
   name for "open".

       <header class="ui-navbar">
         <a class="ui-navbar-brand" href="/">Trailspark</a>
         <button class="ui-navbar-toggle" aria-expanded="false" aria-controls="m">
           <span></span><span></span><span></span>
         </button>
         <div class="ui-navbar-collapse" id="m"><nav class="ui-nav">…</nav></div>
       </header>

   Open/close is a class the product toggles (`.is-open` on BOTH elements) —
   the same one this styles, so a script only ever flips one name. `aria-expanded`
   on the toggle is what a screen reader reads and is the product's job to keep
   in step; nothing here depends on it, so a missing one is an a11y bug rather
   than a broken menu.

   The bars are three `<span>`s, not a glyph font or an SVG, so the X it turns
   into is a `transform` on the same elements — animatable, and no icon
   dependency in a design system that must not have one. */
.ui-navbar-toggle {
	--ui-navbar-toggle-bar: 2px;
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	width: 2.25rem;
	height: 2.25rem;
	margin-inline-start: auto;
	padding: 0;
	background: none;
	border: none;
	cursor: pointer;
}
.ui-navbar-toggle > span {
	display: block;
	height: var(--ui-navbar-toggle-bar);
	background: var(--ui-text);
	border-radius: 1px;
	transition: transform var(--ui-transition), opacity var(--ui-transition);
}
.ui-navbar-toggle.is-open > span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.ui-navbar-toggle.is-open > span:nth-child(2) { opacity: 0; }
.ui-navbar-toggle.is-open > span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.ui-navbar-collapse {
	display: flex;
	align-items: center;
	gap: var(--ui-space-6);
	margin-inline-start: auto;
}
/* Below the breakpoint the links become a panel under the bar. The navbar must
   be a positioning context for that (`position: relative` or `sticky`) — which
   `ui-navbar-sticky` already gives it.

   The query is the house pair (§ 1, "The phone breakpoint"); `site-chrome.css`
   collapses `.navbar-actions` on the SAME one, and `site-chrome.js` relies on
   the two agreeing. */
@media (width < 48rem) {
	.ui-navbar-toggle { display: flex; }
	.ui-navbar-collapse {
		display: none;
		position: absolute;
		inset-inline: 0;
		top: 100%;
		flex-direction: column;
		align-items: stretch;
		gap: var(--ui-space-3);
		padding: var(--ui-space-4) var(--ui-space-5) var(--ui-space-6);
		background: var(--ui-surface-raised);
		border-block-end: 1px solid var(--ui-border);
	}
	.ui-navbar-collapse.is-open { display: flex; }
	.ui-navbar-collapse .ui-nav { flex-direction: column; align-items: stretch; }
}

.ui-nav { display: flex; align-items: center; gap: var(--ui-space-1); }
.ui-nav-link {
	padding: var(--ui-space-2) var(--ui-space-3);
	border-radius: var(--ui-radius-md);
	color: var(--ui-text-muted);
	font-size: var(--ui-text-sm);
	font-weight: var(--ui-weight-semibold);
	transition: background var(--ui-transition), color var(--ui-transition);
}
.ui-nav-link:hover { background: var(--ui-surface-hover); color: var(--ui-text); text-decoration: none; }
.ui-nav-link[aria-current] { background: var(--ui-accent-soft); color: var(--ui-accent-text); }

/* ── Tabs ────────────────────────────────────────────────────────────────*/
.ui-tabs {
	display: flex;
	gap: var(--ui-space-1);
	border-block-end: 1px solid var(--ui-border);
	margin-block-end: var(--ui-space-5);
	overflow-x: auto;
	scrollbar-width: none;
}
.ui-tabs::-webkit-scrollbar { display: none; }
.ui-tab {
	padding: var(--ui-space-2) var(--ui-space-4);
	border: none;
	background: none;
	color: var(--ui-text-muted);
	font-size: var(--ui-text-sm);
	font-weight: var(--ui-weight-semibold);
	white-space: nowrap;
	cursor: pointer;
	/* The active tab's underline sits on the container's border, so nothing
	   moves by a pixel when the selection changes. */
	border-block-end: 2px solid transparent;
	margin-block-end: -1px;
	transition: color var(--ui-transition), border-color var(--ui-transition);
}
.ui-tab:hover { color: var(--ui-text); text-decoration: none; }
.ui-tab[aria-selected="true"], .ui-tab.is-active {
	color: var(--ui-accent-text);
	border-block-end-color: var(--ui-accent);
}

/* Pill tabs — the same vocabulary, for a strip that lives INSIDE an app bar
   rather than under a rule. An underline needs a border to sit on; a full-height
   navbar has none, which is why every app shell that tried reached for its own
   markup and its own hover colour.

       <header class="ui-navbar">
         <span class="ui-navbar-brand">Trailspark</span>
         <nav class="ui-tabs ui-tabs-pill" role="tablist">
           <a class="ui-tab" role="tab" aria-selected="true">Accounts</a>
         </nav>
       </header>

   Selection is `aria-selected` / `.is-active`, as on the underline variant, and
   the tint follows the rule that a persistent selection is accent while hover
   stays neutral. */
.ui-tabs-pill {
	align-self: stretch;
	align-items: stretch;
	gap: 0;
	border-block-end: none;
	margin-block-end: 0;
}
.ui-tabs-pill > .ui-tab {
	display: flex;
	align-items: center;
	gap: var(--ui-space-2);
	margin: var(--ui-space-1) var(--ui-space-1) var(--ui-space-1) 0;
	border-block-end: none;
	border-radius: var(--ui-radius-md);
	transition: color var(--ui-transition), background var(--ui-transition);
}
.ui-tabs-pill > .ui-tab:hover { background: var(--ui-surface-hover); }
.ui-tabs-pill > .ui-tab[aria-selected="true"],
.ui-tabs-pill > .ui-tab.is-active {
	background: var(--ui-accent-soft);
	color: var(--ui-accent-text);
}

/* ── Popover: the floating surface ───────────────────────────────────────
   The surface every overlay shares — a menu, a picker, a tooltip, a small
   acknowledgement chip. It owns the SURFACE only.

   **Positioning is deliberately not here.** An anchored overlay needs
   coordinates from `getBoundingClientRect()` that no stylesheet can know, and
   whether it is `fixed` (survives a scrolling ancestor) or `absolute` (moves
   with one) is the caller's decision. Set `position` and the offsets yourself;
   this sets neither, so it composes with either.

   `z-index` IS here, as one value, because overlays stacking against each
   other is a cross-cutting problem a single product cannot solve locally. */
.ui-popover,
.ui-menu {
	background: var(--ui-surface-raised);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-md);
	box-shadow: var(--ui-shadow-lg);
	padding: var(--ui-space-1);
	/* Above `--ui-z-overlay`, so a menu opened from inside a modal is not
	   hidden behind it. See the layering note in § 2. */
	z-index: var(--ui-z-popover);
}

/* ── Menu ────────────────────────────────────────────────────────────────
   A popover holding a list of actions. The vocabulary below is what a real
   context menu turns out to need — it was consolidated from the richest
   implementation across our products rather than guessed at:

       <div class="ui-menu" role="menu">
         <div class="ui-menu-note ui-menu-note-top">What this menu acts on</div>
         <div class="ui-menu-label">Group</div>
         <button class="ui-menu-item">
           <i class="…"></i> Label
           <span class="ui-menu-shortcut">⌘K</span>
         </button>
         <button class="ui-menu-item ui-menu-item-stacked">
           <span class="ui-menu-item-label">Label</span>
           <span class="ui-menu-item-description">Why you would pick it</span>
         </button>
         <div class="ui-menu-separator"></div>
         <button class="ui-menu-item ui-menu-item-danger">Delete</button>
         <div class="ui-menu-note">A caveat that is not an action</div>
       </div>

   Selection is `aria-selected` / `.is-active` and disabling is `disabled` /
   `aria-disabled`, so how a row looks and what a screen reader is told cannot
   drift apart. */
.ui-menu {
	min-width: 11rem;
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: var(--ui-text-sm);
	/* Long menus scroll rather than running off the viewport. */
	max-height: min(24rem, 70vh);
	overflow-y: auto;
}
.ui-menu-item {
	display: flex;
	align-items: center;
	gap: var(--ui-space-2);
	width: 100%;
	padding: var(--ui-space-2) var(--ui-space-3);
	border-radius: var(--ui-radius-sm);
	background: none;
	border: none;
	color: var(--ui-text);
	font-size: var(--ui-text-rel-md);
	text-align: start;
	cursor: pointer;
	box-sizing: border-box;
}
.ui-menu-item:hover, .ui-menu-item:focus-visible { background: var(--ui-surface-hover); text-decoration: none; color: var(--ui-text); }
.ui-menu-item[aria-selected="true"], .ui-menu-item.is-active { background: var(--ui-accent-soft); color: var(--ui-accent-text); }
.ui-menu-item:disabled, .ui-menu-item[aria-disabled="true"] { opacity: var(--ui-disabled-opacity); cursor: not-allowed; pointer-events: none; }
/* A destructive action. Coloured, not filled — a menu of mostly-safe actions
   with one red BLOCK in it reads as an error state rather than a choice. */
.ui-menu-item-danger { color: var(--ui-danger-text); }
.ui-menu-item-danger:hover, .ui-menu-item-danger:focus-visible { background: var(--ui-danger-soft); color: var(--ui-danger-text); }

/* Right-aligned keyboard accelerator. `margin-inline-start: auto` rather than a
   fixed column, so it sits flush right whatever the label's length. */
.ui-menu-shortcut {
	margin-inline-start: auto;
	padding-inline-start: var(--ui-space-4);
	color: var(--ui-text-muted);
	font-size: var(--ui-text-rel-sm);
	white-space: nowrap;
}

/* The row's leading glyph, in a box of its own.
   A bare `<i>` is fine in a single-line row, where everything is on one line
   anyway — but in a STACKED row it becomes the first item of a column, and the
   row reads as three stacked lines (glyph, then title, then description) instead
   of a titled row with an icon. The box is what lets the grid below put the
   glyph in its own column, spanning both lines. Sized from the ICON scale, in
   `rem`: an icon is a fixed-size object, and one riding `em` shrinks in every
   caption it lands in. */
.ui-menu-item-icon {
	display: flex;
	align-items: center;
	font-size: var(--ui-icon-normal);
	line-height: var(--ui-leading-none);
}

/* Two-line item: TITLE beside the glyph, a muted explanation under the title.
   Use it for an action whose name does not carry its consequence; a menu where
   EVERY row needs one is a menu that needs shorter labels.

   A grid rather than a column of flex items, because the row has two shapes at
   once: one column for the glyph (spanning both lines, so it is centred against
   the pair) and one for the text. `1fr` is `minmax(0, 1fr)` so a long title
   truncates inside its column instead of widening the menu. */
.ui-menu-item-stacked {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	column-gap: var(--ui-space-2);
	row-gap: 0;
}
.ui-menu-item-stacked > .ui-menu-item-icon { grid-area: 1 / 1 / 3 / 2; }
.ui-menu-item-stacked > .ui-menu-item-label { grid-area: 1 / 2; }
.ui-menu-item-stacked > .ui-menu-item-description { grid-area: 2 / 2; }
/* The trailing accelerator keeps to the TITLE's line — under it there is only
   the explanation, and a shortcut floating beside that reads as part of it. */
.ui-menu-item-stacked > .ui-menu-shortcut { grid-area: 1 / 3; margin-inline-start: 0; }
.ui-menu-item-label { display: block; }
.ui-menu-item-description {
	display: block;
	margin-block-start: 2px;
	max-width: 20rem;
	font-size: var(--ui-text-rel-xs);
	line-height: var(--ui-leading-snug);
	color: var(--ui-text-muted);
	white-space: normal;
}

.ui-menu-separator { height: 1px; background: var(--ui-border); margin-block: var(--ui-space-1); }
.ui-menu-label {
	padding: var(--ui-space-2) var(--ui-space-3) var(--ui-space-1);
	font-size: var(--ui-text-xs);
	font-weight: var(--ui-weight-strong);
	letter-spacing: var(--ui-tracking-wider);
	color: var(--ui-text-subtle);
}

/* A muted, NON-INTERACTIVE note. `ui-menu-note-top` pins it above the items —
   use that to say what the menu is acting on, which is otherwise a caption the
   menu has nowhere to put. The top note reads as a caption through weight, not
   italic: the system never sets type in italic (see "No italic" in
   COMPONENTS.md § Conventions) — significance is bold or a muted colour. */
.ui-menu-note {
	padding: var(--ui-space-2) var(--ui-space-3) var(--ui-space-1);
	max-width: 22rem;
	font-size: var(--ui-text-rel-2xs);
	line-height: var(--ui-leading-snug);
	color: var(--ui-text-muted);
	white-space: normal;
}
.ui-menu-note-top { font-weight: var(--ui-weight-medium); }

/* One key of a keyboard shortcut. `ui-menu-shortcut` is the SLOT a menu row
   puts its accelerator in; this is the key itself, and it is also what a help
   overlay or an onboarding hint renders. Empty collapses, so a row whose
   action has no binding does not show a stray blank key. */
.ui-kbd {
	display: inline-block;
	padding: 2px var(--ui-space-2);
	background: var(--ui-surface-hover);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-sm);
	color: var(--ui-text);
	font: inherit;
	font-size: var(--ui-text-xs);
	line-height: var(--ui-leading-normal);
	white-space: nowrap;
}
.ui-kbd:empty { display: none; }

/* Flyout opened beside a parent item, which stays open behind it. */
.ui-submenu { min-width: 14rem; }
.ui-submenu-caret { margin-inline-start: auto; opacity: 0.5; font-size: var(--ui-text-rel-sm); }

/* A small floating acknowledgement pinned near what the user just acted on —
   the in-place alternative to a corner toast when the control that would have
   flashed is already gone (a menu closes on click). Not interactive. */
.ui-chip {
	display: inline-flex;
	align-items: center;
	gap: var(--ui-space-2);
	padding: var(--ui-space-1) var(--ui-space-2);
	background: var(--ui-surface-raised);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-md);
	box-shadow: var(--ui-shadow-lg);
	font-size: var(--ui-text-xs);
	color: var(--ui-text);
	white-space: nowrap;
	pointer-events: none;
	z-index: var(--ui-z-toast);
}
.ui-chip-success > svg, .ui-chip-success > i { color: var(--ui-success-text); }
.ui-chip-danger > svg, .ui-chip-danger > i { color: var(--ui-danger-text); }

/* ── Option ──────────────────────────────────────────────────────────────
   One row of a LIST OF VALUES — a model list, a timezone list, a picker's
   results, a sidebar of choices. `ui-menu-item` is the row of a MENU (an
   action you invoke and the menu closes); this is the row of a list (a value
   you select, and the selection PERSISTS), so it carries a selected state and
   brings no surface with it.

   Splitting the two is what stops the selected state being invented per
   product: hover is neutral, selection is accent (§ Conventions), and the
   state lives on `aria-selected` so the look and what a screen reader hears
   cannot drift. `.is-selected` is the escape hatch for a list whose selection
   is already announced another way. */
.ui-option {
	display: flex;
	align-items: center;
	gap: var(--ui-space-2);
	width: 100%;
	padding: var(--ui-space-1) var(--ui-space-3);
	background: none;
	border: none;
	color: var(--ui-text);
	font-size: var(--ui-text-sm);
	text-align: start;
	cursor: pointer;
	box-sizing: border-box;
}
.ui-option:hover { background: var(--ui-surface-hover); color: var(--ui-text); text-decoration: none; }
.ui-option[aria-selected="true"], .ui-option.is-selected {
	background: var(--ui-accent-soft);
	color: var(--ui-accent-text);
	font-weight: var(--ui-weight-semibold);
}
/* DEVIANT OPACITY, LEFT AS A LITERAL ON PURPOSE (REF-089), and the one that is
   hardest to defend: this section argues that `.ui-option` IS `.ui-menu-item`
   in a different container, and the two dimmed 0.15 apart — 0.35 here against
   the house `--ui-disabled-opacity` of 0.5 there. Whichever way it converges is
   a visible change to one of the two, so it is a decision with a before/after
   rather than something to pick quietly; see DECISIONS.md § Design system. */
.ui-option:disabled, .ui-option[aria-disabled="true"] { opacity: 0.35; pointer-events: none; cursor: not-allowed; }
/* A qualifier beside the label — the dataset a column belongs to, a region, a
   count. Pushed to the far end so a column of rows lines up. */
.ui-option-meta { margin-inline-start: auto; color: var(--ui-text-muted); font-size: var(--ui-text-rel-xs); white-space: nowrap; }
/* A second line under the label. */
.ui-option-sub { display: block; color: var(--ui-text-muted); font-size: var(--ui-text-rel-xs); }

/* ── Picker: a searchable list inside a popover ──────────────────────────
   The other overlay every product builds: a floating panel with a search box
   pinned at the top, a scrolling list of `ui-option` rows in the middle, and
   an optional action row pinned at the bottom.

       <div class="ui-popover ui-picker" style="position: fixed; …">
         <div class="ui-picker-search"><input type="search" …></div>
         <div class="ui-picker-list">
           <div class="ui-picker-group">Bookings <a class="ui-picker-group-action">Add all</a></div>
           <div class="ui-option">Revenue</div>
           <div class="ui-picker-empty">Nothing matches</div>
         </div>
         <div class="ui-picker-footer"><button class="ui-btn ui-btn-primary ui-btn-sm">Apply</button></div>
       </div>

   Every band is optional; a picker with no search is just a scrolling list.
   Positioning stays the caller's, exactly as for `ui-popover` — which is what
   this composes with, so the surface is stated once.

   The bands are edge to edge, so this drops the popover's own padding rather
   than nesting a second inset. It wins on ORDER (it is defined after
   `.ui-popover`, both one class), so keep it below that rule. */
.ui-picker {
	display: flex;
	flex-direction: column;
	min-height: 0;
	max-height: min(30rem, calc(100dvh - 2rem));
	padding: 0;
	overflow: hidden;
	font-size: var(--ui-text-sm);
}
.ui-picker-search {
	flex: none;
	display: flex;
	align-items: center;
	gap: var(--ui-space-2);
	padding: var(--ui-space-2) var(--ui-space-3);
	border-block-end: 1px solid var(--ui-border);
}
.ui-picker-search > input { flex: 1; min-width: 0; }
.ui-picker-list {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding-block: var(--ui-space-1);
}
/* A heading over a run of rows, optionally with one action for the whole
   group. Separated from the run above it by a rule, never by a gap alone —
   a picker is usually scrolled, so a gap reads as the end of the list. */
.ui-picker-group {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--ui-space-2);
	padding: var(--ui-space-2) var(--ui-space-3) 2px;
	margin-block-start: var(--ui-space-2);
	border-block-start: 1px solid var(--ui-border);
	font-size: var(--ui-text-xs);
	font-weight: var(--ui-weight-strong);
	letter-spacing: var(--ui-tracking-wide);
	color: var(--ui-text-muted);
}
.ui-picker-group:first-child { margin-block-start: 0; border-block-start: none; }
.ui-picker-group-action { color: var(--ui-accent-text); font-weight: var(--ui-weight-semibold); cursor: pointer; }
.ui-picker-footer {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: var(--ui-space-2);
	padding: var(--ui-space-2) var(--ui-space-3);
	border-block-start: 1px solid var(--ui-border);
}
/* "Nothing matches" / "loading" — inside the list, so the panel keeps its
   size instead of collapsing to the search box. */
.ui-picker-empty {
	padding: var(--ui-space-4) var(--ui-space-3);
	text-align: center;
	color: var(--ui-text-muted);
}

/* ── Accordion ───────────────────────────────────────────────────────────
   A list of disclosures — an FAQ, a grouped settings page, a docs sidebar.

       <div class="ui-accordion">
         <details class="ui-accordion-item">
           <summary>Does it scale?</summary>
           <div class="ui-accordion-body">Yes.</div>
         </details>
       </div>

   It is `<details>`, not a div with a click handler: open/close, keyboard
   activation, and find-in-page opening a closed section all come from the
   browser. That last one is why the animated-`max-height` version every
   product writes is worse than it looks — its content is not findable, and
   the ceiling it animates to is a guess that silently clips a long answer.

   `<details>` and `<summary>` are already styled by the base layer (including
   the rotating marker); this is the list treatment — items welded into one
   bordered column instead of floating separately. */
.ui-accordion { display: flex; flex-direction: column; }
.ui-accordion-item {
	margin: 0;
	border-radius: 0;
	border-block-end: none;
}
.ui-accordion-item:first-of-type { border-start-start-radius: var(--ui-radius-md); border-start-end-radius: var(--ui-radius-md); }
.ui-accordion-item:last-of-type {
	border-block-end: 1px solid var(--ui-border);
	border-end-start-radius: var(--ui-radius-md);
	border-end-end-radius: var(--ui-radius-md);
}
.ui-accordion-item > summary:hover { color: var(--ui-accent-text); }
.ui-accordion-body { padding-block-start: var(--ui-space-3); color: var(--ui-text-muted); }

/* ── Modal ───────────────────────────────────────────────────────────────
   Scrim + panel, with the header and footer pinned so only the body scrolls.

       <div class="ui-modal-scrim">
         <div class="ui-modal" role="dialog" aria-modal="true" aria-labelledby="t">
           <div class="ui-modal-header" id="t">Rename dashboard</div>
           <div class="ui-modal-body">…</div>
           <div class="ui-modal-footer"><button class="ui-btn">Cancel</button></div>
         </div>
       </div>

   **Prefer the native `<dialog>`** (styled in the base layer above): it gives
   focus trapping, Escape, inertness and the top layer from the browser rather
   than from a script. This exists for the cases that cannot use it — a panel
   inside a shadow root, or an existing custom element whose open/close protocol
   the surrounding app already depends on. Taking the native element's behaviour
   is on you; what you get here is only the look.

   Nothing here sets `display` on the scrim, so a product's own open/close class
   (`.open`, `[hidden]`, a `display: none` default) still decides visibility. */
.ui-modal-scrim {
	position: fixed;
	inset: 0;
	z-index: calc(var(--ui-z-overlay) + var(--ui-overlay-depth, 0) * var(--ui-z-overlay-step));
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--ui-space-4);
	background: var(--ui-scrim);
}

/* ── Overlay ─────────────────────────────────────────────────────────────
   The bare full-viewport layer: what a picker's click-catcher, a blocking
   state or any other "everything behind this is out of reach" surface sits
   on. `ui-modal-scrim` is this plus centring — reach for that when a panel
   goes in the middle; reach for this when the thing on top is positioned
   somewhere else entirely (an anchored popup) or fills the viewport itself.

   The `z-index` is the load-bearing part. Every product hand-writes this rule
   and then hand-increments the number until the stack happens to work
   (`1001`, `1100`, `4000`, `9000` were all in one app); taking it from the
   scale means a popover opened from inside the overlay is above it by
   construction — see § Layering. */
.ui-overlay {
	position: fixed;
	inset: 0;
	z-index: calc(var(--ui-z-overlay) + var(--ui-overlay-depth, 0) * var(--ui-z-overlay-step));
	background: var(--ui-scrim);
}
/* A lighter dim, for an overlay that only has to catch clicks — the content
   underneath stays readable, which is what you want behind a small picker. */
.ui-overlay-light { background: var(--ui-scrim-light); }
/* Centres whatever it holds (a message, a card) without the modal's panel. */
.ui-overlay-center { display: flex; align-items: center; justify-content: center; padding: var(--ui-space-4); }
.ui-modal {
	display: flex;
	flex-direction: column;
	width: min(32rem, 100%);
	/* `dvh`, not `vh`: on a phone `100vh` is the viewport WITHOUT the retracted
	   browser chrome, so a `vh`-capped dialog is taller than what is on screen and
	   its header/footer sit off it. `dvh` tracks the visible viewport. */
	max-height: calc(100dvh - var(--ui-space-16));
	background: var(--ui-surface-raised);
	color: var(--ui-text);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-lg);
	box-shadow: var(--ui-shadow-lg);
}
.ui-modal-wide { width: min(48rem, 100%); }
/* Header and footer do not shrink, so a long body scrolls under a heading that
   stays put and above actions that stay reachable. */
.ui-modal-header, .ui-modal-footer {
	flex-shrink: 0;
	padding: var(--ui-space-4) var(--ui-space-5);
}
.ui-modal-header {
	border-block-end: 1px solid var(--ui-border);
	font-weight: var(--ui-weight-strong);
}
.ui-modal-body {
	flex: 1 1 auto;
	/* Without this a flex child refuses to shrink below its content, and the
	   panel grows past `max-height` instead of scrolling. */
	min-height: 0;
	overflow-y: auto;
	padding: var(--ui-space-4) var(--ui-space-5);
}
.ui-modal-footer {
	display: flex;
	justify-content: flex-end;
	gap: var(--ui-space-2);
	border-block-start: 1px solid var(--ui-border);
}

/* ── Drawer ──────────────────────────────────────────────────────────────
   A panel that slides in from the inline-end edge, full height, over a
   scrim: the surface for a SIDE-CAR of the thing on screen — an item's
   change history, an audit trail, a details pane — where a modal would be
   wrong because the reader is still looking at what it describes.

       <div class="ui-overlay ui-drawer-scrim ui-drawer-open"></div>
       <aside class="ui-drawer ui-drawer-open" role="dialog" aria-modal="true"
              aria-labelledby="t">
         <header class="ui-drawer-head">
           <div>
             <div class="ui-drawer-title" id="t">History</div>
             <div class="ui-drawer-subtitle">Revenue by country</div>
           </div>
           <span class="ui-spacer"></span>
           <button class="ui-icon-btn" aria-label="Close"><i class="ph ph-x"></i></button>
         </header>
         <div class="ui-drawer-body">…</div>
         <footer class="ui-drawer-foot"><button class="ui-btn">Close</button></footer>
       </aside>

   **The scrim is `.ui-overlay` plus a fade — it is not a second scrim.**
   `.ui-drawer-scrim` declares only the transition, so the dim, the
   `position: fixed; inset: 0` and the `z-index` all still come from the one
   place that owns them (§ Overlay). Reach for `.ui-overlay-light` beside it
   when the drawer is an aside rather than a modal interruption.

   **Nothing here opens or closes it.** `.ui-drawer-open` on BOTH elements is
   the open state; without it the panel is parked off-screen and the scrim is
   transparent — so a product's own script (or `@hrayo/foundation-ui-drawer`,
   which also does the focus trap, Escape, scroll lock and ARIA) decides
   visibility, exactly as with `.ui-modal-scrim`.

   Configure a call site with `--ui-drawer-width` (default 26rem) and
   `--ui-drawer-padding`; everything else is a semantic token. Below 30rem of
   viewport the panel takes the whole width — that is the component's rule,
   not the call site's, so no consumer writes its own phone breakpoint.

   The off-screen park is a physical `translateX` because `transform` has no
   logical form; the `:dir(rtl)` twin flips it, since `inset-inline-end` has
   already moved the panel to the other edge. (`:dir()` on the panel, not an
   ancestor `[dir]` selector — the components layer is `.ui-*`-prefixed by
   contract, asserted by `src/layers.test.ts`.) */
.ui-drawer-scrim {
	opacity: 0;
	transition: opacity var(--ui-transition);
}
.ui-drawer-scrim.ui-drawer-open { opacity: 1; }

.ui-drawer {
	position: fixed;
	inset-block: 0;
	inset-inline-end: 0;
	z-index: calc(var(--ui-z-overlay) + var(--ui-overlay-depth, 0) * var(--ui-z-overlay-step));
	display: flex;
	flex-direction: column;
	width: min(var(--ui-drawer-width, 26rem), 100vw);
	max-width: 100%;
	background: var(--ui-surface-raised);
	color: var(--ui-text);
	border-inline-start: 1px solid var(--ui-border);
	box-shadow: var(--ui-shadow-lg);
	transform: translateX(100%);
	transition: transform var(--ui-transition);
}
.ui-drawer:dir(rtl) { transform: translateX(-100%); }
.ui-drawer.ui-drawer-open { transform: none; }

/* Head and foot do not shrink, so a long body scrolls under a heading that
   stays put and above actions that stay reachable — the `.ui-modal-header` /
   `-footer` rule. They are `sticky` as well so the same markup still pins
   them if a consumer makes the whole panel the scroller instead of the body. */
.ui-drawer-head, .ui-drawer-foot {
	flex-shrink: 0;
	position: sticky;
	z-index: 1;
	display: flex;
	align-items: center;
	gap: var(--ui-space-small);
	padding: var(--ui-drawer-padding, var(--ui-space-normal));
	background: var(--ui-surface-raised);
}
.ui-drawer-head {
	inset-block-start: 0;
	align-items: flex-start;
	border-block-end: 1px solid var(--ui-border);
}
.ui-drawer-foot {
	inset-block-end: 0;
	justify-content: flex-end;
	border-block-start: 1px solid var(--ui-border);
}
.ui-drawer-title { font-weight: var(--ui-weight-strong); }
.ui-drawer-subtitle {
	color: var(--ui-text-muted);
	font-size: var(--ui-text-small);
}
.ui-drawer-body {
	flex: 1 1 auto;
	/* Without this a flex child refuses to shrink below its content and the
	   panel grows past the viewport instead of scrolling. */
	min-height: 0;
	overflow-y: auto;
	padding: var(--ui-drawer-padding, var(--ui-space-normal));
}
/* A phone has no room for a page behind the panel, so the panel is the page.
   (The slide itself needs no `prefers-reduced-motion` block here — `reset.css`
   collapses every transition on the page under it, with `!important`.) */
@media (max-width: 30rem) {
	.ui-drawer { width: 100vw; }
}

/* ── Toast ───────────────────────────────────────────────────────────────
   A transient acknowledgement with no anchor. Reach for `.ui-chip` first: when
   there IS something on screen the action relates to, confirming in place beats
   a message in the corner. A toast is for feedback with no anchor and no
   visible state change — "Export started", "Connection restored".

       <div class="ui-toast ui-toast-success is-open">Saved</div>

   Hidden by default and revealed by `.is-open`, because a toast is created once
   and shown repeatedly; `aria-live="polite"` on the element is what makes it
   reach a screen reader. */
.ui-toast {
	position: fixed;
	inset-block-end: var(--ui-space-5);
	inset-inline-end: var(--ui-space-5);
	z-index: var(--ui-z-toast);
	padding: var(--ui-space-3) var(--ui-space-4);
	background: var(--ui-surface-raised);
	color: var(--ui-text);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-lg);
	box-shadow: var(--ui-shadow-lg);
	font-size: var(--ui-text-sm);
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--ui-transition);
}
.ui-toast.is-open { opacity: 1; }
.ui-toast-success { border-color: var(--ui-success); color: var(--ui-success-text); }
.ui-toast-danger  { border-color: var(--ui-danger);  color: var(--ui-danger-text); }
.ui-toast-warning { border-color: var(--ui-warning); color: var(--ui-warning-text); }

/* ── Segmented control ───────────────────────────────────────────────────
   A small row of mutually-exclusive options that reads as ONE control —
   orientation, a unit, a theme, a density. Distinct from `.ui-btn-group`
   (independent actions welded together) because exactly one segment is always
   selected, and distinct from a `<select>` because every option stays visible.

       <div class="ui-segmented" role="group">
         <button class="ui-segmented-btn" aria-pressed="true">Bar</button>
         <button class="ui-segmented-btn" aria-pressed="false">Line</button>
       </div>

   Selection is `aria-pressed` (or `.is-active`) — a control whose whole job is
   showing which option is live must say so to a screen reader too.

   Use it up to about four options; past that the segments get too narrow to
   label and a `<select>` or a menu reads better. */
.ui-segmented {
	display: flex;
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-md);
	/* Clips the first and last segment against the group's corners, so the
	   segments themselves need no radius of their own. */
	overflow: hidden;
}
.ui-segmented-btn {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--ui-space-1);
	padding: var(--ui-space-1) var(--ui-space-2);
	background: var(--ui-surface-raised);
	border: none;
	border-inline-end: 1px solid var(--ui-border);
	color: var(--ui-text);
	font-family: inherit;
	font-size: var(--ui-text-xs);
	line-height: var(--ui-leading-relaxed);
	cursor: pointer;
	white-space: nowrap;
	transition: background var(--ui-transition), color var(--ui-transition);
}
.ui-segmented-btn:last-child { border-inline-end: none; }
.ui-segmented-btn:hover { background: var(--ui-surface-hover); }
/* The selected segment is FILLED, unlike a selected menu row — a segmented
   control has no other affordance for "this one", and a soft tint on one of
   three adjacent segments is easy to miss. */
.ui-segmented-btn[aria-pressed="true"],
.ui-segmented-btn.is-active {
	background: var(--ui-accent);
	color: var(--ui-accent-contrast);
}
.ui-segmented-btn:disabled { opacity: var(--ui-disabled-opacity); cursor: not-allowed; }
/* Two variants of the same welded row, for the case the paragraph above rules
   out — a value set that is neither exclusive nor short.

   `-multi`: every segment is an independent toggle, so several can be pressed at
   once (days of week, months of the year). Nothing changes visually — the point
   is that `aria-pressed` is per segment and the group is `role="group"`, never a
   radio set — so it carries only the multi-select cursor affordance and exists to
   be NAMED at the call site.

   `-wrap`: the row breaks into even rows of `--ui-segmented-cols` (default 3 —
   the twelve months read as quarters). Grid, not `flex-wrap`, so a short last row
   still lines up with the rest; the hairlines are the group's own background
   showing through a 1px gap, which draws them in BOTH axes with no per-segment
   border to reset. */
.ui-segmented-multi > .ui-segmented-btn[aria-pressed="false"]:hover { background: var(--ui-accent-soft); }
.ui-segmented-wrap {
	display: grid;
	grid-template-columns: repeat(var(--ui-segmented-cols, 3), minmax(0, 1fr));
	gap: 1px;
	background: var(--ui-border);
}
.ui-segmented-wrap > .ui-segmented-btn { border-inline-end: none; }

/* ── Toolbar ─────────────────────────────────────────────────────────────*/
.ui-toolbar {
	display: flex;
	align-items: center;
	gap: var(--ui-space-2);
	padding: var(--ui-space-2) var(--ui-space-3);
	background: var(--ui-surface-sunken);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-md);
	flex-wrap: wrap;
}
.ui-toolbar-separator { width: 1px; align-self: stretch; background: var(--ui-border); }

/* ── Steps ───────────────────────────────────────────────────────────────
   A wizard's progress. `aria-current` marks where the visitor is; `.is-done`
   what they have finished. */
.ui-steps {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ui-space-2);
	list-style: none;
	padding: 0;
	margin-block: 0 var(--ui-space-6);
	font-size: var(--ui-text-xs);
}
.ui-steps > li {
	padding: var(--ui-space-1) var(--ui-space-3);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-full);
	color: var(--ui-text-muted);
}
.ui-steps > li[aria-current] {
	background: var(--ui-accent);
	border-color: var(--ui-accent);
	color: var(--ui-accent-contrast);
	font-weight: var(--ui-weight-bold);
}
.ui-steps > li.is-done { color: var(--ui-success-text); border-color: var(--ui-success); }

/* ── Progress / spinner / skeleton ───────────────────────────────────────*/
.ui-progress {
	height: var(--ui-space-2);
	background: var(--ui-surface-sunken);
	border-radius: var(--ui-radius-full);
	overflow: hidden;
}
.ui-progress > * {
	display: block;
	height: 100%;
	background: var(--ui-accent);
	border-radius: inherit;
	transition: width var(--ui-transition);
}
/* Set `--ui-value` (0–1) instead of `width` to animate the bar on the
   compositor rather than through layout — worth it for a bar that updates
   continuously, e.g. an upload. It is also the one way to fill a bar from a
   page under `style-src 'self'`: `--ui-value` is set through the CSSOM
   (`el.style.setProperty`), which CSP does not govern.

   The fill grows from the INLINE-START edge. `transform-origin` has no logical
   keyword — `inline-start` is not a value at all, so the declaration was
   dropped and the fill scaled out from the CENTRE of the track — so the
   physical edge is named and the `:dir(rtl)` twin flips it, the same pairing
   as `.ui-switch` and `.ui-drawer`. */
.ui-progress-scaled > * {
	width: 100%;
	transform: scaleX(var(--ui-value, 0));
	transform-origin: left center;
	transition: transform var(--ui-transition);
}
.ui-progress-scaled > :dir(rtl) { transform-origin: right center; }
/* Tone of the fill, for a bar that reports a LEVEL rather than progress
   towards something — disk pressure, quota, memory. The tone goes on the BAR,
   not on the fill element, so the product only ever swaps one class and the
   status vocabulary matches every other component's. */
.ui-progress-ok > *      { background: var(--ui-success); }
.ui-progress-warning > * { background: var(--ui-warning); }
.ui-progress-danger > *  { background: var(--ui-danger); }

/* The ring the system draws. `--ui-spinner-size` defaults to `1.15em` so an
   inline one tracks the text it sits in; a standalone page-level spinner (a
   "verifying your email…" screen) sets it to an absolute length instead of
   re-declaring the ring — which is what every product did, each with its own
   hardcoded track colour. */
.ui-spinner {
	display: inline-block;
	width: var(--ui-spinner-size, 1.15em);
	height: var(--ui-spinner-size, 1.15em);
	border: var(--ui-spinner-thickness, 2px) solid var(--ui-border-strong);
	border-top-color: var(--ui-accent);
	border-radius: var(--ui-radius-full);
	animation: ui-spin var(--ui-spin-duration, 640ms) linear infinite;
	flex: none;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* Spin anything in place — the icon-font glyph inside a busy button, the
   `ph-circle-notch` a product uses instead of the ring above, an inline `<svg>`.

   It exists because `.ui-spinner` is a *ring the system draws*, and a product
   that already has an icon set does not want a second visual vocabulary for
   "working" — so every one of them re-declared the rotation instead. engeene
   alone carried four: a `.pdm-spin` utility, a rule on the loading banner's
   glyph, a rule on the dashboard card's spinner, and an inline
   inline animation attribute (which is also a hole in `style-src`) — at three
   different durations, 0.7 s / 0.9 s / 0.9 s, for the same gesture. The website's
   verify page had re-declared the keyframes themselves.

   Retune with `--ui-spin-duration`; do not write a second `@keyframes`.

   Reduced motion SLOWS it rather than stopping it: a frozen spinner is not a
   calmer spinner, it is a broken one — the only thing on screen telling the
   reader the page is still working has stopped telling them. */
.ui-spin { animation: ui-spin var(--ui-spin-duration, 800ms) linear infinite; }
@media (prefers-reduced-motion: reduce) {
	.ui-spin, .ui-spinner { animation-duration: 2.4s; }
}

/* A placeholder shaped like the content that is coming.

   The sheen is a transform on an overlay rather than an animated
   `background-position`: background-position is not a compositable property, so
   animating it repaints every skeleton on the main thread, 60 times a second,
   exactly while the page is busy doing the work the skeleton stands in for. */
.ui-skeleton {
	position: relative;
	overflow: hidden;
	background: var(--ui-surface-sunken);
	border-radius: var(--ui-radius-sm);
	color: transparent;
	user-select: none;
}
.ui-skeleton::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg,
		transparent 0%,
		var(--ui-surface-hover) 50%,
		transparent 100%);
	animation: ui-shimmer 1.4s ease infinite;
}
@keyframes ui-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ── Avatar ──────────────────────────────────────────────────────────────*/
.ui-avatar {
	display: inline-grid;
	place-items: center;
	width: 2rem;
	height: 2rem;
	border-radius: var(--ui-radius-full);
	background: var(--ui-accent-soft);
	color: var(--ui-accent-text);
	font-size: var(--ui-text-xs);
	font-weight: var(--ui-weight-strong);
	overflow: hidden;
	flex: none;
	text-transform: uppercase;
}
.ui-avatar > img { width: 100%; height: 100%; object-fit: cover; }

/* ── Breadcrumb ──────────────────────────────────────────────────────────*/
.ui-breadcrumb {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ui-space-2);
	font-size: var(--ui-text-sm);
	color: var(--ui-text-muted);
	list-style: none;
	padding: 0;
}
.ui-breadcrumb > li + li::before {
	content: "/";
	margin-inline-end: var(--ui-space-2);
	color: var(--ui-text-subtle);
}
.ui-breadcrumb [aria-current] { color: var(--ui-text); font-weight: var(--ui-weight-semibold); }

/* ── Stat ────────────────────────────────────────────────────────────────
   Note the absence of `text-transform: uppercase` on the label — see the
   no-all-caps rule at the top of § 4. */
.ui-stat { display: flex; flex-direction: column; gap: var(--ui-space-1); }
.ui-stat-label {
	font-size: var(--ui-text-xs);
	font-weight: var(--ui-weight-bold);
	letter-spacing: var(--ui-tracking-wider);
	color: var(--ui-text-muted);
}
.ui-stat-value {
	font-size: var(--ui-text-2xl);
	font-weight: var(--ui-weight-strong);
	line-height: var(--ui-leading-tight);
	letter-spacing: var(--ui-tracking-tighter);
	/* Figures in a column of numbers must line up. */
	font-variant-numeric: tabular-nums;
}
/* The third line — the qualifier UNDER the figure ("of 1.2 M rows", "since
   Tuesday"), where `-label` is the caption above it. Every consumer that wanted
   one had spelled it out again (engeene's model-editor stat card and its
   `<pdm-stat-card>` element carried byte-similar copies), because the component
   shipped two lines and a stat routinely needs three. */
.ui-stat-sub { font-size: var(--ui-text-xs); color: var(--ui-text-muted); }

/* ── Empty state ─────────────────────────────────────────────────────────
   What a list, table, grid or panel shows when it has nothing to show. Centred,
   muted, and sized so the same class serves both a whole page and a single
   card.

       <div class="ui-empty">
         <i class="ph ph-folder-open ui-empty-icon" aria-hidden="true"></i>
         <p class="ui-empty-title">No dashboards yet</p>
         <p>Create one to get started.</p>
       </div>

   Four sizes and shapes, and they compose:

   | | |
   |---|---|
   | `ui-empty-sm`     | the in-card size — a popup's "no matches" |
   | `ui-empty-row`    | additionally spans every column of a CSS grid or a `<table>` row |
   | `ui-empty-fill`   | fills its HOST rather than standing in a page's flow — the placeholder inside a chart area, a dashboard tile, a results pane |
   | `ui-empty-inline` | glyph BESIDE the text instead of above it, for a host too short to stack in |

   `-fill` and `-inline` are here because "the panel is empty" and "the page is
   empty" are the same component at two altitudes, and every product had
   discovered that separately. engeene alone had seven builds of this — the
   chart placeholder, the highlight placeholder, two dashboard-tile placeholders,
   the in-viz Ask panel, the onboarding panel and a `<td>` — disagreeing about
   the glyph size (2.25× vs 3×), its opacity (.35 vs .4 vs .7), the direction,
   and the gap. Two of them were byte-identical rules under different names.

   Configure a call site with the four custom properties rather than restating
   the rule: `--ui-empty-gap`, `--ui-empty-padding`, `--ui-empty-icon-size`,
   `--ui-empty-title-size`. An onboarding panel that wants an outsized glyph sets
   `--ui-empty-icon-size: var(--ui-text-4xl)` and nothing else.

   An empty state is COPY, and copy is translated — never hard-code the string
   at a render site. */
.ui-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--ui-empty-gap, var(--ui-space-small));
	padding: var(--ui-empty-padding, var(--ui-space-12) var(--ui-space-5));
	text-align: center;
	color: var(--ui-text-muted);
	font-size: var(--ui-text-small);
}
.ui-empty-sm { padding: var(--ui-empty-padding, var(--ui-space-5) var(--ui-space-3)); }
.ui-empty-row { grid-column: 1 / -1; }
/* Fills the box it is dropped into. `height`, not `min-height`: the hosts are
   flex/grid children that have already been given their height by the layout
   above, and a `min-height` would let a long message push the tile taller than
   the row its neighbours are sized to. The generous page padding collapses —
   there is no page here, only a panel. */
.ui-empty-fill { height: 100%; padding: var(--ui-empty-padding, var(--ui-space-normal)); }
.ui-empty-inline { flex-direction: row; }
/* The `<td>` case. **Stand-alone — do not combine it with `.ui-empty`.**
   `.ui-empty` is `display: flex`, and a table cell that is not `display:
   table-cell` stops being a cell: the browser wraps it in an anonymous one and
   the `colspan` silently stops applying, so a "no rows yet" message renders in a
   one-column box instead of spanning the table. So this is the same treatment
   expressed for a cell, rather than the flex one overridden.

       <tr><td colspan="6" class="ui-empty-cell">No rows yet</td></tr> */
.ui-empty-cell {
	padding: var(--ui-space-5) var(--ui-space-3);
	text-align: center;
	color: var(--ui-text-muted);
	font-size: var(--ui-text-sm);
}
.ui-empty-icon { font-size: var(--ui-empty-icon-size, var(--ui-text-3xl)); opacity: 0.4; }
.ui-empty-title {
	color: var(--ui-text);
	font-size: var(--ui-empty-title-size, var(--ui-text-normal));
	font-weight: var(--ui-weight-bold);
	margin: 0;
}
.ui-empty > p { margin: 0; }

/* ── Split row — a name at one end, its value at the other ───────────────
   The shape every "settings summary", "service status", "shortcut list" and
   "review what you configured" list turns out to be: a full-width row with the
   label leading, the value trailing, and a hairline between rows but not after
   the last one.

       <div class="ui-split-row">
         <span class="ui-split-row-label">Region</span>
         <span class="ui-split-row-value">Europe</span>
       </div>

   Four hand-rolled copies were promoted into this: engeene's keyboard-shortcut
   row and its saved-filter reference row, the status page's service row, and a
   dead SSO review row nobody had noticed was dead. They disagreed about the
   gap, the padding and — the one that matters — whether the separator was a
   `border-bottom` with a `:last-child` reset or a `+`-combinator `border-top`;
   the two render differently the moment a row is hidden rather than removed.

   Retune the density with `--ui-split-row-padding` (block padding) and
   `--ui-split-row-gap`; do not re-declare the layout. The separator is drawn on
   the row's own `border-block-end` and cleared on the last one, so a row that
   is `display: none` takes its rule with it — which a `+`-combinator
   `border-top` does not, and that was the difference between two of the copies
   this replaced. */
.ui-split-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--ui-split-row-gap, var(--ui-space-3));
	padding-block: var(--ui-split-row-padding, var(--ui-space-2));
	border-block-end: 1px solid var(--ui-border);
}
.ui-split-row:last-child { border-block-end: none; }
/* `min-width: 0` on both halves so either can ellipsise with `.ui-truncate`
   instead of forcing the row wider than its container. */
.ui-split-row-label { color: var(--ui-text-muted); min-width: 0; }
.ui-split-row-value { font-weight: var(--ui-weight-bold); text-align: end; min-width: 0; }
/* Stacked on a narrow screen: the value drops under its label rather than the
   two colliding in the middle. Opt in — a two-word row is fine as it is. */
.ui-split-row-stack {
	flex-wrap: wrap;
	justify-content: flex-start;
}
.ui-split-row-stack > .ui-split-row-value { text-align: start; }

/* ── Table variants ──────────────────────────────────────────────────────*/
.ui-table-striped tbody tr:nth-child(even) { background: var(--ui-surface-sunken); }
.ui-table-hover tbody tr:hover { background: var(--ui-surface-hover); }
.ui-table-compact :where(th, td) { padding: var(--ui-space-1) var(--ui-space-2); }
/* Numeric columns read correctly only when right-aligned and tabular. */
.ui-num { text-align: end; font-variant-numeric: tabular-nums; }

/* Pins `thead` / `tfoot` when the table scrolls inside a pane. The footer is
   the totals row: a long breakdown is exactly where the overall figures matter
   most, and they are the first thing to scroll out of sight. Both need the
   sticky element to carry its own background, or rows show through. */
.ui-table-sticky-foot tfoot td, .ui-table-sticky-foot tfoot th {
	position: sticky;
	bottom: 0;
	z-index: 1;
	background: var(--ui-surface-hover);
	border-block-start: 2px solid var(--ui-border);
	font-weight: var(--ui-weight-strong);
}

/* The card FRAME a data table sits in. The cells are already styled by the
   base layer, so this is only the border, the radius and the clip that keeps
   the first and last rows inside the rounded corners.

       <div class="ui-table-card"><table class="ui-table-hover">…</table></div>

   It works on the `<table>` itself too, for a table that needs no wrapper —
   hence the margin reset on the class rather than only on a child.

   Every product with an operator screen had hand-rolled this same four-line
   rule; it is here so a table looks the same in all of them. */
.ui-table-card {
	background: var(--ui-surface-raised);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-lg);
	overflow: hidden;
	margin-block-end: 0;
}
.ui-table-card > table { margin-block-end: 0; }

/* Row actions that stay out of the way until the row is pointed at or
   keyboard-focused — the trash / rename / "…" cluster at the end of a row.

   The reveal is `opacity`, never `display` or `visibility`: the buttons keep
   their space, so a row does not reflow under the pointer, and they stay in
   the tab order, so a keyboard user reaches them at all (`:focus-within` then
   makes what they reached visible).

   The hosts are named rather than matched with a bare `:hover .ui-row-actions`
   — that would match every hovered ANCESTOR, i.e. `body`, i.e. always. Give an
   unusual host `.ui-row-host`.

   The HIDDEN state is written inside the hover-reveal query (§ Touch, below),
   never outside it: on a screen nothing can hover, the actions are simply there. */
.ui-row-actions {
	display: flex;
	gap: var(--ui-space-1);
	justify-content: flex-end;
	transition: opacity var(--ui-transition);
}

/* ── Touch — a fingertip is not a cursor ─────────────────────────────────
   Rules 1 and 2 are queries rather than classes, because what they key on is
   the device, not the component; rule 3 (below) is a bubble and its script.

   1. A HOVER REVEAL HIDES ONLY WHERE SOMETHING CAN HOVER. Anything that is
      invisible until its host is pointed at — row actions, a card's "⋮", a
      column header's caret, a category's menu — does not exist on a touch
      screen: there is no pointer to rest on it, and a tap that happens to land
      on the invisible button is luck, not a design. So the hidden state is
      written inside

          @media (hover: hover) and (not (any-pointer: coarse)) { … }

      and NOWHERE ELSE — outside it the part is just visible. A product writes
      its reveal once, in that block, and the touch case needs no second rule
      per component. `(not (any-pointer: coarse))` and not `hover: hover`
      alone, because a touch LAPTOP's primary pointer is its trackpad —
      `hover: hover` would hide the action from the finger on the very same
      screen. An engine that cannot parse the `not (…)` form treats the whole
      query as false, so the part shows: the failure is the safe one. The query
      is repeated by necessity (a custom property cannot be read in a media
      query), exactly like the phone breakpoint.

   2. A CONTROL IS A TAP TARGET ON A COARSE POINTER. `--ui-tap-target`
      (2.75rem, 44 px — Apple's HIG minimum, WCAG 2.2 SC 2.5.5) becomes the
      minimum height of every interactive row and button, as `.ui-icon-btn`'s
      box already did. On the PRIMARY pointer only (`pointer: coarse`): a touch
      laptop driven by its trackpad keeps the dense desktop rhythm — rule 1 is
      about reachability, which is binary; this one is comfort, which follows
      the hand actually in use. Nothing changes for a mouse. */
@media (hover: hover) and (not (any-pointer: coarse)) {
	.ui-row-actions { opacity: 0; }
	:is(tr, li, .ui-option, .ui-card, .ui-row-host):is(:hover, :focus-within) .ui-row-actions,
	.ui-row-actions:focus-within { opacity: 1; }
}
@media (pointer: coarse) {
	.ui-btn, .ui-control, .ui-menu-item, .ui-option, .ui-segmented-btn { min-height: var(--ui-tap-target); }
}
/* 3. A `title` IS REACHABLE BY TOUCH. A browser shows `title` on hover only, and many titles
      carry the only copy of something (a truncated name, a dot's meaning, the list behind a
      warning glyph). `touch-title.js` shows it in this bubble on a long press — or on a tap,
      where the element is not a control. The bubble is a toast-surface sibling: raised, quiet,
      never in the way of a pointer. */
.ui-touch-tip {
	position: fixed;
	z-index: var(--ui-z-toast);
	max-width: min(20rem, calc(100vw - 2 * var(--ui-space-2)));
	padding: var(--ui-space-2) var(--ui-space-3);
	background: var(--ui-surface-raised);
	color: var(--ui-text);
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-md);
	box-shadow: var(--ui-shadow-md);
	font-size: var(--ui-text-sm);
	white-space: pre-line;
	overflow-wrap: anywhere;
	pointer-events: none;
}

/* ── Skip link ───────────────────────────────────────────────────────────
   First focusable element on the page, off-screen until focused (WCAG 2.4.1). */
.ui-skip-link {
	position: absolute;
	inset-inline-start: -9999px;
	top: 0;
	z-index: 999;
	padding: var(--ui-space-2) var(--ui-space-4);
	background: var(--ui-accent);
	color: var(--ui-accent-contrast);
	border-end-end-radius: var(--ui-radius-md);
	font-weight: var(--ui-weight-bold);
}
.ui-skip-link:focus { inset-inline-start: 0; color: var(--ui-accent-contrast); text-decoration: none; }

/* ── Wingman bar ─────────────────────────────────────────────────────────
   "Tell the assistant how to change this" — an optional undo/redo pair, a
   prompt field, and a chrome-less accent glyph that submits. Behaviour is
   `@hrayo/foundation-ui-wingman`, which ships no CSS of its own.

   Four things here are the component and not decoration:

   • The **suggestion** state. A placeholder may be an ordinary hint or a
     suggestion the user accepts with Tab, and the reader has to be able to tell
     which — so `is-suggestion` paints the placeholder in the accent instead of
     the subtle tone every other placeholder takes. `opacity: 1` because the UA
     sheet dims a placeholder by default, which would mute exactly the signal.
   • The **busy row replaces the field inside the group**, so "what it is doing"
     is never a second indicator floating somewhere else on the toolbar. It is
     inserted where the field was, wears the same box, and is the reason the
     component swaps DOM nodes rather than toggling `hidden`: `.ui-input-group`'s
     first/last radius rules key on the DOM, not on visibility. **The failure row
     takes the same slot** for the same reason: a failure is a state of the field
     the user was typing into, and it is a `<button>` because the whole row is the
     "put my field back" target.
   • The **submit glyph lives INSIDE the field**, like a search field's own
     submit — not as a button welded on beside it. `.ui-wingman-input` is what
     makes that possible and is the reason it exists: an `<input>` cannot have
     children, so the BOX (border, fill, radius, focus ring) is the wrapper's
     and the `<input>` inside it is chrome-less. That is also why the glyph is
     laid out rather than absolutely positioned — a flex sibling can never run
     under the typed text, never collide with a textarea's resize grip, and
     grows the field's box by itself when the icon button opens up to its
     44 px coarse-pointer target. Nothing here re-declares `.ui-icon-btn`; the
     one thing this call site configures is its resting tone, because in a
     field the submit action IS the accent (`.ui-icon-btn-accent` alone tints
     only on hover, which is right for a row action and wrong for this one).
   • The wrapper owns the border rather than the field taking the base layer's,
     because it is welded into a control with buttons beside it — so it is the
     wrapper that `.ui-input-group`'s first/last radius and `-1px` overlap rules
     act on, with no wingman-specific override needed.

   One consequence of that last point is a CONTRACT on the host product: in this
   component the BOX is the control and the `<input>` is a chrome-less part of
   it, so a product stylesheet that pins its own control DENSITY on bare
   `input`s must EXCLUDE `.ui-wingman-field`. A fixed height on the field is a
   definite cross size, which (a) defeats the `align-self: stretch` below and
   (b) makes the wrapper that height PLUS its own border — so the bar rendered
   2 px taller than the undo/redo buttons welded beside it, which is the whole
   reason those buttons and this box are in one `.ui-input-group`. The field
   states `height: auto` for exactly this reason, but a `input:not(…):not(…)`
   density selector outranks a single class, so the exclusion has to be at the
   call site. engeene does it in `paradigm-query-web/static/app.css`. */
.ui-wingman { display: flex; flex: 1 1 auto; min-width: 0; flex-direction: column; gap: var(--ui-space-1); }
.ui-wingman-group { flex: 1 1 auto; min-width: 0; max-width: 100%; }
.ui-wingman-group > .ui-btn { flex: 0 0 auto; align-self: stretch; }
/* The field's visible box: the chrome-less `<input>` and its in-field trailing
   action, side by side. `--ui-space-1` on the trailing edge is the optical
   hairline that keeps the glyph flush to the border without touching it. */
/* The field's box and the busy row that REPLACES it are the same slot in the
   welded control, so they state that shape once: same flex behaviour, same
   border, same radius. Only the fill and the inner rhythm differ below — a
   second copy of the box is how the two drift a pixel apart mid-request. */
.ui-wingman-input, .ui-wingman-busy, .ui-wingman-error {
	display: flex;
	align-items: center;
	flex: 1 1 auto;
	min-width: 0;
	border: 1px solid var(--ui-border-strong);
	border-radius: var(--ui-radius-md);
}
.ui-wingman-input {
	gap: var(--ui-space-1);
	min-width: 8rem;
	width: 0; /* flex basis: the group owns the width, not the field's size attr */
	padding-inline: var(--ui-space-small) var(--ui-space-1);
	background: var(--ui-surface);
	/* Containing block for the suggestions menu below — the field's BOX is what the
	   list belongs to (its width, its leading edge), not the whole welded group.
	   The reply panel positions against `.ui-wingman-reply` instead, because it
	   belongs to the reply affordance and hangs off the trailing edge. */
	position: relative;
}
.ui-wingman-input:focus-within { border-color: var(--ui-accent); z-index: 1; }
/* In a field, the submit action is the accent at rest — not only on hover. */
.ui-wingman-input > .ui-icon-btn-accent { color: var(--ui-accent-text); }
/* `align-self: stretch` so the typing target is the whole box rather than one
   line-height in the middle of it: the box's own height comes from the tallest
   thing in it (the submit glyph's 1.75rem target, or the welded siblings when
   the group stretches it), and a field that did not fill it would leave a dead
   strip above and below the caret that still LOOKS like the field. It stretches
   because its `height` is `auto` — see the contract in the section comment. */
/* The field is a RICH text box (a `contenteditable` host), not an `<input>`,
   because a reference is part of the sentence and so has to live IN it — a pill
   sits where the words it replaced sat and moves with the text around it. Three
   consequences are the component and not decoration:

   • `white-space: pre` keeps the user's own spacing, which matters here in a way
     it does not in a plain field: the space each side of a pill is real typed
     text, and collapsing it would move the object against its neighbour.
   • the placeholder is drawn from `data-placeholder`, and shown on
     `[data-empty="true"]` rather than on `:empty` — a field holding only pills
     has no text and is not empty.
   • it centres rather than stretching, because a rich field is only as tall as
     its line; the BOX stays the typing target because the component focuses the
     field from a click on it. `overflow: hidden` is the single-line form: the
     browser still scrolls the caret into view, so a long prompt runs off the
     edge exactly as it did in an `<input>`, without a scrollbar in a one-line
     control. */
.ui-wingman-field {
	flex: 1 1 auto;
	align-self: center;
	min-width: 0;
	width: 0;
	height: auto;
	border: 0;
	padding: 0;
	font-size: var(--ui-text-rel-small);
	background: none;
	color: var(--ui-text);
	white-space: pre;
	overflow: hidden;
}
.ui-wingman-field:focus { outline: none; }
.ui-wingman-field[data-empty="true"]::before {
	content: attr(data-placeholder);
	color: var(--ui-text-subtle);
	pointer-events: none;
}
.ui-wingman-field.is-suggestion[data-empty="true"]::before { color: var(--ui-accent-text); }
/* The KEY that accepts the offer. It is a `.ui-kbd` — the shared keycap — and
   not part of the placeholder string, because a suggestion is prose the reader
   reads and Tab is a key they press: one string cannot render the second as a
   key, and glueing "⇥" onto the sentence makes it look like punctuation. It
   lives in the field's box so it sits with the offer it belongs to — in FRONT
   of it, because the key is read before the offer it accepts and because a
   suggestion long enough to ellipsise would otherwise push its own key off the
   field's edge — and it never shrinks: a keycap squeezed by a long suggestion
   stops reading as one. */
.ui-wingman-hint { flex: 0 0 auto; }
/* In the panel form the box is bottom-aligned (the glyph sits beside the last
   line of a growing prompt), but the placeholder it prefixes starts on the
   FIRST line — so the keycap follows the text, not the glyph. */
.ui-wingman-multiline .ui-wingman-hint { align-self: flex-start; }
/* The REFERENCES the prompt carries — the application's own objects (a dashboard,
   a column) — as pills INSIDE the sentence, at the place the words they stand for
   were typed. There is deliberately no rail: a rail puts every object at the front
   whatever the user meant, so the one thing a reference is for (saying WHERE in
   the ask the object belongs) is the one thing it could not express. The pill is
   the standard rich-input chip: `contenteditable="false"` inside the editable
   host, so the browser itself makes it atomic — the caret steps over it, a
   keystroke cannot rewrite half of it, and a Backspace against it takes the whole
   thing.

   A pill IS a `.ui-tag` — the system's removable filled token, worn as-is, with
   `.ui-tag-remove` as its dismiss affordance. A reference is exactly what that
   component already means (a named thing, attached, removable), so re-declaring
   its surface here under a wingman name would be the second-pill-under-a-private-
   name this system exists to prevent. All this states is how it sits in a line of
   text: on the text's baseline, and never wider than a share of the field. */
.ui-wingman-ref { max-width: 14rem; }
/* "⌘+Click to open the dashboard" — the row's OTHER meaning. It IS a
   `.ui-menu-shortcut` (it wears that class); the only thing stated here is the
   reveal, because a hint on every row at rest would be a wall of text on a list
   whose rows are read by their titles. Hover for the pointer, `aria-selected` for
   the keyboard — the roving highlight is what a keyboard user has instead of a
   hover, and a chord advertised to one and not the other is not an affordance. */
.ui-wingman-action-hint { display: none; }
.ui-menu-item:hover > .ui-wingman-action-hint,
.ui-menu-item[aria-selected="true"] > .ui-wingman-action-hint { display: inline; }
/* On a two-line row it takes the trailing side of the SECOND line, so a row that
   carries both an accelerator and a chord hint does not stack them on one cell. */
.ui-menu-item-stacked > .ui-wingman-action-hint { grid-area: 2 / 3; }
/* The assistant's ANSWER, on the trailing side. Deliberately NOT a placeholder:
   a suggestion is an offer the user accepts INTO the field, a reply is what came
   back, and the one place both could render is the one place they would be
   confused. So it is a collapsed, truncated affordance that keeps its distance
   from the caret, capped at a share of the box so the field it annotates stays
   the larger thing. */
.ui-wingman-reply {
	position: relative;
	min-width: 0;
	max-width: 40%;
	display: flex;
	padding: 0 var(--ui-space-1);
	font-size: var(--ui-text-rel-small);
	color: var(--ui-text-muted);
}
/* The standing DISCLOSURE — "this is AI, it can be wrong" — on the field's
   trailing side. Three things about it are the design and not decoration:

   • It is only ever up while the field is FOCUSED and EMPTY, which is why it can
     sit IN the box at all: the one moment it is read is the moment the box is
     otherwise unused, and it is gone before the prompt needs the width. A
     disclaimer parked under the bar forever is the alternative, and it is both
     easier to stop seeing and a permanent line of chrome.
   • **The FOCUS half of that condition is here, and the EMPTY half is the
     component's.** `[hidden]` is the component saying there is no room (the field
     holds text or a pill, a reply has the slot, the bar is disabled) — a field
     holding only pills has no text and is not empty, which is state only it can
     see. Focus is the opposite: holding it in the component means catching its
     events, and a host that focuses the bar as it boots produces none to catch
     (`focus()` on the already-active element fires nothing), so the notice never
     appeared. `:focus-within` asks the browser instead of remembering.
   • It SHRINKS rather than pushing: `flex: 0 1 auto` with `min-width: 0`, so a
     narrow bar ellipsises the notice instead of squeezing the field the notice
     is about. It is not a control — no pointer events, no selection — so it can
     never take a click meant for the field behind it.

   The tone is `--ui-text-subtle`: quieter than the reply (`--ui-text-muted`),
   because a reply is content and this is a standing fact about the field. */
.ui-wingman-notice {
	display: none;
	flex: 0 1 auto;
	min-width: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	font-size: var(--ui-text-rel-small);
	color: var(--ui-text-subtle);
	pointer-events: none;
	user-select: none;
}
/* `:not([hidden])` so the component's "there is no room" always wins — without it
   this rule would out-specify the UA's `[hidden] { display: none }`. */
.ui-wingman-input:focus-within > .ui-wingman-notice:not([hidden]) { display: block; }
/* In the panel form the box is bottom-aligned around a growing prompt, so the
   notice follows the LAST line — beside the glyph it sits with — rather than
   floating against the first. */
.ui-wingman-multiline .ui-wingman-notice { align-self: flex-end; }
/* The panel IS a `.ui-popover` — it wears that class and this rule only places
   it. Re-declaring the raised surface here would be a second popover under a
   private name, which is exactly what the system exists to prevent. Revealed by
   hover, by keyboard focus AND by `is-open` (the tap toggle) — all three,
   because a hover-only reveal is unreachable with a keyboard and invisible on a
   touch screen. `text-align` because a `<button>` centres its content. */
.ui-wingman-reply-full {
	position: absolute;
	inset-inline-end: 0;
	top: calc(100% + var(--ui-space-1));
	display: none;
	max-width: min(26rem, 90vw);
	padding: var(--ui-space-small);
	color: var(--ui-text);
	text-align: start;
}
.ui-wingman-reply:hover > .ui-wingman-reply-full,
.ui-wingman-reply:focus-visible > .ui-wingman-reply-full,
.ui-wingman-reply.is-open > .ui-wingman-reply-full { display: block; }
/* The thought process, when the host has one — under a rule, in the quieter
   tone, because it explains the answer rather than being it. */
.ui-wingman-reply-body, .ui-wingman-reply-detail { display: block; }
.ui-wingman-reply-detail {
	margin-block-start: var(--ui-space-small);
	padding-block-start: var(--ui-space-small);
	border-block-start: 1px solid var(--ui-border);
	color: var(--ui-text-muted);
}
/* What the APPLICATION offers for what is being typed. This is the ONE thing the
   component adds to the shared vocabulary and it is placement only: the surface,
   the rows, the group headings and the selected state are all `.ui-popover
   .ui-menu` / `.ui-menu-item` / `.ui-menu-label` / `aria-selected`, worn by the
   markup the component writes. Re-declaring any of that here would be a second
   menu under a private name, which is exactly what the system exists to prevent.

   It spans the field's box rather than hugging its content, because a list of
   places to go to reads as a continuation of the field it was typed into — and
   because a row's title is arbitrary product text, so a content-width menu would
   change width on every keystroke. `.ui-menu`'s own scroll cap handles a long
   answer; nothing here re-states one. */
.ui-wingman-menu {
	position: absolute;
	inset-block-start: calc(100% + var(--ui-space-1));
	inset-inline: 0;
}
/* The menu's own `--ui-z-popover` is not enough, and the reason is the one thing
   about stacking that is easy to get wrong: `.ui-wingman-input` is POSITIONED and
   the `:focus-within` rule above gives it `z-index: 1`, which makes it a stacking
   context — so everything inside it, the 2000 included, is squashed into that
   single layer at z-index 1, and a `--ui-z-sticky` (100) table header outside it
   paints straight over the menu. (Found by `WebUiAskSearchTest`, where a results
   `<th>` intercepted the click.) So the BOX has to be raised to the popover layer
   for as long as it holds an open menu — a `:has()` on the component's own
   `hidden`, not a state class, because the component toggles `hidden` and a second
   name for the same fact is a second thing to keep in step. Still the token; never
   a hand-picked number. */
.ui-wingman-input:has(> .ui-wingman-menu:not([hidden])) { z-index: var(--ui-z-popover); }
/* Nothing to send: the glyph is EMPTY. A host that supplies `submitEmptyIcon`
   gets a genuinely outlined mark; with one glyph this tone is the whole signal,
   so it must read as "inert", not as "accent, dimmed". */
.ui-wingman-input > .ui-icon-btn-accent.is-empty { color: var(--ui-text-subtle); }
/* Busy and failure are one row in two states, so the box is one rule and only the
   tone differs. `font: inherit` / `cursor: pointer` are NOT restated on the
   failure `<button>` — `reset.css` already gives every button both, and a second
   copy here is the drift this system exists to prevent. */
.ui-wingman-busy, .ui-wingman-error {
	gap: var(--ui-space-small);
	padding: 0 var(--ui-space-small);
	font-size: var(--ui-text-rel-small);
}
.ui-wingman-busy {
	background: var(--ui-surface-sunken);
	color: var(--ui-text-muted);
}
/* One truncating line in the field's slot — the busy row's status and the failure
   row's sentence are the same part in two states, so they are one rule. */
.ui-wingman-status, .ui-wingman-error-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The failure row takes the FIELD's slot, like the busy row — a red line hanging
   under the bar is easy to miss and impossible to dismiss, and a failure is a
   state of the thing the user was typing into. It is a `<button>` because the one
   action available is "put my field back", so the whole row is the target. */
.ui-wingman-error {
	background: var(--ui-danger-soft);
	color: var(--ui-danger-text);
	text-align: start;
}
/* Multiline: a form in a panel rather than a welded toolbar control. The glyph
   is still in the field, but anchored to its BOTTOM edge — beside the last line
   of a growing prompt, and (because it is laid out rather than positioned) to
   the side of the textarea's resize grip rather than on top of it. */
.ui-wingman-multiline .ui-wingman-group { display: flex; align-items: flex-end; }
.ui-wingman-multiline .ui-wingman-input {
	align-items: flex-end;
	width: 100%;
	padding: var(--ui-space-small);
	gap: var(--ui-space-small);
}
/* The panel form WRAPS: a prompt several lines long is what the panel is for, so
   the field wraps its text (rather than the single-line bar's sideways scroll),
   grows with what is typed, and starts scrolling only once it is taller than a
   short paragraph. `align-self: auto` undoes the single-line centring — here the
   field's own height is the box's, and the glyph sits beside its last line. */
.ui-wingman-multiline .ui-wingman-field {
	display: block;
	align-self: auto;
	width: 100%;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	overflow-y: auto;
	min-height: calc(2em * var(--ui-leading-normal));
	max-height: 12rem;
}
.ui-wingman-multiline .ui-wingman-busy, .ui-wingman-multiline .ui-wingman-error { padding: var(--ui-space-small); }


/* ══════════════════════════════════════════════════════════════════════════
   5. LAYOUT + UTILITIES — the handful that replace an inline `style=`.

   Deliberately small. A utility per CSS property is a second language to
   learn and ends up in markup that says less than the CSS it replaced; these
   exist because "a column with even gaps" and "quieter text" are the two
   things every page needs and nobody should re-type.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── App shell ───────────────────────────────────────────────────────────
   The frame an APPLICATION lays out in, as opposed to a document: the page is
   exactly the viewport, the chrome is fixed, and there is exactly one
   scrolling region inside it.

       <html class="ui-app-shell"><body class="ui-app-shell">
         <header class="ui-navbar">…</header>
         <main class="ui-app-content">…</main>
       </body></html>

   Both elements take the class — `height: 100%` on the body means nothing
   unless the root has a height too, which is the step every product gets
   wrong once. `min-height: 0` on the content is the other one: without it a
   flex child refuses to shrink below its content and the page scrolls as a
   whole, taking the fixed chrome with it.

   Also zero the shell's own min-height: a product reset often sets
   `body { min-height: 100dvh }`, and a flex item's default `min-height: auto`
   is content-sized — either one alone is enough for the document to grow past
   the viewport and drag fixed chrome (navbar) with it. Cap at `100dvh` so
   mobile browser chrome cannot re-open a document scrollbar either. */
.ui-app-shell {
	height: 100%;
	height: 100dvh;
	max-height: 100dvh;
	min-height: 0;
	margin: 0;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	background: var(--ui-surface-sunken);
	color: var(--ui-text);
}
.ui-app-content { flex: 1; min-height: 0; overflow: auto; }

/* ── Section / hero ──────────────────────────────────────────────────────
   The two shapes a marketing or documentation page is made of, which an
   application does not have: a full-bleed horizontal band with generous
   vertical rhythm, and the tall first one.

       <section class="ui-section"><div class="ui-container">…</div></section>
       <section class="ui-hero"><div class="ui-container">…</div></section>

   Retune one instance with `--ui-section-space` rather than a stack of margin
   utilities — the whole reason these exist is that "how much air does a
   section get" is one decision per site, not one per section. `ui-section-tint`
   reverses the tone for a band that needs to stand out; the page's own
   background stays the product's. */
.ui-section {
	--ui-section-space: var(--ui-space-16);
	padding-block: var(--ui-section-space);
}
.ui-section-tight { --ui-section-space: var(--ui-space-10); }
.ui-section-tint { background: var(--ui-surface-raised); }
.ui-hero {
	--ui-section-space: var(--ui-space-20);
	padding-block: var(--ui-section-space);
	/* Clears fixed chrome above it, and only that — a hero that also pins a
	   height stops fitting its own content in the first translation that runs
	   long. */
	padding-block-start: calc(var(--ui-section-space) + var(--ui-navbar-height, 0px));
}

.ui-container {
	width: 100%;
	max-width: var(--ui-container);
	margin-inline: auto;
	padding-inline: var(--ui-space-5);
}
.ui-container-narrow { max-width: var(--ui-prose); }

/* A vertical rhythm without margins on the children. Override the gap per
   instance with `style="--ui-gap: var(--ui-space-8)"` — one custom property
   is a legitimate inline value; a block of layout is not. */
.ui-stack {
	display: flex;
	flex-direction: column;
	gap: var(--ui-gap, var(--ui-space-4));
}
/* A horizontal row that wraps instead of overflowing. */
.ui-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ui-gap, var(--ui-space-3));
}
.ui-row-between { justify-content: space-between; }
.ui-row-end { justify-content: flex-end; }
.ui-row-top { align-items: flex-start; }
/* A row of `.ui-field`s: each is label-over-control and they are rarely the same
   height, so the CONTROLS line up along the bottom rather than the labels along the
   middle. The missing member of this family — every consumer had been writing
   `align-items: flex-end` inline beside `.ui-row`'s other three declarations. */
.ui-row-bottom { align-items: flex-end; }
.ui-row-nowrap { flex-wrap: nowrap; }
/* Column count adapts to the width available, with no breakpoints to keep. */
.ui-grid {
	display: grid;
	gap: var(--ui-gap, var(--ui-space-4));
	grid-template-columns: repeat(auto-fit, minmax(var(--ui-col, 16rem), 1fr));
}
/* `min-width: 0` is not an extra — it is half of what "take the leftover width"
   means. A `flex: 1` child will not shrink below its CONTENT's intrinsic width, so
   without it a `.ui-truncate` inside a spacer never truncates and the row overflows
   instead; every consumer had learned to write `style="min-width:0"` beside the class
   (seven copies in engeene's shell alone, three of them in shared factories). An empty
   spacer — the pure filler use — has no content, so nothing changes for it. */
.ui-spacer { flex: 1; min-width: 0; }

/* Long-form text: measure capped, and links underlined, because in running
   prose colour alone does not reliably read as a link. */
.ui-prose { max-width: var(--ui-prose); }
.ui-prose a { text-decoration: underline; text-underline-offset: 0.15em; }

/* ── Markdown block — vertical rhythm for RENDERED markup ────────────────
   `.ui-prose` caps the measure of text you authored as HTML. This is the other
   half: a container whose CHILDREN arrive as generated `<h1>`/`<p>`/`<ul>`/
   `<pre>` from a markdown renderer, so nothing at the call site can put a class
   on them and the rhythm has to be stated by element.

       <div class="ui-markdown">…rendered markdown…</div>

   Promoted from copies that had drifted: engeene's dashboard markdown viz
   (which also backs the AI "Explain" dialog) and the marketing site's legal
   pages, both of which now compose this. They disagreed about heading scale
   and, more visibly, about `<code>` — one tinted the inline span and the
   fenced block, one only the block, so the same snippet read as two different
   things on two of our own pages. (A third copy lives in the knowledge-base
   site generator, which emits its own stylesheet from a sibling repo — it is
   not a consumer of this package yet.)

   Sizes are `em`, not tokens, so the block scales with whatever font-size the
   host gives it — a dashboard card sets `.9em` and gets a proportionate
   heading scale for free. Combine with `.ui-prose` when the block is a page of
   running text rather than a card. */
.ui-markdown { line-height: var(--ui-leading-relaxed); }
.ui-markdown > :first-child { margin-block-start: 0; }
.ui-markdown > :last-child { margin-block-end: 0; }
.ui-markdown h1 { font-size: var(--ui-text-rel-xl); margin-block: 0 0.5em; line-height: var(--ui-leading-tight); }
.ui-markdown h2 { font-size: var(--ui-text-rel-lg); margin-block: 0.8em 0.4em; line-height: var(--ui-leading-snug); }
.ui-markdown h3 { font-size: var(--ui-text-rel-md); margin-block: 0.8em 0.3em; }
/* The outline has to keep DESCENDING past h3. Stopping at h3 does not leave h4
   unstyled — it hands it to the bare-element rule, where `h4` is
   `--ui-text-lg`, i.e. LARGER than the h3 above it, and the document reads as
   though the section headings had been shuffled. Generated markdown is exactly
   where this shows up: nothing at the call site can class the children, and a
   long documentation article is one of the few surfaces that really reaches h4. */
.ui-markdown h4, .ui-markdown h5, .ui-markdown h6 {
	font-size: var(--ui-text-rel-small);
	margin-block: 0.8em 0.3em;
	line-height: var(--ui-leading-snug);
}
.ui-markdown p { margin-block: 0.3em; }
.ui-markdown ul, .ui-markdown ol { margin-block: 0.3em; margin-inline: 1.2em 0; padding: 0; }
.ui-markdown li { margin-block: 0.15em; }
.ui-markdown blockquote {
	margin-block: 0.5em;
	margin-inline: 0;
	padding-inline-start: var(--ui-space-3);
	border-inline-start: 2px solid var(--ui-border);
	color: var(--ui-text-muted);
}
/* Inline code and a fenced block are the SAME surface at two scales — that is
   the drift this fixes. `.ui-code-block` remains the standalone, copyable
   block (a token, a curl command); this is the one a renderer emits. */
.ui-markdown code {
	font-family: var(--ui-font-mono);
	font-size: var(--ui-text-rel-sm);
	background: var(--ui-surface-sunken);
	padding: 1px var(--ui-space-1);
	border-radius: var(--ui-radius-sm);
}
.ui-markdown pre {
	background: var(--ui-surface-sunken);
	border-radius: var(--ui-radius-md);
	padding: var(--ui-space-3);
	overflow: auto;
	margin-block: 0.5em;
}
.ui-markdown pre code { background: none; padding: 0; font-size: var(--ui-text-rel-md); }
/* The bare `table` rule is `0 0 1rem`: flush against whatever is above it, so
   a table right under a code block or a paragraph read as glued to it. A table
   in rendered markup takes the same rhythm as a fenced block. */
.ui-markdown table, .ui-markdown .ui-table-scroll { margin-block: 0.5em; }
/* A table in its scroll wrapper hands the rhythm to the wrapper: the wrapper
   scrolls, so it is its own formatting context and the table's margins would
   stay inside it, adding to the neighbours' instead of collapsing with them. */
.ui-markdown .ui-table-scroll > table { margin-block: 0; }
/* A table's automatic layout gives the prose column the room and squeezes a
   column of identifiers to its narrowest, so `--languages` broke at its
   hyphen. An identifier in a cell stays on one line; a table that then
   outgrows its column scrolls inside its `.ui-table-scroll`. */
.ui-markdown :where(th, td) code { white-space: nowrap; }
.ui-markdown a { color: var(--ui-accent-text); text-decoration: underline; text-underline-offset: 0.15em; }
.ui-markdown img { max-width: 100%; height: auto; }
/* A rule between top-level sections, the shape a long legal / policy page
   wants. Opt in — a dashboard note does not. */
.ui-markdown-sectioned h2 {
	margin-block-start: 3em;
	padding-block-start: 1.5em;
	border-block-start: 1px solid var(--ui-border);
}
.ui-markdown-sectioned h2:first-child {
	margin-block-start: 0;
	padding-block-start: 0;
	border-block-start: none;
}
/* More air, for a block that IS the page — a documentation article read top to
   bottom — rather than a note inside a card. The base rhythm is tight because
   its first consumers were a dashboard tile and a dialog, where a paragraph gap
   of a full line reads as a hole. On a long article the same gaps let a heading
   sit as close to the section it ends as to the one it opens. Opt in.

   Only the space ABOVE a heading grows: what sets a section apart is that the
   heading is nearer its own text than the text before it. The space around a
   picture goes on the paragraph the renderer wraps it in, not on the `<img>` —
   an inline image's margins do not collapse with its neighbours', a block's do.
   `.ui-markdown > :first-child` outweighs these, so the block still starts
   flush. */
.ui-markdown-spacious p { margin-block: 0.8em; }
.ui-markdown-spacious h1 { margin-block-start: 1.6em; }
.ui-markdown-spacious h2 { margin-block-start: 1.8em; }
.ui-markdown-spacious h3 { margin-block-start: 1.5em; }
.ui-markdown-spacious h4, .ui-markdown-spacious h5, .ui-markdown-spacious h6 { margin-block-start: 1.3em; }
.ui-markdown-spacious p:has(> img:only-child, > a:only-child > img:only-child) { margin-block: 1.6em; }
/* A code block or a table is a framed box, not a line of text: at the base
   0.5em two consecutive fences, or a fence and the table that explains it,
   read as one block. Give them more air than a paragraph's 0.8em. */
.ui-markdown-spacious pre, .ui-markdown-spacious table, .ui-markdown-spacious .ui-table-scroll { margin-block: 1.4em; }

.ui-muted { color: var(--ui-text-muted); }
.ui-subtle { color: var(--ui-text-subtle); }
.ui-danger-text { color: var(--ui-danger-text); }
.ui-success-text { color: var(--ui-success-text); }
.ui-warning-text { color: var(--ui-warning-text); }
.ui-info-text { color: var(--ui-info-text); }
.ui-accent-text { color: var(--ui-accent-text); }
.ui-mono { font-family: var(--ui-font-mono); font-variant-ligatures: none; }
/* Digits on a fixed advance, so a column of numbers lines up and a live counter
   does not jitter as it ticks. `.ui-num` is this plus end-alignment. */
.ui-tabular { font-variant-numeric: tabular-nums; }
.ui-weight-normal { font-weight: var(--ui-weight-normal); }
.ui-weight-medium { font-weight: var(--ui-weight-medium); }
.ui-weight-bold { font-weight: var(--ui-weight-bold); }
.ui-text-end { text-align: end; }
.ui-w-full { width: 100%; }
/* The ABSOLUTE ladder as utilities. It runs to the top of the ladder on purpose:
   the three display stops below used to be missing while `--ui-text-3xl/4xl/5xl`
   existed, and a consumer reaching for the documented `.ui-text-4xl` got a class
   NO stylesheet declared — so the element fell back to whatever sized it. That is
   silent in every possible way: no console warning, no build failure, nothing to
   see unless you already know the intended size. It shipped on ten headings of
   eight marketing pages, where four `<h1 class="ui-text-4xl">` rendered at the
   `h1` size (3.00× -> 2.25×) and an `<h2 class="ui-text-4xl">` rendered at the
   `h2` size (1.75×) — the same class, two different sizes, one page apart
   (UX-042). A rung with a token and no utility is a trap; if a rung is added
   above, its utility goes in here in the same edit.

   Unlike the SEMANTIC heading tokens these are flat: `--ui-text-h1`/`-h2` step
   down below the phone breakpoint (§ 2) and a ladder rung never does, because a
   caller reaching for a raw rung is asking for that size and not for a level in a
   document outline. There is deliberately no `.ui-text-md` — that stop is
   `.ui-text-normal`, which is also what `body` already inherits. */
.ui-text-xs { font-size: var(--ui-text-xs); }
.ui-text-sm { font-size: var(--ui-text-sm); }
.ui-text-lg { font-size: var(--ui-text-lg); }
.ui-text-xl { font-size: var(--ui-text-xl); }
.ui-text-2xl { font-size: var(--ui-text-2xl); }
.ui-text-3xl { font-size: var(--ui-text-3xl); }
.ui-text-4xl { font-size: var(--ui-text-4xl); }
.ui-text-5xl { font-size: var(--ui-text-5xl); }
/* The three semantic sizes, as utilities. Prefer these over the ladder ones
   above for ordinary copy — see § Type, SEMANTIC. */
.ui-text-small { font-size: var(--ui-text-small); }
.ui-text-normal { font-size: var(--ui-text-normal); }
.ui-text-large { font-size: var(--ui-text-large); }
/* The same three, sized against the INHERITED size — what chrome nested inside
   an already-shrunk container wants. These exist as classes so generated HTML
   can stop writing `style="font-size:…"`, which was the single most repeated
   inline style in this codebase. */
.ui-text-rel-small { font-size: var(--ui-text-rel-small); }
.ui-text-rel-normal { font-size: var(--ui-text-rel-normal); }
.ui-text-rel-large { font-size: var(--ui-text-rel-large); }
.ui-strong { font-weight: var(--ui-weight-strong); }
.ui-center { text-align: center; }

/* ── Icon ────────────────────────────────────────────────────────────────
   Sizes a glyph — an icon-font `<i class="ph …">` or an inline `<svg>` — from
   the shared icon scale, so every product's icons agree. `normal` is the
   default and needs no modifier.

       <i class="ph ph-gear ui-icon" aria-hidden="true"></i>
       <i class="ph ph-trash ui-icon ui-icon-lg" aria-hidden="true"></i>

   `.ui-icon-btn` already sizes its own glyph; this is for an icon that is
   NOT a button — beside a label, in a list row, in an empty state.

   `line-height: 1` matters more than it looks: an icon font inherits the
   container's leading, so a 20 px glyph in a 1.55-leading row silently
   claims 31 px of line box and pushes the row taller than its neighbours. */
.ui-icon {
	font-size: var(--ui-icon-normal);
	line-height: var(--ui-leading-none);
	flex: none;
}
.ui-icon-sm { font-size: var(--ui-icon-small); }
.ui-icon-lg { font-size: var(--ui-icon-large); }
.ui-icon:is(svg), .ui-icon > svg { width: 1em; height: 1em; }

/* ── Tinted SVG mask icon ─────────────────────────────────────────────────
   An arbitrary SVG file painted in `currentColor` — the icon a product has as
   a file rather than as a glyph in the icon font, which is every brand mark,
   every provider logo and every one-off diagram it needs to tint like the
   text around it. A `<img src>` cannot be recoloured; a mask can.

       el.style.setProperty("--icon-url", "url('/assets/icons/export.svg')");
       <span class="ui-icon-svg"></span>

   `--icon-url` has NO declaration here on purpose: it is per element, and it
   is set through `style.setProperty` rather than in an HTML attribute string
   so an allowlisted path never has to survive HTML escaping — hence the
   suppressions. `--icon-rotation` is the same, and defaults to no rotation.
   `--ui-icon-svg-size` overrides the box for one call site or one subtree.

   This shipped inside `@hrayo/foundation-ui-dropdown` for the life of that
   package (REF-070) — a `ui-`-namespaced class defined by a component package,
   invisible to this reference, unavailable to a product that loads the design
   system without the dropdown, and its own comment already described it as
   usable outside a dropdown. It lives here now; the dropdown keeps a copy
   scoped to `.ui-dropdown` because that package is standalone-capable by
   contract, and `packages/ui-dropdown/src/__tests__/icon-svg-conformance.test.ts`
   pins the two blocks equal. Change one, change both. */
.ui-icon-svg {
	display: inline-block;
	/* `--ui-icon-svg-size` is a per-call-site knob and is deliberately undefined
	   at the root — the fallback IS the default. */
	/*noinspection CssUnresolvedCustomProperty*/
	width: var(--ui-icon-svg-size, var(--ui-icon-normal));
	/*noinspection CssUnresolvedCustomProperty*/
	height: var(--ui-icon-svg-size, var(--ui-icon-normal));
	background-color: currentColor;
	/*noinspection CssUnresolvedCustomProperty*/
	transform: rotate(var(--icon-rotation, 0deg));
	/*noinspection CssUnresolvedCustomProperty*/
	-webkit-mask-image: var(--icon-url);
	/*noinspection CssUnresolvedCustomProperty*/
	mask-image: var(--icon-url);
	-webkit-mask-size: contain;
	mask-size: contain;
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-position: center;
	mask-position: center;
}

/* The quiet heading over a group of anything — a sidebar section, a settings
   block, a panel, a column of controls. Every product had reinvented this one
   ("smaller, heavier, muted, slightly tracked") several times over, at several
   sizes, which is why the SIZES are here too rather than being re-typed.

   It does not upper-case, and must not: see § No all-caps. */
.ui-label {
	display: block;
	font-size: var(--ui-text-xs);
	font-weight: var(--ui-weight-strong);
	letter-spacing: var(--ui-tracking-wide);
	color: var(--ui-text-muted);
}
.ui-label-sm { font-size: var(--ui-text-2xs); }
.ui-label-lg { font-size: var(--ui-text-sm); }

/* One line, ellipsised. */
.ui-truncate {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 0;
}
/* N lines, then ellipsised — set `--ui-lines`. */
.ui-clamp {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--ui-lines, 2);
	line-clamp: var(--ui-lines, 2);
	overflow: hidden;
}
/* A long unbroken identifier (a URL, a token) inside a narrow box. */
.ui-break { overflow-wrap: anywhere; word-break: break-word; }

/* ── Selection ───────────────────────────────────────────────────────────
   An APPLICATION and a DOCUMENT disagree about what a drag across text means.
   In a document it is a selection, and that is right. In an application it is
   almost always a mis-drag — the user reached for a tab, a menu row, a card
   header or a drag handle — and the smear of blue that comes back is the
   single clearest tell that a screen is a web page wearing an app's clothes.

   So: `.ui-app-unselectable` on the app-shell root turns selection OFF for the
   chrome inside it, and the things a user genuinely copies turn it back on.

       <body class="ui-app-shell ui-app-unselectable">

   It is a SEPARATE class from `.ui-app-shell` on purpose. Two products already
   wear the shell (a data app and an admin console), and "this frame is
   viewport-sized with fixed chrome" is a layout statement, not a licence to
   change what a drag does everywhere it is adopted. One class on one element,
   deleted in one edit if a product decides otherwise.

   What comes back on, without anyone applying a class: **form controls** (a
   `user-select: none` input is unusable — no drag-select, and on Safari no
   caret placement either), **verbatim text** (`code` / `pre` / `kbd` / `samp`
   — an id, a token, a snippet, all copied by definition), **the components
   that exist to be copied or read** (`.ui-copy-field`, `.ui-code-block`,
   `.ui-markdown` prose, and `.ui-alert` — an error message the user has to
   paste into a ticket), and **`.ui-selectable`**, the opt-in a product puts on
   its own data output: a result table, a KPI number, a log line.

   `.ui-unselectable` is the inverse escape hatch — a chrome island (a row of
   actions, a legend, a sticky header) inside a selectable region.

   Both utilities work OUTSIDE the app scope too, so a document-shaped page can
   mark one region either way without adopting the app default.

   Specificity is deliberate: the scope's re-enables are `:where()`-wrapped so
   they weigh exactly one class, and `.ui-unselectable` is declared after them
   and therefore wins on a tie. Selection is inherited, so a class on a
   container covers its whole subtree and neither rule needs a `*`. */
.ui-app-unselectable { user-select: none; }
:where(.ui-app-unselectable) :is(input, textarea, select, [contenteditable],
code, pre, kbd, samp, .ui-selectable, .ui-copy-field, .ui-code-block,
.ui-markdown, .ui-alert),
.ui-selectable { user-select: text; }
.ui-unselectable, :where(.ui-app-unselectable) .ui-unselectable { user-select: none; }

/* Available to a screen reader, invisible on screen. */
.ui-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Surfaces, for a panel that is not a card. */
.ui-surface { background: var(--ui-surface); }
.ui-surface-raised { background: var(--ui-surface-raised); }
.ui-surface-sunken { background: var(--ui-surface-sunken); }
.ui-bordered { border: 1px solid var(--ui-border); border-radius: var(--ui-radius-md); }

/* A thin scrollbar that follows the theme, for panes that scroll inside the
   page. Applied deliberately rather than globally: overriding every scrollbar
   on a page is the kind of thing that reads as heavy-handed on a desktop. */
.ui-scroll {
	overflow: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--ui-border-strong) transparent;
}
.ui-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.ui-scroll::-webkit-scrollbar-track { background: transparent; }
.ui-scroll::-webkit-scrollbar-thumb {
	background: var(--ui-border-strong);
	border-radius: var(--ui-radius-full);
}
.ui-scroll::-webkit-scrollbar-thumb:hover { background: var(--ui-text-subtle); }

/* Hidden until the viewport is wide/narrow enough to want it. Both arms of the
   house pair (§ 1, "The phone breakpoint") — they used to be `max-width: 48rem`
   against `min-width: 48.0625rem`, a 1 px band in which `.ui-hide-sm` and
   `.ui-show-sm` were BOTH visible.

   The two display headings shrink here too — but by reassigning their TOKENS,
   which is a § 2 concern and lives there. */
@media (width < 48rem) {
	.ui-hide-sm { display: none !important; }
	.ui-container { padding-inline: var(--ui-space-4); }
}
@media (width >= 48rem) {
	.ui-show-sm { display: none !important; }
}

/* Printing: drop the chrome, keep the content. */
@media print {
	.ui-navbar, .ui-tabs, .ui-skip-link, .ui-toolbar, [data-ui-no-print] { display: none !important; }
	body { background: #fff; color: #000; }
	.ui-card, pre, table { break-inside: avoid; }
}


:root {
	/* Cards float on a recessed page. */
	--ui-body-background: var(--ui-surface-sunken);

	/* The generated site's frame, number for number (--kb-max-width,
	   --kb-sidebar-width, its .container gap and padding), so a reader walking
	   Knowledge Base → Questions → Chat → Settings sees the navigation and the
	   page in the same two columns. The article column is what is left; a page
	   with no navigation keeps that width rather than growing into the empty
	   one. */
	--wm-frame-width: 75rem;
	--wm-nav-width: 16.25rem;
	--wm-frame-gap: var(--ui-space-12);
	--wm-main-width: calc(var(--wm-frame-width) - 2 * var(--ui-space-normal) - var(--wm-nav-width) - var(--wm-frame-gap));
}

/* The bar is the same bar on every page, and on the generated site's pages
   beside these: the same measure, the same edge, the same height. So its row
   is not the page's column — a bar sitting on one once started somewhere
   else on every page — and
   its height is stated rather than left to whatever is in it, which is a Sign
   out button here, a theme toggle there and nothing on the sign-in screen.
   The numbers are the generator's (--kb-max-width, .nav-inner, and the
   --ui-navbar-height its own .ui-navbar states). */
.ui-navbar {
	--ui-navbar-height: 4rem;
	padding-inline: 0;
}
.wm-bar {
	display: flex;
	align-items: center;
	gap: var(--ui-space-normal);
	width: 100%;
	max-width: var(--wm-frame-width);
	margin-inline: auto;
	padding-inline: var(--ui-space-normal);
}

/* The page itself never scrolls — the generated site's rule: the bar stays
   put and each column scrolls on its own, so the navigation is not lost under
   a long article and the article not lost under a long list. */
body {
	display: flex;
	flex-direction: column;
	height: 100dvh;
	overflow: hidden;
}
body > .ui-navbar {
	flex: none;
}
.wm-frame {
	display: grid;
	flex: 1;
	gap: var(--wm-frame-gap);
	grid-template-columns: minmax(0, var(--wm-main-width));
	justify-content: center;
	width: 100%;
	max-width: var(--wm-frame-width);
	min-height: 0;
	margin-inline: auto;
	padding-inline: var(--ui-space-normal);
}
.wm-frame-split {
	grid-template-columns: var(--wm-nav-width) minmax(0, 1fr);
}
.wm-side,
.wm-main {
	min-height: 0;
	min-width: 0;
	overflow-y: auto;
	padding-block: var(--ui-space-normal) var(--ui-space-large);
}
/* An uploaded setting's picture, at about the size it is drawn — a launcher
   is 56px — so the owner judges it as visitors will see it. */
.wm-setting-image {
	display: block;
	width: var(--ui-space-12);
	height: var(--ui-space-12);
	object-fit: cover;
	border: 1px solid var(--ui-border);
	border-radius: var(--ui-radius-md);
}
/* A colour picker is a swatch, not a text box: tall enough to see the colour
   and no wider than it needs to be. */
.ui-field input[type="color"] {
	width: var(--ui-space-20);
	height: var(--ui-space-10);
	padding: var(--ui-space-1);
	cursor: pointer;
}
footer {
	margin-block-start: var(--ui-space-10);
	color: var(--ui-text-muted);
	font-size: var(--ui-text-sm);
}

/* The full-page chat. The panel *is* the page here, so it gets every pixel of
   the article column — the component's inline placement fills its container,
   and a container with no height would collapse to nothing. Layout the design
   system has no opinion about, which is the only kind of rule that belongs in
   this file.

   Everything visible in the rail is a shared component — .ui-option for a row,
   .ui-btn for the actions, .ui-label for the heading, .ui-scroll for the pane,
   .ui-toolbar for the dictation bar. What is below is placement and nothing
   else, which is the whole test for whether a rule belongs here. */
body.wm-chat-page .wm-main {
	display: flex;
	flex-direction: column;
}
.wm-chat-layout {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: var(--ui-space-3);
	min-height: 0;
}
.wm-chat {
	flex: 1;
	min-height: 22rem;
}

/* The rail's heading and New button stay put; only its list scrolls. */
.wm-chat-rail {
	display: flex;
	flex-direction: column;
	gap: var(--ui-space-3);
	overflow: hidden;
}
.wm-rail-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--ui-space-2);
}
.wm-rail {
	display: flex;
	flex-direction: column;
	gap: var(--ui-space-1);
	min-height: 0;
}
.wm-rail-list {
	display: flex;
	flex-direction: column;
	gap: var(--ui-space-1);
	overflow-y: auto;
	min-height: 0;
}
/* The row is a .ui-option; the link fills it so the whole row is the target, and
   the Forget button sits at the end without leaving the row. */
.wm-rail-row {
	gap: var(--ui-space-2);
}
.wm-rail-link {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
	color: inherit;
	text-decoration: none;
}
.wm-rail-forget {
	flex: none;
}
.wm-rail-empty {
	margin: 0;
}

.wm-dictation {
	display: flex;
	flex-direction: column;
	gap: var(--ui-space-2);
}
.wm-dictation-draft {
	flex: 1;
	margin: 0;
	min-width: 0;
}

/* One step of a journal entry: an accordion item whose summary is the step's
   name and what it came to on the first line and — collapsed — the questions
   behind it, one per line under it, without their scores. Open, the full
   scored list and every other detail replace them. */
.wm-step > summary {
	flex-wrap: wrap;
}
.wm-step-name {
	min-inline-size: 6rem;
	color: var(--ui-text-muted);
}
.wm-step-preview {
	display: flex;
	flex-basis: 100%;
	flex-direction: column;
	gap: var(--ui-space-1);
	min-width: 0;
	padding-inline-start: calc(6rem + 2 * var(--ui-space-2));
	font-weight: var(--ui-weight-normal);
	font-size: var(--ui-text-sm);
}
.wm-step[open] .wm-step-preview {
	display: none;
}

/* The questions list, in the frame's navigation column. A row is the chat
   rail's own (.ui-option + .wm-rail-link). */
.wm-questions-nav {
	display: flex;
	flex-direction: column;
	gap: var(--ui-space-1);
}
/* The search over the list: the bare input, which already fills the column.
   While a search is on, the field ends in a cross that clears it — a link,
   laid over the input's end, in place of the browser's own. */
.wm-questions-search {
	position: relative;
	margin-block-end: var(--ui-space-2);
}
.wm-questions-searching input {
	/* Room for the cross at its largest — the tap target on a coarse pointer. */
	padding-inline-end: var(--ui-tap-target);
}
.wm-questions-searching input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}
.wm-questions-search-clear {
	position: absolute;
	inset-block: 0;
	inset-inline-end: var(--ui-space-1);
	margin-block: auto;
}
/* The questions as a tree: a sub-question in a disclosure under the row of
   the broader question it is part of, one step in for every level. The
   disclosure is the browser's own <details>, stripped of the card the theme
   gives a bare one; its summary is only the theme's disclosure marker — which
   turns as the branch opens — laid over a slot every row keeps at its start,
   so a question with sub-questions and one without line up, and the row's
   link still opens the question. */
.wm-question-tree {
	display: flex;
	flex-direction: column;
	gap: var(--ui-space-1);
	margin: 0;
	padding: 0;
	list-style: none;
}
.wm-question-item {
	position: relative;
}
.wm-question-row {
	padding-inline-start: var(--ui-space-6);
}
.wm-question-branch {
	margin: 0;
	padding: 0;
	padding-inline-start: var(--ui-space-4);
	background: none;
	border: none;
}
.wm-question-branch > .wm-question-tree {
	margin-block-start: var(--ui-space-1);
}
/* As tall as the row's first line, so the marker sits beside the first line
   of a question that wraps. */
.wm-question-toggle {
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: 0;
	justify-content: center;
	inline-size: var(--ui-space-6);
	block-size: calc(1lh + 2 * var(--ui-space-1));
	font-size: var(--ui-text-sm);
	border-radius: var(--ui-radius-sm);
	cursor: pointer;
}
.wm-question-toggle:hover {
	background: var(--ui-surface-hover);
}

/* A table in a rendered answer is wrapped by the renderer, so one wider than
   the article scrolls inside it. */
.wm-table {
	overflow-x: auto;
}

/* The answer editor. The editor is a library (editor-app.ts) and these are its
   class names; its own stylesheet is not served, because it brings a palette
   and no surface here picks a colour of its own. The box is a .ui-input; what
   follows is the bar above it and what Markdown looks like while it is being
   typed, in the shared tokens. */
/* The library draws its row inside the element it is handed, so the box is
   ours and the row is its. */
.TMCommandBar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ui-space-1);
}
.wm-editor-bar {
	padding: var(--ui-space-1) var(--ui-space-2);
	background: var(--ui-surface-sunken);
	border: 1px solid var(--ui-border-strong);
	border-block-end: none;
	border-start-start-radius: var(--ui-radius-md);
	border-start-end-radius: var(--ui-radius-md);
	user-select: none;
}
.TMCommandButton {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--ui-space-8);
	height: var(--ui-space-8);
	border-radius: var(--ui-radius-sm);
	color: var(--ui-text-muted);
	cursor: pointer;
}
.TMCommandButton svg {
	fill: currentColor;
}
.TMCommandButton:hover {
	background: var(--ui-accent-soft);
	color: var(--ui-text);
}
.TMCommandButton_Active {
	background: var(--ui-accent-soft);
	color: var(--ui-accent-text);
}
.TMCommandButton_Disabled,
.TMCommandButton_Disabled:hover {
	background: none;
	color: var(--ui-text-subtle);
	cursor: default;
}
.TMCommandDivider {
	align-self: stretch;
	width: 1px;
	margin-inline: var(--ui-space-1);
	background: var(--ui-border);
}
.wm-editor {
	display: block;
	min-height: 20rem;
	border-start-start-radius: 0;
	border-start-end-radius: 0;
	line-height: var(--ui-leading-relaxed);
	overflow-wrap: anywhere;
}
.TMBlankLine {
	min-height: 1lh;
}
.TMH1, .TMH2, .TMH3, .TMH4, .TMH5, .TMH6, .TMSetextH1, .TMSetextH2 {
	font-weight: var(--ui-weight-bold);
}
.TMH1, .TMSetextH1 {
	font-size: var(--ui-text-rel-xl);
}
.TMH2, .TMSetextH2 {
	font-size: var(--ui-text-rel-lg);
}
/* The Markdown marks themselves stay in the text — it is the source that is
   being edited — and step back so the words read first. */
.TMMark {
	color: var(--ui-text-subtle);
}
.TMCode, .TMFencedCodeBacktick, .TMFencedCodeTilde, .TMIndentedCode,
.TMCodeFenceBacktickOpen, .TMCodeFenceBacktickClose, .TMCodeFenceTildeOpen, .TMCodeFenceTildeClose {
	font-family: var(--ui-font-mono);
	font-size: var(--ui-text-rel-sm);
	background: var(--ui-surface-sunken);
}
.TMInfoString, .TMLinkDestination, .TMAutolink {
	color: var(--ui-accent-text);
}
.TMBlockquote {
	padding-inline-start: var(--ui-space-3);
	border-inline-start: 2px solid var(--ui-border);
	color: var(--ui-text-muted);
}
.TMLink, .TMImage, .TMLinkDestination, .TMAutolink {
	text-decoration: underline;
}
.TMHR, .TMHTML, .TMHTMLBlock {
	color: var(--ui-text-muted);
}

/* The operator console: the conversations in the side column, the one open
   beside them in the chat component — the full-page chat's own layout
   (.wm-chat-layout, .wm-chat). Rows are .ui-option, states .ui-badge. */
.wm-operator-list {
	display: flex;
	flex-direction: column;
	gap: var(--ui-space-1);
}
.wm-operator-row {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	min-width: 0;
	color: inherit;
	text-decoration: none;
}
.wm-operator-row-head,
.wm-operator-head {
	display: flex;
	align-items: center;
	gap: var(--ui-space-2);
	min-width: 0;
}
.wm-operator-title {
	flex: 1;
	margin: 0;
}
.wm-operator-state {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--ui-space-2);
	margin-block: var(--ui-space-2);
}
.wm-operator-state p {
	margin: 0;
}
/* The mute menu: a bare <details> (the base layer's card taken off) whose
   summary is the button and whose ui-menu opens under it, right-aligned.
   The buttons keep to the right edge even when they wrap under the
   sentence, so the menu always opens inwards. */
.wm-operator-mute-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	align-items: center;
	gap: var(--ui-space-2);
	margin-inline-start: auto;
}
.wm-operator-mute {
	position: relative;
	border: none;
	padding: 0;
	margin: 0;
	background: none;
}
.wm-operator-mute > summary {
	cursor: pointer;
}
.wm-operator-mute > summary::before {
	display: none;
}
.wm-operator-mute[open] > summary {
	margin-block-end: 0;
}
.wm-operator-mute > .ui-menu,
.wm-operator-rich > .wm-operator-rich-form {
	position: absolute;
	inset-inline-end: 0;
	inset-block-start: calc(100% + var(--ui-space-1));
}
/* *Send HTML or a page*: the same bare <details>, its panel a ui-popover
   holding a form — wide enough to paste into, never wider than the screen. */
.wm-operator-rich > .wm-operator-rich-form {
	display: flex;
	flex-direction: column;
	gap: var(--ui-space-2);
	width: min(28rem, calc(100vw - 2 * var(--ui-space-4)));
}
.wm-operator-rich-form > .ui-btn {
	align-self: flex-end;
}
/* The conversation's cost line, above the transcript. Its events, when shown,
   are drawn by the chat component between the bubbles (event rows). */
.wm-operator-events {
	margin: 0 0 var(--ui-space-2);
}
/* An open conversation fills the column to its foot — the settings footer is
   about the settings, and under a transcript it only takes room from it. */
body.wm-operator-open .wm-main > footer {
	display: none;
}
/* The way back to the list is for a narrow screen, where the list is hidden
   while a conversation is open. */
.wm-operator-back {
	display: none;
}

/* One column once the navigation would squeeze the page, and the page scrolls
   as a whole again — two panes stacked in a short window would each get a
   sliver. The chat's rail keeps its place above the panel rather than being
   hidden: it is the only way to another conversation, and a narrow window is
   not a reason to lose it. */
@media (max-width: 60rem) {
	body {
		height: auto;
		min-height: 100dvh;
		overflow: visible;
	}
	.wm-frame,
	.wm-frame-split {
		gap: 0;
		grid-template-columns: minmax(0, 1fr);
	}
	.wm-side,
	.wm-main {
		overflow: visible;
	}
	.wm-rail-list {
		max-height: 12rem;
	}
	/* A signed-in bar holds more tabs than a phone is wide. The tabs scroll
	   sideways inside the bar rather than pushing the page wider than the
	   screen; the brand and Sign out stay where they are. */
	.wm-bar {
		gap: var(--ui-space-2);
	}
	.wm-bar .ui-nav {
		flex: 1 1 auto;
		min-width: 0;
		overflow-x: auto;
		scrollbar-width: none;
	}
	.wm-bar .ui-navbar-spacer {
		display: none;
	}
	.wm-bar .ui-navbar-brand,
	.wm-bar > .ui-btn {
		flex: none;
	}
	/* A phone shows the list or the conversation, never a sliver of both: the
	   list until one is opened, then the conversation, filling the screen, with
	   the way back above it. */
	body.wm-operator-open .wm-operator-list {
		display: none;
	}
	body.wm-operator-open .wm-operator-back {
		display: inline-flex;
	}
	/* An open conversation keeps the desk's rule even here: the page does not
	   scroll, the conversation fills what is under its heading, and only the
	   transcript scrolls — the heading and the reply field stay on screen. */
	body.wm-operator-open {
		height: 100dvh;
		overflow: hidden;
	}
	body.wm-operator-open .wm-main {
		overflow-y: auto;
	}
	/* With none open, the heading and what to do come before the list. */
	body.wm-operator-page:not(.wm-operator-open) .wm-main {
		order: -1;
		padding-block-end: 0;
	}
	/* The article first: somebody who followed a link to one question came to
	   read it, and the way to the others is under it. */
	.wm-questions-nav {
		order: 1;
	}
}
