/* ═══════════════════════════════════════════════════
   JACQUARD DESIGN SYSTEM — Web Kit Components
   Version 2.1 · April 2026
   Every value references a token from tokens.css. No hex,
   no arbitrary px, no arbitrary durations or easings.
   ═══════════════════════════════════════════════════ */

/* ── Scale (transform feedback) ──
   Kit-level tokens for interactive scale transforms.
   Not generated from the JSON token source — these live
   here because they are web-only CSS values. */
:root {
  --scale-pressed: 0.95;
  --scale-tapped: 0.97;
  --scale-lifted: 1.02;
  --scale-dragged: 1.03;
  --scale-dragged-heavy: 1.05;
  --scale-bounced: 1.15;
}

/* ── Mobile tap-highlight suppression ──
   Prevent the default blue/grey tap overlay on iOS and Android.
   Components provide :active feedback instead. */
[class^='j-'],
[class*=' j-'] {
  -webkit-tap-highlight-color: transparent;
}

/* ── Eyebrow / Section / Numeric primitives ── */
.j-eyebrow,
.j-eyebrow-kicker {
  /* v5.0: the JS <Eyebrow> primitive defaults to rendering <p>, and
     consumers may opt into <p> with raw class application as well.
     Browser UA stylesheets give <p> top/bottom margin; reset here so
     the visual treatment is element-independent. The
     `.j-section-header > .j-section-header-main > .j-eyebrow-kicker`
     selector below has higher specificity and still applies its
     intentional margin-bottom override inside SectionHeader. */
  margin: 0;
  padding: 0;
}

.j-eyebrow {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--type-nano);
  letter-spacing: var(--track-label-loose);
  text-transform: uppercase;
  color: var(--fg-3);
}

.j-eyebrow-kicker {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--type-nano);
  letter-spacing: var(--track-compact);
  text-transform: uppercase;
  color: var(--fg-brand);
}

.j-display-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--type-title);
  line-height: var(--lh-tight);
  letter-spacing: var(--track-display);
  color: var(--fg-1);
  font-feature-settings: 'tnum' 1;
}

.j-section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-md);
  margin-bottom: var(--sp-md);
}

.j-section-header > .j-section-header-main > .j-eyebrow-kicker {
  margin-bottom: var(--sp-xs);
}

/* ── Buttons ──────────────────────────────────────── */
.j-btn {
  font-family: var(--font-body);
  font-weight: 500;
  letter-spacing: var(--track-compact);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  cursor: pointer;
  border: var(--bw-hairline) solid transparent;
  transition:
    background var(--motion-feedback-button-press) var(--ease-snap),
    color var(--motion-feedback-button-press) var(--ease-snap),
    border-color var(--motion-feedback-button-press) var(--ease-snap),
    transform var(--motion-feedback-button-press) var(--ease-snap);
}

.j-btn:disabled {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

/* Tap feedback — scale down briefly on press. The transform transition is
   already registered on .j-btn; this just declares the target state. */
.j-btn:not(:disabled):active {
  transform: scale(var(--scale-tapped));
}

.j-btn:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  box-shadow: none;
}

/* Sizes — every variant meets at least --touch-compact (32px) so even the
   "extra-small" button stays tappable. xs/sm are intended for inline /
   compact contexts (filter chips, table actions). */
.j-btn-xs {
  padding: var(--sp-xs) var(--sp-sm-p);
  font-size: var(--type-label);
  border-radius: var(--r-compact);
  min-height: var(--touch-compact);
}
.j-btn-sm {
  padding: var(--sp-xs) var(--sp-sm-p);
  font-size: var(--type-caption);
  border-radius: var(--r-image);
  min-height: var(--touch-compact);
}
.j-btn-md {
  padding: var(--sp-sm) var(--sp-md);
  font-size: var(--type-small);
  border-radius: var(--r-control);
  min-height: var(--sp-2xl);
}
.j-btn-lg {
  padding: var(--sp-sm-p) var(--sp-lg);
  font-size: var(--type-compact-body);
  border-radius: var(--r-button);
  min-height: var(--touch-min);
}
.j-btn-xl {
  padding: var(--sp-md) var(--sp-lg);
  font-size: var(--type-heading);
  border-radius: var(--r-button);
  min-height: var(--touch-large);
}

.j-btn-full {
  width: 100%;
}

.j-btn-primary {
  background: var(--color-neutral-900);
  color: var(--color-neutral-100);
  border-color: var(--color-neutral-900);
}

.j-btn-secondary {
  background: var(--color-neutral-200);
  color: var(--color-neutral-900);
}

.j-btn-ghost {
  background: transparent;
  color: var(--color-neutral-900);
  border-color: var(--rule-on-layer);
}

.j-btn-tinted {
  background: var(--color-theme-100);
  color: var(--color-theme-700);
}

/* Theme intent — dark brand fill (like FAB theme); brand-bearing, reskins with seed.
   v5 audit #10 (2026-05-16): the `.j-btn-glycine` v4 alias was previously
   mapped to `.j-btn-theme` by the bulk family rename, but `.j-btn-theme`
   already meant "dark brand fill" here — adopters migrating raw className
   strings would have gotten the dark variant instead of the pale tint.
   Adopters with raw `.j-btn-glycine` className should migrate to
   `.j-btn-tinted` (pale brand background). Adopters using the prop API
   already pass `intent="tinted"` or `intent="theme"` explicitly, so the
   prop migration is the table in the Batch A changeset. */
.j-btn-theme {
  background: var(--color-theme-700);
  color: var(--color-neutral-100);
}

.j-btn-destructive {
  background: var(--color-error-700);
  color: var(--color-neutral-100);
}

.j-btn-link {
  background: transparent;
  color: var(--color-theme-700);
}

@media (hover: hover) {
  /* Hover affordance grammar (consumer feedback, 2026-05-20):
       Surface-tier (ghost, secondary, icon-btn, card-interactive,
         table-row, segmented active pill) → LIFT via --layer-elevated.
         Containers re-bind --layer-elevated so the lift stays visible
         wherever the button renders (Card / Modal / Popover / Menu).
       Theme-tier (primary, tinted, theme) → SATURATE via theme-500.
         Stays in the brand ramp; predictable direction in both themes.
       Destructive → DARKEN via opaque gradient wash (intentional
         gravity for irreversible actions; kept as deliberate exception).
     Previously each button class hardcoded its own neutral/rule value,
     producing a split-brain language: ghost lit on the page but
     dissolved on a card (--color-neutral-100 = --surface-1); primary
     jumped to neutral-700 (out of the brand ramp); etc. */
  .j-btn-primary:hover:not(:disabled) {
    /* Stays in the theme ramp: brand-deep (theme-700) → brand-mid
       (theme-500). Previously hovered to --color-neutral-700 which
       jumped from purple to flat grey — read as "lighten to grey"
       which adopters flagged as the random-direction case. */
    background: var(--color-theme-500);
    border-color: var(--color-theme-500);
  }
  .j-btn-secondary:hover:not(:disabled) {
    /* Surface-tier lift. Previously --color-rule which depended on
       the page surface to look "darker"; inside a Card it produced
       an inconsistent direction. --layer-elevated always moves up
       the surface ramp wherever the button renders. */
    background: var(--layer-elevated);
  }
  .j-btn-ghost:hover:not(:disabled) {
    /* Surface-tier lift. Previously --color-neutral-100 = --surface-1
       which equals Card bg — hover was invisible inside Cards (the
       common case). --layer-elevated keeps a visible step in every
       container context. */
    background: var(--layer-elevated);
  }
  .j-btn-tinted:hover:not(:disabled) {
    background: var(--color-theme-500);
    color: var(--color-neutral-100);
  }
  .j-btn-theme:hover:not(:disabled) {
    background: var(--color-theme-500);
  }
  .j-btn-destructive:hover:not(:disabled) {
    /* Destructive bucket — SATURATE direction (consumer feedback,
       2026-05-20): hover intensifies toward a deeper saturated red so
       the affordance reads as "destructive intent getting more real,"
       paired to the theme-tier ELEVATE and surface-tier ELEVATE buckets.
       Was a --color-neutral-950 wash which DARKENED in light mode but
       LIGHTENED in dark (neutral-950 flips), making the destructive
       hover direction theme-dependent. The #8a2a38 anchor is a literal
       so the saturate direction stays consistent across themes; the
       color-mix preserves the rose hue while increasing chroma and
       lowering luminance — perceptual "more destructive" gravity. */
    background: color-mix(in srgb, var(--color-error-700) 70%, #8a2a38 30%);
  }
  .j-btn-link:hover:not(:disabled) {
    text-decoration: underline;
  }
}

/* Active (tap) feedback — touch users see the same color shift as hover. */
.j-btn-primary:not(:disabled):active {
  background: var(--color-theme-500);
  border-color: var(--color-theme-500);
}
.j-btn-secondary:not(:disabled):active {
  background: var(--layer-elevated);
}
.j-btn-ghost:not(:disabled):active {
  background: var(--layer-elevated);
}
.j-btn-tinted:not(:disabled):active {
  background: var(--color-theme-500);
  color: var(--color-neutral-100);
}
.j-btn-theme:not(:disabled):active {
  background: var(--color-theme-500);
}
.j-btn-destructive:not(:disabled):active {
  /* Active matches hover — same saturate recipe (see hover block above). */
  background: color-mix(in srgb, var(--color-error-700) 70%, #8a2a38 30%);
}

/* Icon slots inside buttons */
.j-btn-icon {
  display: inline-flex;
  flex-shrink: 0;
}

/* Loading / busy state */
.j-btn[aria-busy='true'] {
  pointer-events: none;
}

/* Mixed-children gap (consumer feedback #10, 2026-05-20): adopters
   passing `<Dot /> Label` into <Button> got no space between the icon
   and text because Button wraps children in a single `.j-btn-label`
   span — the outer `.j-btn { gap }` rule applies between DIRECT
   children, but with the label wrapper there's only one direct child.
   Apply the same gap recipe inline so mixed children space correctly.
   Adopters who pass only text get the same single-child layout (no
   gap renders against a single child). */
.j-btn-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
}

.j-btn[aria-busy='true'] > .j-btn-label {
  opacity: 0.7;
}

.j-btn-spinner {
  display: inline-flex;
  animation: j-spin 0.8s linear infinite;
}

@keyframes j-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Forced-colors (Windows High Contrast) — centralized residual block.
   Per-component forced-colors blocks live adjacent to each component's
   base rules; this centralized block is reserved for:
     (a) cross-cutting rules whose base selectors all live BEFORE this
         block (the `.j-btn` family — base at lines 84-198), and
     (b) Med/Low-severity entries whose property-collision risk does not
         (today) defeat the high-contrast story even when the base wins
         on source order. These are tracked in
         `docs/forced-colors-cascade-audit-2026-05-21.md` for PR-B
         (Med-severity) and PR-C (Low-severity) follow-up sweeps.
   PR-A (this commit) extracted the High-severity entries — icon-btn,
   switch family, checkbox + on-state, radio + on-state, modal-close,
   fab + fab-theme, toggle + toggle-pressed, menu / menu-item /
   menu-divider, select-standalone, creatable-select-status, link, and
   the DatePicker family (trigger + focus-visible, calendar, nav,
   nav focus-visible, day + selected + in-range) — into co-located
   blocks immediately after each component family's base rules. See
   the audit doc's §"PR-A status" section for the post-fix anchor
   selectors. */
@media (forced-colors: active) {
  .j-btn {
    border: 1px solid ButtonBorder;
  }
  .j-btn:focus-visible {
    outline: 2px solid Highlight;
  }
  .j-btn-primary {
    background: ButtonFace;
    color: ButtonText;
    border-color: ButtonBorder;
  }
  .j-btn-destructive {
    background: ButtonFace;
    color: ButtonText;
    border-color: ButtonBorder;
  }
  /* .j-icon-btn (High-severity border rule) extracted to a co-located
     block after the .j-icon-btn base — PR-A 2026-05-21. The
     :focus-visible Med-severity entry stays here pending PR-B. */
  .j-icon-btn:focus-visible {
    outline: 2px solid Highlight;
  }
  /* Segmented control forced-colors rules live AFTER the base
     .j-segmented::before rule (see "Segmented Control / Toggle Pill"
     block below). Co-locating them with their base would mean placing
     them BEFORE the base in source order — equal specificity, later
     source wins, so the base would clobber the forced-colors recipe.
     PR #161 (cascade-order fix surfaced during PR #147 round-2 review).
     PR-A (2026-05-21) applied the same extraction to switch, checkbox,
     radio, modal-close, fab, toggle, menu, select-standalone,
     creatable-select-status, link, and DatePicker — see the
     per-component co-located blocks further down the file. */
  /* .j-switch-thumb checked-state (Med-severity background: HighlightText)
     stays here pending PR-B; the unchecked-thumb High-severity rule was
     extracted in PR-A. */
  .j-switch[data-checked='true'] .j-switch-thumb {
    background: HighlightText;
  }
  /* .j-checkbox-label input:focus-visible ~ .j-checkbox-box (Med) stays
     here pending PR-B. */
  .j-checkbox-label input:focus-visible ~ .j-checkbox-box {
    outline: 2px solid Highlight;
  }
  /* .j-radio-label input:focus-visible ~ .j-radio-circle (Med) stays
     here pending PR-B. */
  .j-radio-label input:focus-visible ~ .j-radio-circle {
    outline: 2px solid Highlight;
  }
  /* .j-modal-sheet (Low, hygiene-only — no live collision today) stays
     here pending PR-C. */
  .j-modal-sheet {
    border: 2px solid ButtonBorder;
  }
  /* .j-modal-close:focus-visible (Med) stays here pending PR-B. */
  .j-modal-close:focus-visible {
    outline: 2px solid Highlight;
  }
  /* .j-fab:focus-visible (Med) stays here pending PR-B. */
  .j-fab:focus-visible {
    outline: 2px solid Highlight;
  }
  /* .j-toggle:focus-visible (Med) stays here pending PR-B. */
  .j-toggle:focus-visible {
    outline: 2px solid Highlight;
  }
  /* .j-menu-item:focus-visible (Med) stays here pending PR-B. */
  .j-menu-item:focus-visible {
    outline: 2px solid Highlight;
  }
  /* .j-split-btn-divider (Low — !important is load-bearing; see audit
     Q5) stays here pending PR-C. */
  .j-split-btn-divider {
    background: ButtonBorder !important;
  }
  /* .j-select-standalone:focus-visible (Med) stays here pending PR-B. */
  .j-select-standalone:focus-visible {
    outline: 2px solid Highlight;
  }
  /* .j-link:visited (Med — selector-mismatch partial) and
     .j-link:focus-visible (Med) stay here pending PR-B. */
  .j-link:visited {
    color: VisitedText;
  }
  .j-link:focus-visible {
    outline: 2px solid Highlight;
  }
  /* Date Picker — Med entries (today indicator, range-hint) stay here
     pending PR-B; High entries were extracted in PR-A. */
  .j-datepicker-day[data-today='true'] {
    box-shadow: inset 0 0 0 1px Highlight;
  }
  .j-datepicker-range-hint {
    background: Canvas;
    color: CanvasText;
    border: 1px solid ButtonBorder;
  }
  /* .j-table-cell-sort-btn (Low/Med) stays here pending PR-C. */
  .j-table-cell-sort-btn {
    color: CanvasText;
  }
  .j-table-cell-sort-btn:focus-visible {
    outline: 2px solid Highlight;
  }
}

/* Prefers-contrast Toggle rules were extracted from this block in v5.4
   (task #116) and co-located with the Toggle base further down the file
   — see the dedicated `@media (prefers-contrast: more)` block adjacent
   to the `.j-toggle` base. The Segmented control extraction (PR #166)
   removed the other family that lived here. With both extractions in
   place, the centralized prefers-contrast block at this position is
   now empty and no longer required; future prefers-contrast entries
   should be authored directly co-located with their base, per the
   PR #161 / #166 / v5.4-task-#116 convention. */

/* Compact square icon button used for nav arrows, modal close, etc. */
.j-icon-btn {
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: var(--r-image);
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-neutral-700);
  transition:
    background var(--motion-feedback-button-press) var(--ease-snap),
    color var(--motion-feedback-button-press) var(--ease-snap),
    transform var(--motion-feedback-button-press) var(--ease-snap);
}

.j-icon-btn:disabled {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

@media (hover: hover) {
  .j-icon-btn:hover:not(:disabled) {
    /* Surface-tier lift (consumer feedback 2026-05-20) — was
       --color-neutral-100 which collided with --surface-1 = Card bg. */
    background: var(--layer-elevated);
    color: var(--color-neutral-900);
  }
}
.j-icon-btn:not(:disabled):active {
  background: var(--layer-elevated);
  color: var(--color-neutral-900);
  transform: scale(var(--scale-pressed));
}

.j-icon-btn:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  box-shadow: none;
}

.j-icon-btn[aria-busy='true'] {
  pointer-events: none;
}

.j-icon-btn-sm {
  width: var(--sp-xl);
  height: var(--sp-xl);
  border-radius: var(--r-image);
}
.j-icon-btn-lg {
  width: var(--touch-large);
  height: var(--touch-large);
}
.j-icon-btn-round {
  border-radius: var(--r-pill);
}

@media (hover: hover) {
  .j-icon-btn-destructive:hover:not(:disabled) {
    color: var(--color-error-700);
    background: var(--color-error-100);
  }
}
.j-icon-btn-destructive:not(:disabled):active {
  color: var(--color-error-700);
  background: var(--color-error-100);
}

/* Icon button — forced-colors (Windows High Contrast).
   Co-located with the base .j-icon-btn rule (above) so that source
   order resolves the cascade correctly. The centralized
   `@media (forced-colors: active)` block earlier in the file declares
   most button-family HC rules BEFORE this base — and equal-specificity
   ties (the base `.j-icon-btn { border: none }` against the HC
   `border: 1px solid ButtonBorder`) were being won by the LATER base
   rule, defeating the high-contrast border under Windows HC. PR-A
   2026-05-21 (sibling to PR #161). */
@media (forced-colors: active) {
  .j-icon-btn {
    border: 1px solid ButtonBorder;
  }
}

/* ── Badge ────────────────────────────────────────── */
.j-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  font-weight: 600;
  line-height: var(--lh-heading);
  white-space: nowrap;
  letter-spacing: var(--track-compact);
}

.j-badge-sm {
  padding: var(--r-micro) var(--sp-sm);
  font-size: var(--type-micro);
}
.j-badge-md {
  padding: var(--r-tiny) var(--sp-sm-p);
  font-size: var(--type-label);
}
.j-badge-lg {
  padding: var(--r-tiny) var(--sp-md);
  font-size: var(--type-small);
}

.j-badge-dot {
  width: var(--sp-xs);
  height: var(--sp-xs);
  border-radius: var(--r-pill);
  display: inline-block;
}

.j-badge-theme {
  background: var(--color-theme-100);
  color: var(--color-theme-700);
}
.j-badge-theme .j-badge-dot {
  background: var(--color-theme-500);
}
.j-badge-success {
  background: var(--color-success-100);
  color: var(--color-success-700);
}
.j-badge-success .j-badge-dot {
  background: var(--color-success-500);
}
.j-badge-error {
  background: var(--color-error-100);
  color: var(--color-error-700);
}
.j-badge-error .j-badge-dot {
  background: var(--color-error-500);
}
.j-badge-warning {
  background: var(--color-warning-100);
  color: var(--color-warning-700);
}
.j-badge-warning .j-badge-dot {
  background: var(--color-warning-500);
}
.j-badge-info {
  background: var(--color-info-100);
  color: var(--color-info-700);
}
.j-badge-info .j-badge-dot {
  background: var(--color-info-500);
}
.j-badge-neutral {
  background: var(--color-neutral-200);
  color: var(--color-neutral-700);
}
.j-badge-neutral .j-badge-dot {
  background: var(--color-neutral-500);
}

/* ── Card ─────────────────────────────────────────── */
.j-card {
  /* Redeclare role tokens so descendants resolve them against the
     card's own surface, not the :root ground. Without this, a
     `<button>` inside a Card that used `background: var(--hover-on-layer)`
     would color-mix against --surface-0 (the page) and produce a
     darker-than-card result — the inverse of the intended hover lift.
     ADR-029 documents the Card scope; this declaration realizes it.
     Claude adversarial review r4 finding #5.

     Audit 2026-05-20: extended to the full role-token set so
     primitives nested in a card (fields, dividers, secondary text)
     re-tone to the card layer the same way they do inside a modal
     sheet. --layer is the card-specific surface (surface-1, distinct
     from :root's surface-0 page ground).

     --rule-on-layer is a color-mix derived from the card's own
     --layer + --on-layer rather than repeating the :root --color-rule.
     The 20% recipe lands at ~1.5:1 against the card surface in light
     mode (matching current --color-rule visibility on the page) and
     re-tones per container so a divider hairline inside a card stays
     visually distinct from the card surface — not inheriting a value
     tuned against the darker page. This is the systemic answer to
     consumer feedback that the layer-token sweep was a no-op without
     scoped values.

     --on-layer / --on-layer-2 intentionally repeat the :root defaults
     here (primary text on a card has the same contrast target as on
     the page; the modal sheet repoints --on-layer-2 separately for
     the subtle-icon case the close button needs). */
  /* v5.2.1 HOTFIX (2026-05-22) — role-token redeclarations live on
     `.j-card > *` below this rule, NOT on `.j-card`. CSS custom-property
     reassignments apply to the element they're declared on AS WELL AS
     descendants — so the v5.2.0 pattern of
     `.j-card { --layer-container: var(--surface-2); --layer-elevated: color-mix(...); }`
     made Card paint --surface-2 (not --surface-1 as intended) and
     made Card-interactive hover paint the darker color-mix (not
     --surface-2). Same trap rippled to every descendant reading
     --layer-elevated inside Card (e.g., button hover backgrounds).
     Empirical confirmation by adopter probe: `.j-card` computed
     --layer-container = #fbfbfc (surface-2) instead of the intended
     #eeeff3 (surface-1).
     Moving the redeclarations to a descendant-scope selector restores
     cascade flow: Card itself reads inherited :root values, descendants
     see Card-scoped values. The cascade-contract regression test (#188)
     didn't catch this because it only verified the cascade FLOWS through
     descendants — not that the container's own paint reads inherited
     values. See ADR-029 §"Container nesting contract" + the new v5.2.1
     amendment for the failure-mode + fix. */
  /* Stash the actual painted surface (resolves `--layer-container` in the
     inherited cascade BEFORE the descendant rule below redeclares it) so
     `.j-card > *` can wire `--layer` to whatever Card painted — not a
     hardcoded `--surface-1`. Card-in-:root paints surface-1 → descendant
     `--layer` = surface-1 (rule-on-layer toned for surface-1). Card-in-
     Modal-sheet paints surface-2 (Modal sheet redeclares
     `--layer-container: var(--surface-2)` per ADR-029 §C + §E codex r2 P2
     refinement — the overlay was rejected because it would collapse
     Card rest with Card hover) → descendant `--layer` = surface-2
     (dividers/hover ramps re-tone to surface-2). Codex review r1 P2:
     without this stash, descendants computed `--rule-on-layer` against
     a different surface than Card actually painted. The private-var
     prefix `--_` keeps this internal to the kit; adopters override the
     public role tokens, not the stash. */
  --_layer-painted: var(--layer-container);
  /* `background-color` (not the shorthand `background`) so adopters who
     stack a custom `background-image` via unsafe_className survive
     both the rest and hover passes — codex review r5 caught that
     `background: var(--surface-1)` would reset every background
     longhand (including bg-image), wiping the adopter's gradient
     overlay when the hover swap fires (and at rest too, depending on
     cascade order). The shorthand wasn't intentional; only the color
     was ever the contract.

     ADR-029 2026-05-21 amendment: paints via --layer-container so the
     surface lifts cascade-relative to the parent --layer (page → tier-1
     by default; tier-2 inside another container; overlay inside Modal/
     Popover). Previously hardcoded var(--surface-1). Reads the stash
     so the rest+hover transition sees the same value as descendants. */
  background-color: var(--_layer-painted);
  border-radius: var(--r-card);
  padding: var(--sp-lg);
  /* Borderless edge — the surface-1 vs surface-0 luminance step
     carries the edge in both light and dark themes. Adopters who
     genuinely need a hairline outline override at the call site via
     `unsafe_style` or compose a wrapper. Audit (2026-05-17): adopter
     feedback flagged the static border as visually noisy on dense
     dashboards; the background-only contour matches the surface-1
     family (Modal sheet, Empty container, Toast). */
  /* `background-color` is in the transition list so the interactive-
     hover elevation step (surface-1 → --layer-elevated) animates on
     the same hover-feedback curve as transform / scale. box-shadow
     stays in the list for back-compat with adopter overrides that
     still set shadows via unsafe_className. */
  transition:
    transform var(--motion-feedback-hover) var(--ease-snap),
    background-color var(--motion-feedback-hover) var(--ease-snap),
    box-shadow var(--motion-feedback-hover) var(--ease-snap);
}

/* v5.2.1 HOTFIX — Card-scope role-token redeclarations live here, on
   descendants of Card (not on .j-card itself). See the explanatory
   comment block in the .j-card rule above for the bug context.

   Custom properties inherit, so a redeclaration on `.j-card > *`
   propagates to all deeper descendants via normal CSS inheritance.

   `--layer` is wired to the private stash `--_layer-painted` set on
   `.j-card` so descendants always see whatever surface Card actually
   painted (cascade-relative — handles Card-in-:root, Card-in-Card,
   Card-in-Modal sheet, Card-in-Popover uniformly). Codex review r1 P2.

   Tokens NOT redeclared (post-codex r3 design re-eval, 2026-05-22):
   - `--on-layer` (:root default = --fg-1)
   - `--on-layer-2` (:root default = --fg-2)
   These values are identical to the :root defaults, so redeclaring
   them is a no-op for the visual baseline but ACTIVELY HARMFUL for
   adopter overrides: an adopter writing `<Card style={{'--on-layer':
   'red'}}>...</Card>` declares the override ON `.j-card`, but the
   redeclaration here on `.j-card > *` has higher specificity for
   descendants (one extra class match), so it would shadow the
   adopter's override and stop it from reaching descendants. Dropping
   the redeclarations lets the inheritance chain flow:
       :root (--fg-1) → .j-card (adopter style override, if any)
                      → .j-card > * (no redeclaration, inherits)
                      → deeper descendants (inherit).
   See ADR-029 §B.bis (Non-redeclaration of `:root`-default-matching
   tokens). Pinned by the propagation tests in
   src/kit/primitives/__tests__/Card.test.tsx. */
.j-card > * {
  /* --layer: the surface I sit on, sourced from `.j-card`'s stash so it
     matches what Card actually painted in this cascade context.
     Card-in-:root → surface-1; Card-in-Card → surface-2; Card-in-
     Modal-sheet / Card-in-Popover / Card-in-Menu / Card-in-CropDialog
     → surface-2 (those containers redeclare --layer-container to
     surface-2 per ADR-029 §E codex r2 P2; the overlay would collapse
     Card rest with Card hover). */
  --layer: var(--_layer-painted);
  /* --layer-container: surface a nested raised-tier container paints.
     Held at `--surface-2` per ADR-029 §B Option 1 ("static second-tier
     override"): the 3-tier ramp tops at surface-2, and Card-in-Card
     is spec-disallowed (blueprint/components/43-card.md:23) so the
     deeper-nesting collapse is accepted. Hard-coded value avoids the
     same self-application trap as the v5.2.0 bug. */
  --layer-container: var(--surface-2);
  /* --layer-elevated: in-layer affordance lift (hover bgs, active
     pills). ADR-037: routes to the real --surface-above sentinel tier
     (shipped #209's 11-tier ladder) instead of the prior
     color-mix(--surface-2, --on-layer) overlay, which theme-flipped
     (darkened on hover in light mode). Lift = brighter in both themes,
     flat — no shadow, no hairline (ADR-009). */
  --layer-elevated: var(--surface-above);
  /* ADR-042 (finalized; was the #126 prototype). --layer-recess recesses
     one tier BELOW the Card's painted --layer. Symmetric counterpart to
     --layer-elevated above: elevated lifts above --layer, recess sits
     below it. Card-in-:root paints surface-1 → recess = surface-0
     (page ground). Segmented's tray reads as "punched into the card"
     the same way fields do via --field-bg. Lives on `.j-card > *`
     (descendant scope) per the v5.2.1 HOTFIX pattern — Segmented is
     always rendered as a descendant of Card, never as Card itself. */
  --layer-recess: var(--surface-0);
  /* --rule-on-layer: divider/border tuned to Card's surface (var(--layer)
     base + 20% --on-layer mix). Now re-tones automatically when Card
     paints a non-surface-1 layer (Card-in-Modal / Popover / Menu /
     CropDialog → surface-2; Card-in-Card → surface-2) because --layer
     is wired to --_layer-painted above. */
  --rule-on-layer: color-mix(in srgb, var(--layer) 80%, var(--on-layer) 20%);
  /* Fields inside Card recess to --surface-0 (page tier) so they
     read as inset against the brighter card surface. */
  --field-bg: var(--surface-0);
  /* Disabled field bg — color-mix derived from card's --field-bg +
     --on-layer so the muted state stays visible against the card
     surface in both themes. */
  --field-bg-disabled: color-mix(in srgb, var(--field-bg) 88%, var(--on-layer) 12%);
}

/* Last-child / first-child margin reset.
   Browser default <p>/<h*> ship with margin-block ~1em. Inside a Card
   with `padding: var(--sp-lg)`, that margin compounds with the
   padding and looks like the Card has "extra" bottom padding
   (visible = padding + margin ≈ 32px when adopters expect padding
   only). Reset edge margins so the Card's padding is the sole space
   contributor. Audit (2026-05-17): adopter feedback flagged this. */
.j-card > :first-child {
  margin-block-start: 0;
}
.j-card > :last-child {
  margin-block-end: 0;
}

.j-card-interactive {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
@media (hover: hover) {
  .j-card-interactive:hover {
    /* Hover treatment: bg elevation (surface-1 → --layer-elevated)
       + translateY lift + scale-lifted. Adopter feedback (2026-05-18,
       Hover treatment A/B prototype in the showcase): the prior
       shadow-only lift felt heavier than the rest of the kit's
       affordances; routing through --layer-elevated keeps the lift
       perceptible while scaling with the role-token cascade (ADR-029).
       Inside a modal sheet, --layer-elevated resolves to
       var(--surface-above) (ADR-037) so the hover step still lifts brighter
       against the surface-2 card bg. `background-color` (longhand) so adopters
       layering a `background-image` via unsafe_className aren't
       wiped by the hover swap — codex review r5. */
    background-color: var(--layer-elevated);
    transform: translateY(calc(-1 * var(--sp-xs))) scale(var(--scale-lifted));
  }
}
.j-card-interactive:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Disabled state — WAI-ARIA APG "discoverable disabled" pattern: the
   card stays focusable (so AT users discover it exists) but loses
   activation. Visual treatment mirrors .j-btn:disabled — opacity dim
   + not-allowed cursor — and suppresses the hover lift so the surface
   doesn't move when an unavailable card is hovered. Consumer feedback
   #9 (Cabinet audit, 2026-05-20). The React-level activation
   suppression lives in Card.tsx. */
.j-card-interactive[aria-disabled='true'] {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}
@media (hover: hover) {
  .j-card-interactive[aria-disabled='true']:hover {
    /* Suppress both the bg lift and the translate/scale transform so
       a disabled card stays visually inert under hover. The selector
       specificity matches the active hover rule above; aria-disabled
       wins by attribute presence. Mirrors the rest fill so disabled
       hover stays cascade-relative — ADR-029 amendment §E. */
    background-color: var(--layer-container);
    transform: none;
  }
}

/* Windows High Contrast / forced-colors fallback. Codex audit #111 R1:
   in forced-colors: active, browsers flatten authored backgrounds and
   ignore box-shadows, so the --surface-0 ↔ --surface-1 luminance step
   that normally bounds the card stops working. A 1px ButtonBorder
   outline preserves the card boundary for high-contrast users without
   re-introducing the visible border in normal mode. */
@media (forced-colors: active) {
  .j-card {
    border: 1px solid ButtonBorder;
  }
  /* Hover affordance for high-contrast mode. The default
     surface-1 → --layer-elevated bg swap is flattened by forced-colors,
     so the rest-vs-hover state would otherwise be indistinguishable.
     Promote the border to Highlight on hover so AT users still get a
     visible state change. `(hover: hover)` gate matches the normal
     hover rule at line 692 — touch devices in forced-colors mode (rare
     but possible, e.g., Windows tablet with Narrator) don't flash the
     Highlight border on every tap. Claude adversarial review r4
     finding #6. */
  @media (hover: hover) {
    .j-card-interactive:hover {
      border-color: Highlight;
    }
  }
  .j-card-interactive:focus-visible {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}

/* ── Input / Select / Textarea ────────────────────── */
.j-field {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  /* ADR-029 v5.1 amendment (round 2 — consumer audit 2026-05-20):
     bg routes through --field-bg, border routes through --rule-on-layer.
     Inside Card/Modal/Popover/Menu the container redeclares these so
     the field re-tones per scope.

     v5.1 :root defaults:
       --field-bg:      var(--surface-2)  (floating tier — bare Field
                                           pops above the --surface-0
                                           page bg, restoring the ADR
                                           §1 contract)
       --rule-on-layer: var(--color-rule) (same as v5.0.1)

     Adopter migration (v5.0 → v5.1): the page-level field bg shifts
     from --surface-0 (v5.0 mid-grey) to --surface-2 (v5.1 near-white
     in light, deepest dark-tier in dark). On a bare browser page with
     no body bg the field reads as floating chrome — the intended kit
     look. Adopters who want the prior gray-on-page recipe override
     :root { --field-bg: var(--surface-0); }.

     Inside containers:
       .j-card / .j-modal-sheet  --field-bg = --surface-0 (recess
                                  below the surface-1 container)
       .j-popover / .j-menu      --field-bg = --surface-1 (recess
                                  below the surface-2 floating panel)
     See each container's role-token block. */
  background: var(--field-bg);
  border: var(--bw-standard) solid var(--rule-on-layer);
  border-radius: var(--r-control);
  padding: var(--sp-xs) var(--sp-sm-p);
  transition: border-color var(--motion-feedback-field-focus) var(--ease-snap);
  font-family: var(--font-body);
  width: 100%;
  min-height: var(--touch-min);
}

/* ADR-031 — fieldWidth value→CSS mapping. The data-attribute is the
   selector hook; the React layer emits it. The base `.j-field { width:
   100% }` declaration above stays authoritative when no attribute is
   present (specificity (0,1,0)); the attribute selectors below are
   (0,1,1) and win when the React component emits them. For Input
   adopters in v5.1 the React layer ALWAYS emits a value
   (default `'fill'`) so the base rule never has to win — but other
   controls that don't opt in still hit the base. */
.j-field[data-field-width='fill'] {
  inline-size: 100%;
}
.j-field[data-field-width='content'] {
  inline-size: fit-content;
  max-inline-size: 100%;
}
.j-field[data-field-width='auto'] {
  inline-size: auto;
  max-inline-size: 100%;
}
.j-field[data-field-width-numeric] {
  inline-size: var(--field-inline-size, 100%);
  max-inline-size: 100%;
}

/* WCAG 2.5.5 target-size floor — applies to both content-sized and
   numeric paths. `'fill'` and `'auto'` are excluded because they're
   parent-driven (filling or shrinking to layout); enforcing a floor on
   them would break legitimate narrow layouts. */
.j-field[data-field-width='content'],
.j-field[data-field-width-numeric] {
  min-inline-size: var(--touch-min);
}

/* Inner-input flex release under 'content' — without this, the
   `.j-input { flex: 1 }` rule below stretches the input back to 100%
   inside the wrapper. Adopters typically pair fieldWidth='content'
   with native size={N} on the <input> to set intrinsic measure
   (the @atelierpx/jacquard/field-width-prefers-typed-prop ESLint
   rule warns when 'content' is used without a paired size). */
.j-field[data-field-width='content'] .j-input {
  flex: 0 0 auto;
  inline-size: auto;
  min-inline-size: 0;
}

/* ── FieldGroup (ADR-035) ───────────────────────────────────────────
   Layout-level field-width carrier. The `<FieldGroup width="X">`
   primitive (src/kit/primitives/FieldGroup.tsx) renders a
   `<div class="j-field-group">` with `display: contents` (so the
   wrapper does not consume a flex / grid track per OQ-3 lock); it
   emits `data-field-width-mode="<mode>"` plus the
   `--field-width-target` CSS custom property as the substrate signal.

   Six wrapper selectors across five controls consume the signal:
     - .j-field                     (Input)
     - .j-select-wrapper            (Select)
     - .j-creatable-select          (CreatableSelect — Select branch)
     - .j-creatable-select-create   (CreatableSelect — Input branch)
     - .j-datepicker-trigger        (DatePicker)
     - .j-time-picker               (TimePicker)

   Direct-child combinator `>` is load-bearing for innermost-wins
   nested-FieldGroup semantics (ADR-035 §5). With descendant combinator
   both outer and inner FieldGroups would match the field and last-in-
   source would win, not closest-ancestor. Direct-child confines each
   FieldGroup's rule to its own immediate field-control child, so a
   nested inner FieldGroup's rule fires on the field and an outer
   FieldGroup's rule does not — matching the React-layer composition
   semantics that the `input-field-width-to-field-group` codemod
   (ADR-032 §Codemod edge case 1) relies on. */
.j-field-group {
  display: contents;
}

/* fill — the field stretches to the parent's available inline-size.
   Matches `.j-field { width: 100% }` baseline default for Input; used
   as the explicit "fill the parent" signal under the FieldGroup
   substrate so Select / CreatableSelect / DatePicker / TimePicker
   (which default to `width: auto` / `inline-block`) can opt into the
   filling behavior layout-side rather than per-control. */
.j-field-group[data-field-width-mode='fill'] > .j-field,
.j-field-group[data-field-width-mode='fill'] > .j-select-wrapper,
.j-field-group[data-field-width-mode='fill'] > .j-creatable-select,
.j-field-group[data-field-width-mode='fill'] > .j-creatable-select-create,
.j-field-group[data-field-width-mode='fill'] > .j-datepicker-trigger,
.j-field-group[data-field-width-mode='fill'] > .j-time-picker {
  inline-size: var(--field-width-target);
  max-inline-size: 100%;
}

/* content — the field hugs its intrinsic measure. Asymmetric across
   the five controls by design (ADR-032 §Decision Q5): input-backed
   controls (Input / TimePicker) read their `<input>`'s intrinsic
   measure; trigger-button controls (Select / CreatableSelect Select
   branch / DatePicker) read the trigger label's text width. */
.j-field-group[data-field-width-mode='content'] > .j-field,
.j-field-group[data-field-width-mode='content'] > .j-select-wrapper,
.j-field-group[data-field-width-mode='content'] > .j-creatable-select,
.j-field-group[data-field-width-mode='content'] > .j-creatable-select-create,
.j-field-group[data-field-width-mode='content'] > .j-datepicker-trigger,
.j-field-group[data-field-width-mode='content'] > .j-time-picker {
  inline-size: var(--field-width-target);
  max-inline-size: 100%;
}

/* numeric — the field renders at the pixel value carried via
   `--field-width-target: <N>px` (the React layer emits the value).
   `max-inline-size: 100%` caps the width against the parent so a
   FieldGroup numeric directive cannot blow out of a narrow container. */
.j-field-group[data-field-width-mode='numeric'] > .j-field,
.j-field-group[data-field-width-mode='numeric'] > .j-select-wrapper,
.j-field-group[data-field-width-mode='numeric'] > .j-creatable-select,
.j-field-group[data-field-width-mode='numeric'] > .j-creatable-select-create,
.j-field-group[data-field-width-mode='numeric'] > .j-datepicker-trigger,
.j-field-group[data-field-width-mode='numeric'] > .j-time-picker {
  inline-size: var(--field-width-target);
  max-inline-size: 100%;
}

/* auto — no-op declaration block. The per-control wrapper falls back
   to its own existing default (Input: `width: 100%`; Select /
   CreatableSelect: `width: auto`; DatePicker: `inline-flex` intrinsic;
   TimePicker: `inline-block` intrinsic). FieldGroup's React layer
   resolves `width="auto"` to `data-field-width-mode="auto"` WITHOUT
   `--field-width-target`, so no inline-size declaration applies and
   the cascade lets the existing per-control rule win. The empty
   declaration block documents the intentional no-op. */
.j-field-group[data-field-width-mode='auto'] > .j-field,
.j-field-group[data-field-width-mode='auto'] > .j-select-wrapper,
.j-field-group[data-field-width-mode='auto'] > .j-creatable-select,
.j-field-group[data-field-width-mode='auto'] > .j-creatable-select-create,
.j-field-group[data-field-width-mode='auto'] > .j-datepicker-trigger,
.j-field-group[data-field-width-mode='auto'] > .j-time-picker {
  /* No-op: per-control default applies. See block-level comment. */
}

/* Inner-input flex release under FieldGroup content/numeric — without
   this, the `.j-input { flex: 1 }` rule (declared elsewhere for the
   Field wrapper's input child) stretches the input back to its
   parent's inline-size, defeating the content/numeric directive. Same
   pattern as ADR-031's release rule for `.j-field[data-field-width='content']`
   at the line ~973 block above; applied under both 'content' and
   'numeric' modes so the inner input can shrink to FieldGroup's
   declared bound. */
.j-field-group[data-field-width-mode='content'] > .j-field > .j-input,
.j-field-group[data-field-width-mode='numeric'] > .j-field > .j-input {
  flex: 0 0 auto;
  inline-size: auto;
  min-inline-size: 0;
}

.j-field:focus-within {
  /* Border-color shifts to the theme so the focused field reads as a single
     coherent affordance — the previous neutral-950 + theme-ring combo
     stacked a black inner border around the input then a theme halo
     outside it, which adopter feedback flagged as a "double border."
     Theme-500 here matches the focus-ring color below, so the visual is
     one tinted edge instead of two competing rings. */
  border-color: var(--color-theme-500);
}

/* Keyboard-only focus ring: only paint the ring when the focused descendant
   was focused via keyboard (`:focus-visible`). Mouse clicks keep the quieter
   border-only treatment. Requires `:has()` (Chrome 105+, Safari 15.4+,
   Firefox 121+).

   Single high-contrast ring instead of the legacy two-ring `--focus-ring` —
   adopter audit on the demo page flagged the stacked rings as "redundant."
   Codex audit #110 R1 caught a follow-on a11y regression: an earlier
   single-ring at `2px solid theme-100` dropped below the 3:1 focus-ring
   contrast floor against adjacent surfaces, and the hard-coded `2px`
   bypassed the AAA preset's `--bw-selection: 3px`. Uses
   `--focus-ring-color` (neutral-950 — guaranteed high contrast against
   any surface) and `--bw-selection` (AAA-aware) so keyboard users on
   inputs/selects/textareas keep a clearly visible focus cue. */
.j-field:focus-within:has(:focus-visible) {
  box-shadow: 0 0 0 var(--bw-selection) var(--focus-ring-color);
}

.j-field[data-disabled='true'],
.j-field.is-disabled {
  /* Reads --field-bg-disabled (ADR-029 v5.1 amendment §5). Default at
     :root is --color-neutral-100 (preserves v5.0.1 visual). Inside
     Card/Modal/Popover/Menu the container overrides this to a
     color-mix(--field-bg, --on-layer) derivation so the disabled
     state never collides with the container's surface — codex
     adversarial review caught that dark-mode --color-neutral-100
     equals --surface-1, dissolving disabled fields into the Card. */
  background: var(--field-bg-disabled);
  cursor: not-allowed;
}

.j-field-prefix,
.j-field-suffix {
  color: var(--fg-2);
  font-size: var(--type-small);
  font-family: var(--font-body);
  display: inline-flex;
  align-items: center;
}

.j-input,
.j-textarea,
.j-select {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--type-small);
  color: var(--fg-1);
  padding: 0;
  width: 100%;
}

.j-input::placeholder,
.j-textarea::placeholder {
  color: var(--fg-3);
}

.j-textarea {
  resize: vertical;
  line-height: var(--lh-caption);
  min-height: var(--sp-4xl);
  padding: var(--sp-sm) 0;
}

/* Standalone select (no wrapper field) — v5
   -webkit-appearance: none is required on macOS Safari to fully
   override native styling and prevent dropdown position offset. */
.j-select-standalone {
  -webkit-appearance: none;
  appearance: none;
  font-family: var(--font-body);
  font-size: var(--type-small);
  color: var(--fg-1);
  /* Field-adjacent control — bg routes through --field-bg per ADR-029
     v5.1 amendment so a standalone select inside a Popover/Menu
     (where --field-bg = --surface-1) re-tones to match a sibling
     .j-field, not stays at the raw page-surface tier. */
  background: var(--field-bg);
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-control);
  padding: 0 var(--sp-lg) 0 var(--sp-sm-p);
  cursor: pointer;
  width: 100%;
  height: var(--touch-min);
  line-height: var(--touch-min);
  position: relative;
  /* Custom chevron via background SVG — light mode stroke (neutral-500 #656870) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23656870' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-sm) center;
  background-size: 12px 12px;
  transition:
    border-color var(--motion-feedback-field-focus) var(--ease-snap),
    box-shadow var(--motion-feedback-field-focus) var(--ease-snap);
}

/* Dark-mode chevron: lighter stroke for contrast against dark surface */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .j-select-standalone {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%239496a0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}
[data-theme='dark'] .j-select-standalone {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%239496a0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Focus ring: outline, not box-shadow */
.j-select-standalone:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  box-shadow: none;
}

/* Hover */
@media (hover: hover) {
  .j-select-standalone:hover:not(:disabled) {
    border-color: var(--color-neutral-700);
  }
}

/* Disabled */
.j-select-standalone:disabled {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

/* Error */
.j-select-error {
  border-color: var(--color-error-700);
}

/* Small size */
.j-select-sm {
  height: var(--touch-compact);
  line-height: var(--touch-compact);
  font-size: var(--type-label);
  padding: 0 var(--sp-lg) 0 var(--sp-sm);
}

/* ── Custom Select dropdown ─────────────────────── */

/* Wrapper positions the listbox relative to the trigger */
.j-select-wrapper {
  position: relative;
  display: inline-block;
  /* `auto` so a row of <Select>s in `display: flex; flex-wrap: wrap`
     doesn't claim its own row each. Adopters previously had to thread
     `style={{ width: 160 }}` to the inner button, but the wrapper still
     consumed the full flex track — every Select got its own row. The
     inner .j-select-standalone still respects `width: 100%` so the
     button fills the wrapper bounds, and adopters who want full-width
     can size the wrapper inline through `style.width` / `unsafe_style`
     (see the v5.1.x hotfix note below) or by placing the Select inside
     a `<FormField>` that imposes block layout. (`unsafe_className`
     applies to the trigger button, not this wrapper — sizing has to
     reach the wrapper via the React-layer style forwarding.)
     Consumer feedback #6 (Cabinet audit, 2026-05-20).

     v5.1.x hotfix (Cabinet audit, 2026-05-21): the React layer also
     forwards the layout-axis subset of `style` / `unsafe_style`
     (`width` / `minWidth` / `maxWidth` / `inlineSize` /
     `minInlineSize` / `maxInlineSize` / `flex` / `flexBasis` /
     `flexGrow` / `flexShrink`) from `<Select>` to this wrapper. Before
     the v5.1 wrapper landed, those props sized the trigger button
     directly; with the wrapper in place, a percentage or `calc(...)`
     width applied to the inner button resolved against `width: auto`
     here and collapsed to min-content. Forwarding the layout keys
     restores the v5.0.x sizing behavior — see `splitLayoutStyle` in
     `src/kit/primitives/Select.tsx`. Non-layout style properties stay
     on the trigger button so unrelated semantics don't change. */
  width: auto;
}

/* Trigger button resets — styled via .j-select-standalone */
.j-select-standalone {
  text-align: start;
}

/* Placeholder text color */
.j-select-placeholder {
  color: var(--fg-3);
}

/* Value display — prevent overflow */
.j-select-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Listbox dropdown anchored below trigger */
.j-select-listbox {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + var(--sp-xs));
  z-index: var(--z-dropdown, 100);
  max-height: calc(8 * var(--touch-compact));
  overflow-y: auto;
  overflow-x: hidden;
}

/* Option items — use div not button, so override cursor */
.j-select-option {
  cursor: pointer;
  user-select: none;
}

/* Label text — truncate long labels to one line.
   Must be a real element (not anonymous text node) so
   text-overflow works inside the flex parent. */
.j-select-option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Check icon reserved space to keep labels aligned */
.j-select-option-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--sp-md);
  height: var(--sp-md);
  color: var(--fg-1);
}

/* Optional leading icon */
.j-select-option-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--sp-md);
  height: var(--sp-md);
  color: var(--fg-2);
}

/* Selected option styling */
.j-select-option-selected {
  font-weight: 500;
}

/* Focused-option highlight lives in the .j-menu-item state block as
   the compound selector `.j-menu-item.j-select-option-focused` per
   v5.2.1 (PR #200). See ADR-036 for the v6 cascade-layers migration. */

/* ── Sentinel "action" option (e.g. "Add item...") ─────────── */
.j-select-option-action {
  color: var(--fg-2);
}

.j-select-option-action .j-select-option-check {
  color: var(--fg-2);
}

/* Select (standalone) — forced-colors (Windows High Contrast).
   Co-located with the base .j-select-standalone rules (above) so that
   source order resolves the cascade correctly. The centralized
   `@media (forced-colors: active)` block earlier in the file declares
   this HC rule BEFORE the base — equal-specificity tie + later source
   wins meant the base `border: var(--bw-hairline) solid
   var(--rule-on-layer)` clobbered the HC `border: 2px solid
   ButtonBorder`. PR-A 2026-05-21 (sibling to PR #161). */
@media (forced-colors: active) {
  .j-select-standalone {
    border: 2px solid ButtonBorder;
  }
}

/* ── CreatableSelect ─────────────────────────────── */
.j-creatable-select {
  /* Same horizontal-row rationale as .j-select-wrapper — adopters
     putting CreatableSelect components in a flex-wrap row shouldn't
     have each instance claim its own track. The inner controls
     respect their own sizing; the outer wrapper stays auto.
     Consumer feedback #6 (Cabinet audit, 2026-05-20) — Codex PR #144
     review caught that the original Select fix didn't reach
     CreatableSelect's outer wrapper. */
  width: auto;
}

/* Create mode: input + two icon buttons on a single row.
   No flex-wrap — buttons always stay beside the input. */
.j-creatable-select-create {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
}
.j-creatable-select-create > :first-child {
  flex: 1;
  min-width: 0;
}
/* sm variant: compact field height matching j-select-sm */
.j-creatable-select-create-sm .j-field {
  min-height: var(--touch-compact);
  padding: var(--r-micro) var(--sp-sm);
  border-width: var(--bw-hairline);
}
.j-creatable-select-create-sm .j-input {
  font-size: var(--type-label);
}
.j-creatable-select-create-sm .j-icon-btn {
  width: var(--sp-xl);
  height: var(--sp-xl);
}

.j-creatable-select-status {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  margin-top: var(--sp-xs);
  padding: var(--sp-xs) var(--sp-sm);
  min-height: var(--touch-compact);
  border: var(--bw-hairline) solid var(--color-error-700);
  border-radius: var(--r-compact);
  background: var(--color-error-100);
  color: var(--fg-1);
  font-family: var(--font-body);
  font-size: var(--type-label);
  line-height: var(--lh-small);
}

.j-creatable-select-status > svg {
  flex-shrink: 0;
}

/* CreatableSelect status row — forced-colors (Windows High Contrast).
   Co-located with the base .j-creatable-select-status rule (above) so
   that source order resolves the cascade correctly. The centralized
   `@media (forced-colors: active)` block earlier in the file declares
   this HC rule BEFORE the base — equal-specificity tie + later source
   wins meant the base `border + background + color` clobbered the HC
   recipe entirely, so an inline-error status row inside CreatableSelect
   no longer read as an error under the system palette. PR-A
   2026-05-21 (sibling to PR #161). */
@media (forced-colors: active) {
  .j-creatable-select-status {
    background: Canvas;
    color: CanvasText;
    border: 2px solid ButtonBorder;
    forced-color-adjust: auto;
  }
}

/* ── Checkbox ─────────────────────────────────────── */
.j-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--type-small);
  color: var(--fg-1);
  min-height: var(--touch-min);
  line-height: var(--lh-field);
}

.j-checkbox-box {
  width: var(--checkbox-sz);
  height: var(--checkbox-sz);
  border-radius: var(--r-checkbox);
  border: var(--bw-standard) solid var(--rule-on-layer);
  /* Field-adjacent control — routes through --field-bg per ADR-029
     v5.1 amendment so a checkbox inside a Popover/Menu re-tones with
     the surrounding .j-field group. */
  background: var(--field-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background var(--motion-feedback-switch-flip) var(--ease-snap),
    border-color var(--motion-feedback-switch-flip) var(--ease-snap);
}

.j-checkbox-label input:checked ~ .j-checkbox-box,
.j-checkbox-box[data-checked='true'] {
  background: var(--color-neutral-900);
  border-color: var(--color-neutral-900);
}

/* The native input is visually hidden but still receives focus for keyboard
   users. Surface that focus state on the styled box via :focus-visible so
   we don't trip the ring on mouse clicks. */
.j-checkbox-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Focus ring: outline per ADR-014 §9, not box-shadow */
.j-checkbox-label input:focus-visible ~ .j-checkbox-box {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  box-shadow: none;
}

/* Hover: subtle border darkening, pointer-only */
@media (hover: hover) {
  .j-checkbox-label:hover .j-checkbox-box {
    border-color: var(--color-neutral-700);
  }
}

/* Active / pressed: scale feedback */
.j-checkbox-label:active .j-checkbox-box {
  transform: scale(var(--scale-tapped));
}

/* Disabled: dimmed + not-allowed */
.j-checkbox-label:has(input:disabled) {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

/* Indeterminate / mixed — same fill as checked */
.j-checkbox-box[data-checked='mixed'] {
  background: var(--color-neutral-900);
  border-color: var(--color-neutral-900);
}

/* Small size variant */
.j-checkbox-sm .j-checkbox-box {
  width: 16px;
  height: 16px;
  border-radius: var(--r-tiny);
}
.j-checkbox-sm {
  font-size: var(--type-label);
  min-height: var(--touch-compact);
}

/* Checkbox — forced-colors (Windows High Contrast).
   Co-located with the base .j-checkbox-box rules (above) so that
   source order resolves the cascade correctly. The centralized
   `@media (forced-colors: active)` block earlier in the file declared
   these HC rules BEFORE the base — equal-specificity ties + later
   source wins meant the base `border: var(--bw-standard) solid
   var(--rule-on-layer)` and the checked/mixed `background +
   border-color` recipes clobbered the HC `ButtonBorder` / `Highlight`
   palette story. PR-A 2026-05-21 (sibling to PR #161). The
   :focus-visible Med-severity entry stays in the centralized block
   pending PR-B. */
@media (forced-colors: active) {
  .j-checkbox-box {
    border: 2px solid ButtonBorder;
  }
  .j-checkbox-box[data-checked='true'],
  .j-checkbox-box[data-checked='mixed'] {
    background: Highlight;
    border-color: Highlight;
  }
}

/* ── Radio ────────────────────────────────────────── */
.j-radio-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--type-small);
  color: var(--fg-1);
  min-height: var(--touch-min);
  line-height: var(--lh-field);
}

.j-radio-circle {
  width: var(--checkbox-sz);
  height: var(--checkbox-sz);
  border-radius: var(--r-pill);
  border: var(--bw-standard) solid var(--rule-on-layer);
  /* Field-adjacent control — routes through --field-bg per ADR-029
     v5.1 amendment so a radio inside a Popover/Menu re-tones with
     the surrounding .j-field group. */
  background: var(--field-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background var(--motion-feedback-switch-flip) var(--ease-snap),
    border-color var(--motion-feedback-switch-flip) var(--ease-snap);
}

/* Selected: filled circle with inner dot */
.j-radio-circle[data-checked='true'] {
  background: var(--color-neutral-900);
  border-color: var(--color-neutral-900);
}
.j-radio-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--color-neutral-100);
}

/* Hidden native input */
.j-radio-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Focus ring: outline per ADR-014 §9, not box-shadow */
.j-radio-label input:focus-visible ~ .j-radio-circle {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  box-shadow: none;
}

/* Hover: subtle border darkening, pointer-only */
@media (hover: hover) {
  .j-radio-label:hover .j-radio-circle {
    border-color: var(--color-neutral-700);
  }
}

/* Active / pressed: scale feedback */
.j-radio-label:active .j-radio-circle {
  transform: scale(var(--scale-tapped));
}

/* Disabled: dimmed + not-allowed */
.j-radio-label:has(input:disabled) {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

/* Small size variant */
.j-radio-sm .j-radio-circle {
  width: 16px;
  height: 16px;
}
.j-radio-sm .j-radio-dot {
  width: 6px;
  height: 6px;
}
.j-radio-sm {
  font-size: var(--type-label);
  min-height: var(--touch-compact);
}

/* Group layout */
.j-radio-group {
  display: flex;
  gap: var(--sp-lg);
}
.j-radio-group-vertical {
  flex-direction: column;
  gap: 0; /* min-height on labels provides sufficient vertical spacing */
}

/* Radio — forced-colors (Windows High Contrast).
   Co-located with the base .j-radio-circle rules (above) so that
   source order resolves the cascade correctly. The centralized
   `@media (forced-colors: active)` block earlier in the file declared
   these HC rules BEFORE the base — equal-specificity ties + later
   source wins meant the base `border` and the [data-checked='true']
   `background + border-color` recipes clobbered the HC `ButtonBorder`
   / `Highlight` palette story. PR-A 2026-05-21 (sibling to PR #161).
   The :focus-visible Med-severity entry stays in the centralized
   block pending PR-B. */
@media (forced-colors: active) {
  .j-radio-circle {
    border: 2px solid ButtonBorder;
  }
  .j-radio-circle[data-checked='true'] {
    background: Highlight;
    border-color: Highlight;
  }
}

/* ── Modal ────────────────────────────────────────── */
@keyframes j-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes j-pop {
  from {
    opacity: 0;
    transform: translateY(calc(-1 * var(--sp-xs))) scale(var(--scale-tapped));
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes j-slide-up {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Non-dismissible modal — overlay doesn't suggest clickability */
.j-modal-nondismissible {
  cursor: default;
  pointer-events: none;
}
.j-modal-nondismissible > .j-modal-sheet {
  pointer-events: auto;
}

.j-modal-overlay {
  position: fixed;
  inset: 0;
  background: color-mix(
    in srgb,
    var(--color-neutral-900) calc(var(--op-scrim) * 100%),
    transparent
  );
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--sp-lg);
  animation: j-fade var(--motion-transition-modal-enter) var(--ease-out);
}

.j-modal-sheet {
  position: relative;
  /* Modal panels use surface-1 (raised), not a brighter surface. The scrim
     on .j-modal-overlay carries the elevation lift; stacking the panel on
     surface-2 would double-count the signal. See tokens.css surface ramp.

     ADR-029 layer-aware role tokens (v5): the sheet redeclares role
     tokens so descendants (header divider, close-button pill, nested
     primitives) re-resolve --layer / --on-layer / --on-layer-2 /
     --rule-on-layer against the MODAL surface, not the page surface
     they inherited from :root. This is the systemic answer to the
     "modal close button reads weak" bug the ADR uses as a motivating
     example (line 23, line 73–79). --on-layer-2 is re-pointed to
     --fg-1 (stronger than the default --fg-2) so subtle icons on the
     modal surface still hit WCAG 1.4.11.

     --layer-elevated overrides the default surface-2 lift with a
     color-mix toward the fg tone, so nested elevated content (hover
     cards, sub-panels) keeps a visible step inside the modal —
     v5 kit's surface ramp tops at surface-2, so without this
     override there's no rung above the sheet to lift into.

     --layer-container override (v5.2.1, codex review r1+r2): a
     `<Card>` nested inside the Modal sheet paints `var(--layer-container)`,
     so the sheet must redeclare this role so Card-in-Modal lifts above
     the sheet's surface-1. We pick `--surface-2` (NOT the color-mix
     overlay used for `--layer-elevated`) so Card-in-Modal rest paint
     stays DISTINCT from Card-in-Modal hover paint (hover reads
     --layer-elevated = overlay). Codex r2 P2: using the same overlay
     recipe for both --layer-container and --layer-elevated collapsed
     rest and hover into the same color, killing the hover affordance.
     Before this declaration, Card-in-Modal collapsed onto the sheet's
     surface-1 paint; the v5.2.0 hotfix's accidental Card self-app
     papered over the gap. */
  --layer: var(--surface-1);
  --layer-container: var(--surface-2);
  /* ADR-043 §B.bis: --on-layer NOT redeclared (= :root default --fg-1).
     --on-layer-2 IS kept (non-default --fg-1, stronger than the :root --fg-2)
     so subtle icons on the modal sheet still hit WCAG 1.4.11. */
  --on-layer-2: var(--fg-1);
  /* Same 20%-mix recipe as .j-card — re-tones dividers and field
     borders inside the modal to the modal's own surface. The
     :root --color-rule was tuned against the page surface; using
     it inside a brighter modal sheet produced a flatter divider
     than design intent. */
  --rule-on-layer: color-mix(in srgb, var(--layer) 80%, var(--on-layer) 20%);
  /* Fields inside a modal recess to --surface-0 per ADR-029 —
     identical to .j-card's pattern for tonal consistency between
     the two modal-family containers. */
  --field-bg: var(--surface-0);
  /* Disabled field bg — same derivation as .j-card so a disabled
     field inside the modal stays visible against the sheet surface
     (dark mode --color-neutral-100 = --surface-1 = sheet bg, so the
     :root default would dissolve the disabled state). */
  --field-bg-disabled: color-mix(in srgb, var(--field-bg) 88%, var(--on-layer) 12%);
  --layer-elevated: var(--surface-above);
  /* ADR-042 (finalized; was the #126 prototype). Modal sheet paints --surface-1;
     recess drops to --surface-0 (same tier as fields recess via
     --field-bg above — see the .j-card pattern). Segmented inside a
     Modal reads as inset against the sheet surface. */
  --layer-recess: var(--surface-0);
  /* ADR-043 (P-13): own-paint via the private stash mirroring --layer (kept
     declared above for descendant inheritance + the ADR-029 R4 adopter knob).
     Modal has no own border, so only --layer is stashed. */
  --_layer-painted: var(--layer);
  background: var(--_layer-painted);
  border-radius: var(--r-sheet);
  width: 100%;
  max-width: var(--max-modal-width);
  max-height: calc(100vh - var(--sp-3xl));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  animation: j-pop var(--motion-transition-modal-enter) var(--ease-snap);
}

.j-modal-header {
  padding: var(--sp-lg) var(--sp-xl) var(--sp-md);
  /* Reads --rule-on-layer so the divider tones to the modal surface
     (ADR-029); the sheet's role-token override at .j-modal-sheet
     keeps the source value but the layer-aware indirection lets
     adopter overrides re-tone the divider per scope without
     monkey-patching this selector. */
  border-bottom: var(--bw-hairline) solid var(--rule-on-layer);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-md);
}

.j-modal-body {
  /* Explicit overflow-y so long content always scrolls inside the
     sheet. `min-height: 0` is required for a flex child with
     overflow — without it, a very tall body would force the sheet
     past its max-height and clip against .j-modal-sheet's
     `overflow: hidden`. `overscroll-behavior: contain` prevents
     scroll-chaining into the page behind the modal. */
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  flex: 1;
  overscroll-behavior: contain;
}

.j-modal-close {
  flex-shrink: 0;
  width: var(--sp-xl);
  height: var(--sp-xl);
  border-radius: var(--r-pill);
  border: none;
  /* Adopter feedback (2026-05-22, v5.2.1 hotfix): the two prior
     recipes both missed. v5.1.x used a 50/50 color-mix pill
     (3.20:1 light / 4.51:1 dark vs the sheet) — clears WCAG 1.4.11
     but reads as a heavyweight chip in the modal corner, "too dark."
     v5.2.0 (PR #181, Bug 3) overcorrected to a transparent rest +
     --layer-elevated hover — adopters reported the rest state lost
     its affordance entirely ("we don't like the transparent rest
     state"). v5.2.1 lands the middle path: a SUBTLE-but-visible chip
     at rest, with a clearly-lifted hover.

     Rest state: color-mix(--layer 88%, --on-layer 12%) — a faint
     overlay on the modal sheet that reads as a button shape without
     dominating the corner. Contrast measurements (sRGB WCAG 2.x):
       light: pill vs sheet = 1.26:1 (visible chip, well below the
              v5.1.x "too dark" 3.20:1); icon (--on-layer) on pill
              = 11.84:1 (WCAG 1.4.11 ✓, 3:1 floor for graphical UI).
       dark:  pill vs sheet = 1.37:1; icon on pill = 10.52:1.
     The 1.5–2.5:1 band is the kit's "subtle affordance" zone —
     visible at rest, not aggressive. Below ~1.1:1 the chip dissolves
     into the sheet (the v5.2.0 failure mode); above ~2.5:1 the chip
     starts competing with title weight (the v5.1.x failure mode).

     Hover state: color-mix(--layer 55%, --on-layer 45%) — a clear
     step up from rest. Contrast measurements:
       light: pill vs sheet = 2.78:1 (clear lift, ~2.2× the rest
              step); icon on pill = 5.39:1 (WCAG 1.4.11 ✓).
       dark:  pill vs sheet = 3.93:1; icon on pill = 3.68:1.
     The light-mode 2.78:1 sits just under the 3:1 "target" — pushing
     higher (50/50 = 3.20:1) re-triggers the v5.1.x "too dark" report
     because the hover IS what adopters were reading as the dominant
     rest chip. The 55/45 mix preserves a perceptually clear lift
     (delta luminance ~2.2× rest) while staying lighter than the
     v5.1.x baseline.

     The recipe reads layer-aware role tokens (--layer, --on-layer)
     so adopters rendering the close button outside the modal sheet
     get the same chip resolved against their container's surface
     (Popover, Card, raw page) per ADR-029.

     Cascade-order note: the forced-colors `ButtonBorder` override
     below stays — HC users still need the visible boundary the
     color-mix recipe can't carry through forced-colors mode. */
  background: color-mix(in srgb, var(--layer) 88%, var(--on-layer) 12%);
  color: var(--on-layer);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--motion-feedback-button-press) var(--ease-snap),
    color var(--motion-feedback-button-press) var(--ease-snap);
}

@media (hover: hover) {
  .j-modal-close:hover {
    /* Hover lifts the chip with a heavier color-mix — a clearly
       perceptible step up from the 88/12 rest (light 1.26 → 2.78;
       dark 1.37 → 3.93). The icon stays --on-layer through the
       transition; icon-on-pill contrast stays above WCAG 1.4.11's
       3:1 floor (light 5.39, dark 3.68). Same role-token grammar
       as rest, so adopters get consistent hover lift in any
       container context. */
    background: color-mix(in srgb, var(--layer) 55%, var(--on-layer) 45%);
    color: var(--on-layer);
  }
}
.j-modal-close:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  box-shadow: none;
}

/* Floating close button for headerless modals — positioned in the
   top-right corner of the sheet, independent of header content. */
.j-modal-close-float {
  position: absolute;
  top: var(--sp-sm);
  inset-inline-end: var(--sp-sm);
  z-index: 2;
}

/* Drag handle — hidden on desktop; shown on mobile via the
   @media (max-width: 767px) block below. Touch-draggable via
   useSheetDrag hook. */
.j-modal-drag-handle {
  display: none;
}
.j-modal-drag-pill {
  width: 36px;
  height: 4px;
  background: var(--color-neutral-300);
  border-radius: var(--r-pill);
}

/* Modal close button — forced-colors (Windows High Contrast).
   Co-located with the base .j-modal-close rule (above) so that source
   order resolves the cascade correctly. The centralized
   `@media (forced-colors: active)` block earlier in the file declared
   this HC rule BEFORE the base — equal-specificity tie + later source
   wins meant the base `border: none` clobbered the HC `border: 1px
   solid ButtonBorder`, so the modal close button lost its visible
   boundary under Windows HC. PR-A 2026-05-21 (sibling to PR #161).
   The :focus-visible Med-severity entry stays in the centralized
   block pending PR-B. */
@media (forced-colors: active) {
  .j-modal-close {
    border: 1px solid ButtonBorder;
  }
}

/* ── Divider ──────────────────────────────────────── */
.j-divider {
  block-size: var(--bw-hairline);
  background: var(--rule-on-layer);
  inline-size: 100%;
  border: none;
  /* Reset native <hr> margin so the rule sits flush; adopters add
     surrounding spacing at the parent layout level. */
  margin: 0;
}

.j-divider[data-orientation='vertical'] {
  block-size: 100%;
  inline-size: var(--bw-hairline);
}

/* ── Progress ─────────────────────────────────────── */
.j-progress {
  position: relative;
  width: 100%;
  border-radius: var(--r-pill);
  overflow: hidden;
  height: var(--sp-sm);
}

.j-progress-fill {
  height: 100%;
  border-radius: var(--r-pill);
  transition: width var(--motion-feedback-hover) var(--ease-snap);
}

.j-progress-marker {
  position: absolute;
  top: calc(-1 * var(--r-micro));
  width: var(--r-micro);
  background: var(--color-neutral-900);
  transform: translateX(-50%);
}

.j-progress-theme {
  background: var(--color-theme-100);
}
.j-progress-theme > .j-progress-fill {
  background: var(--color-theme-500);
}
.j-progress-success {
  background: var(--color-success-100);
}
.j-progress-success > .j-progress-fill {
  background: var(--color-success-500);
}
.j-progress-error {
  background: var(--color-error-100);
}
.j-progress-error > .j-progress-fill {
  background: var(--color-error-500);
}
.j-progress-warning {
  background: var(--color-warning-100);
}
.j-progress-warning > .j-progress-fill {
  background: var(--color-warning-500);
}
.j-progress-info {
  background: var(--color-info-100);
}
.j-progress-info > .j-progress-fill {
  background: var(--color-info-500);
}

/* Overflow state: fill flips to success when value > max */
.j-progress-fill[data-overflow='true'] {
  background: var(--color-success-500) !important;
}

/* ── Thumb ────────────────────────────────────────── */
.j-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--color-neutral-300), var(--color-neutral-200));
  color: var(--color-neutral-700);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: var(--track-heading);
  text-transform: uppercase;
  border-radius: var(--r-image);
}

.j-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.j-thumb[data-image-mode='cutout'] img {
  object-fit: contain;
}

.j-thumb-theme {
  background: var(--color-theme-100);
  color: var(--color-theme-700);
}
.j-thumb-success {
  background: var(--color-success-100);
  color: var(--color-success-700);
}
.j-thumb-error {
  background: var(--color-error-100);
  color: var(--color-error-700);
}
.j-thumb-warning {
  background: var(--color-warning-100);
  color: var(--color-warning-700);
}
.j-thumb-info {
  background: var(--color-info-100);
  color: var(--color-info-700);
}

/* ── Data row (grid-based tables) ─────────────────── */
.j-table-header {
  display: grid;
  gap: var(--sp-sm-p);
  padding: var(--sp-sm) var(--sp-md);
  align-items: center;
  border-bottom: var(--bw-hairline) solid var(--rule-on-layer);
}

.j-table-cell-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--type-micro);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--fg-3);
  user-select: none;
}

.j-table-cell-sort {
  margin-inline-start: var(--sp-xs);
  color: var(--fg-1);
}

/* Reset for the sort button wrapping a sortable header label.
   Table.tsx emits this class on a <button> that wraps the label;
   without the reset, default browser <button> chrome (gray
   background, padding, font) breaks the table's typography
   alignment. The button stays semantically a button (Enter/Space
   still activate); the explicit :focus-visible rule below replaces
   the suppressed browser ring with the kit's standard focus
   treatment. */
.j-table-cell-sort-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: inherit;
  cursor: pointer;
}
.j-table-cell-sort-btn:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  border-radius: var(--r-micro);
}

.j-table-row {
  display: grid;
  gap: var(--sp-sm-p);
  padding: 0 var(--sp-md);
  min-height: var(--touch-min);
  align-items: center;
  border-bottom: var(--bw-hairline) solid var(--rule-on-layer);
  transition: background var(--motion-feedback-state) var(--ease-snap);
}

.j-table-row[data-clickable='true'] {
  cursor: pointer;
}
@media (hover: hover) {
  .j-table-row[data-clickable='true']:hover {
    /* Surface-tier lift (consumer feedback 2026-05-20) — was
       --color-neutral-100 = --surface-1 = Card bg, so clickable rows
       inside a Card (the common case) had an invisible hover state.
       --layer-elevated keeps a visible step inside every container. */
    background: var(--layer-elevated);
  }
}
.j-table-row[data-dim='true'] {
  opacity: var(--op-dimmed);
}

/* ── Empty state ──────────────────────────────────── */
.j-empty {
  padding-block: var(--sp-4xl);
  padding-inline: var(--sp-lg);
  text-align: center;
  color: var(--fg-2);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xs);
}

.j-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-block-end: var(--sp-sm);
  color: var(--fg-2);
}

.j-empty-icon[data-tone='info'] {
  color: var(--color-theme-700);
}

.j-empty-icon[data-tone='error'] {
  color: var(--color-error-700);
}

.j-empty-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--type-compact);
  color: var(--fg-1);
  letter-spacing: var(--track-compact);
  margin: 0;
}

.j-empty-description {
  font-size: var(--type-small);
  color: var(--fg-2);
  line-height: var(--lh-compact-body);
  max-inline-size: 56ch;
}

.j-empty-actions {
  display: flex;
  gap: var(--sp-sm);
  justify-content: center;
  margin-block-start: var(--sp-sm);
}

/* v4 alias class — retained so adopters with custom CSS targeting
   `.j-empty-hint` still render correctly during the deprecation
   window. Same rules as `.j-empty-description`. Removed in v6. */
.j-empty-hint {
  font-size: var(--type-small);
  color: var(--fg-2);
  line-height: var(--lh-compact-body);
}

/* ── Form (2.24) ───────────────────────────────────
   Layout-only wrapper for the native <form> element. Default
   vertical stacking with the standard --sp-md gap; adopters who
   want a grid layout compose with .j-form-grid or their own. */
.j-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}

/* ── Form field / Stat cell ───────────────────────── */
.j-form-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}
.j-form-field-label {
  /* alias .j-eyebrow used inline */
}

/* ── Label primitive (2.25) ─────────────────────────
   IMPORTANT: `.j-label` is defined in src/css/typography.css with
   the canonical body-label typography rhythm (--type-label,
   --track-label, --fg-3, uppercase, weight 600). DO NOT redefine
   `.j-label` here — the duplicate caused a silent v5.0 collision
   (different font-size/letter-spacing tokens depending on CSS load
   order). The Label primitive composes against the typography
   class for its text rules and adds only the layout-specific
   modifier classes below.

   `.j-label-required` is the asterisk indicator — color-error to
   draw the eye while the sr-only "(required)" text carries the
   AT-perceivable signal per ADR-014 §3-carrier rule. */
.j-label-required {
  color: var(--color-error-500);
  font-weight: 700;
  margin-inline-start: var(--sp-xs);
}

.j-stat-cell {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}
.j-stat-cell-value {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--type-compact-body);
  color: var(--fg-1);
}
.j-stat-cell-value-mono {
  font-family: var(--font-mono);
  font-size: var(--type-small);
}

/* ── ID tag ──────────────────────────────────────── */
.j-id-tag {
  /* Reset the UA button styling since kit.jsx now renders IdTag as a
     <button> for keyboard accessibility. Every visual comes from the
     rules below; border / font inheritance come from the reset. */
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--type-micro);
  color: var(--fg-3);
  padding: 0 var(--sp-xs);
  border: none;
  border-radius: var(--r-tiny);
  background: transparent;
  cursor: pointer;
  user-select: none;
  letter-spacing: var(--track-compact);
  transition:
    color var(--motion-feedback-state) var(--ease-snap),
    background var(--motion-feedback-state) var(--ease-snap);
  min-height: var(--sp-md);
}

.j-id-tag[data-copied='true'] {
  color: var(--color-success-700);
  background: var(--color-success-100);
}

.j-id-tag:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ── Segmented Control / Toggle Pill ───────────────
   Visual recipe per blueprint/components/14-segmented-control-eng-design.md
   and ADR-029 (layer-aware role tokens) / ADR-033 (compound API).

   Surface derivation — every value is role-token derived. NEVER
   hardcode hex; container scopes (.j-card, .j-modal-sheet, .j-popover,
   .j-menu, adopter panels) re-bind --layer / --on-layer / --layer-elevated
   / --rule-on-layer / --hover-on-layer so the segmented recipe inherits
   the correct surface tone automatically.

     Tray bg                ← --layer (current container surface)
     Selected pill bg       ← --layer-elevated (role-token lift)
     Selected pill rule     ← color-mix(--layer 35%, --on-layer 65%)
                              — strengthened from the eng-design's
                              48/52 candidate to clear the buffered
                              3.5:1 non-text floor in every neutral-
                              layer scope (matrix-test verified). The
                              default --rule-on-layer (20% mix) cannot
                              carry the buffered selected-state floor
                              on its own; the segmented rule uses a
                              stronger custom mix that still flows
                              through --layer / --on-layer so adopter
                              container overrides re-tone the boundary
                              automatically. prefers-contrast: more
                              strengthens it further to --on-layer.
     Hover bg               ← --hover-on-layer (15% mix recipe)
     Active fg              ← --on-layer
     Inactive fg            ← --on-layer (held at full contrast per
                             eng-design §"Visual acceptance criteria" —
                             inactive hierarchy is via the active pill,
                             not by weakening text contrast)

   Private --_seg-* vars stay implementation detail (ADR-033 §4 — adopter
   override is via role tokens, not these private vars). */
.j-segmented {
  display: inline-flex;
  position: relative;
  width: fit-content;
  gap: var(--sp-xs);
  padding: var(--sp-xs);
  /* ADR-042 — finalized segmented recipe (was the #126 prototype).
     Tray paints --layer-recess (one tier BELOW the current --layer)
     instead of --layer; the active pill paints --layer-elevated (one
     tier ABOVE, = --surface-above per ADR-037/#214). The recess→elevated
     surface step is the PRIMARY structural cue between inactive tray and
     active pill. Per-scope recess kept (NOT collapsed to --surface-below
     — ADR-042 §1; --surface-below reads as a heavy block in light / a
     void in dark).

     Belt-and-suspenders: an inset hairline (--_seg-indicator-rule) ALSO
     rides both the tray and the pill, carrying the WCAG 1.4.11 3:1
     boundary contrast that the surface delta alone cannot achieve
     (surface delta tops out at 1.27:1 in light, 1.02:1 in dark). The
     recipe `color-mix(in srgb, var(--on-layer) 75%, var(--layer-recess))`
     is layer-aware: it re-tones automatically when --on-layer /
     --layer-recess override in container scopes, clearing 5.58:1+ in
     light and 8.57:1+ in dark across all 5 layer contexts × 2 themes.
     This is a BESPOKE always-on reinforcement boundary — deliberately
     NOT folded into ADR-041's --edge-cue, whose active default
     (--rule-on-layer, ~1.5:1) is sub-floor here (ADR-042 §3).

     Container overrides set --layer-recess to "one tier below" the
     scope's --layer (the binding rule; post-#195 paint tiers — Card/Panel
     both paint --surface-1 via inherited :root --layer-container after
     the v5.2.1 HOTFIX moved role-token redeclarations to descendant scope):
       :root        color-mix(--surface-0 88%, --on-layer 12%) light
                    color-mix(--surface-0 88%, #000 12%)        dark
                    (--layer = --surface-0)
       .j-card      --surface-1 painted → recess --surface-0
       .j-panel     --surface-1 painted → recess --surface-0
       .j-popover   --surface-2 painted → recess --surface-1
       .j-menu      --surface-2 painted → recess --surface-1
       .j-modal-sheet --surface-1 painted → recess --surface-0

     Hover bg for inactive options is rebound to --layer (one tier
     ABOVE the new tray surface, one tier BELOW the active pill) so
     hover reads as a partial lift toward the active state without
     fully landing on the elevated pill tier. */
  background: var(--layer-recess);
  border-radius: var(--r-pill);
  /* Narrow-container behavior (v5.2.1 hotfix): force single-row layout
     with horizontal scroll + scroll-snap. The browser default for
     flex-wrap is `nowrap`, but adopter parent contexts (white-space,
     constrained columns under 360px) were forcing the tray to wrap.
     When wrap occurred the sliding pill (positioned via
     top: var(--sp-xs); bottom: var(--sp-xs)) stayed pinned to row 1
     while the active button shifted to row 2, producing the reported
     "unfilled active option" visual. Standard platform pattern (iOS /
     Material Android) for narrow Segmented is a single-row scroller —
     adopt it here so the pill measurement stays valid regardless of
     parent constraints. Scrollbar is visually hidden (affordance is
     touch / hover); scroll-snap-type pins options to edges so partial
     options never end up half-occluded.

     `max-width: 100%` is load-bearing: the tray declares `width:
     fit-content` above, so without an inline-size cap it grows to the
     full intrinsic content width and `overflow-x: auto` never engages
     — the parent clips instead and the JS overflow gate
     (scrollWidth > clientWidth) reads false, defeating the fix. The
     cap forces the tray to shrink to the parent's content box, after
     which the children spill into the internal scrollport as
     intended. (Codex review on PR #198 round 1.)

     `box-sizing: border-box` is paired with the cap: the tray
     declares `padding: var(--sp-xs)`, so under default `content-box`
     sizing the actual rendered width is `100% + 2 * --sp-xs` — the
     parent still clips the padding zone and in near-fit cases
     `scrollWidth <= clientWidth` can stay true even though visual
     overflow exists. With `border-box` the cap includes padding so
     the rendered box matches the parent's content box exactly.
     (Codex review on PR #198 round 3.) */
  box-sizing: border-box;
  max-width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/legacy Edge */
  -webkit-overflow-scrolling: touch; /* iOS momentum scroll */
  /* Private vars — derived from role tokens.
     --_seg-indicator-rule: hairline boundary color carried on the tray
     AND the active pill (see .j-segmented::before below). Recipe is
     75% --on-layer over --layer-recess so the rule tones to the
     painted tray surface — re-resolves per container scope via the
     CSS custom-property cascade.
     --_seg-hover-bg: inactive hover lifts to --layer (one tier above
     --layer-recess, one tier below the active pill's --layer-elevated)
     — a partial step toward the active state without erasing the
     active option's neighbour-hover signal. */
  --_seg-indicator-bg: var(--layer-elevated);
  --_seg-indicator-rule: color-mix(in srgb, var(--on-layer) 75%, var(--layer-recess));
  --_seg-active-fg: var(--on-layer);
  --_seg-inactive-fg: var(--on-layer);
  --_seg-hover-bg: var(--layer);
  /* Tray inset hairline — carries the tray-vs-parent 3:1 boundary that
     the surface lift alone cannot deliver (light delta tops out at
     1.27:1; dark at 1.02:1). Cascade-order note: this base shadow
     MUST sit before the forced-colors / prefers-contrast blocks below
     for the overrides to win equal-specificity ties. */
  box-shadow: inset 0 0 0 var(--bw-hairline) var(--_seg-indicator-rule);
}

/* Hide the scrollbar across Chrome / Safari / Chromium Edge. Firefox +
   legacy declarations live on the .j-segmented tray rule above
   (scrollbar-width / -ms-overflow-style). Affordance is hover/touch +
   scroll-snap so the missing visual scrollbar isn't a UX regression
   at narrow widths. */
.j-segmented::-webkit-scrollbar {
  display: none;
}

/* Sliding pill indicator — positioned via --_seg-x / --_seg-w
   custom properties set by SegmentedControl.tsx (or JS in demos). */
.j-segmented::before {
  content: '';
  position: absolute;
  top: var(--sp-xs);
  bottom: var(--sp-xs);
  /* Intentionally physical `left: 0` here. SegmentedControl.measure()
     writes --_seg-x from activeBtn.offsetLeft (a physical-left offset),
     and transform: translateX() moves in physical X. Migrating this
     anchor to inset-inline-start without also making the JS measurement
     RTL-aware would put the pill on the wrong side under dir="rtl".
     The paired RTL fix (sign-flip --_seg-x via `:dir(rtl)` or compute
     in JS) is tracked as a follow-up audit item. */
  left: 0;
  width: var(--_seg-w, 0);
  transform: translateX(var(--_seg-x, 0));
  /* Active pill bg = --layer-elevated via the private --_seg-indicator-bg
     alias. Container scopes (.j-popover, .j-menu, …) route --layer-elevated
     to the --surface-above sentinel (ADR-037/#214) so the lift stays
     perceptible — brighter — on lighter floating surfaces. */
  background: var(--_seg-indicator-bg);
  border-radius: var(--r-pill);
  /* ADR-042 §2 — single-layer box-shadow: the inset hairline ONLY.
     --_seg-indicator-rule carries the pill-vs-tray WCAG 1.4.11 3:1
     boundary (the recess→elevated surface lift alone doesn't clear 3:1
     in any of the 10 layer × theme cells). The prior v5.2.0 --shadow-rest
     drop-shadow second layer was DROPPED here — it was a residual
     elevation cue contrary to ADR-009 (flat/shadowless); separation is
     carried by the surface step + this hairline, not by a drop shadow.
     Cascade-order note: this base shadow MUST sit BEFORE the forced-
     colors / prefers-contrast blocks below for the overrides to win
     equal-specificity ties (docs/forced-colors-cascade-audit-2026-05-
     21.md). */
  box-shadow: inset 0 0 0 var(--bw-hairline) var(--_seg-indicator-rule);
  transition:
    transform var(--motion-feedback-segmented-slide, 150ms) var(--ease-snap),
    width var(--motion-feedback-segmented-slide, 150ms) var(--ease-snap);
  z-index: 0;
  pointer-events: none;
}

/* #136: width="fill" — stretch the tray to the container's inline size and
   distribute options evenly (overrides the default width: fit-content). The
   sliding pill keeps measuring from each option's offsetLeft/offsetWidth, so
   it tracks the flex-distributed widths automatically.
   `flex: 1 0 0` = grow equally, basis 0 (even columns), but shrink 0 — this
   PRESERVES the base .j-segmented-option no-shrink contract, so when option
   content can't fit the container the tray still overflows to its horizontal
   scroller (fill and the narrow-container scroll recipe stay compatible). */
.j-segmented-fill {
  width: 100%;
}
.j-segmented-fill .j-segmented-option {
  flex: 1 0 0;
}

.j-segmented-option {
  position: relative;
  z-index: 1;
  /* Narrow-container behavior (v5.2.1 hotfix): keep intrinsic width
     (no flex-shrink) so options never compress under narrow parents —
     overflow is handled by the tray's horizontal scroll. scroll-snap-
     align: start pairs with the tray's scroll-snap-type: x mandatory
     to pin each option to a scroll position. */
  flex-shrink: 0;
  scroll-snap-align: start;
  font-family: var(--font-body);
  font-size: var(--type-small);
  /* Hold font-weight stable across inactive + active states. Browsers
     don't interpolate weight smoothly, so animating it produces a pop;
     the active pill now earns its emphasis from the surface shift +
     inset rule, not a weight jump. */
  font-weight: 500;
  /* Inactive fg = --on-layer (full contrast). Eng-design §"Visual
     acceptance criteria" — inactive text must clear the text floor
     in every layer/branded matrix. Hierarchy is expressed via the
     active pill (surface lift + rule), NOT by weakening text contrast
     (the previous opacity:0.7 dropped below the buffered floor on
     branded role-token panels where --on-layer is non-neutral). */
  color: var(--_seg-inactive-fg);
  padding: var(--sp-sm) var(--sp-md);
  border: none;
  background: transparent;
  border-radius: var(--r-pill);
  cursor: pointer;
  /* Explicit property list so width / layout never animates. The active
     pill slides in via box-shadow + background crossfade, same duration
     and easing as every other interactive surface. Reduced-motion gate
     below disables transitions entirely. */
  transition:
    background var(--motion-feedback-button-press) var(--ease-snap),
    color var(--motion-feedback-button-press) var(--ease-snap),
    box-shadow var(--motion-feedback-button-press) var(--ease-snap),
    transform var(--motion-feedback-button-press) var(--ease-snap);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  min-height: var(--touch-compact);
}

@media (hover: hover) {
  .j-segmented-option:not([disabled]):not([data-active='true']):hover {
    /* Inactive hover = --hover-on-layer (role-token derived). Active
       option doesn't take hover bg — it already has the pill. */
    background: var(--_seg-hover-bg);
  }
}
.j-segmented-option:not([disabled]):active {
  transform: scale(var(--scale-tapped));
}

.j-segmented-option[data-active='true'] {
  background: transparent;
  /* Active fg = --on-layer via private alias. Active option earns
     emphasis from the pill surface + inset rule, not from a contrast
     delta against inactive (which would erase inactive readability). */
  color: var(--_seg-active-fg);
}

.j-segmented-option:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  box-shadow: none;
}

/* Size: small — compact variant for dense contexts */
.j-segmented-sm {
  padding: var(--r-micro);
  gap: var(--r-micro);
}

/* Re-anchor the sliding pill's vertical inset to match the sm tray's
   --r-micro (2px) padding. The base .j-segmented::before rule uses
   --sp-xs (4px) for top/bottom — correct for the default md tray
   (which also uses --sp-xs padding) but stale for sm. Without this
   override, the active pill on .j-segmented-sm shows ~2px of tray
   visible above and below the pill but flush left/right (where the
   pill width is JS-measured to the option's exact bounds). Adopters
   reported the visible asymmetry on the Cabinet canvas picker
   filters + Settings visibility row (2026-05-20). */
.j-segmented-sm::before {
  top: var(--r-micro);
  bottom: var(--r-micro);
}

.j-segmented-sm .j-segmented-option {
  font-size: var(--type-caption);
  padding: var(--sp-xs) var(--sp-sm-p);
  min-height: var(--sp-lg);
}

/* Disabled */
.j-segmented[aria-disabled='true'] {
  opacity: var(--op-dimmed);
  pointer-events: none;
}

/* Per-option disabled — visible muting without affecting other items.
   Compound-API per-item disabled flows via the `disabled` attribute on
   the underlying <button>; this rule mutes the visual without dimming
   the whole group. */
.j-segmented-option[disabled] {
  opacity: var(--op-dimmed);
  cursor: not-allowed;
}

/* Reduced motion — disable the sliding-pill transitions when the user
   prefers reduced motion. Source order: AFTER the base rule so the
   override wins equal-specificity ties (forced-colors-cascade-audit
   2026-05-21 convention). */
@media (prefers-reduced-motion: reduce) {
  .j-segmented::before,
  .j-segmented-option {
    transition: none;
  }
  .j-segmented-option:not([disabled]):active {
    transform: none;
  }
}

/* Segmented control — forced-colors (Windows High Contrast).
   Co-located with the base .j-segmented rules (above) so that source
   order resolves the cascade correctly. The general forced-colors
   block earlier in the file (around line 327) targets buttons,
   switches, checkboxes, etc., all of which have their base rules
   declared BEFORE that block. Segmented's base rule lives here,
   AFTER the general block — so equal-specificity ties (e.g. the
   base `.j-segmented::before` against the forced-colors recipe)
   were being won by the LATER base rule, defeating high-contrast
   customization. Splitting the segmented rules out of the general
   block and placing them here ensures the forced-colors recipe
   wins under (forced-colors: active). Pre-existing bug surfaced
   during PR #147 round-2 review; tracked separately for switch /
   modal-sheet / fab / toggle which share the same ordering quirk.
   The .j-segmented-sm variant inherits these styles via the
   .j-segmented::before selector — the sm override only re-anchors
   top/bottom inset, no color properties, so no sm-specific entry
   is needed here.

   Engineering-design §"Forced colors" — focus outline uses ButtonText
   (NOT Highlight) so the ring stays visible when focus lands on the
   active option (whose fill is Highlight). outline-offset: 2px places
   the ring on the Canvas/tray edge, not inside the Highlight fill. */
@media (forced-colors: active) {
  .j-segmented {
    background: Canvas;
    border: 1px solid ButtonBorder;
  }
  .j-segmented::before {
    background: Highlight;
    border: 1px solid ButtonText;
    box-shadow: none;
    forced-color-adjust: none;
  }
  .j-segmented-option {
    color: ButtonText;
  }
  .j-segmented-option[data-active='true'] {
    color: HighlightText;
  }
  .j-segmented-option:focus-visible {
    outline-color: ButtonText;
    outline-offset: 2px;
  }
}

/* Segmented control — prefers-contrast: more (high-contrast escalation).
   Co-located with the base .j-segmented rules (above) so that source
   order resolves the cascade correctly. The general prefers-contrast
   block earlier in the file (around line 516) targets segmented + toggle
   together, but segmented's base rule lives here, AFTER that block —
   so equal-specificity ties (the base `.j-segmented::before` against
   the high-contrast border recipe) were being won by the LATER base
   rule, defeating the visible pill boundary that high-contrast users
   need. Splitting the segmented rule out of the general block and
   placing it here ensures the prefers-contrast recipe wins under
   (prefers-contrast: more). Sibling fix to PR #161 (forced-colors
   cascade-order); same surgical extraction pattern, different media
   query. Other components in the original general block (.j-toggle,
   .j-toggle-pressed, .j-toggle-group variants) share the same source
   order quirk and are tracked separately under the systemic audit
   (task #72). The .j-segmented-sm variant inherits this style via the
   .j-segmented::before selector — the sm override only re-anchors
   top/bottom inset, no border/shadow properties, so no sm-specific
   entry is needed here.

   Eng-design §"Candidate CSS contract" — strengthens the same private
   --_seg-indicator-rule var to --on-layer rather than hardcoding a
   neutral, so branded role-token panels still get a buffered boundary. */
@media (prefers-contrast: more) {
  .j-segmented {
    --_seg-indicator-rule: var(--on-layer);
    /* Thicker tray hairline mirrors the pill's prefers-contrast bump
       below — both edges escalate to --bw-standard so the tray-vs-parent
       and pill-vs-tray boundaries survive high-contrast audits. */
    box-shadow: inset 0 0 0 var(--bw-standard) var(--_seg-indicator-rule);
  }
  .j-segmented::before {
    box-shadow: inset 0 0 0 var(--bw-standard) var(--_seg-indicator-rule);
  }
}

/* ── FilterButton + FilterGroup (chip-tier filter trigger) ──
   Spec: blueprint/components/66-filter-button.md
   ADR: blueprint/governance/adrs/ADR-030-filter-button-primitive.md

   Locked decisions honored here:
     - Shape: --r-button (14px) — NOT --r-pill (PR #143 / ADR-030)
     - APG pattern: Disclosure (button + popover)
     - State buckets: rest = surface ELEVATE; applied = theme TINT
     - Open-state border bucket loyalty (rest → --on-layer-2; applied
       → --color-theme-500). Border weight ramps 1px → 2px in both
       open variants; this is the orthogonal "owns the popover"
       signal that survives forced-colors palette swap.
     - No box-shadow on the trigger (shadow tokens are reserved for
       floating surfaces — Popover, Menu, FAB; see spec §12 do/don't).
     - Clear (✕) is a sibling <button>, NOT nested (HTML §4.10.6
       forbids interactive-in-interactive). Positioned via
       inset-inline-end (RTL-safe).
     - Chevron rotation 180° via [data-popover-open='true']; the
       kit's global reduced-motion block at line ~4360 floors the
       transition-duration at --motion-feedback-button-press (60ms)
       via its (0,0,0)-specificity :where() catch-all. The chevron
       is intentionally NOT in the transform-none selector list at
       lines ~4397-4411 (rotation persists under RM, just at press
       speed — state legibility guard per A4 amendment). */

.j-filter-btn-shell {
  /* Unconditional inline shell (rendered in rest AND applied states)
     so DOM identity is stable across applied transitions and the
     parent FilterGroup flex row does not jitter as Clear comes/goes.
     <span> (inline) not <div> (block) — no block-reflow boundary.

     Clear sits on the trailing edge of the trigger via a negative
     `margin-inline-start` on the flex sibling (NOT absolute
     positioning) — see `.j-filter-btn-clear` below. The shell stays
     a plain `inline-flex` container; no `position: relative` because
     no descendant is absolutely positioned. */
  display: inline-flex;
  align-items: center;
}

.j-filter-btn {
  /* Reset UA button chrome — visuals come from rules below. */
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  font-family: var(--font-body);
  font-size: var(--type-small);
  font-weight: 500;
  color: var(--on-layer);
  background: transparent;
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-button);
  /* logical-property padding for RTL safety */
  padding: var(--sp-xs) var(--sp-sm-p);
  min-height: var(--touch-compact);
  /* Single-char labels still breathe (spec §2). */
  min-width: 6ch;
  cursor: pointer;
  user-select: none;
  transition:
    background var(--motion-feedback-button-press) var(--ease-snap),
    border-color var(--motion-feedback-state) var(--ease-snap),
    color var(--motion-feedback-state) var(--ease-snap),
    transform var(--motion-feedback-button-press) var(--ease-snap);
}

@media (hover: hover) {
  .j-filter-btn:hover:not(:disabled) {
    /* Rest hover = surface-tier ELEVATE (PR #143). */
    background: var(--layer-elevated);
  }
}

.j-filter-btn:not(:disabled):active {
  transform: scale(var(--scale-tapped));
}

.j-filter-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Rest, popover OPEN — bucket-loyal (surface bucket). */
.j-filter-btn[data-popover-open='true']:not([data-applied='true']) {
  background: var(--layer-elevated);
  border-color: var(--on-layer-2);
  border-width: var(--bw-standard);
  /* Compensate the layout for the 1px → 2px border bump so the chip's
     min-height (and surrounding flex row) does not jitter. The border-
     box model would handle this but we keep the default content-box
     ergonomics by trimming the inline padding by 1px (it reads as
     2px → 1px slot offset against the 1px border-weight delta). */
  padding-inline: calc(var(--sp-sm-p) - 1px);
}

/* Applied (closed). bucket-loyal (theme bucket). */
.j-filter-btn[data-applied='true'] {
  background: var(--color-theme-100);
  /* Derived applied-closed border (no --color-theme-300 token exists
     in src/css/tokens.css; the kit's theme series ships -100/-500/
     -700 only). 60/40 mix lands visually between the bg tint and
     the saturated open border. See spec §4 derivation note. */
  border-color: color-mix(in srgb, var(--color-theme-100) 60%, var(--color-theme-500) 40%);
}

.j-filter-btn[data-applied='true'] .j-filter-btn-value {
  color: var(--color-theme-700);
}

@media (hover: hover) {
  .j-filter-btn[data-applied='true']:hover:not(:disabled) {
    /* Hover-applied bg uses a 70/30 mix (skewing toward -100) — see
       spec §4 "Hover-applied background" rationale; 60/40 would
       approach the open-state border ramp and blur the hover/open
       distinction. */
    background: color-mix(in srgb, var(--color-theme-100) 70%, var(--color-theme-500) 30%);
    border-color: var(--color-theme-500);
  }
}

/* Applied, popover OPEN — theme bucket. */
.j-filter-btn[data-applied='true'][data-popover-open='true'] {
  border-color: var(--color-theme-500);
  border-width: var(--bw-standard);
  padding-inline: calc(var(--sp-sm-p) - 1px);
}

/* Disabled */
.j-filter-btn:disabled {
  pointer-events: none;
  cursor: not-allowed;
}

.j-filter-btn:disabled:not([data-applied='true']) {
  background: var(--field-bg-disabled);
}

/* Disabled content dim — applies to all slots (label, value, icon,
   chevron). Applied + disabled keeps the theme-100 tint bg so the
   chip still reads as "filter has a value" while frozen. */
.j-filter-btn:disabled .j-filter-btn-label,
.j-filter-btn:disabled .j-filter-btn-value,
.j-filter-btn:disabled .j-filter-btn-icon,
.j-filter-btn:disabled .j-filter-btn-chevron,
.j-filter-btn:disabled .j-filter-btn-sep {
  opacity: var(--op-dimmed);
}

/* Slot inventory ─────────────────────────────────── */

.j-filter-btn-label {
  /* Truncate at 24ch (longer labels should use <Select> field-style;
     see spec §2 + dev-warn 'jkit.filter-button.label-overflow'). */
  display: inline-block;
  max-width: 24ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.j-filter-btn-value {
  /* CSS-based inline-value truncation (no JS measurement). Boundary:
     length > 16 triggers ellipsis; length === 16 renders in full. */
  display: inline-block;
  max-width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  /* Stop chip width jitter on count changes (e.g. "(9)" → "(10)"). */
  font-variant-numeric: tabular-nums;
}

.j-filter-btn-count {
  /* Count badge inherits tabular-nums from .j-filter-btn-value above. */
  font-variant-numeric: tabular-nums;
}

.j-filter-btn-sep {
  /* Separator between label and value. The literal ":" + NBSP is in
     the React tree; no CSS content needed. */
  white-space: nowrap;
}

.j-filter-btn-icon {
  display: inline-flex;
  align-items: center;
  color: var(--on-layer-2);
  flex-shrink: 0;
}

.j-filter-btn-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--on-layer-2);
  flex-shrink: 0;
  /* Static rotation transform — toggled below via the data attribute.
     transition-duration collapses to 60ms under prefers-reduced-motion
     via the kit's global :where() catch-all at ~kit.css:4360. The
     transform-none selector list at ~kit.css:4397-4411 intentionally
     EXCLUDES .j-filter-btn-chevron (state-legibility guard per A4
     amendment) — rotation persists under RM, just at press speed. */
  transition: transform var(--motion-feedback-state) var(--ease-snap);
}

.j-filter-btn[data-popover-open='true']:not(:disabled) .j-filter-btn-chevron {
  transform: rotate(180deg);
}

/* ── Size: sm ─────────────────────────────────────── */
.j-filter-btn-sm {
  font-size: var(--type-caption);
  padding: var(--sp-xs) var(--sp-sm);
  border-radius: var(--r-control);
}

.j-filter-btn-sm[data-popover-open='true'] {
  padding-inline: calc(var(--sp-sm) - 1px);
}

/* ── Clear (✕) sibling ───────────────────────────── */
.j-filter-btn-clear {
  /* Reset UA chrome. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--on-layer-2);
  /* Tap-target floor (WCAG 2.5.8 AA = 24×24 minimum). Icon stays
     12×12; the rest is invisible hit area. */
  inline-size: 24px;
  block-size: 24px;
  border-radius: var(--r-tiny);
  /* RTL-safe positioning via flex-sibling negative margin (NOT
     absolute positioning — keeps the shell free of `position:
     relative` and avoids a stacking-context that would interact
     badly with the parent FilterGroup's overflow-x scroll mode).
     `margin-inline-start: -sp-xs` pulls the Clear button left by
     ~4px so it sits on the trailing edge of the trigger, visually
     paired without crowding the trigger's chevron. The logical
     property flips to `margin-inline-end` in RTL. */
  margin-inline-start: calc(-1 * var(--sp-xs));
  transition:
    background var(--motion-feedback-button-press) var(--ease-snap),
    color var(--motion-feedback-state) var(--ease-snap);
}

@media (hover: hover) {
  .j-filter-btn-clear:hover {
    color: var(--color-error-700);
    background: var(--layer-elevated);
  }
}

.j-filter-btn-clear:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Coarse-pointer escalation: tap floor → 44×44 around a 16×16 icon. */
@media (pointer: coarse) {
  .j-filter-btn,
  .j-filter-btn-sm {
    min-height: var(--touch-min);
  }
  .j-filter-btn-clear {
    inline-size: var(--touch-min);
    block-size: var(--touch-min);
  }
  .j-filter-btn-clear svg {
    inline-size: 16px;
    block-size: 16px;
  }
}

/* ── FilterGroup ────────────────────────────────── */
.j-filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-sm);
}

.j-filter-group-scroll-x {
  flex-wrap: nowrap;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  /* Allow children to participate in scroll-snap. */
  scroll-padding-inline: var(--sp-sm);
}

.j-filter-group-scroll-x > .j-filter-btn-shell {
  scroll-snap-align: start;
  flex-shrink: 0;
}

.j-filter-group-summary {
  font-size: var(--type-caption);
  color: var(--on-layer-2);
}

.j-filter-group-clear-all {
  margin-inline-start: auto;
}

/* ── Forced-colors (system high-contrast palette) ──
   Spec §7 forced-colors block. The shape token degrades gracefully
   (border-radius: 0) so user agents can render the chip in the
   chosen high-contrast palette. Border weight ramp (1px → 2px) on
   data-popover-open remains the orthogonal "owns the popover"
   signal that survives the palette swap. */
@media (forced-colors: active) {
  .j-filter-btn {
    background-color: ButtonFace;
    color: ButtonText;
    border: 1px solid ButtonBorder;
    border-radius: 0;
  }
  .j-filter-btn[data-applied='true'] {
    background-color: Highlight;
    color: HighlightText;
    border-color: ButtonBorder;
  }
  .j-filter-btn[data-popover-open='true'] {
    border-width: 2px;
  }
  .j-filter-btn-label,
  .j-filter-btn-value,
  .j-filter-btn-sep {
    color: inherit;
  }
  .j-filter-btn-icon,
  .j-filter-btn-chevron,
  .j-filter-btn-clear svg {
    color: CanvasText;
  }
}

/* ── Search input (preset) ───────────────────────── */
.j-search {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  /* Field-adjacent — routes through --field-bg so a Search inside a
     Popover (e.g. filter search header) re-tones to surface-1 instead
     of staying at the page surface. ADR-029 v5.1 amendment. */
  background: var(--field-bg);
  border: var(--bw-standard) solid var(--rule-on-layer);
  border-radius: var(--r-control);
  padding: var(--sp-xs) var(--sp-sm-p);
  min-height: var(--touch-min);
  width: 100%;
  transition: border-color var(--motion-feedback-state) var(--ease-snap);
}

.j-search:focus-within {
  border-color: var(--color-neutral-900);
}
.j-search:focus-within:has(:focus-visible) {
  box-shadow: var(--focus-ring);
}
.j-search > svg {
  color: var(--fg-2);
  flex-shrink: 0;
}
.j-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--type-small);
  color: var(--fg-1);
}
.j-search input[type='search']::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* ── Skeleton (6.4) ────────────────────────────────
   Content-shape loading placeholder. Block element with a subtle
   shimmer animation that mirrors the content shape. */
.j-skeleton {
  display: block;
  /* ADR-029 cascade-relative paint: read --layer-elevated so the
     placeholder lifts one tier above the current container's --layer,
     regardless of nesting. Previously hardcoded var(--surface-2),
     which painted the absolute lightest surface tier unconditionally —
     inside a Modal sheet (which already paints surface-1 and lifts
     descendant --layer-elevated to var(--surface-above) per ADR-037) the skeleton
     read as flat / near-invisible because it kept the absolute tier
     while the surrounding layer rebound. Skeleton is NOT a container
     primitive (per ADR-029 §B + §C, only Card / Panel / Modal sheet
     are raised containers and Popover / Menu / Tooltip are floating
     containers); it is an "in-layer raised affordance," which is the
     exact use case --layer-elevated was introduced for in the v5.1
     amendment. See ADR-029 §"Container nesting contract" for the
     surface-tier / floating-tier classification. */
  background: var(--layer-elevated);
  background-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  background-position: -100% 0;
  border-radius: var(--r-tiny);
  animation: j-skeleton-shimmer 1.5s ease-in-out infinite;
}

@keyframes j-skeleton-shimmer {
  to {
    background-position: 200% 0;
  }
}

.j-skeleton-rect {
  /* default rect shape uses adopter width/height inline */
}

.j-skeleton-text {
  block-size: 1em;
  border-radius: var(--r-pill);
  display: inline-block;
  inline-size: 100%;
}

.j-skeleton-circle {
  border-radius: 50%;
}

.j-skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
}

@media (prefers-reduced-motion: reduce) {
  .j-skeleton {
    /* Stop the shimmer under reduced-motion. Skeleton placeholders
       aren't time-critical (the gray base + shape still indicates
       loading); static-only is appropriate. !important to defeat
       the kit's global [class^='j-'] reduced-motion catch-all. */
    animation: none !important;
  }
}

/* ── Spinner (6.5) ──────────────────────────────────
   Indeterminate loading indicator. The SVG ships with a partial-ring
   stroke-dasharray (rendered by src/kit/primitives/Spinner.tsx); this
   rule rotates the WHOLE SVG so the arc appears to spin. Reviewer
   note: codex adversarial review 2026-05-19 caught that this rule was
   missing in main — the primitive was rendering a static partial ring
   despite the Spinner.tsx comment claiming the CSS animates it. */
.j-spinner {
  animation: j-spinner-rotate 0.75s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes j-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .j-spinner {
    /* Honor reduced-motion BUT keep the spinner indicating active
       loading. The kit's global [class^='j-'] reduced-motion rule
       would collapse animation-duration + iteration-count with
       !important — a spinner that runs ONCE and then freezes loses
       the in-progress signal that's Spinner's whole reason to exist.
       Override with !important to keep continuous rotation at a
       slower 3 s cadence: still perceptibly indicating loading, not
       a vestibular trigger. Matches the contract documented in
       Spinner.tsx and the v5 changelog. */
    animation-duration: 3s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ── Toast ────────────────────────────────────────── */
.j-toast {
  position: fixed;
  /* `left: 50%; transform: translateX(-50%)` is the standard centering
     trick. Kept physical because (a) there is no `inset-inline-start: 50%`
     equivalent that pairs cleanly with `translateX(-50%)`, and (b) the
     centering is direction-agnostic — the toast appears centered in both
     LTR and RTL viewports without flipping. Logical-property lint rules
     should allow this idiom. */
  left: 50%;
  bottom: var(--sp-xl);
  transform: translateX(-50%);
  z-index: 300;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  background: var(--color-neutral-900);
  color: var(--color-neutral-100);
  font-family: var(--font-body);
  font-size: var(--type-small);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r-control);
  box-shadow: var(--shadow-floating);
  animation: j-toast-enter var(--motion-transition-toast-enter) var(--ease-snap);
}

@keyframes j-toast-enter {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(calc(-1 * var(--sp-xs))) scale(var(--scale-tapped));
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.j-toast-dot {
  width: var(--sp-xs);
  height: var(--sp-xs);
  border-radius: var(--r-pill);
  background: var(--color-success-500);
}

.j-toast[data-tone='danger'] .j-toast-dot {
  background: var(--color-error-500);
}
.j-toast[data-tone='warning'] .j-toast-dot {
  background: var(--color-warning-500);
}

/* ── Accordion / Collapsible ──────────────────────── */
.j-accordion-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  background: transparent;
  border: none;
  color: var(--fg-3);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--type-micro);
  letter-spacing: var(--track-label-loose);
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
}

.j-accordion-chevron {
  transition: transform var(--motion-feedback-state) var(--ease-snap);
}

.j-accordion-trigger[data-open='true'] > .j-accordion-chevron,
.j-accordion-trigger[aria-expanded='true'] > .j-accordion-chevron {
  transform: rotate(90deg);
}

.j-accordion-trigger:focus-visible {
  outline: none;
  border-radius: var(--r-tiny);
  box-shadow: var(--focus-ring);
}

/* ── Collapsible (ADR-034) ────────────────────────────
   Content-side partner to .j-accordion-trigger. Animates
   between collapsed (0fr) and expanded (1fr) grid rows so
   the panel grows to its natural content height without a
   JS measurement step. The inner element owns overflow
   clipping; the outer owns the interpolation.

   --dur-quick (150ms) matches the chevron rotation on
   .j-accordion-trigger so the trigger and the content
   land at the same beat. --ease-decelerate is the kit's
   "settling into rest" curve (token comment in tokens.css:178),
   appropriate for content arriving into view.

   Browser support note: `grid-template-rows` is an animatable
   property in all evergreen browsers shipped after Chrome 107
   (Nov 2022) / Firefox 119 (Oct 2023) / Safari 17 (Sep 2023).
   Older browsers fall back to an instant snap between the
   collapsed and expanded states with no other rendering
   regression — the panel still reveals correctly. */
.j-collapsible {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-quick) var(--ease-decelerate);
}

.j-collapsible[data-state='open'] {
  grid-template-rows: 1fr;
}

.j-collapsible__inner {
  min-height: 0;
  overflow: hidden;
}

/* `prefers-reduced-motion: reduce` — collapse the row-height
   interpolation to a 0ms step. The grid-template-rows still
   flips between 0fr and 1fr instantly so the panel reveals
   without animation. Same recipe other primitives use under
   reduced motion (e.g., Toast, Modal). */
@media (prefers-reduced-motion: reduce) {
  .j-collapsible {
    transition-duration: 0ms;
  }
}

/* Windows High Contrast — no boundary chrome at the
   Collapsible layer (the content inside owns its own
   high-contrast affordances). Declared AFTER the base
   rule per the cascade-order audit at
   docs/forced-colors-cascade-audit-2026-05-21.md so the
   base transition declaration can't clobber any future
   high-contrast override. The empty block documents
   intent — there's no override today, but the source-
   order discipline is locked in for forward audits. */
@media (forced-colors: active) {
  .j-collapsible {
    /* No high-contrast override at the wrapper level today.
       Descendants paint their own forced-colors story. */
  }
}

/* ── Form grid utilities (responsive) ─────────────── */
.j-form-grid {
  display: grid;
  gap: var(--sp-sm-p);
}
.j-form-grid-2 {
  display: grid;
  gap: var(--sp-sm-p);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.j-form-grid-3 {
  display: grid;
  gap: var(--sp-sm-p);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.j-form-grid-4 {
  display: grid;
  gap: var(--sp-sm-p);
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Mobile breakpoint — below bp.md (768px) per ADR-011.
   v4 used 820px; migrated to 767px (= not matching min-width: 768px).
   Source of truth: tokens/reference/dimension.json#bp.md.
   PostCSS @custom-media will eventually replace this literal. */
@media (max-width: 767px) {
  .j-form-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .j-form-grid-2,
  .j-form-grid-3,
  .j-form-grid {
    grid-template-columns: 1fr;
  }
  /* Mobile breakpoint — below bp.md (768px) per ADR-011.
     Bottom-sheet form for modals without an explicit width.
     Dialogs with a width prop (e.g. confirmDialog at 440px) keep their
     centered floating style on mobile. */
  .j-modal-overlay:has(> .j-modal-sheet:not([style*='max-width'])) {
    padding: 0;
    align-items: flex-end;
  }
  .j-modal-sheet:not([style*='max-width']) {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    max-height: 85dvh;
    border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    animation: j-slide-up var(--motion-transition-sheet-present) var(--ease-snap);
  }
  /* Drag handle visible on ALL mobile modals (not just full-width ones).
     Width-constrained modals still get the handle for drag-to-dismiss. */
  .j-modal-drag-handle {
    display: flex;
    justify-content: center;
    padding: var(--sp-sm) 0 var(--sp-xs);
    cursor: grab;
    touch-action: none;
    flex-shrink: 0;
  }
  .j-modal-drag-handle:active {
    cursor: grabbing;
  }
  .j-modal-sheet:not([style*='max-width']) .j-modal-header {
    padding: var(--sp-sm) var(--sp-md) var(--sp-sm);
  }
  .j-modal-sheet:not([style*='max-width']) .j-modal-body {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

/* ── Switch ──────────────────────────────────────── */
.j-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--type-small);
  color: var(--fg-1);
  user-select: none;
}

.j-switch[data-disabled='true'] {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
  pointer-events: none;
}

.j-switch-track {
  position: relative;
  width: var(--switch-track-w);
  height: var(--switch-track-h);
  border-radius: var(--r-pill);
  /* Uses --color-rule, not --color-neutral-300 — post-elevation-flip,
     neutral-300 IS --surface-0, so an unchecked switch on the page
     blended into the background (codex audit #107). */
  background: var(--color-rule);
  border: none;
  flex-shrink: 0;
  transition: background var(--motion-feedback-switch-flip) var(--ease-snap);
}

.j-switch[data-checked='true'] .j-switch-track {
  background: var(--color-theme-500);
}

.j-switch-error[data-checked='true'] .j-switch-track {
  background: var(--color-error-500);
}
.j-switch-warning[data-checked='true'] .j-switch-track {
  background: var(--color-warning-500);
}
.j-switch-info[data-checked='true'] .j-switch-track {
  background: var(--color-info-500);
}
.j-switch-success[data-checked='true'] .j-switch-track {
  background: var(--color-success-500);
}

.j-switch-thumb {
  position: absolute;
  top: calc((var(--switch-track-h) - var(--switch-thumb)) / 2);
  /* Intentionally physical `left:` here. The [data-checked='true']
     rule below uses `translateX(...)` to slide the thumb to the on
     position. Migrating the rest anchor to inset-inline-start without
     also flipping the translateX sign would push the thumb off the
     track in RTL. Paired RTL fix tracked as audit follow-up. */
  left: calc((var(--switch-track-h) - var(--switch-thumb)) / 2);
  width: var(--switch-thumb);
  height: var(--switch-thumb);
  border-radius: var(--r-pill);
  background: var(--color-neutral-100);
  box-shadow: var(--shadow-thumb);
  transition: transform var(--motion-feedback-switch-flip) var(--ease-snap);
}

.j-switch[data-checked='true'] .j-switch-thumb {
  transform: translateX(calc(var(--switch-track-w) - var(--switch-track-h)));
}

.j-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.j-switch input:focus-visible ~ .j-switch-track {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  box-shadow: none;
}

/* Size: small — for dense contexts alongside compact controls.
   Must appear AFTER default thumb rules to override sizing.
   Track 36×20 and thumb 16 are switch-specific geometry with no
   matching spacing token. Inset uses --r-micro (2px). */
.j-switch-sm .j-switch-track {
  width: 36px;
  height: 20px;
}
.j-switch-sm .j-switch-thumb {
  width: var(--sp-md);
  height: var(--sp-md);
  top: var(--r-micro);
  /* Physical `left:` — see .j-switch-thumb above for rationale. */
  left: var(--r-micro);
}
.j-switch-sm[data-checked='true'] .j-switch-thumb {
  transform: translateX(var(--sp-md));
}
.j-switch-sm .j-switch-label {
  font-size: var(--type-caption);
}

/* Switch — forced-colors (Windows High Contrast).
   Co-located with the base .j-switch-track / .j-switch-thumb rules
   (above) so that source order resolves the cascade correctly. The
   centralized `@media (forced-colors: active)` block earlier in the
   file declared these HC rules BEFORE the base — equal-specificity
   ties + later source wins meant:
     - the base `.j-switch-track { border: none }` clobbered the HC
       `border: 2px solid ButtonBorder`,
     - the base `.j-switch[data-checked='true'] .j-switch-track
       { background: var(--color-theme-500) }` clobbered the HC
       `background + border-color: Highlight`, and
     - the base `.j-switch-thumb { background: var(--color-neutral-100) }`
       clobbered the HC `background: ButtonText`.
   So the on/off identity of a Switch dissolved entirely under Windows
   HC. PR-A 2026-05-21 (sibling to PR #161). The
   `.j-switch[data-checked='true'] .j-switch-thumb` Med-severity entry
   stays in the centralized block pending PR-B. */
@media (forced-colors: active) {
  .j-switch-track {
    border: 2px solid ButtonBorder;
  }
  .j-switch[data-checked='true'] .j-switch-track {
    background: Highlight;
    border-color: Highlight;
  }
  .j-switch-thumb {
    background: ButtonText;
  }
}

/* ── Panel (tinted container) ────────────────────── */
.j-panel {
  /* v5.2.1 HOTFIX (2026-05-22) — role-token redeclarations live on
     `.j-panel > *` below, NOT on `.j-panel`. Same same-element CSS
     custom-property self-application trap as the v5.2.0 Card bug.
     Panel itself reads inherited :root --layer-container = surface-1
     for its paint; descendants see Panel-scope values via `.j-panel > *`. */
  /* Stash the actual painted surface for descendants — same pattern as
     .j-card. Codex review r1 P2. */
  --_layer-painted: var(--layer-container);
  background-color: var(--_layer-painted);
  border-radius: var(--r-card);
  padding: var(--sp-lg);
}

.j-panel > * {
  /* Panel-scope role tokens for descendants. Same recipe set as
     `.j-card > *` above — see that rule for per-line rationale,
     including the post-codex-r3 design re-eval (2026-05-22)
     non-redeclaration of `--on-layer` / `--on-layer-2` so adopter
     overrides on `.j-panel` propagate to descendants via inheritance
     rather than being shadowed by a redundant redeclaration here.
     See ADR-029 §B.bis. */
  --layer: var(--_layer-painted);
  --layer-container: var(--surface-2);
  --layer-elevated: var(--surface-above);
  /* ADR-042 (finalized; was the #126 prototype). Post-#195 Panel paints
     --surface-1 (same paint tier as Card after the v5.2.1 HOTFIX moved
     role-token redeclarations to the descendant scope), so the "one
     tier below painted surface" binding rule places --layer-recess at
     --surface-0 (page ground). NOTE: prior to #195, Panel painted
     --surface-2 directly via the same-element redeclaration, and the
     round-1 codex blocker-1 fix bound Panel recess to --surface-1. The
     post-#195 paint tier resolves to --surface-1, so recess drops to
     --surface-0 to keep the "one tier below" contract. See rebase note
     in PR #199. */
  --layer-recess: var(--surface-0);
  --rule-on-layer: color-mix(in srgb, var(--layer) 80%, var(--on-layer) 20%);
  --field-bg: var(--surface-0);
  --field-bg-disabled: color-mix(in srgb, var(--field-bg) 88%, var(--on-layer) 12%);
}

.j-panel-header {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--type-small);
  color: var(--fg-1);
  margin-bottom: var(--sp-md);
  letter-spacing: var(--track-compact);
}

.j-panel-theme {
  background: var(--color-theme-100);
}
.j-panel-theme > .j-panel-header {
  color: var(--color-theme-700);
}
.j-panel-error {
  background: var(--color-error-100);
}
.j-panel-error > .j-panel-header {
  color: var(--color-error-700);
}
.j-panel-warning {
  background: var(--color-warning-100);
}
.j-panel-warning > .j-panel-header {
  color: var(--color-warning-700);
}
.j-panel-info {
  background: var(--color-info-100);
}
.j-panel-info > .j-panel-header {
  color: var(--color-info-700);
}
.j-panel-success {
  background: var(--color-success-100);
}
.j-panel-success > .j-panel-header {
  color: var(--color-success-700);
}
.j-panel-neutral {
  background: var(--color-neutral-200);
}
.j-panel-neutral > .j-panel-header {
  color: var(--fg-2);
}

/* ── Ledger Row ──────────────────────────────────── */
.j-ledger-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-md);
  padding: var(--sp-sm) 0;
  font-family: var(--font-body);
  font-size: var(--type-small);
  color: var(--fg-1);
  line-height: var(--lh-field);
}

.j-ledger-row-label {
  flex-shrink: 0;
  color: var(--fg-2);
}

.j-ledger-row-value {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
  text-align: end;
  color: var(--fg-1);
  min-width: 0;
}

.j-ledger-row-bold .j-ledger-row-label {
  font-weight: 600;
  color: var(--fg-1);
}
.j-ledger-row-bold .j-ledger-row-value {
  font-weight: 700;
}

.j-ledger-row-muted {
  color: var(--fg-3);
}
.j-ledger-row-muted .j-ledger-row-label {
  color: var(--fg-3);
}
.j-ledger-row-muted .j-ledger-row-value {
  color: var(--fg-3);
}

.j-ledger-row-highlight {
  background: var(--color-theme-100);
  padding: var(--sp-sm) var(--sp-md);
  margin-inline-start: calc(-1 * var(--sp-md));
  margin-inline-end: calc(-1 * var(--sp-md));
  border-radius: var(--r-compact);
}

.j-ledger-row-indent {
  padding-inline-start: var(--sp-lg);
}

.j-ledger-row-divider {
  border-top: var(--bw-hairline) solid var(--rule-on-layer);
  margin-top: var(--sp-xs);
  padding-top: var(--sp-sm-p);
}

/* ── Metric Display ──────────────────────────────── */
.j-metric {
  font-feature-settings: 'tnum' 1;
  line-height: var(--lh-tight);
  color: var(--fg-1);
}

.j-metric-short {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(var(--type-heading), 3vw, var(--type-title));
  letter-spacing: var(--track-display);
}

.j-metric-medium {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(var(--type-compact), 2.5vw, var(--type-title));
  letter-spacing: var(--track-heading);
}

.j-metric-long {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(var(--type-body), 2vw, var(--type-heading));
  letter-spacing: var(--track-compact);
}

.j-metric-sm.j-metric-short {
  font-size: clamp(var(--type-compact-body), 2.5vw, var(--type-heading));
}
.j-metric-sm.j-metric-medium {
  font-size: clamp(var(--type-small), 2vw, var(--type-compact));
}
.j-metric-sm.j-metric-long {
  font-size: clamp(var(--type-caption), 1.5vw, var(--type-body));
}

.j-metric-theme {
  color: var(--color-theme-700);
}
.j-metric-error {
  color: var(--color-error-700);
}
.j-metric-warning {
  color: var(--color-warning-700);
}
.j-metric-info {
  color: var(--color-info-700);
}
.j-metric-success {
  color: var(--color-success-700);
}

/* ── Inline Edit ─────────────────────────────────── */
.j-inline-edit {
  display: inline-flex;
  align-items: center;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  min-width: var(--sp-2xl);
  position: relative;
}

.j-inline-edit-display {
  cursor: text;
  padding: var(--sp-xs) var(--sp-xs);
  border-radius: var(--r-tiny);
  border: var(--bw-hairline) solid transparent;
  transition:
    background var(--motion-feedback-state) var(--ease-snap),
    border-color var(--motion-feedback-state) var(--ease-snap);
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  background: transparent;
  text-align: inherit;
}

@media (hover: hover) {
  .j-inline-edit-display:hover:not(:disabled) {
    background: var(--color-neutral-200);
    border-color: var(--rule-on-layer);
  }
}

.j-inline-edit-display:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.j-inline-edit-input {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  /* Field-adjacent — routes through --field-bg per ADR-029 v5.1
     amendment. Border stays on raw neutral-950 (high-contrast active
     editing affordance — intentional, doesn't route through layer
     tokens). */
  background: var(--field-bg);
  border: var(--bw-standard) solid var(--color-neutral-900);
  border-radius: var(--r-tiny);
  padding: var(--sp-xs) var(--sp-xs);
  outline: none;
  width: 100%;
  min-width: var(--sp-2xl);
  box-shadow: var(--focus-ring);
}

.j-inline-edit-placeholder {
  color: var(--fg-3);
}

.j-inline-edit-input::placeholder {
  color: var(--fg-3);
}

/* ── Bulk Action Bar ─────────────────────────────── */
@keyframes j-bulk-bar-enter {
  from {
    opacity: 0;
    transform: translateY(calc(-1 * var(--sp-sm)));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.j-bulk-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--sp-sm-p);
  background: var(--surface-inverse);
  color: var(--fg-on-dark);
  font-family: var(--font-body);
  font-size: var(--type-small);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-floating);
  animation: j-bulk-bar-enter var(--motion-transition-toast-enter) var(--ease-snap);
}

.j-bulk-bar-count {
  font-weight: 600;
  font-feature-settings: 'tnum' 1;
  white-space: nowrap;
}

.j-bulk-bar-clear {
  background: transparent;
  border: var(--bw-hairline) solid currentColor;
  color: inherit;
  font-family: var(--font-body);
  font-size: var(--type-caption);
  font-weight: 500;
  padding: var(--sp-xs) var(--sp-sm-p);
  border-radius: var(--r-pill);
  cursor: pointer;
  white-space: nowrap;
  opacity: var(--op-prominent);
  transition:
    opacity var(--motion-feedback-state) var(--ease-snap),
    transform var(--motion-feedback-button-press) var(--ease-snap);
}

@media (hover: hover) {
  .j-bulk-bar-clear:hover {
    opacity: 1;
  }
}
.j-bulk-bar-clear:not(:disabled):active {
  transform: scale(var(--scale-tapped));
}
.j-bulk-bar-clear:focus-visible {
  outline: none;
  box-shadow: 0 0 0 var(--bw-selection) var(--color-neutral-100);
}

.j-bulk-bar-spacer {
  flex: 1;
}

.j-bulk-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

/* ── Popover ─────────────────────────────────────── */
.j-popover {
  position: fixed;
  z-index: 150;
  /* Floating: always the topmost surface tier (surface-2), regardless of
     the surface it appears over. See tokens.css surface ramp.

     ADR-029 layer-token override: popovers render through createPortal
     to document.body (see ADR §"Portal caveat") so they detach from
     any opener's DOM subtree — their role tokens MUST be self-declared
     here rather than inherited. Without these declarations a primitive
     nested in the popover (e.g. a Field inside a filter popover) would
     resolve --field-bg / --rule-on-layer / --hover-on-layer against
     the :root layer (surface-0), producing wrong-tone bg / dividers /
     hover swaps against the surface-2 popover. */
  --layer: var(--surface-2);
  /* ADR-043 §B.bis: --on-layer / --on-layer-2 NOT redeclared — they equal the
     :root defaults (--fg-1 / --fg-2), so descendants inherit the same value and
     an adopter --on-layer override propagates instead of being shadowed. */
  /* Same 20%-mix recipe as .j-card / .j-modal-sheet — the popover
     sits on the lightest surface tier (surface-2), so :root's
     --color-rule reads even flatter here than on a card. */
  --rule-on-layer: color-mix(in srgb, var(--layer) 80%, var(--on-layer) 20%);
  /* Fields inside a popover (autocomplete dropdowns, filter chips,
     in-popover search inputs) recess to --surface-1 — one tier
     below the popover's surface-2, keeping the same "inset
     affordance" pattern as cards/modals use one tier down from
     their own surface-1. */
  --field-bg: var(--surface-1);
  /* Disabled field bg — color-mix derives from the popover's field
     bg so the muted state stays visible against the popover surface
     in both themes (same rationale as .j-card). */
  --field-bg-disabled: color-mix(in srgb, var(--field-bg) 88%, var(--on-layer) 12%);
  /* Popover sits on --surface-2 (lightest tier), so the :root default
     --layer-elevated = --surface-2 collapses to --layer — no rung above
     for hover affordances to lift into. Override to the same color-mix
     overlay .j-modal-sheet uses (kit.css:1365) so descendant primitives
     reading --layer-elevated (button hovers, table-row hovers, segmented
     active pill) keep a visible step against the popover surface. */
  --layer-elevated: var(--surface-above);
  /* --layer-container override (v5.2.1, codex review r1+r2): a `<Card>`
     nested inside the popover paints `var(--layer-container)`. Without
     this, Card-in-Popover inherits `:root --layer-container = --surface-1`
     and paints BELOW the popover's surface-2 ground (inverted-lift —
     codex r1 P2). The popover surface tier is already at the top of the
     3-tier ramp (surface-2), so a nested Card cannot lift to a brighter
     surface; we keep it at surface-2 (matching the popover surface, so
     rest-state collapse — a pre-existing ADR-029 limitation that
     resolves only when the surface ramp grows beyond 3 tiers). Codex r2
     P2: setting --layer-container to a color-mix overlay would collapse Card-in-
     Popover REST with Card-in-Popover HOVER (hover reads --layer-elevated,
     = var(--surface-above) per ADR-037). Popover paints `var(--layer)`, not `var(--layer-container)`,
     so self-applying this role here is harmless to popover's own paint. */
  --layer-container: var(--surface-2);
  /* ADR-042 (finalized; was the #126 prototype). Popover paints --surface-2
     (floating tier); recess drops to --surface-1 — one tier below
     the popover surface, matching the .j-popover --field-bg pattern
     above. Segmented inside a Popover reads as inset against the
     floating panel. */
  --layer-recess: var(--surface-1);
  /* ADR-043 (P-13): own-paint via private stashes that MIRROR the public
     tokens (which stay declared above for descendant inheritance + the
     ADR-029 §Portal-caveat R4 adopter `--layer` re-tone knob). Reading the
     private alias on the property — not the public token — satisfies P-13. */
  --_layer-painted: var(--layer);
  --_rule-painted: var(--rule-on-layer);
  background: var(--_layer-painted);
  border: var(--bw-hairline) solid var(--_rule-painted);
  border-radius: var(--r-control);
  box-shadow: var(--shadow-floating);
  /* Base content padding bumped to --sp-sm-p (12px) from --sp-sm (8px)
     per consumer feedback that popovers read as cramped. Subselector
     blocks (.j-popover-header / -body / -footer) own their own padding;
     the :has() rule below drops this outer padding when those
     subselectors are present, mirroring the .j-modal-sheet pattern. */
  padding: var(--sp-sm-p);
  font-family: var(--font-body);
  font-size: var(--type-small);
  color: var(--on-layer);
  /* Tighter content floor — was --sp-4xl (60px), which collapsed
     short content to a sliver. --sp-2xl (40px) keeps short popovers
     readable while still allowing tight layouts (color swatches,
     mini-menus). */
  min-width: var(--sp-2xl);
  /* Hard cap so popovers stay panel-shaped on desktop. Was
     calc(100vw - --sp-lg - --sp-lg) which allowed near-viewport-wide
     popovers on desktop. 22rem (352px) is the standard floating-panel
     cap used by Material 3 / Radix / Ariakit; popovers wider than
     that should be modals or sheets. Mobile fallback in the
     `@media (max-width: 480px)` block below releases this cap and
     pins the popover to viewport bottom (bottom-sheet escalation). */
  max-width: min(22rem, calc(100vw - var(--sp-lg) - var(--sp-lg)));
  /* Was `--dur-pop` (100ms) — felt snappy/dated next to the kit's
     newer interactions. `--dur-quick` (150ms) with `--ease-out`
     decelerates into the resting state, closer to industry norm
     (Material ~225ms, Linear ~150ms decelerate). */
  animation: j-pop var(--motion-transition-popover-enter) var(--ease-out);
  overflow: hidden;
}

/* When the popover uses the full structured layout (body present),
   subselectors own their own padding — drop the outer padding so
   adopters don't double-pad.

   Body is the "I'm committing to structured layout" signal:
   adopters who use only .j-popover-header alongside raw sibling
   content (e.g., `<div class="j-popover-header">Title</div><p>raw</p>`)
   would otherwise get padding: 0 + raw children flush to the panel
   edge. Codex review G1 caught that gap. Keeping outer padding when
   body is absent lets header-only and header+footer-only compositions
   stay readable; the header/footer's own padding stacks visually but
   that's the price of supporting partial structures.

   :has() is the kit's established conditional-style mechanism (see
   .j-field:focus-within:has(:focus-visible), .j-checkbox-label:has(...)).
   Browser baseline: Chrome 105+ / Safari 15.4+ / Firefox 121+. */
.j-popover:has(.j-popover-body) {
  padding: 0;
}

/* ── Popover layout subselectors (consumer feedback 2026-05-20) ──
   Mirror the .j-modal-{header,body,footer} pattern at a tighter scale
   so adopters get a consistent layout primitive instead of laying out
   popover content from scratch each time. */
.j-popover-header {
  padding: var(--sp-sm-p) var(--sp-md) var(--sp-sm);
  border-bottom: var(--bw-hairline) solid var(--rule-on-layer);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-sm);
  font-weight: 600;
  color: var(--on-layer);
}

.j-popover-body {
  /* Same overflow story as .j-modal-body: a popover with long content
     scrolls internally rather than overflowing past max-height. min-height
     0 unlocks flex-child overflow. overscroll-behavior: contain stops
     scroll-chaining into the page behind the popover.

     max-height caps at 50vh - --sp-3xl (Codex review G3 — was 70vh,
     which on a 768px viewport allowed ~490px popover body, reading
     as modal-range rather than floating-panel-range). 50vh - 48px
     resolves to ~336px on 768px / ~402px on 900px — well within the
     floating-panel size convention (Material 3 / Radix / Ariakit
     popovers cap around 400-500px maximum). Mobile fallback in the
     @media block below releases this for sheet-mode. */
  padding: var(--sp-sm-p) var(--sp-md);
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  overscroll-behavior: contain;
  max-height: calc(50vh - var(--sp-3xl));
}

.j-popover-footer {
  padding: var(--sp-sm) var(--sp-md) var(--sp-sm-p);
  border-top: var(--bw-hairline) solid var(--rule-on-layer);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-sm);
}

.j-popover:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), var(--shadow-floating);
}

.j-popover-arrow {
  position: absolute;
  width: var(--sp-sm);
  height: var(--sp-sm);
  /* Reads --layer so the arrow tracks the popover panel's surface —
     including adopter overrides like `.my-overlay { --layer: var(--surface-1) }`
     that would otherwise leave the arrow on raw surface-2 while the
     panel re-toned (codex adversarial review, 2026-05-20). The panel's
     own --layer override is at .j-popover above. */
  background: var(--layer);
  border: var(--bw-hairline) solid var(--rule-on-layer);
  transform: rotate(45deg);
}

/* Popover arrows: `data-side` is the arrow's physical orientation, set
   by the positioning logic in Popover.tsx. The border-erasure rules
   here intentionally use physical property names because the data-side
   value IS the physical direction — these rules don't represent inline-
   flow start/end, they represent which two edges to erase to form a
   triangle. A future RTL refactor of Popover positioning would also
   parameterize data-side values; until then, physical names match the
   trigger value 1:1. */
.j-popover-arrow[data-side='bottom'] {
  border-top: none;
  border-left: none;
}
.j-popover-arrow[data-side='top'] {
  border-bottom: none;
  border-right: none;
}
.j-popover-arrow[data-side='left'] {
  border-top: none;
  border-right: none;
}
.j-popover-arrow[data-side='right'] {
  border-bottom: none;
  border-left: none;
}

/* Bottom-sheet escalation at ≤480px (mobile portrait).
   Desktop / tablet-landscape (≥481px) keep the existing fixed-position
   anchored behavior above. On narrow viewports the fixed anchored
   panel sits awkwardly mid-screen with no clear dismiss affordance
   for touch users, so it escalates to a bottom-sheet that slides up
   from the bottom edge, takes full inline-width, and exposes a drag-
   handle indicator. Dismiss still routes through Esc / mousedown-
   outside as on desktop.

   Inline-style override pattern: Popover.tsx sets inline
   `style={{ insetBlockStart, insetInlineStart }}` from the
   positioning calc; the @media block here MUST override via
   !important to win against the inline `style` attribute. Same
   pattern as `.j-modal-sheet:not([style*='max-width'])` at line 2341.

   Breakpoint cross-reference: the 480px literal below mirrors
   `--bp-xs: 480px` in tokens.css (source-of-truth at
   tokens/reference/dimension.json#bp.xs). CSS media-query conditions
   cannot consume var(), so the literal here is the kit-side
   restatement; any change to --bp-xs MUST match here. See ADR-011 for
   the xs (phone-only) escalation rationale. */
@media (max-width: 480px) {
  .j-popover {
    /* Override Popover.tsx inline positioning */
    inset-block-start: auto !important;
    inset-block-end: 0 !important;
    inset-inline-start: 0 !important;
    inset-inline-end: 0 !important;
    inline-size: 100% !important;
    /* Allow narrower max-width override (set on desktop above) to not
       constrain the full-width sheet. */
    max-inline-size: 100% !important;
    /* iOS Safari: vh measures the LARGE viewport (excludes the
       collapsible toolbar), so 85vh under-allocates when the toolbar
       expands on first tap. dvh measures the dynamic viewport that
       matches what the user actually sees. Both declared so browsers
       without dvh (older WebKit / pre-2022 evergreen) get vh. Mirrors
       .j-modal-sheet at line 2344. */
    max-block-size: 85vh;
    max-block-size: 85dvh;
    /* Top corners only (mirroring .j-modal-sheet bottom-sheet at
       line 2346). --r-sheet matches the modal sheet recipe so a
       Popover-as-sheet visually matches a Modal-as-sheet on the same
       viewport. */
    border-start-start-radius: var(--r-sheet);
    border-start-end-radius: var(--r-sheet);
    border-end-start-radius: 0;
    border-end-end-radius: 0;
    /* Reserve space at the top for the drag handle (::before sits at
       inset-block-start var(--sp-sm) with block-size 4px; pad enough
       to clear the handle plus a comfortable gap). */
    padding-block-start: calc(var(--sp-sm) + 4px + var(--sp-sm));
    /* j-sheet-up keyframe is translate-only — j-pop's scale/opacity
       entrance reads as a desktop-affordance gesture, wrong for a
       sheet that should slide up from the bottom edge. The keyframe
       intentionally omits opacity (no fade): an additional fade on
       top of the translate doubles motion at low-RM contexts, and
       the modal-sheet pattern in this file is likewise translate-only.
       --motion-transition-popover-enter resolves to --dur-quick
       (150ms); --ease-decelerate is the canonical Material
       "decelerate" curve — fast start, slow end, feels caught by
       the screen — defined alongside --ease-snap / --ease-out /
       --ease-inout. */
    animation: j-sheet-up var(--motion-transition-popover-enter) var(--ease-decelerate);
  }
  .j-popover::before {
    /* Drag handle indicator — visual affordance only at this layer.
       (Drag-to-dismiss gestures would be a future addition; the
       handle alone communicates "this dismisses downward" to touch
       users even without the gesture wired up.)
       --on-layer-3 is the tier-3 foreground tone (--on-layer at 30%
       via color-mix). Container scopes that redefine --on-layer get
       a re-toned tier-3 automatically. Matches the contrast level
       adopted by the .j-modal-drag-handle visual elsewhere. */
    content: '';
    position: absolute;
    inset-block-start: var(--sp-sm);
    inset-inline-start: 50%;
    transform: translateX(-50%);
    inline-size: 12%;
    block-size: 4px;
    border-radius: 999px;
    background: var(--on-layer-3);
  }
  /* Sheet-tier padding for the named slots. .j-popover-header /
     -body / -footer carry their own padding-inline via the desktop
     subselector rules above; at sheet width we re-state the inline
     padding so the slots align to the sheet's own --sp-md gutters
     (folded in from PR #146; the :has() guard keeps the rule a no-op
     for popovers that don't use the slot anatomy). */
  .j-popover:has(.j-popover-header) .j-popover-header,
  .j-popover:has(.j-popover-body) .j-popover-body,
  .j-popover:has(.j-popover-footer) .j-popover-footer {
    padding-inline: var(--sp-md);
  }
  .j-popover-body {
    /* Body-level vertical cap inside the sheet. The outer panel caps
       at 85vh/85dvh above; this scopes the *content slot* to 60vh so
       long lists scroll within the body while the header/footer stay
       pinned. (Folded in from PR #146.) */
    max-height: 60vh;
  }
  /* The anchor arrow points at a trigger; once the panel is pinned to
     the viewport edge as a sheet, it no longer relates to the trigger
     visually, so hide it. (Folded in from PR #146.) */
  .j-popover-arrow {
    display: none;
  }
}

/* Sheet slide-up entry — used by the bottom-sheet escalation above.
   Translate-only by design (see the .j-popover animation comment for
   rationale); do NOT add an opacity 0→1 here. */
@keyframes j-sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* ── Menu (shared primitive) ─────────────────────── */
.j-menu {
  padding: var(--sp-xs) var(--sp-zero);
  min-width: calc(3 * var(--sp-4xl));
  max-width: calc(7 * var(--sp-2xl));
  /* Floating: always surface-2 (lightest tier). See tokens.css surface
     ramp. Same ADR-029 portal rationale as .j-popover above — DropdownMenu
     portals to document.body, so role tokens MUST be self-declared. */
  --layer: var(--surface-2);
  /* ADR-043 §B.bis: --on-layer / --on-layer-2 NOT redeclared — they equal the
     :root defaults (--fg-1 / --fg-2), so descendants inherit the same value and
     an adopter --on-layer override propagates instead of being shadowed. */
  /* Same 20%-mix recipe as .j-popover; menu sits on the same
     surface tier so the derivation is shared. */
  --rule-on-layer: color-mix(in srgb, var(--layer) 80%, var(--on-layer) 20%);
  --field-bg: var(--surface-1);
  --field-bg-disabled: color-mix(in srgb, var(--field-bg) 88%, var(--on-layer) 12%);
  /* Same --layer-elevated override as .j-popover — menu sits on
     surface-2, so the :root default collapses; descendants hovering
     into --layer-elevated need a real rung above. */
  --layer-elevated: var(--surface-above);
  /* --layer-container override (v5.2.1, codex review r1+r2): same
     rationale as .j-popover — Card-in-Menu would inherit :root
     --layer-container = surface-1 and paint BELOW the menu's surface-2.
     Held at surface-2 (matching menu surface; pre-existing top-tier-
     collapse limitation) instead of the overlay to keep Card hover
     distinct from Card rest. Menu paints `var(--layer)`, not
     `var(--layer-container)`, so the self-app is harmless. */
  --layer-container: var(--surface-2);
  /* ADR-042 (finalized; was the #126 prototype). Same recess tier as
     .j-popover — menu sits on --surface-2 so recess drops to --surface-1
     (mirrors .j-menu --field-bg). Symmetric with --layer-elevated above. */
  --layer-recess: var(--surface-1);
  /* ADR-043 (P-13): own-paint via private stashes that MIRROR the public
     tokens (which stay declared above for descendant inheritance + the
     ADR-029 §Portal-caveat R4 adopter `--layer` re-tone knob). Reading the
     private alias on the property — not the public token — satisfies P-13. */
  --_layer-painted: var(--layer);
  --_rule-painted: var(--rule-on-layer);
  background: var(--_layer-painted);
  border: var(--bw-hairline) solid var(--_rule-painted);
  border-radius: var(--r-control);
  box-shadow: var(--shadow-floating);
  font-family: var(--font-body);
  font-size: var(--type-small);
  /* Entry animation */
  animation: j-menu-enter
    var(--motion-feedback-dropdown-expand, var(--motion-transition-popover-enter)) var(--ease-out)
    both;
}

/* v5.2.1 (PR #200): state rules co-located under base so the focused-
   option compound selector wins the kit-internal cascade vs the base
   `.j-menu-item { background: transparent }` rule via specificity
   (0,2,0 > 0,1,0). This protects against the v5.2.0 cascade-order bug
   regressing inside kit.css. It is NOT a defense against adopter
   `!important`, later same-specificity adopter rules, `:where()`-
   wrapped contexts, or `@scope` adjustments — those are governed by
   the broader cascade and adopter sheet ordering. ADR-036 records the
   v6 cascade-layers migration that makes state-vs-base resolution
   architecturally explicit instead of specificity-driven. */
/* ADR-041: activate the insufficient-contrast boundary edge for menu/popover
   focused + hovered options. The option boundary (--layer-elevated =
   --surface-above) sits on the surface-2 panel and clears only ~1.03:1
   (light) / ~1.63:1 (dark) — both below the WCAG 1.4.11 3:1 floor (the
   contrast matrix pins this), so the inset hairline on the option carries the
   focus-traversal boundary. The edge resolves to --edge-cue-strong, a TUNED
   >=3:1 value in DEFAULT mode (neutral-700 light ~5.4:1 / neutral-800 dark
   ~5.0:1 vs the lifted fill) — NOT the ~1.5:1 --rule-on-layer divider, which
   failed WCAG 1.4.11 AA in default rendering (the prefers-contrast escalation
   below does not discharge an AA obligation evaluated in default mode). Set in
   BOTH themes because both are below floor here (refines ADR-037/041's "dark
   gets no edge" note, which held for the surface-1 card case, not surface-2). */
.j-popover,
.j-menu {
  --edge-cue: var(--edge-cue-strong);
}

/* ADR-041: under prefers-contrast: more, step the edge UP from the conformant
   >=3:1 default to full --on-layer (9-16:1) so high-contrast users get genuine
   headroom above the AA floor rather than the floor becoming the ceiling. The
   matching width bump (--bw-standard) is co-located after the menu-item rules
   below. Lives here (a scope rule, NOT among the .j-menu-item state rules) so
   it doesn't interleave the contiguous menu-item cascade block. */
@media (prefers-contrast: more) {
  .j-popover,
  .j-menu {
    --edge-cue: var(--on-layer);
  }
}

.j-menu-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  /* Inset rounded highlight — item is narrower than container with auto margin */
  width: calc(100% - var(--sp-sm));
  margin-inline: auto;
  padding: var(--sp-sm) var(--sp-sm);
  border: none;
  border-radius: var(--r-compact);
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--type-small);
  color: var(--fg-1);
  line-height: var(--lh-small);
  cursor: pointer;
  text-align: start;
  text-decoration: none;
  font: inherit;
  transition:
    background var(--motion-feedback-field-focus) var(--ease-snap),
    color var(--motion-feedback-field-focus) var(--ease-snap);
  min-height: var(--touch-compact);
}

@media (hover: hover) {
  .j-menu-item:hover:not(:disabled) {
    /* Routes through --layer-elevated (same role-token contract as
       PR #143). ADR-037: inside .j-menu / .j-popover --layer-elevated now
       resolves to --surface-above (the real top-tier sentinel shipped in
       #209's 11-tier ladder), restoring "lift = brighter" in both themes —
       replacing the prior color-mix(--surface-2, --on-layer) overlay that
       theme-flipped (darker in light). The panel sits on --surface-2, so
       this lift is only ~1.03:1 light / ~1.63:1 dark — both below the WCAG
       1.4.11 3:1 floor, so the ADR-041 --edge-cue inset hairline carries the
       boundary (1px; --edge-cue is set on .j-menu / .j-popover below). */
    background: var(--layer-elevated);
    box-shadow: inset 0 0 0 var(--bw-hairline) var(--edge-cue);
  }
}

/* Keyboard-focused option — compound selector (0,2,0) beats the
   .j-menu-item base (0,1,0) inside the kit-internal cascade. Uses
   --layer-elevated for visual parity with :hover. v5.2.1 PR #200;
   see ADR-036 for the v6 cascade-layers migration.
   ADR-041: this is the active-descendant keyboard-focus highlight (the
   only cue that moves as you arrow through options — distinct from the
   :focus-visible ring below, which rides the listbox, not the option).
   The lift to --surface-above is ~1.03:1 on the surface-2 panel, so the
   --edge-cue inset hairline is the load-bearing focus boundary (WCAG 2.4.7
   / 1.4.11) and pins 1px (--bw-hairline) so it can't sub-pixel-vanish. */
.j-menu-item.j-select-option-focused {
  background: var(--layer-elevated);
  box-shadow: inset 0 0 0 var(--bw-hairline) var(--edge-cue);
}

.j-menu-item:focus-visible {
  outline: none;
  background: var(--color-neutral-200);
  box-shadow: var(--focus-ring-inset);
}

/* ADR-041: when a menu item is BOTH keyboard-focused and hovered (a
   DropdownMenu item under mouse after keyboard nav), the focus ring must win
   over the --edge-cue hairline — both write box-shadow, and without this the
   :hover edge (0,3,0) clobbers the :focus-visible ring (0,2,0), dropping the
   focus indicator. This compound selector (0,4,0) wins in both default and
   prefers-contrast. Inside @media (hover: hover) per the bare-:hover lint.
   (Select options use aria-activedescendant, never :focus-visible, so they're
   unaffected — only DropdownMenu items hit this.) */
@media (hover: hover) {
  .j-menu-item:focus-visible:hover:not(:disabled) {
    box-shadow: var(--focus-ring-inset);
  }
}

.j-menu-item:active:not(:disabled) {
  /* In dark mode --surface-2 (menu panel bg) == --color-neutral-300, so
     using neutral-300 here erased the pressed state. --color-rule is
     decoupled from the neutral ramp and stays visible in both themes
     (codex audit #107 R2). */
  background: var(--color-rule);
}

.j-menu-item:disabled {
  color: var(--fg-3);
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

/* ADR-041: high-contrast width bump for the option boundary edge. Placed AFTER
   the contiguous .j-menu-item state rules (so it doesn't interleave them — the
   v5.2.1 cascade-collision contiguity guard) and after the base focused/hover
   rules so it wins at equal specificity. Pairs with the --edge-cue colour
   escalation on the .j-popover / .j-menu scope above (kept separate so no
   non-menu-item selector sits among the menu-item state rules): under
   prefers-contrast the edge colour jumps to --on-layer AND the hairline
   thickens to --bw-standard — well above the WCAG 1.4.11 3:1 floor, mirroring
   the segmented control's --_seg-indicator-rule escalation. The DEFAULT edge is
   already conformant: --edge-cue resolves to --edge-cue-strong (~5:1 both
   themes) so the focused option clears 1.4.11 AA without this block (ADR-041
   conformance fix). This block is now a STEP-UP above the AA floor for
   high-contrast users, not the sole 3:1 path. */
@media (prefers-contrast: more) {
  .j-menu-item.j-select-option-focused {
    box-shadow: inset 0 0 0 var(--bw-standard) var(--edge-cue);
  }
}
/* The hover half is split into a compound (hover: hover) media so the bare
   :hover stays inside an @media (hover: hover) context (lint:hover) and never
   sticky-hovers on touch. */
@media (hover: hover) and (prefers-contrast: more) {
  .j-menu-item:hover:not(:disabled) {
    box-shadow: inset 0 0 0 var(--bw-standard) var(--edge-cue);
  }
}

.j-menu-item-destructive {
  color: var(--color-error-700);
}

@media (hover: hover) {
  .j-menu-item-destructive:hover:not(:disabled) {
    background: var(--color-error-100);
    color: var(--color-error-700);
  }
}

/* Pressed — must come after hover so :active wins when both apply */
.j-menu-item-destructive:active:not(:disabled) {
  background: var(--color-error-500);
  color: var(--color-neutral-100);
}
.j-menu-item-destructive:active:not(:disabled) .j-menu-item-desc,
.j-menu-item-destructive:active:not(:disabled) .j-menu-item-icon {
  color: var(--color-neutral-100);
}

.j-menu-item-destructive:focus-visible {
  outline: none;
  background: var(--color-error-100);
  color: var(--color-error-700);
  box-shadow: var(--focus-ring-inset);
}

.j-menu-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--sp-md);
  height: var(--sp-md);
  color: var(--fg-2);
}

.j-menu-item-destructive .j-menu-item-icon {
  color: var(--color-error-700);
}

.j-menu-item:disabled .j-menu-item-icon {
  color: var(--fg-3);
}

.j-menu-item-desc {
  display: block;
  font-size: var(--type-caption);
  color: var(--fg-3);
  line-height: var(--lh-caption);
  font-weight: 400;
  margin-top: var(--sp-xs);
}

.j-menu-divider {
  height: var(--bw-hairline);
  background: var(--rule-on-layer);
  margin: var(--sp-xs) var(--sp-zero);
  border: none;
}

@keyframes j-menu-enter {
  from {
    opacity: 0;
    transform: scale(var(--scale-pressed)) translateY(calc(-1 * var(--sp-xs)));
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* j-menu-exit keyframe deferred — Menu is currently unmounted
   synchronously on close. Exit animation requires an 'exiting' state
   machine in the consumer. Tracked for follow-up. */

/* Menu — forced-colors (Windows High Contrast).
   Co-located with the base .j-menu / .j-menu-item / .j-menu-divider
   rules (above) so that source order resolves the cascade correctly.
   The centralized `@media (forced-colors: active)` block earlier in
   the file declared these HC rules BEFORE the base — equal-specificity
   ties + later source wins meant:
     - the base .j-menu `background + border + box-shadow` clobbered
       the HC `Canvas + ButtonBorder + box-shadow: none`,
     - the base .j-menu-item `color: var(--fg-1)` clobbered the HC
       `color: CanvasText`, and
     - the base .j-menu-divider `background: var(--rule-on-layer)`
       clobbered the HC `background: ButtonBorder`.
   So menu panels, items, and dividers all lost their system-palette
   identity under Windows HC. PR-A 2026-05-21 (sibling to PR #161).
   The .j-menu-item:focus-visible Med-severity entry stays in the
   centralized block pending PR-B. */
@media (forced-colors: active) {
  .j-menu {
    border: 2px solid ButtonBorder;
    box-shadow: none;
    background: Canvas;
  }
  .j-menu-item {
    color: CanvasText;
  }
  /* ADR-041 conformance: the focused Select option's --edge-cue is a
     box-shadow, which forced-colors strips, and :focus-visible never fires on
     the option (Select uses aria-activedescendant — DOM focus stays on the
     trigger). Without this the keyboard-focused option had ZERO traversal cue
     in Windows High Contrast (WCAG 2.4.7 failure). An inset Highlight outline
     restores it. */
  .j-menu-item.j-select-option-focused {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
  .j-menu-divider {
    background: ButtonBorder;
  }
}

/* ── Date Picker / Month Picker ─────────────────── */
.j-datepicker-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--sp-sm);
  min-height: var(--touch-compact);
  min-width: calc(4 * var(--sp-4xl));
  max-width: 100%;
  padding: 0 var(--sp-md);
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-control);
  /* Field-adjacent (datepicker trigger looks like a .j-field) —
     routes through --field-bg per ADR-029 v5.1 amendment. */
  background: var(--field-bg);
  color: var(--fg-1);
  font-family: var(--font-body);
  font-size: var(--type-small);
  line-height: var(--lh-field);
  text-align: start;
  cursor: pointer;
  forced-color-adjust: auto;
  /* Border + focus ring snap on field-focus (matches .j-field convention).
     Background + color crossfade at quick/out so hover feels like a fade
     rather than a snap (matches .j-card-interactive). */
  transition:
    border-color var(--motion-feedback-field-focus) var(--ease-snap),
    box-shadow var(--motion-feedback-field-focus) var(--ease-snap),
    background var(--motion-feedback-hover) var(--ease-out),
    color var(--motion-feedback-hover) var(--ease-out);
}

.j-datepicker-trigger[data-placeholder='true'] {
  color: var(--fg-3);
}

@media (hover: hover) {
  .j-datepicker-trigger:hover:not(:disabled) {
    border-color: var(--color-neutral-500);
    /* ADR-029 2026-05-21 amendment §C — NOT a container-tier hover.
       The datepicker trigger is a field-tier control (rest = --field-bg).
       Its hover is a within-field tonal shift, not a container surface
       lift, so it is not routed through --layer-container. The literal
       --surface-1 reference here is part of the field-hover vocabulary
       (also used by other field-like controls) and is not addressed by
       this amendment; routing field hovers through a dedicated
       --field-bg-hover role token is tracked as follow-up work. */
    background: var(--surface-1);
  }
}

.j-datepicker-trigger:focus-visible {
  outline: none;
  border-color: var(--color-theme-500);
  box-shadow: var(--focus-ring);
}

.j-datepicker-trigger.j-datepicker-error {
  border-color: var(--color-error-700);
}

.j-datepicker-trigger:disabled {
  color: var(--fg-3);
  background: var(--field-bg-disabled);
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

.j-datepicker-trigger > svg {
  flex: 0 0 auto;
  color: var(--fg-2);
}

.j-datepicker-calendar {
  /* ADR-029 floating-container pattern (mirrors .j-popover at line 3504+).
     The calendar is a floating panel (renders absolute-positioned with
     a floating shadow, per the box-shadow declaration below at adopter
     wrapping) and therefore owns its own absolute surface tier per
     ADR-029 §C "floating tier classification" — surface-2.

     Previously hardcoded `background: var(--surface-0)`, which is the
     baseline PAGE tier and produced two failures:
       1. Inside any container that already paints surface-0 (the page,
          a non-container adopter section) the calendar read as recessed
          rather than lifted — exactly inverted against its floating
          shadow.
       2. Inside containers painting a higher tier (Card on surface-1,
          Modal sheet on surface-1, Popover on surface-2) the calendar
          regressed below the surrounding layer — inverted-lift.

     Fix: redeclare --layer (and the companion role tokens) to the
     floating-tier surface, then paint var(--layer). Descendants (fields,
     dividers, hover affordances inside the calendar) resolve against
     the calendar's own surface instead of inheriting the page surface
     from :root. --layer-elevated resolves to var(--surface-above) (ADR-037)
     because the calendar sits on surface-2 (top of the surface ramp)
     and there's no rung above for descendant hovers to lift into —
     identical to Popover/Menu/Modal sheet's pattern. */
  --layer: var(--surface-2);
  /* ADR-043 §B.bis: --on-layer / --on-layer-2 NOT redeclared — they equal the
     :root defaults (--fg-1 / --fg-2), so descendants inherit the same value and
     an adopter --on-layer override propagates instead of being shadowed. */
  --rule-on-layer: color-mix(in srgb, var(--layer) 80%, var(--on-layer) 20%);
  --field-bg: var(--surface-1);
  --field-bg-disabled: color-mix(in srgb, var(--field-bg) 88%, var(--on-layer) 12%);
  --layer-elevated: var(--surface-above);
  inline-size: min(100vw - var(--sp-lg) - var(--sp-lg), calc(5 * var(--sp-4xl)));
  padding: var(--sp-sm);
  border-radius: var(--r-control);
  /* ADR-043 (P-13): own-paint via the private stash mirroring --layer (kept
     declared above for descendant inheritance + the ADR-029 R4 adopter knob).
     `color: var(--on-layer)` reads inherited :root --fg-1 (same value). */
  --_layer-painted: var(--layer);
  background: var(--_layer-painted);
  color: var(--on-layer);
  font-family: var(--font-body);
  font-size: var(--type-small);
  forced-color-adjust: auto;
}

.j-datepicker-calendar-narrow {
  inline-size: calc(4 * var(--sp-4xl));
}

.j-datepicker-calendar-range {
  inline-size: min(100vw - var(--sp-lg) - var(--sp-lg), calc(5 * var(--sp-4xl) + var(--sp-md)));
}

.j-datepicker-calendar:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring-inset);
}

.j-datepicker-nav {
  display: grid;
  grid-template-columns: var(--touch-compact) 1fr var(--touch-compact);
  align-items: center;
  gap: var(--sp-xs);
  margin-bottom: var(--sp-sm);
}

.j-datepicker-nav-btn,
.j-datepicker-nav-title {
  min-height: var(--touch-compact);
  border: 0;
  border-radius: var(--r-compact);
  background: transparent;
  color: var(--fg-1);
  font: inherit;
  cursor: pointer;
  /* Quick/out for hover crossfade — matches .j-card-interactive feel. */
  transition:
    background var(--motion-feedback-hover) var(--ease-out),
    color var(--motion-feedback-hover) var(--ease-out);
}

.j-datepicker-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-compact);
}

.j-datepicker-nav-title {
  font-weight: 600;
}

@media (hover: hover) {
  .j-datepicker-nav-btn:hover,
  .j-datepicker-nav-title:hover {
    background: var(--color-neutral-200);
  }
  /* Hover-bg only on unselected, not-in-range cells — hovering a
     selected cell must not blank out the white foreground. */
  .j-datepicker-day:hover:not(:disabled):not([data-selected='true']):not([data-in-range='true']),
  .j-monthpicker-cell:hover:not(:disabled):not([data-selected='true']) {
    background: var(--color-neutral-200);
  }
  /* Hover-over-selected: flip from saturated theme-700 fill (with
     neutral-50 text) → pale theme-100 fill (with theme-700 text).
     Uses the same brand-tier token pair as the in-range hover below,
     which means dark mode flips automatically (theme-100 / theme-700
     are defined in both light + dark stops). Reads as the cell
     "softening" on hover — a clear, distinct state without the
     previous stacked-ring glitch. */
  .j-datepicker-day[data-selected='true']:hover:not(:disabled),
  .j-monthpicker-cell[data-selected='true']:hover:not(:disabled) {
    background: var(--color-theme-100);
    color: var(--color-theme-700);
  }
  /* In-range hover lifts the band — switch foreground to theme-700
     (brand-tier, exists as a token) against the theme-100 background. */
  .j-datepicker-day[data-in-range='true']:hover:not(:disabled):not([data-selected='true']) {
    background: var(--color-theme-100);
    color: var(--color-theme-700);
  }
}

.j-datepicker-nav-btn:focus-visible,
.j-datepicker-nav-title:focus-visible,
.j-datepicker-day:focus-visible,
.j-monthpicker-cell:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring-inset);
}

.j-datepicker-weekdays,
.j-datepicker-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--sp-xs);
}

/* Wrapper that the JSX re-keys on viewYear/viewMonth/level change so
   the contents fade in fresh on each navigation. Without the keyed
   remount, swapping the grid contents was an instant snap. */
.j-datepicker-view {
  animation: j-fade var(--motion-transition-popover-enter) var(--ease-out);
}

/* Date / Month / Year grids use semantic rows for axe (role="row")
   while keeping the visual grid layout via display:contents. */
.j-grid-row {
  display: contents;
}

.j-datepicker-weekdays {
  margin-bottom: var(--sp-xs);
}

.j-datepicker-weekday {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--sp-lg);
  color: var(--fg-3);
  font-size: var(--type-caption);
  line-height: var(--lh-caption);
  font-weight: 600;
}

.j-datepicker-day,
.j-monthpicker-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-compact);
  border: 0;
  border-radius: var(--r-compact);
  background: transparent;
  color: var(--fg-1);
  font: inherit;
  cursor: pointer;
  /* Quick/out for hover + selection crossfade — the previous 60ms made
     each cell snap rather than fade. Matches .j-card-interactive cadence.
     Filter is on the transition list so the selected-cell hover lift
     (brightness 1.1) eases in instead of popping. */
  transition:
    background var(--motion-feedback-hover) var(--ease-out),
    color var(--motion-feedback-hover) var(--ease-out),
    box-shadow var(--motion-feedback-hover) var(--ease-out),
    filter var(--motion-feedback-hover) var(--ease-out);
}

.j-datepicker-day[data-outside='true'] {
  color: var(--fg-3);
  opacity: var(--op-dimmed);
}

.j-datepicker-day[data-today='true'] {
  box-shadow: inset 0 0 0 var(--bw-hairline) var(--color-theme-500);
}

.j-datepicker-day[data-in-range='true'] {
  background: var(--color-theme-100);
  color: var(--color-theme-700);
}

.j-datepicker-day[data-selected='true'],
.j-monthpicker-cell[data-selected='true'] {
  background: var(--color-theme-700);
  color: var(--color-neutral-100);
}

.j-datepicker-day:disabled,
.j-monthpicker-cell:disabled {
  color: var(--fg-3);
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

.j-datepicker-range-hint {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  margin-bottom: var(--sp-sm);
  padding: var(--sp-xs) var(--sp-sm);
  border-radius: var(--r-compact);
  background: var(--color-info-100);
  color: var(--color-info-700);
  font-size: var(--type-caption);
  line-height: var(--lh-caption);
}

/* Standalone Calendar — same surface as the popover dialog,
   but renders inline (no portal, no trigger). */
.j-calendar {
  display: inline-block;
  width: auto;
  border: var(--bw-hairline) solid var(--rule-on-layer);
}

.j-calendar[aria-disabled='true'] {
  opacity: var(--op-dimmed);
  pointer-events: none;
}

.j-monthpicker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-xs);
}

/* Audit #16 (2026-05-16): below 560px the DatePicker trigger spans
   the row and the calendar popover fits the viewport. 560px is a
   component-local mobile-narrow threshold — intentionally NOT
   published as a public breakpoint token, because the kit's public
   breakpoint contract (ADR-011) is fixed at sm/md/lg/xl/2xl. Codex
   round 2 caught that exposing `--bp-xs` here would mean adopters
   could @media (--bp-xs) in PostCSS without a matching `useBreakpoint`
   value of 'xs'. The literal stays inline as a component exception. */
@media not all and (min-width: 560px) {
  .j-datepicker-trigger {
    width: 100%;
    min-width: 0;
  }

  .j-datepicker-calendar {
    width: calc(100vw - var(--sp-md) - var(--sp-md)) !important;
    max-height: min(70dvh, calc(11 * var(--touch-compact)));
    overflow: auto;
  }
}

/* Date Picker / Month Picker / Calendar — forced-colors
   (Windows High Contrast).
   Co-located with the base .j-datepicker-* / .j-monthpicker-* rules
   (above) so that source order resolves the cascade correctly. The
   centralized `@media (forced-colors: active)` block earlier in the
   file declared these HC rules BEFORE the base — equal-specificity
   ties + later source wins meant the entire DatePicker forced-colors
   recipe was dead.

   HEADLINE FIX (WCAG 2.4.7 Focus Visible, Level AA):
     The base `.j-datepicker-trigger:focus-visible` sets
     `outline: none; border-color; box-shadow: var(--focus-ring)` —
     and under (forced-colors: active) the browser FLATTENS
     `box-shadow`, so the base provides no visible focus indicator
     under the system palette. The HC rule `outline: 2px solid
     Highlight` is the only thing that can render a visible focus
     ring on the trigger button — and it died on cascade order. The
     same flatten-then-die pattern applied to the nav-btn / nav-title
     / day / month-cell focus-visible rules (base uses
     `box-shadow: var(--focus-ring-inset)`). So keyboard navigation
     of the date picker under Windows High Contrast was rendering
     with NO visible focus indicator — a WCAG 2.4.7 (Level AA)
     accessibility blocker for keyboard users on the system palette.
     This co-located block restores the system-palette outline so
     keyboard focus is visible at every step of the date-picker
     interaction (trigger → nav → day grid).

   Other High-severity collisions repaired by this extraction:
     - .j-datepicker-trigger { border + background + color } (base
       clobbered the ButtonFace / ButtonBorder / ButtonText recipe),
     - .j-datepicker-calendar { background + color + border } (base
       clobbered the Canvas / CanvasText / ButtonBorder recipe),
     - .j-datepicker-nav-btn, .j-datepicker-nav-title { color }
       (base `var(--fg-1)` clobbered HC `CanvasText`),
     - .j-datepicker-day, .j-monthpicker-cell { color } (same),
     - selected-day and in-range-day backgrounds (base brand-token
       fills clobbered HC `Highlight + HighlightText`).

   Med-severity entries (`[data-today]`, `.j-datepicker-range-hint`)
   remain in the centralized block pending PR-B. PR-A 2026-05-21
   (sibling to PR #161). */
@media (forced-colors: active) {
  .j-datepicker-trigger {
    border: 1px solid ButtonBorder;
    background: ButtonFace;
    color: ButtonText;
  }
  .j-datepicker-trigger:focus-visible {
    outline: 2px solid Highlight;
  }
  .j-datepicker-calendar {
    border: 2px solid ButtonBorder;
    background: Canvas;
    color: CanvasText;
  }
  .j-datepicker-nav-btn,
  .j-datepicker-nav-title {
    color: CanvasText;
  }
  .j-datepicker-nav-btn:focus-visible,
  .j-datepicker-nav-title:focus-visible,
  .j-datepicker-day:focus-visible,
  .j-monthpicker-cell:focus-visible {
    outline: 2px solid Highlight;
  }
  .j-datepicker-day,
  .j-monthpicker-cell {
    color: CanvasText;
  }
  .j-datepicker-day[data-selected='true'],
  .j-monthpicker-cell[data-selected='true'] {
    background: Highlight;
    color: HighlightText;
  }
  .j-datepicker-day[data-in-range='true'] {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
}

/* ── Image Field / Crop Dialog ──────────────────── */
.j-imagefield-dropzone {
  display: flex;
  min-height: calc(4 * var(--touch-compact));
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  padding: var(--sp-lg);
  border: var(--bw-hairline) dashed var(--rule-on-layer);
  border-radius: var(--r-card);
  /* ADR-029 2026-05-21 amendment §C — dropzone is a raised, bordered,
     padded container (visually a Card-tier surface for the file drop
     target), so its rest fill cascades via --layer-container. On the
     page paints --surface-1; inside a Card scope paints --surface-2;
     inside Modal/Popover the overlay recipe. The dropzone-hover and
     data-dragover states intentionally retain the theme-color tint —
     those are state highlights, not surface elevation. */
  background: var(--layer-container);
  color: var(--fg-1);
  font-family: var(--font-body);
  text-align: center;
  cursor: pointer;
  forced-color-adjust: auto;
  transition:
    border-color var(--motion-feedback-field-focus) var(--ease-snap),
    background var(--motion-feedback-field-focus) var(--ease-snap),
    box-shadow var(--motion-feedback-field-focus) var(--ease-snap);
}

@media (hover: hover) {
  .j-imagefield-dropzone:hover:not([aria-disabled='true']) {
    border-color: var(--color-theme-500);
    background: var(--color-theme-100);
  }
}

.j-imagefield-dropzone:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.j-imagefield-dropzone[data-dragover='true'] {
  border-color: var(--color-theme-500);
  background: var(--color-theme-100);
  box-shadow: inset 0 0 0 var(--bw-selection) var(--color-theme-500);
}

.j-imagefield-dropzone[aria-disabled='true'] {
  color: var(--fg-3);
  background: var(--field-bg-disabled);
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

.j-imagefield-dropzone-icon {
  display: inline-flex;
  color: var(--fg-2);
}

.j-imagefield-dropzone-label {
  font-weight: 600;
  font-size: var(--type-small);
  line-height: var(--lh-small);
}

.j-imagefield-dropzone-hint {
  color: var(--fg-3);
  font-size: var(--type-caption);
  line-height: var(--lh-caption);
}

.j-imagefield-preview {
  position: relative;
  display: block;
  min-height: calc(4 * var(--touch-compact));
  overflow: hidden;
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-card);
  /* ADR-029 2026-05-21 amendment §C — preview is the raised container
     that holds the cropped image; sits at the same surface tier as the
     dropzone. Cascade via --layer-container for consistency with
     Card / Panel / Modal sheet. */
  background: var(--layer-container);
  forced-color-adjust: auto;
}

.j-imagefield-preview > img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
}

.j-imagefield-meta {
  position: absolute;
  inset-inline-start: var(--sp-sm);
  inset-block-start: var(--sp-sm);
  max-width: calc(100% - var(--sp-lg));
  padding: var(--sp-xs) var(--sp-sm);
  border-radius: var(--r-compact);
  background: color-mix(in srgb, var(--surface-0) 92%, transparent);
  color: var(--fg-2);
  font-size: var(--type-caption);
  line-height: var(--lh-caption);
}

.j-imagefield-actions {
  position: absolute;
  inset-inline: var(--sp-sm);
  inset-block-end: var(--sp-sm);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-xs);
}

.j-imagefield-action-btn {
  min-height: var(--touch-compact);
  padding: 0 var(--sp-sm);
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-control);
  background: color-mix(in srgb, var(--surface-0) 94%, transparent);
  color: var(--fg-1);
  font-family: var(--font-body);
  font-size: var(--type-caption);
  line-height: var(--lh-caption);
  cursor: pointer;
  transition:
    background var(--motion-feedback-button-press) var(--ease-snap),
    color var(--motion-feedback-button-press) var(--ease-snap),
    border-color var(--motion-feedback-button-press) var(--ease-snap);
}

@media (hover: hover) {
  .j-imagefield-action-btn:hover {
    background: var(--surface-0);
    border-color: var(--color-neutral-500);
  }
}

.j-imagefield-action-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.j-imagefield-action-btn-destructive {
  color: var(--color-error-700);
  /* Derived light destructive border (no --color-error-300 token exists; the
     kit's error series ships -100/-500/-700 only). 60/40 mix mirrors the
     applied-FilterButton derivation above for the missing -300 tier. */
  border-color: color-mix(in srgb, var(--color-error-100) 60%, var(--color-error-500) 40%);
}

.j-crop-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 1000);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-lg);
  background: color-mix(in srgb, var(--color-neutral-900) 55%, transparent);
  forced-color-adjust: auto;
}

.j-crop-dialog {
  /* ADR-029 floating-container pattern (mirrors .j-popover at line 3504+).
     Crop dialog is a floating modal-style container (carries
     var(--shadow-floating) and lives above an overlay scrim). The
     previous declaration was self-contradictory: `background:
     var(--surface-0)` painted the BASELINE page tier while
     `box-shadow: var(--shadow-floating)` declared floating elevation.
     The two signals fought — adopters saw an inset-looking panel with
     a drop shadow.

     Fix: redeclare --layer + companion role tokens to the floating-tier
     surface (surface-2) and paint var(--layer). Descendants (fields,
     dividers, buttons, the crop area's hover affordances) resolve
     against the dialog's own surface instead of the page surface from
     :root. --layer-elevated resolves to var(--surface-above) (ADR-037)
     because the dialog sits on surface-2 (top of the ramp) — same
     reason and recipe as .j-popover / .j-menu / .j-modal-sheet.
     --rule-on-layer derivation re-tones the border declared just
     above so it reads as a real hairline against the lifted surface
     rather than collapsing toward the page-tone --color-rule.

     --layer-container override (v5.2.1 design re-eval, ADR-029 §C.bis):
     parallels .j-popover / .j-menu — a `<Card>` nested inside a crop
     dialog paints `var(--layer-container)`. Without this redeclaration,
     it would inherit `:root --layer-container = --surface-1` and paint
     BELOW the dialog's surface-2 (inverted lift). Pin to --surface-2
     (matching dialog surface) so Card-in-CropDialog rest collapses
     with the host surface — pre-existing ADR-029 3-tier ramp
     limitation, same as Card-in-Popover/Menu. Card hover remains
     distinct via --layer-elevated = var(--surface-above). */
  --layer: var(--surface-2);
  /* ADR-043 §B.bis: --on-layer / --on-layer-2 NOT redeclared — they equal the
     :root defaults (--fg-1 / --fg-2), so descendants inherit the same value and
     an adopter --on-layer override propagates instead of being shadowed. */
  --rule-on-layer: color-mix(in srgb, var(--layer) 80%, var(--on-layer) 20%);
  --field-bg: var(--surface-1);
  --field-bg-disabled: color-mix(in srgb, var(--field-bg) 88%, var(--on-layer) 12%);
  --layer-elevated: var(--surface-above);
  --layer-container: var(--surface-2);
  width: min(calc(100vw - var(--sp-lg) - var(--sp-lg)), calc(8 * var(--sp-4xl)));
  max-height: calc(100dvh - var(--sp-lg) - var(--sp-lg));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  /* ADR-043 (P-13): own-paint via private stashes mirroring the public tokens
     (kept declared above for descendant inheritance + the ADR-029 R4 adopter
     --layer knob). `color: var(--on-layer)` reads inherited :root --fg-1. */
  --_layer-painted: var(--layer);
  --_rule-painted: var(--rule-on-layer);
  border: var(--bw-hairline) solid var(--_rule-painted);
  border-radius: var(--r-card);
  background: var(--_layer-painted);
  color: var(--on-layer);
  box-shadow: var(--shadow-floating);
  font-family: var(--font-body);
}

.j-crop-dialog:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), var(--shadow-floating);
}

.j-crop-header,
.j-crop-footer {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md);
}

.j-crop-header {
  justify-content: space-between;
  border-bottom: var(--bw-hairline) solid var(--rule-on-layer);
}

.j-crop-title {
  font-size: var(--type-small);
  line-height: var(--lh-small);
  font-weight: 600;
}

.j-crop-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-compact);
  height: var(--touch-compact);
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
}

@media (hover: hover) {
  .j-crop-close:hover {
    background: var(--color-neutral-200);
    color: var(--fg-1);
  }
}

.j-crop-close:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring-inset);
}

.j-crop-canvas-wrap {
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: var(--sp-md);
  background: var(--color-neutral-900);
}

.j-crop-canvas-wrap canvas {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-compact);
}

.j-crop-aspects {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
  padding: var(--sp-sm) var(--sp-md);
  border-top: var(--bw-hairline) solid var(--rule-on-layer);
}

.j-crop-aspect-btn {
  min-height: var(--touch-compact);
  padding: 0 var(--sp-sm);
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-control);
  background: var(--surface-0);
  color: var(--fg-1);
  font: inherit;
  cursor: pointer;
}

.j-crop-aspect-btn[data-active='true'] {
  border-color: var(--color-theme-700);
  background: var(--color-theme-100);
  color: var(--color-theme-700);
}

.j-crop-aspect-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.j-crop-footer {
  justify-content: flex-end;
  border-top: var(--bw-hairline) solid var(--rule-on-layer);
}

/* Audit #16: below 560px, image-field actions stack full-width inside
   the modal footer. 560px is a component-local threshold (see same
   block above) — not a public breakpoint token per ADR-011. */
@media not all and (min-width: 560px) {
  .j-imagefield-actions {
    position: static;
    padding: var(--sp-sm);
    justify-content: stretch;
    background: var(--surface-0);
  }

  .j-imagefield-action-btn {
    flex: 1 1 auto;
  }

  .j-crop-scrim {
    align-items: stretch;
    padding: var(--sp-sm);
  }

  .j-crop-dialog {
    width: 100%;
    max-height: calc(100dvh - var(--sp-md));
  }

  .j-crop-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}

/* ── FAB (Floating Action Button) ────────────────── */
.j-fab {
  position: fixed;
  z-index: var(--z-fab, 50);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-floating);
  border-radius: var(--r-card);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--type-small);
  letter-spacing: var(--track-compact);
  white-space: nowrap;
  transition:
    background var(--motion-feedback-button-press) var(--ease-snap),
    color var(--motion-feedback-button-press) var(--ease-snap),
    transform var(--motion-feedback-fab-hover) var(--ease-out),
    box-shadow var(--motion-feedback-fab-hover) var(--ease-out),
    opacity var(--motion-feedback-button-press) var(--ease-snap);
  width: var(--fab);
  height: var(--fab);
}

.j-fab-extended {
  width: auto;
  gap: var(--sp-sm);
  padding: 0 var(--sp-lg);
}

.j-fab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.j-fab-primary {
  background: var(--color-neutral-900);
  color: var(--color-neutral-100);
}

.j-fab-secondary {
  background: var(--color-neutral-100);
  color: var(--color-neutral-900);
}

.j-fab-theme {
  background: var(--color-theme-700);
  color: var(--color-neutral-100);
}

@media (hover: hover) {
  .j-fab-primary:hover:not(:disabled) {
    background: var(--color-neutral-700);
    box-shadow: var(--shadow-fab-hover);
    transform: translateY(-2px);
  }
  .j-fab-secondary:hover:not(:disabled) {
    background: var(--color-neutral-200);
    box-shadow: var(--shadow-fab-hover);
    transform: translateY(-2px);
  }
  .j-fab-theme:hover:not(:disabled) {
    background: var(--color-theme-500);
    box-shadow: var(--shadow-fab-hover);
    transform: translateY(-2px);
  }
  .j-fab-bottom-center:hover:not(:disabled) {
    transform: translateX(-50%) translateY(-2px);
  }
}

/* FAB position classes (.j-fab-bottom-right, .j-fab-bottom-left,
   .j-fab-bottom-center): the FABPosition prop API exposes
   'bottom-right' / 'bottom-left' / 'bottom-center' as PHYSICAL
   viewport positions. Adopters passing position="bottom-right" expect
   the FAB to render at the physical bottom-right corner regardless of
   text direction. Migrating to inset-inline-* would swap sides under
   dir="rtl", breaking the API contract. Logical equivalents would need
   a parallel API (position="bottom-end" / "bottom-start"). Kept
   physical until that API is added. */
.j-fab-bottom-right {
  bottom: calc(var(--sp-md) + env(safe-area-inset-bottom, 0px));
  right: var(--sp-md);
}
.j-fab-bottom-left {
  bottom: calc(var(--sp-md) + env(safe-area-inset-bottom, 0px));
  left: var(--sp-md);
}
.j-fab-bottom-center {
  bottom: calc(var(--sp-md) + env(safe-area-inset-bottom, 0px));
  /* Standard centering trick — see j-toast above for rationale. */
  left: 50%;
  transform: translateX(-50%);
}

.j-fab:disabled {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

.j-fab:not(:disabled):active {
  transform: scale(var(--scale-pressed));
  box-shadow: var(--shadow-rest);
}
.j-fab-primary:not(:disabled):active {
  background: var(--color-neutral-700);
}
.j-fab-secondary:not(:disabled):active {
  background: var(--color-neutral-200);
}
.j-fab-theme:not(:disabled):active {
  background: var(--color-theme-500);
}
.j-fab-bottom-center:not(:disabled):active {
  transform: translateX(-50%) scale(var(--scale-pressed));
  box-shadow: var(--shadow-rest);
}

.j-fab:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  box-shadow: var(--shadow-floating);
}

.j-fab-hidden {
  transform: translateY(
    calc(100% + var(--sp-md) + var(--sp-md) + env(safe-area-inset-bottom, 0px))
  );
  transition-property: transform;
  transition-duration: var(--motion-layout-fab-scroll-hide);
  transition-timing-function: var(--ease-out);
}
.j-fab-hidden.j-fab-bottom-center {
  transform: translateX(-50%)
    translateY(calc(100% + var(--sp-md) + var(--sp-md) + env(safe-area-inset-bottom, 0px)));
}

.j-fab[aria-busy='true'] {
  pointer-events: none;
}
.j-fab[aria-busy='true'] > .j-fab-label {
  opacity: var(--op-dimmed);
}

.j-fab-spinner {
  display: inline-flex;
  animation: j-spin 0.8s linear infinite;
}

/* FAB — forced-colors (Windows High Contrast).
   Co-located with the base .j-fab / .j-fab-theme rules (above) so
   that source order resolves the cascade correctly. The centralized
   `@media (forced-colors: active)` block earlier in the file declared
   these HC rules BEFORE the base — equal-specificity ties + later
   source wins meant:
     - the base `.j-fab { border: none; box-shadow: var(--shadow-floating) }`
       clobbered the HC `border: 2px solid ButtonBorder; box-shadow: none`
       (the FAB lost its visible boundary AND the box-shadow stayed
       declared, which forced-colors flattens — so the FAB rendered
       as a borderless silhouette under HC),
     - the base `.j-fab-theme { background: var(--color-theme-700);
       color: var(--color-neutral-100) }` clobbered the HC
       `background: Highlight; color: HighlightText` recipe.
   PR-A 2026-05-21 (sibling to PR #161). The .j-fab:focus-visible
   Med-severity entry stays in the centralized block pending PR-B. */
@media (forced-colors: active) {
  .j-fab {
    border: 2px solid ButtonBorder;
    box-shadow: none;
  }
  .j-fab-theme {
    background: Highlight;
    color: HighlightText;
    border: 2px solid ButtonBorder;
  }
}

/* ── Toggle (pressed button) ─────────────────────── */
.j-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-compact);
  background: transparent;
  color: var(--color-neutral-700);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  white-space: nowrap;
  transition:
    background var(--motion-feedback-button-press) var(--ease-snap),
    color var(--motion-feedback-button-press) var(--ease-snap),
    border-color var(--motion-feedback-button-press) var(--ease-snap),
    transform var(--motion-feedback-button-press) var(--ease-snap);
}

/* Sizes */
.j-toggle-md {
  padding: var(--sp-xs) var(--sp-sm-p);
  font-size: var(--type-small);
  min-height: var(--touch-min);
}
.j-toggle-sm {
  padding: var(--sp-xs) var(--sp-sm);
  font-size: var(--type-label);
  min-height: var(--touch-compact);
}

/* Pressed state — tonal fill, no border emphasis.
   Mirrors .j-btn-primary: solid surface-inverse bg, light fg.
   Border becomes transparent (the fill IS the boundary). */
/* v5.3.0: compound selector (specificity 0,2,0) wins over the base
   `.j-toggle` (0,1,0) regardless of source order. Prior to recompound,
   `.j-toggle-pressed` at equal specificity (0,1,0) relied on source-order
   cascade — same trap as PR #200's Select focused-option collision.
   Caught by PR #202's cascade-order guard. See ADR-036 for the v6 cascade-layers
   migration that makes state-vs-base resolution architecturally explicit. */
.j-toggle.j-toggle-pressed {
  background: var(--surface-inverse);
  color: var(--fg-on-dark);
  border-color: transparent;
}

/* Hover — scoped to pointer devices */
@media (hover: hover) {
  .j-toggle:hover:not(:disabled) {
    background: var(--color-neutral-200);
    color: var(--color-neutral-900);
  }
  .j-toggle-pressed:hover:not(:disabled) {
    background: var(--color-neutral-700);
    color: var(--fg-on-dark);
  }
}

/* Active (tap feedback) — scale on all toggles, tonal bg only on unpressed */
.j-toggle:not(:disabled):active {
  transform: scale(var(--scale-tapped));
}
.j-toggle:not(.j-toggle-pressed):not(:disabled):active {
  background: var(--color-neutral-200);
}

/* Disabled */
.j-toggle:disabled {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

/* Focus */
.j-toggle:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  box-shadow: none;
}

/* ── ToggleGroup ─────────────────────────────────── */
.j-toggle-group {
  display: inline-flex;
  gap: 0;
}
.j-toggle-group-vertical {
  flex-direction: column;
}

/* Connected borders — middle items share borders, corners removed.
   A thin divider line between adjacent pressed items prevents them
   from merging into one indistinguishable dark block. */
.j-toggle-group > .j-toggle:not(:first-child) {
  margin-inline-start: calc(-1 * var(--bw-hairline));
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}
.j-toggle-group > .j-toggle:not(:last-child) {
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}
/* Pressed items in group: restore a subtle inline-start divider so
   adjacent pressed items remain visually distinct. */
.j-toggle-group > .j-toggle-pressed:not(:first-child) {
  border-inline-start: var(--bw-hairline) solid var(--color-neutral-700);
}
/* Vertical group */
.j-toggle-group-vertical > .j-toggle:not(:first-child) {
  margin-block-start: calc(-1 * var(--bw-hairline));
  margin-inline-start: 0;
  border-start-start-radius: 0;
  border-start-end-radius: 0;
  border-end-start-radius: 0;
  border-end-end-radius: 0;
}
.j-toggle-group-vertical > .j-toggle:not(:last-child) {
  border-end-start-radius: 0;
  border-end-end-radius: 0;
  border-start-start-radius: 0;
  border-start-end-radius: 0;
}
.j-toggle-group-vertical > .j-toggle-pressed:not(:first-child) {
  border-block-start: var(--bw-hairline) solid var(--color-neutral-700);
}
.j-toggle-group-vertical > .j-toggle:first-child {
  border-start-start-radius: var(--r-compact);
  border-start-end-radius: var(--r-compact);
}
.j-toggle-group-vertical > .j-toggle:last-child {
  border-end-start-radius: var(--r-compact);
  border-end-end-radius: var(--r-compact);
}

/* Toggle — forced-colors (Windows High Contrast).
   Co-located with the base .j-toggle / .j-toggle-pressed rules
   (above, including the ToggleGroup variants) so that source order
   resolves the cascade correctly. The centralized
   `@media (forced-colors: active)` block earlier in the file declared
   these HC rules BEFORE the base — equal-specificity ties + later
   source wins meant:
     - the base `.j-toggle { border: var(--bw-hairline) solid
       var(--rule-on-layer) }` clobbered the HC `border: 1px solid
       ButtonBorder`, and
     - the base `.j-toggle-pressed { background + color + border-color }`
       clobbered the HC `background: Highlight; color: HighlightText;
       border-color: Highlight` (the pressed-state visual identity).
   PR-A 2026-05-21 (sibling to PR #161). The .j-toggle:focus-visible
   Med-severity entry stays in the centralized block pending PR-B. */
@media (forced-colors: active) {
  .j-toggle {
    border: 1px solid ButtonBorder;
  }
  /* v5.4 task #116 (codex review round 1): compound selector matches
     the base pressed rule `.j-toggle.j-toggle-pressed` (specificity
     0,2,0). The previous bare `.j-toggle-pressed` selector (0,1,0)
     lost the cascade to the base regardless of source order — the
     v5.3.0 recompound of the base pressed rule was incomplete and
     left this forced-colors entry mismatched. Compounding here
     closes the gap and pins the high-contrast rest-state pressed
     identity. */
  .j-toggle.j-toggle-pressed {
    background: Highlight;
    color: HighlightText;
    border-color: Highlight;
  }
  /* v5.4 task #116 (codex review round 2): the hover variant of the
     pressed state has specificity 0,3,0 at
     `.j-toggle-pressed:hover:not(:disabled)` (line ~5430, inside
     `@media (hover: hover)`) and sets `background` + `color`. Under
     `forced-colors: active` AND `hover: hover` AND pointer-over the
     pressed toggle, that hover rule (0,3,0) would win over a 0,2,0
     forced-colors pressed entry regardless of source order, and the
     HC pressed identity would silently revert to the tonal-press
     palette. Restating the HC pressed identity at the matching
     0,3,0 specificity closes that gap. The `:not(:disabled)` clause
     mirrors the hover rule's pattern (disabled toggles don't take
     hover or pressed escalation). */
  .j-toggle.j-toggle-pressed:hover:not(:disabled) {
    background: Highlight;
    color: HighlightText;
  }
}

/* Toggle — prefers-contrast: more (high-contrast escalation).
   Co-located with the base .j-toggle / .j-toggle-pressed rules
   (above, including the ToggleGroup variants) so source order
   resolves the cascade correctly. The general prefers-contrast block
   earlier in the file (around the IconButton section) used to host
   these declarations; codex flagged a SECOND-ORDER cascade bug there
   beyond simple equal-specificity-tie + later-source-wins (the
   pattern PR #161 / #166 already addressed for forced-colors and
   segmented-prefers-contrast respectively):

     SHORTHAND-RESETS-LONGHAND. The prefers-contrast declarations are
     longhands (`border-color`, `border-width`,
     `border-inline-start-color`, `border-block-start-color`). The
     Toggle base rules use SHORTHANDS:
       - `.j-toggle { border: var(--bw-hairline) solid var(--rule-on-layer) }`
       - `.j-toggle-group > .j-toggle-pressed:not(:first-child)
            { border-inline-start: var(--bw-hairline) solid var(--color-neutral-700) }`
       - `.j-toggle-group-vertical > .j-toggle-pressed:not(:first-child)
            { border-block-start: var(--bw-hairline) solid var(--color-neutral-700) }`

     Per the CSS spec, a `border` / `border-inline-start` /
     `border-block-start` shorthand expands at parse time into all of
     its longhands and RESETS each one to the shorthand's value (or
     the property's initial value for the longhands the shorthand
     does not address). So even though the property NAMES were
     different (`border-color` vs `border`), the base shorthand
     declared LATER in source order silently clobbered the
     prefers-contrast longhand. The high-contrast escalation never
     painted under `(prefers-contrast: more)` without `(forced-colors:
     active)`. Source-grep regression test:
     `src/test/prefers-contrast-toggle-cascade.test.ts`.

   The `.j-toggle-pressed` border-color override is intentionally
   omitted here: v5.3.0 recompounded the pressed base selector to
   `.j-toggle.j-toggle-pressed { … border-color: transparent }`
   (0,2,0) — a longhand, not a shorthand — so there's no shorthand
   reset to fix on that path. The Windows-HC pressed identity
   (background / color / border-color) is owned by the
   `.j-toggle.j-toggle-pressed` rules inside the forced-colors block
   above — both the rest-state entry (compounded to 0,2,0) and the
   hover variant (compounded to 0,4,0 to beat the
   `.j-toggle-pressed:hover:not(:disabled)` base rule at 0,3,0).
   Codex review at PR #206 caught both gaps:
     - Round 1: previous bare `.j-toggle-pressed` (0,1,0) lost to
       the 0,2,0 base — fixed by compounding the forced-colors entry.
     - Round 2: the hover-state cascade was still open at 0,2,0 vs
       0,3,0 — fixed by adding a dedicated
       `.j-toggle.j-toggle-pressed:hover:not(:disabled)` entry at
       0,4,0.
   The v5.3.0 recompound of the pressed base was incomplete on both
   the HC rest and HC hover surfaces; this PR completes both.
   Re-introducing a bare `.j-toggle-pressed` entry here at 0,1,0
   would re-open the rest-state trap this PR closes.

   v5.4 task #116 / sibling to PR #166 (same surgical extraction
   pattern, same media query, different component family). The audit
   that catalogued this bug is `docs/forced-colors-cascade-audit-
   2026-05-21.md` §2.2. */
@media (prefers-contrast: more) {
  .j-toggle {
    border-color: var(--color-neutral-700);
    border-width: var(--bw-standard);
  }
  /* v5.4 task #116 codex r3: compound the pressed-state entry to 0,2,0
     so it wins over the base `.j-toggle.j-toggle-pressed { border-color:
     transparent }` (also 0,2,0). Without this, the @media rule above
     (specificity 0,1,0) loses on pressed toggles in high-contrast mode
     and border-color stays transparent while border-width still bumps
     — thicker invisible border. Same trap class as PR #200's Select
     focused-option collision, manifesting in conditional @-rule scope
     (cascade-order guard's documented blind spot, tracked v5.4 #131). */
  .j-toggle.j-toggle-pressed {
    border-color: var(--color-neutral-700);
    border-width: var(--bw-standard);
  }
  .j-toggle-group > .j-toggle-pressed:not(:first-child) {
    border-inline-start-color: var(--color-neutral-100);
  }
  .j-toggle-group-vertical > .j-toggle-pressed:not(:first-child) {
    border-block-start-color: var(--color-neutral-100);
  }
}

/* ── SplitButton ─────────────────────────────────── */
.j-split-btn {
  display: inline-flex;
  align-items: stretch;
  position: relative;
}

/* Primary action — remove trailing radius */
.j-split-btn-action {
  border-start-end-radius: 0;
  border-end-end-radius: 0;
  border-inline-end: none;
}

/* Divider between zones */
.j-split-btn-divider {
  width: var(--bw-hairline);
  align-self: stretch;
  flex-shrink: 0;
}
/* Divider color per intent */
.j-split-btn .j-btn-primary + .j-split-btn-divider {
  background: color-mix(in srgb, var(--color-neutral-100) 20%, transparent);
}
.j-split-btn .j-btn-secondary + .j-split-btn-divider,
.j-split-btn .j-btn-ghost + .j-split-btn-divider {
  /* See .j-switch-track / .j-modal-header — neutral-300 == --surface-0
     post-flip, so a ghost split-button on the page lost its internal
     divider (codex audit #107 R3). */
  background: var(--rule-on-layer);
}
.j-split-btn .j-btn-destructive + .j-split-btn-divider {
  background: color-mix(in srgb, var(--color-neutral-100) 20%, transparent);
}
.j-split-btn .j-btn-tinted + .j-split-btn-divider {
  background: color-mix(in srgb, var(--color-theme-500) 40%, transparent);
}
.j-split-btn .j-btn-theme + .j-split-btn-divider {
  background: color-mix(in srgb, var(--color-neutral-100) 20%, transparent);
}

/* Disabled: dim divider when adjacent button is disabled */
.j-split-btn .j-btn:disabled + .j-split-btn-divider {
  opacity: var(--op-dimmed);
}

/* Menu trigger — remove leading radius, square-ish */
.j-split-btn-trigger {
  border-start-start-radius: 0;
  border-end-start-radius: 0;
  border-inline-start: none;
  /* Override padding for the narrow trigger */
  padding-inline: var(--sp-sm) !important;
}

/* Chevron icon in trigger */
.j-split-btn-chevron {
  display: inline-flex;
  transition: transform var(--motion-feedback-button-press) var(--ease-snap);
}
.j-split-btn-trigger[aria-expanded='true'] .j-split-btn-chevron {
  transform: rotate(180deg);
}

/* SplitButton menu — positioning override for portal usage.
   Visual surface, items, hover, and keyboard styles are inherited
   from the shared .j-menu / .j-menu-item classes. */
.j-split-btn-menu {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + var(--sp-xs));
  z-index: var(--z-fab, 50);
  min-width: max(180px, 100%);
  transform-origin: top right;
}

/* ── Link ────────────────────────────────────────── */
.j-link {
  color: var(--color-theme-700);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  transition: color var(--motion-feedback-button-press) var(--ease-out);
  border-radius: var(--r-micro);
}

/* Inline: always underlined */
.j-link-inline {
  text-decoration: underline;
  text-decoration-color: var(--color-theme-500);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

/* Standalone: underline on hover only */
.j-link-standalone {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  font-weight: 500;
  letter-spacing: var(--track-compact);
}

/* Standalone sizes */
.j-link-standalone.j-link-md {
  font-size: var(--type-small);
}
.j-link-standalone.j-link-sm {
  font-size: var(--type-label);
}

/* Muted intent */
.j-link-muted {
  color: var(--color-neutral-700);
}
.j-link-muted.j-link-inline {
  text-decoration-color: var(--color-neutral-500);
}

/* Hover — scoped to pointer devices */
@media (hover: hover) {
  .j-link:hover {
    color: var(--color-theme-500);
  }
  .j-link-standalone:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .j-link-muted:hover {
    color: var(--color-neutral-900);
  }
}

/* Active/pressed */
.j-link:active {
  color: var(--color-theme-700);
  opacity: var(--op-press-fb);
}

/* Focus visible */
.j-link:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
  text-decoration: none;
}

/* Visited — opt-in via class */
.j-link-visited:visited {
  color: var(--color-neutral-700);
}
.j-link-visited:visited.j-link-inline {
  text-decoration-color: var(--color-neutral-500);
}

/* External icon */
.j-link-external-icon {
  display: inline-flex;
  flex-shrink: 0;
  width: 0.75em;
  height: 0.75em;
}

/* Link — forced-colors (Windows High Contrast).
   Co-located with the base .j-link rule (above) so that source order
   resolves the cascade correctly. The centralized
   `@media (forced-colors: active)` block earlier in the file declared
   this HC rule BEFORE the base — equal-specificity tie + later source
   wins meant the base `color: var(--color-theme-700)` clobbered the
   HC `color: LinkText`, so links rendered in the brand-theme palette
   instead of the system LinkText palette under Windows HC. PR-A
   2026-05-21 (sibling to PR #161). The :visited and :focus-visible
   Med-severity entries stay in the centralized block pending PR-B —
   the :visited selector-mismatch issue (audit Q4) needs its own
   selector-alignment fix and is intentionally left for that PR. */
@media (forced-colors: active) {
  .j-link {
    color: LinkText;
  }
}

/* ── Reduced motion respects ──────────────────────── */
/* Catch-all rule: anything that animates or transitions inside the kit
   collapses to a near-instant change AND drops the entrance transforms
   entirely — WCAG 2.3.3 (Animation from Interactions) considers
   translate/scale entrances as motion, not just duration. A reduce-
   motion user still gets the opacity fade (to signal the state change)
   but never the y-translate / scale pop. */
@media (prefers-reduced-motion: reduce) {
  /* `:where()` drops this catch-all to specificity (0,0,0) so per-
     primitive reduced-motion overrides with their own !important can
     win on the specificity tiebreak among !important rules. Before
     this wrap, the catch-all and a per-primitive override BOTH had
     specificity (0,1,0) with !important — same-strength same-
     specificity → source-order tiebreak → catch-all (later) won, so
     overrides like `.j-skeleton { animation: none !important }` and
     `.j-spinner { animation-iteration-count: infinite !important }`
     were silently dead. Codex adversarial review 2026-05-19 r2 caught
     this. The (0,0,0) `:where()` wrap still wins over non-!important
     component animations (e.g., `.j-modal-sheet { animation: j-pop }`)
     because !important beats no-!important regardless of specificity,
     so the catch-all retains its load-bearing role for primitives
     that don't declare their own override. */
  :where(
    [class^='j-'],
    [class*=' j-'],
    .j-modal-overlay,
    .j-modal-sheet,
    .j-progress-fill,
    .j-accordion-chevron
  ) {
    /* prefers-reduced-motion floor: collapse every kit transition/
       animation to button-press speed (60ms). Using the semantic
       --motion-feedback-button-press token (which resolves to
       --dur-micro) keeps the kit's "all motion via semantic tokens"
       contract intact even at the reduced-motion override layer. */
    transition-duration: var(--motion-feedback-button-press) !important;
    animation-duration: var(--motion-feedback-button-press) !important;
    animation-iteration-count: 1 !important;
  }

  /* Drop all kit-originated transforms. Applies to the modal sheet's
     y-translate entrance, the pop keyframes (scale 0.98 → 1), and the
     segmented / btn tap-scale feedback. The !important is intentional
     and scoped to kit selectors so app-level transforms aren't affected. */
  .j-modal-sheet,
  .j-btn:not(:disabled):active,
  .j-icon-btn:not(:disabled):active,
  .j-segmented-option:not([disabled]):active,
  .j-toggle:not(:disabled):active,
  .j-checkbox-label:active .j-checkbox-box,
  .j-radio-label:active .j-radio-circle,
  .j-bulk-bar-clear:not(:disabled):active,
  .j-card-interactive:hover,
  .comp-pop-animate,
  .j-popover,
  .j-split-btn-chevron,
  .j-bulk-bar {
    transform: none !important;
  }
  .j-toast,
  .j-popover,
  .j-bulk-bar,
  .j-menu,
  .j-split-btn-menu {
    animation-name: j-fade !important;
  }
  .j-fab:hover:not(:disabled),
  .j-fab:not(:disabled):active {
    transform: none !important;
    box-shadow: var(--shadow-floating) !important;
  }
  .j-fab-bottom-center:hover:not(:disabled),
  .j-fab-bottom-center:not(:disabled):active {
    transform: translateX(-50%) !important;
    box-shadow: var(--shadow-floating) !important;
  }
  .j-fab-hidden {
    transform: none !important;
    opacity: 0;
  }
  .j-fab-hidden.j-fab-bottom-center {
    transform: translateX(-50%) !important;
    opacity: 0;
  }
  .j-fab {
    transition-property: background, color, opacity !important;
  }
}

/* ── Color Picker ─────────────────────────────────── */

/* Root is a block-level flex column — fills parent width so the
   wrapping swatch grid below uses the available horizontal space.
   Previous `inline-flex` root collapsed the CSS grid's `auto-fill`
   tracks to a single column (shrink-to-fit parent gave the grid no
   width budget to lay out against — verified empirically with
   `getBoundingClientRect().width === 32` in a 598 px card). */
.j-color-picker {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  forced-color-adjust: auto;
}

.j-color-picker-grid {
  /* Flex-wrap > grid here: fixed-size swatches lay out tightly and
     wrap to fill the parent's width regardless of intrinsic-vs-
     definite-size context. Common pattern in Material / shadcn
     palette pickers. */
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}

.j-color-picker-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: var(--touch-compact);
  block-size: var(--touch-compact);
  padding: 0;
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-compact);
  background: var(--swatch-bg, var(--surface-0));
  color: var(--swatch-fg, var(--fg-1));
  cursor: pointer;
  forced-color-adjust: none;
  /* The hover-lift uses transform: scale(--scale-lifted); under the old
     60ms duration the lift snapped instead of easing in. Quick/out gives
     it the same cadence as .j-card-interactive's hover translate. */
  transition:
    border-color var(--motion-feedback-hover) var(--ease-out),
    transform var(--motion-feedback-hover) var(--ease-out);
}

.j-color-picker-sm .j-color-picker-swatch {
  inline-size: calc(var(--touch-compact) - var(--sp-xs));
  block-size: calc(var(--touch-compact) - var(--sp-xs));
}

@media (hover: hover) {
  .j-color-picker-swatch:hover:not(:disabled) {
    transform: scale(var(--scale-lifted));
  }
}

@media (prefers-reduced-motion: reduce) {
  .j-color-picker-swatch {
    transition: none;
  }
  .j-color-picker-swatch:hover:not(:disabled) {
    transform: none;
  }
}

.j-color-picker-swatch:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
}

.j-color-picker-swatch[data-checked='true'] {
  border-color: var(--color-neutral-700);
  border-width: var(--bw-standard);
}

.j-color-picker-swatch:disabled {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

/* Hex input composed inside a Field — leading chip shows the live
   colour preview, input renders via the standard .j-input style. */
.j-color-picker-input-field.j-field {
  inline-size: 100%;
  min-block-size: var(--touch-compact);
}

.j-color-picker-input-field.j-color-picker-input-error.j-field {
  border-color: var(--color-error-700);
}

.j-color-picker-input {
  font-family: var(--font-mono);
}

.j-color-picker-input-chip {
  display: inline-block;
  inline-size: var(--sp-md);
  block-size: var(--sp-md);
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-compact);
  background: var(--swatch-bg, transparent);
  forced-color-adjust: none;
}

@media (forced-colors: active) {
  .j-color-picker-swatch {
    border: 2px solid ButtonBorder;
  }
  .j-color-picker-swatch[data-checked='true'] {
    border-color: Highlight;
  }
  .j-color-picker-swatch:focus-visible {
    outline: 2px solid Highlight;
  }
  .j-color-picker-input-chip {
    border: 1px solid ButtonBorder;
  }
}

[data-a11y-preset='aaa'] .j-color-picker-swatch {
  border-width: var(--bw-standard);
}

/* ── Time Picker ──────────────────────────────────── */

/* Thin wrapper around a native `<input type="time">`. All keyboard,
   accessibility, mobile picker, validation, and bounds handling is
   delegated to the browser (ADR-005 Tier 1 system-control
   substitution). Visual chrome lives on the Jacquard `<Field>`. */
.j-time-picker {
  display: inline-block;
  min-inline-size: calc(3 * var(--sp-4xl));
}

.j-time-picker-sm .j-field {
  min-block-size: var(--touch-compact);
}

.j-time-picker-input {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  /* Strip the dated desktop UA chrome — the up/down hour-minute
     spinner and the dropdown indicator both render as 1990s
     stair-stepping carousels on macOS and Windows. The input still
     accepts typed HH:mm and still surfaces the OS-native picker on
     mobile (taps trigger it directly), so we lose nothing functional
     but get a clean Jacquard-shaped field. */
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  outline: none;
  padding: 0;
  margin: 0;
  font-size: var(--type-small);
  color: var(--fg-1);
  inline-size: 100%;
  min-block-size: var(--touch-min);
}

.j-time-picker-input::-webkit-inner-spin-button,
.j-time-picker-input::-webkit-outer-spin-button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  display: none;
}

.j-time-picker-input::-webkit-calendar-picker-indicator {
  /* Hide the desktop UA dropdown indicator entirely — it triggered the
     dated browser carousel popover. Mobile UAs surface their native
     time picker on input tap, not via this indicator, so removing it
     is safe across platforms. */
  display: none;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.j-time-picker-input::placeholder {
  color: var(--fg-3);
}

.j-time-picker-field-error.j-field {
  border-color: var(--color-error-700);
}

@media (forced-colors: active) {
  .j-time-picker-field-error.j-field {
    border-color: Mark;
  }
}

/* ── Rating ───────────────────────────────────────── */

.j-rating {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  forced-color-adjust: auto;
}

.j-rating-items {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
}

.j-rating-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: var(--touch-min);
  block-size: var(--touch-min);
  padding: 0;
  border: 0;
  border-radius: var(--r-compact);
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
  /* Quick/out so the hover-preview "warms up" rather than snaps —
     critical for the preview state to feel distinct from a confirmed
     fill (which doesn't transition on commit). */
  transition:
    color var(--motion-feedback-hover) var(--ease-out),
    background var(--motion-feedback-hover) var(--ease-out);
}

.j-rating-sm .j-rating-item {
  inline-size: var(--touch-compact);
  block-size: var(--touch-compact);
}

.j-rating-item:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
}

/* Committed star — filled (Lucide receives fill="currentColor" in JSX). */
.j-rating-item[data-filled='true'] {
  color: var(--color-theme-500);
}

/* Hover preview — outline-only, theme-stroked. Distinct from the
   confirmed filled state so the user can tell "considered" from
   "committed". JSX passes fill="none" when data-filled is absent. */
.j-rating-item[data-preview='true'] {
  color: var(--color-theme-500);
}

.j-rating-item:disabled {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

.j-rating-item-static {
  cursor: default;
}

.j-rating-value {
  font-size: var(--type-label);
  color: var(--fg-1);
  white-space: nowrap;
}

@media (forced-colors: active) {
  .j-rating-item {
    color: CanvasText;
  }
  .j-rating-item[data-filled='true'],
  .j-rating-item[data-preview='true'] {
    color: Highlight;
  }
  .j-rating-item:focus-visible {
    outline: 2px solid Highlight;
  }
}

/* ── Transfer ─────────────────────────────────────── */

.j-transfer {
  /* Outer wrapper IS the query container. Container queries only
     apply to a container's descendants — restyling `.j-transfer`
     itself via its own @container rule was a no-op (Codex #medium).
     Layout grid lives on `.j-transfer-layout` (a descendant) so the
     narrow-viewport stack actually fires.

     `inline-size: 100%` fills the flex parent — without it the root
     collapses to 0 width and the grid below has no width budget
     (verified in headless Chrome). */
  display: block;
  inline-size: 100%;
  container-type: inline-size;
  forced-color-adjust: auto;
}

.j-transfer-layout {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--sp-lg);
  align-items: stretch;
}

/* Breakpoint cross-reference: the 480px literal below mirrors
   `--bp-xs: 480px` in tokens.css (source-of-truth at
   tokens/reference/dimension.json#bp.xs). CSS container-query
   conditions cannot consume var(), so the literal here is the
   kit-side restatement; any change to --bp-xs MUST match here.
   See ADR-011 for the xs (phone-only) escalation rationale. */
@container (max-width: 480px) {
  .j-transfer-layout {
    grid-template-columns: 1fr;
  }
  .j-transfer-layout .j-transfer-actions {
    flex-direction: row;
    justify-self: center;
    flex-wrap: wrap;
  }
}

.j-transfer-pool {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  min-block-size: calc(10 * var(--touch-compact));
  padding: var(--sp-md);
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-control);
  background: var(--surface-0);
}

.j-transfer-pool[data-error='true'] {
  border-color: var(--color-error-700);
}

.j-transfer-pool-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-sm);
  padding-block-end: var(--sp-xs);
  border-block-end: var(--bw-hairline) solid var(--rule-on-layer);
  font-size: var(--type-label);
  font-weight: 600;
  color: var(--fg-1);
  letter-spacing: 0.02em;
}

.j-transfer-pool-count {
  color: var(--fg-3);
  font-weight: 400;
  font-size: var(--type-caption);
  white-space: nowrap;
}

.j-transfer-search {
  inline-size: 100%;
  min-block-size: var(--touch-compact);
  padding: 0 var(--sp-sm);
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-compact);
  /* Field-adjacent (search input inside a transfer panel) — routes
     through --field-bg per ADR-029 v5.1 amendment. */
  background: var(--field-bg);
  color: var(--fg-1);
  font-size: var(--type-small);
  forced-color-adjust: auto;
  transition:
    border-color var(--motion-feedback-field-focus) var(--ease-snap),
    box-shadow var(--motion-feedback-field-focus) var(--ease-snap);
}

.j-transfer-search:focus-visible {
  outline: none;
  border-color: var(--color-theme-500);
  box-shadow: var(--focus-ring);
}

.j-transfer-listbox {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  flex: 1;
  min-block-size: calc(8 * var(--touch-compact));
  max-block-size: calc(12 * var(--touch-compact));
  overflow-y: auto;
  padding-block: var(--sp-xs);
  padding-inline: 0;
}

.j-transfer-option {
  display: flex;
  align-items: center;
  min-block-size: var(--touch-compact);
  padding: 0 var(--sp-sm);
  border: var(--bw-hairline) solid transparent;
  border-radius: var(--r-compact);
  background: transparent;
  color: var(--fg-1);
  font-size: var(--type-small);
  text-align: start;
  cursor: pointer;
  /* Quick/out for marked + hover crossfade — the previous 60ms made
     marking and hover both feel instantaneous, which read as "buggy"
     rather than responsive. Filter is included so the marked-hover
     brightness lift eases instead of snapping. */
  transition:
    background var(--motion-feedback-hover) var(--ease-out),
    border-color var(--motion-feedback-hover) var(--ease-out),
    color var(--motion-feedback-hover) var(--ease-out),
    filter var(--motion-feedback-hover) var(--ease-out);
}

@media (hover: hover) {
  .j-transfer-option:hover:not(:disabled):not([data-marked='true']) {
    background: var(--color-neutral-200);
  }
  /* Hover-over-marked: flip from saturated theme-700 / neutral-50 →
     pale theme-100 / theme-700 (same pattern as the calendar selected-
     cell hover). The token pair flips automatically in dark mode, so
     contrast holds in both. */
  .j-transfer-option[data-marked='true']:hover:not(:disabled) {
    background: var(--color-theme-100);
    color: var(--color-theme-700);
    border-color: var(--color-theme-100);
  }
}

.j-transfer-option:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: -2px;
}

.j-transfer-option[data-marked='true'] {
  background: var(--color-theme-700);
  color: var(--color-neutral-100);
  border-color: var(--color-theme-700);
}

.j-transfer-option:disabled {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

.j-transfer-empty {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: var(--sp-md);
  color: var(--fg-3);
  font-size: var(--type-small);
  text-align: center;
}

.j-transfer-actions {
  display: flex;
  flex-direction: column;
  align-self: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm);
}

.j-transfer-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: var(--touch-min);
  min-block-size: var(--touch-min);
  padding: 0 var(--sp-xs);
  border: var(--bw-hairline) solid var(--rule-on-layer);
  border-radius: var(--r-compact);
  /* Field-family control (touch-min button with --rule-on-layer
     border) — routes through --field-bg per ADR-029 v5.1 amendment
     so it tones with the surrounding transfer panel's field tier. */
  background: var(--field-bg);
  color: var(--fg-1);
  cursor: pointer;
  /* Quick/out — these are button-shaped controls; matching the
     card-interactive cadence reads as "smooth response" rather than
     the old 60ms snap. */
  transition:
    background var(--motion-feedback-hover) var(--ease-out),
    border-color var(--motion-feedback-hover) var(--ease-out),
    color var(--motion-feedback-hover) var(--ease-out);
}

@media (hover: hover) {
  .j-transfer-action:hover:not(:disabled) {
    background: var(--color-theme-100);
    border-color: var(--color-theme-500);
    color: var(--color-theme-700);
  }
}

.j-transfer-action:focus-visible {
  outline: var(--bw-selection) solid var(--focus-ring-color);
  outline-offset: 2px;
}

.j-transfer-action:disabled {
  cursor: not-allowed;
  opacity: var(--op-dimmed);
}

.j-transfer-announce {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (forced-colors: active) {
  .j-transfer-pool {
    border: 1px solid ButtonBorder;
    background: Canvas;
    color: CanvasText;
  }
  .j-transfer-search {
    border: 1px solid ButtonBorder;
    background: ButtonFace;
    color: ButtonText;
  }
  .j-transfer-search:focus-visible,
  .j-transfer-option:focus-visible,
  .j-transfer-action:focus-visible {
    outline: 2px solid Highlight;
  }
  .j-transfer-option {
    color: CanvasText;
  }
  .j-transfer-option[data-marked='true'] {
    background: Highlight;
    color: HighlightText;
  }
  .j-transfer-action {
    border: 1px solid ButtonBorder;
    background: ButtonFace;
    color: ButtonText;
  }
}

/* Date Picker / Calendar boundary live region — visually hidden,
   announced by screen readers when ArrowLeft/Right hits a hard
   min/max boundary with no enabled date in the requested direction. */
.j-datepicker-announce {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
