/* =============================================================================
   SectraTEK components v1.1 (Phase 1 stage B). CANONICAL SOURCE: this file and ./parts/ in
   packages/design-system (ADR-010 decision 3 and 4). docs/design/components/components.css is the
   historical Phase 0 reference and is no longer edited.

   This file only lists the parts, in cascade order. `pnpm build` inlines them into dist/components.css
   (and the minified copy). Plain CSS, BEM-like names (.block, .block__element, .block--modifier, state via
   aria-* and .is-*). Requires tokens.css. No inline styles, no data: URIs, no remote URLs, no hand-typed
   durations, easings or colors (stylelint, `pnpm lint:css`); the only color literals are in
   parts/00-constants.css.

   Conventions
   - Layers: base < components < utilities. Unlayered page CSS always wins.
   - Motion: only transform, opacity and clip-path animate (plus the discrete display and overlay
     properties for dialogs and popovers). Hover and press use state layers: a ::before overlay whose
     opacity changes.
   - States: every interactive component supports hover, focus-visible, active, disabled and (where it
     makes sense) loading. Pinning classes .is-hover, .is-active, .is-focus exist for the gallery and for
     visual regression tests.
   - Themes: tokens switch light, dark and forced colors; the forced-colors block of each component only
     adds what system colors need (borders, outlines, selected indicators).
   - Reduced motion: tokens zero the shifts and shorten the durations; components additionally stop
     animation loops (spinner, pulse, live dot) and show a static equivalent.
   - Density: data-density="comfortable|compact|dense" on any container.
   - Cross-document view transitions are NOT here: the apps must not load them (gap 3.1 of the app
     prototypes). The public site adds site-transitions.css.
   ============================================================================= */
@layer base, components, utilities;

/* =============================================================================
   Component constants. The ONLY component-layer file allowed to hold color literals (the stylelint
   rule sectra/color-tokens-only allows them here and in src/tokens). These are the pure black and
   white overlays and the thumb shadow that the Phase 0 CSS typed by hand: state layers, the logo tile,
   print. They do not change with the theme. Every other file reads tokens or these names.
   ============================================================================= */
:root {
  --black: #000000;
  --white: #ffffff;
  --logo-tile: #ffffff;        /* the tile behind the official logo PNG; it stays white in every theme */
  --white-12: rgb(255 255 255 / 0.12);
  --white-18: rgb(255 255 255 / 0.18);
  --white-22: rgb(255 255 255 / 0.22);
  --shadow-thumb: 0 1px 3px rgb(0 0 0 / 0.3);
}

/* =============================================================================
   BASE
   ============================================================================= */
@layer base {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; tab-size: 4; }
  @media (prefers-reduced-motion: no-preference) { html:not([data-motion="reduce"]) { scroll-behavior: smooth; } }
  body {
    margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
    font: var(--weight-regular) var(--text-body) / var(--lh-body) var(--font-sans);
    letter-spacing: var(--track-body);
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  }
  :where(h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol, pre) { margin: 0; }
  :where(ul, ol) { padding-inline-start: 1.25em; }
  :where(img, video, canvas) { display: block; max-width: 100%; height: auto; }
  :where(svg) { max-width: 100%; }
  :where(button, input, select, textarea) { font: inherit; color: inherit; letter-spacing: inherit; }
  :where(button) { cursor: pointer; }
  :where(hr) { border: 0; border-block-start: 1px solid var(--line); margin: var(--space-6) 0; }
  :where(table) { border-collapse: collapse; }
  [hidden] { display: none !important; }
  ::selection { background: var(--selection); }

  h1, h2, h3, h4 { font-weight: var(--weight-semibold); color: var(--ink); text-wrap: balance; }
  h1 { font-size: var(--text-h1); line-height: var(--lh-h1); letter-spacing: var(--track-h1); }
  h2 { font-size: var(--text-h2); line-height: var(--lh-h2); letter-spacing: var(--track-h2); }
  h3 { font-size: var(--text-h3); line-height: var(--lh-h3); letter-spacing: var(--track-h3); }
  h4 { font-size: var(--text-h4); line-height: var(--lh-h4); letter-spacing: var(--track-h4); }
  p { text-wrap: pretty; }
  small { font-size: var(--text-small); }
  strong, b { font-weight: var(--weight-semibold); }
  code, kbd, samp, pre { font-family: var(--font-mono); font-size: var(--text-mono); letter-spacing: 0; }

  a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
  a:hover { color: var(--link-hover); text-decoration-thickness: 2px; }

  /* Focus: one ring, everywhere, no transition (plan 11.5.1). */
  :where(a, button, input, select, textarea, summary, [tabindex], [role="button"], [role="tab"], [role="menuitem"], [role="option"]):focus-visible,
  .is-focus {
    outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset);
  }
  :where(input, select, textarea):focus-visible { outline-offset: 0; }
  :focus:not(:focus-visible) { outline: none; }
}

/* =============================================================================
   TYPOGRAPHY, LAYOUT, UTILITIES (a small, deliberate set)
   ============================================================================= */
@layer components {
  .display { font-size: var(--text-display); line-height: var(--lh-display); letter-spacing: var(--track-display); font-weight: var(--weight-semibold); text-wrap: balance; }
  .h1 { font-size: var(--text-h1); line-height: var(--lh-h1); letter-spacing: var(--track-h1); font-weight: var(--weight-semibold); text-wrap: balance; }
  .h2 { font-size: var(--text-h2); line-height: var(--lh-h2); letter-spacing: var(--track-h2); font-weight: var(--weight-semibold); text-wrap: balance; }
  .h3 { font-size: var(--text-h3); line-height: var(--lh-h3); letter-spacing: var(--track-h3); font-weight: var(--weight-semibold); }
  .h4 { font-size: var(--text-h4); line-height: var(--lh-h4); letter-spacing: var(--track-h4); font-weight: var(--weight-semibold); }
  .lead { font-size: var(--text-lead); line-height: var(--lh-lead); color: var(--ink-2); max-width: var(--measure); }
  .body { font-size: var(--text-body); line-height: var(--lh-body); }
  .ui { font-size: var(--text-ui-density); line-height: var(--lh-ui); letter-spacing: var(--track-ui); }
  .small { font-size: var(--text-small); line-height: var(--lh-small); }
  .caption { font-size: var(--text-caption); line-height: var(--lh-small); color: var(--muted); }
  .eyebrow { font-size: var(--text-caption); line-height: var(--lh-tight); letter-spacing: var(--track-eyebrow); text-transform: uppercase; font-weight: var(--weight-semibold); color: var(--link); }
  .mono { font-family: var(--font-mono); font-size: var(--text-mono); letter-spacing: 0; }
  .tabular { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
  .muted { color: var(--muted); }
  .ink-2 { color: var(--ink-2); }
  .prose { max-width: var(--measure); }
  .prose > * + * { margin-block-start: var(--space-4); }
  .prose > h2 { margin-block-start: var(--space-7); }
  .prose > h3 { margin-block-start: var(--space-6); }
  .prose li + li { margin-block-start: var(--space-1); }

  .container { width: 100%; max-width: calc(var(--content-max) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
  .container--wide { max-width: calc(var(--content-wide) + 2 * var(--gutter)); }
  .container--narrow { max-width: calc(46rem + 2 * var(--gutter)); }
  .section { padding-block: var(--section-y); }
  .section--tight { padding-block: var(--space-8); }
  .stack { display: flex; flex-direction: column; gap: var(--stack, var(--space-4)); }
  .stack--4 { --stack: var(--space-4); }
  .stack--1 { --stack: var(--space-1); } .stack--2 { --stack: var(--space-2); } .stack--3 { --stack: var(--space-3); }
  .stack--5 { --stack: var(--space-5); } .stack--6 { --stack: var(--space-6); } .stack--7 { --stack: var(--space-7); }
  .cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster, var(--space-3)); }
  .cluster--2 { --cluster: var(--space-2); } .cluster--4 { --cluster: var(--space-4); } .cluster--5 { --cluster: var(--space-5); }
  .cluster--between { justify-content: space-between; }
  .cluster--end { justify-content: flex-end; }
  .grid { display: grid; gap: var(--grid-gap, var(--space-5)); grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--min, 16rem)), 1fr)); }
  .grid--sm { --min: 12rem; } .grid--md { --min: 16rem; } .grid--lg { --min: 22rem; }
  .grid--gap-4 { --grid-gap: var(--space-4); } .grid--gap-6 { --grid-gap: var(--space-6); }
  .split { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 1fr); align-items: center; }
  @media (min-width: 64em) { .split { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--space-8); } }

  /* Bands: full-width page sections. Navy is for hero, header bar and footer attribution only. */
  .band { background: var(--bg); }
  .band--surface { background: var(--surface); }
  .band--navy {
    background: var(--grad-navy-hero); color: var(--on-navy);
    --ink: var(--on-navy); --ink-2: var(--on-navy-2); --muted: var(--on-navy-2);
    --link: var(--navy-accent); --link-hover: var(--on-navy); --focus: var(--focus-on-navy);
    --control-border: var(--navy-line); --line: var(--navy-line);
  }
  .band--navy h1, .band--navy h2, .band--navy h3, .band--navy h4 { color: var(--on-navy); }
  /* on-navy-2, not navy-accent: navy-accent over the lightest gradient stop (--glow) is 3.99:1 in light (gap 1 of the app prototypes) */
  .band--navy .eyebrow { color: var(--on-navy-2); }

  .sr-only, .visually-hidden {
    position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .skip-link {
    position: fixed; z-index: var(--z-skip); inset-block-start: var(--space-2); inset-inline-start: var(--space-2);
    padding: var(--space-3) var(--space-4); border-radius: var(--radius-ctl); background: var(--inverse-bg); color: var(--inverse-fg);
    font-weight: var(--weight-medium); text-decoration: none; transform: translateY(-200%);
  }
  .skip-link:focus-visible { transform: none; }
  .divider { border: 0; border-block-start: 1px solid var(--line); margin: 0; }
  .nowrap { white-space: nowrap; }
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

  /* Staggered entrance: classes only, never an inline style (SIT-12). Apply .enter on the
     parent or the item, then .d1 to .d6 on items. */
  .enter { animation: enter var(--dur-base) var(--ease-out) both; }
  .enter-hero { animation: enter-hero var(--dur-hero) var(--ease-out) both; }
  .d1 { animation-delay: calc(var(--stagger) * 1); } .d2 { animation-delay: calc(var(--stagger) * 2); }
  .d3 { animation-delay: calc(var(--stagger) * 3); } .d4 { animation-delay: calc(var(--stagger) * 4); }
  .d5 { animation-delay: calc(var(--stagger) * 5); } .d6 { animation-delay: calc(var(--stagger) * 6); }
  @keyframes enter { from { opacity: 0; transform: translateY(var(--shift-sm)); } to { opacity: 1; transform: none; } }
  @keyframes enter-hero { from { opacity: 0; transform: translateY(var(--shift-lg)); } to { opacity: 1; transform: none; } }

  /* Scroll reveal. Scroll-driven where supported; the 1 KB IntersectionObserver fallback in
     components.js adds .is-visible. Without either, content is simply visible (rule zero). */
  .reveal { opacity: 1; }
  @supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
      :root:not([data-motion="reduce"]) .reveal {
        animation: enter linear both; animation-timeline: view(); animation-range: entry 0% entry 55%;
      }
    }
  }
  @supports not (animation-timeline: view()) {
    .js .reveal { opacity: 0; transform: translateY(var(--shift-sm)); transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); }
    .js .reveal.is-visible { opacity: 1; transform: none; }
  }
}

/* =============================================================================
   ICON
   ============================================================================= */
@layer components {
  .icon {
    width: var(--icon-md); height: var(--icon-md); flex: none; display: inline-block; vertical-align: -0.2em;
    fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  }
  .icon--md { width: var(--icon-md); height: var(--icon-md); }
  .icon--sm { width: var(--icon-sm); height: var(--icon-sm); stroke-width: 1.75; }
  .icon--lg { width: var(--icon-lg); height: var(--icon-lg); }
  .icon--xl { width: var(--icon-xl); height: var(--icon-xl); stroke-width: 1.25; }
  .icon-tile {
    display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: var(--radius-md);
    background: var(--accent-soft); color: var(--link);
  }
  .icon-tile--lg { width: 56px; height: 56px; border-radius: var(--radius-card); }
  .icon-tile--success { background: var(--success-soft); color: var(--success-ink); }
  .icon-tile--warning { background: var(--warning-soft); color: var(--warning-ink); }
  .icon-tile--danger { background: var(--danger-soft); color: var(--danger-ink); }
  .icon-tile--neutral { background: var(--surface-3); color: var(--ink-2); }
  @media (forced-colors: active) { .icon-tile { border: 1px solid CanvasText; } }
}

/* =============================================================================
   BUTTONS (primary, secondary, tertiary, destructive-with-confirmation, icon, loading)
   Primary is SectraTEK blue. There is no red button (BRAND_TOKENS rule 3): a destructive
   action is blue-outlined, the danger color lives on the icon and the consequence text.
   ============================================================================= */
@layer components {
  .btn {
    --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-bd: var(--line-strong);
    --btn-state: var(--ink); --state-hover: 0.05; --state-active: 0.12;
    position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: var(--ctl-h); min-width: var(--target-min); padding: 0 var(--space-4);
    border: var(--bw) solid var(--btn-bd); border-radius: var(--radius-ctl); background: var(--btn-bg); color: var(--btn-fg);
    font-family: inherit; font-size: var(--text-ui-density); font-weight: var(--weight-medium); line-height: 1.2; letter-spacing: var(--track-ui);
    text-decoration: none; white-space: nowrap; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    transition: transform var(--dur-instant) var(--ease-out);
  }
  /* A button whose label is long (a file name) wraps on a phone instead of running past the screen edge */
  .btn { max-width: 100%; }
  @media (max-width: 40em) { .btn { white-space: normal; text-align: center; overflow-wrap: anywhere; padding-block: 8px; } }
  .btn::before {
    content: ""; position: absolute; inset: -1px; border-radius: inherit; z-index: -1; pointer-events: none;
    background: var(--btn-state); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out);
  }
  .btn:hover, .btn.is-hover { color: var(--btn-fg); text-decoration: none; }
  .btn:hover::before, .btn.is-hover::before { opacity: var(--state-hover); }
  .btn:active, .btn.is-active { transform: scale(var(--scale-press)); }
  .btn:active::before, .btn.is-active::before { opacity: var(--state-active); transition-duration: var(--dur-instant); }
  .btn .icon { margin-inline: -2px; }

  .btn--primary { --btn-bg: var(--accent-fill); --btn-fg: var(--on-accent); --btn-bd: var(--accent-fill); --btn-state: var(--black); --state-hover: 0.16; --state-active: 0.28; }
  .btn--secondary { }
  .btn--tertiary { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--link); --btn-state: var(--accent); --state-hover: 0.10; --state-active: 0.18; padding-inline: var(--space-3); }
  .btn--destructive { --btn-bg: transparent; --btn-bd: var(--accent); --btn-fg: var(--ink); --btn-state: var(--accent); --state-hover: 0.08; --state-active: 0.16; border-width: var(--bw-strong); }
  /* stylelint-disable-next-line sectra/status-colors-only -- BRAND_TOKENS rule 3: the danger color lives on the icon and the consequence text of a destructive action, never on the button */
  .btn--destructive .icon, .btn__icon--danger { color: var(--danger); }
  .btn--lg { min-height: var(--ctl-h-lg); padding-inline: var(--space-5); font-size: var(--text-body); }
  .btn--sm { min-height: var(--ctl-h-sm); padding-inline: var(--space-3); font-size: var(--text-small); border-radius: var(--radius-sm); }
  .btn--pill { border-radius: var(--radius-pill); }
  .btn--block { display: flex; width: 100%; }
  .btn--icon { width: var(--ctl-h); padding: 0; }
  .btn--icon.btn--sm { width: var(--ctl-h-sm); }
  .btn--icon.btn--lg { width: var(--ctl-h-lg); }
  .btn--icon .icon { margin: 0; }
  .btn--ghost-icon { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--ink-2); }

  /* Buttons on navy bands */
  .band--navy .btn--secondary, .on-navy .btn--secondary { --btn-bg: var(--white-12); --btn-bd: var(--navy-line); --btn-fg: var(--on-navy); --btn-state: var(--white); --state-hover: 0.10; --state-active: 0.18; }
  .band--navy .btn--tertiary, .on-navy .btn--tertiary { --btn-fg: var(--on-navy); --btn-state: var(--white); }

  /* Disabled */
  .btn:disabled, .btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; transform: none; }
  .btn:disabled::before, .btn[aria-disabled="true"]::before { display: none; }

  /* Loading: the label stays (and should change to a present participle), a spinner replaces the icon */
  .btn > .spinner { display: none; }
  .btn.is-loading, .btn[aria-busy="true"] { cursor: progress; pointer-events: none; }
  .btn.is-loading > .spinner, .btn[aria-busy="true"] > .spinner { display: inline-block; }
  .btn.is-loading > .icon, .btn[aria-busy="true"] > .icon { display: none; }

  /* Split group */
  .btn-group { display: inline-flex; }
  .btn-group > .btn:not(:first-child) { margin-inline-start: -1px; border-start-start-radius: 0; border-end-start-radius: 0; }
  .btn-group > .btn:not(:last-child) { border-start-end-radius: 0; border-end-end-radius: 0; }

  /* Passkey button: the preferred sign-in action */
  .passkey-btn {
    --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-bd: var(--line-strong); --btn-state: var(--ink); --state-hover: 0.05; --state-active: 0.12;
    position: relative; isolation: isolate; display: flex; align-items: center; gap: var(--space-3); width: 100%; text-align: start;
    min-height: 64px; padding: var(--space-3) var(--space-4); border: var(--bw) solid var(--btn-bd); border-radius: var(--radius-card);
    background: var(--btn-bg); color: var(--btn-fg); cursor: pointer; font-size: var(--text-ui-density); transition: transform var(--dur-instant) var(--ease-out);
  }
  .passkey-btn::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; z-index: -1; background: var(--btn-state); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); pointer-events: none; }
  .passkey-btn:hover::before, .passkey-btn.is-hover::before { opacity: var(--state-hover); }
  .passkey-btn:active, .passkey-btn.is-active { transform: scale(var(--scale-press)); }
  .passkey-btn:active::before, .passkey-btn.is-active::before { opacity: var(--state-active); }
  .passkey-btn__text { display: grid; gap: 2px; flex: 1; min-width: 0; }
  .passkey-btn__title { font-weight: var(--weight-semibold); }
  .passkey-btn__hint { font-size: var(--text-small); color: var(--muted); }
  .passkey-btn:disabled { opacity: 0.4; cursor: not-allowed; }
  .passkey-btn--primary { --btn-bg: var(--accent-fill); --btn-fg: var(--on-accent); --btn-bd: var(--accent-fill); --btn-state: var(--black); --state-hover: 0.16; --state-active: 0.28; }
  /* no opacity on the hint: white on the blue fill is 4.70:1 only at full strength (axe color-contrast) */
  .passkey-btn--primary .passkey-btn__hint { color: var(--on-accent); }
  .passkey-btn--primary .icon-tile { background: var(--white-18); color: var(--on-accent); }
  .passkey-btn[aria-busy="true"] { cursor: progress; pointer-events: none; }

  @media (forced-colors: active) {
    .btn, .passkey-btn { border: 1px solid ButtonText; background: ButtonFace; color: ButtonText; forced-color-adjust: auto; }
    .btn--primary, .passkey-btn--primary { border-width: 2px; }
    .btn:disabled, .btn[aria-disabled="true"] { opacity: 1; border-color: GrayText; color: GrayText; }
    .btn::before, .passkey-btn::before { display: none; }
    .btn:hover, .btn.is-hover { border-color: Highlight; }
  }
}

/* =============================================================================
   LINKS
   ============================================================================= */
@layer components {
  .link { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; border-radius: var(--radius-xs); }
  .link:hover, .link.is-hover { color: var(--link-hover); text-decoration-thickness: 2px; }
  .link:active, .link.is-active { color: var(--accent-strong); }
  .link--quiet { text-decoration: none; font-weight: var(--weight-medium); }
  .link--quiet:hover { text-decoration: underline; }
  .link--muted { color: var(--ink-2); }
  .link--arrow { display: inline-flex; align-items: center; gap: 4px; font-weight: var(--weight-medium); text-decoration: none; }
  .link--arrow .icon { transition: transform var(--dur-fast) var(--ease-out); }
  .link--arrow:hover .icon { transform: translateX(3px); }
  .link--arrow:hover { text-decoration: underline; }
  .link[aria-disabled="true"] { color: var(--muted); pointer-events: none; text-decoration: none; }
  .band--navy .link { color: var(--navy-accent); }
  .kbd {
    display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
    border: 1px solid var(--line-strong); border-block-end-width: 2px; border-radius: var(--radius-xs); background: var(--surface-2); color: var(--ink-2);
    font-family: var(--font-mono); font-size: var(--text-micro); line-height: 1;
  }
}

/* =============================================================================
   FORM CONTROLS: field, text, select, textarea, checkbox, radio, switch,
   file drop, OTP, search, validation states
   ============================================================================= */
@layer components {
  .form { display: grid; gap: var(--space-5); }
  .form__row { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr); }
  @media (min-width: 48em) { .form__row--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form__row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
  .fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: var(--space-3); }
  .fieldset__legend { padding: 0; font-size: var(--text-small); font-weight: var(--weight-semibold); color: var(--ink); margin-block-end: var(--space-1); }

  .field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; align-content: start; }
  .field__label { font-size: var(--text-small); font-weight: var(--weight-medium); color: var(--ink); line-height: 1.3; display: flex; gap: var(--space-2); align-items: baseline; justify-content: space-between; }
  .field__opt { font-weight: var(--weight-regular); color: var(--muted); font-size: var(--text-caption); }
  .field__hint { font-size: var(--text-caption); line-height: 1.4; color: var(--muted); }
  .field__msg { display: none; align-items: flex-start; gap: 6px; font-size: var(--text-caption); line-height: 1.4; font-weight: var(--weight-medium); }
  .field__msg .icon { margin-block-start: 1px; }
  .field__msg--error { color: var(--danger-ink); }
  .field__msg--success { color: var(--success-ink); }
  .field__msg--warning { color: var(--warning-ink); }
  .field--error .field__msg--error, .field--success .field__msg--success, .field--warning .field__msg--warning { display: flex; }
  .field--error .field__hint { display: none; }

  .control {
    appearance: none; -webkit-appearance: none; display: block; width: 100%; min-height: var(--ctl-h); padding: 0 var(--space-3);
    border: var(--bw) solid var(--control-border); border-radius: var(--radius-ctl); background: var(--surface); color: var(--ink);
    font-family: inherit; font-size: var(--text-ui-density); line-height: 1.3; letter-spacing: var(--track-ui);
  }
  .control::placeholder { color: var(--muted); opacity: 1; }
  .control:hover, .control.is-hover { border-color: var(--ink-2); }
  .control:focus, .control.is-focus { outline: var(--focus-width) solid var(--focus); outline-offset: 0; border-color: var(--focus); box-shadow: var(--ring-accent); }
  .control:disabled { background: var(--surface-3); color: var(--muted); border-color: var(--line-strong); cursor: not-allowed; }
  .control[readonly] { background: var(--surface-2); }
  .control[aria-invalid="true"], .field--error .control { border-color: var(--danger); border-width: var(--bw-strong); }
  .field--success .control { border-color: var(--success); border-width: var(--bw-strong); }
  .field--warning .control { border-color: var(--warning); border-width: var(--bw-strong); }
  .control--lg { min-height: var(--ctl-h-lg); font-size: var(--text-body); padding-inline: var(--space-4); }
  .control--sm { min-height: var(--ctl-h-sm); font-size: var(--text-small); }
  .control--mono { font-family: var(--font-mono); font-size: var(--text-mono); letter-spacing: 0; }
  textarea.control { padding: var(--space-3); min-height: 7.5rem; resize: vertical; line-height: var(--lh-ui); field-sizing: content; max-height: 24rem; }
  input.control[type="file"] { padding: 6px; }

  /* Select: native control, custom chevron drawn with borders (no data: URI, CSP-clean) */
  .select { position: relative; display: block; }
  .select > select.control { padding-inline-end: 38px; cursor: pointer; text-overflow: ellipsis; }
  .select::after {
    content: ""; position: absolute; inset-inline-end: 16px; inset-block-start: 50%; width: 7px; height: 7px; pointer-events: none;
    border-inline-end: 1.5px solid var(--muted); border-block-end: 1.5px solid var(--muted); transform: translateY(-70%) rotate(45deg);
  }
  .select:has(select:disabled)::after { opacity: 0.5; }

  /* Search and input groups */
  .input-group { position: relative; display: block; }
  .input-group__icon { position: absolute; inset-inline-start: 12px; inset-block-start: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
  .input-group > .control { padding-inline-start: 38px; }
  .input-group__end { position: absolute; inset-inline-end: 6px; inset-block-start: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 4px; }
  .input-group__end ~ .control, .input-group > .control:has(~ .input-group__end) { padding-inline-end: 56px; }

  /* Checkbox and radio. Markup: label.check > input.check__input + span.check__box + span.check__label */
  .check, .radio {
    position: relative; display: inline-flex; align-items: flex-start; gap: 10px; min-height: var(--target-min); padding-block: 2px;
    cursor: pointer; font-size: var(--text-ui-density); line-height: 1.4;
  }
  .check__input, .radio__input { position: absolute; inset-block-start: 2px; inset-inline-start: 0; width: 20px; height: 20px; margin: 0; opacity: 0; cursor: pointer; }
  .check__box, .radio__box {
    position: relative; flex: none; width: 20px; height: 20px; margin-block-start: 0; border: var(--bw-strong) solid var(--control-border);
    background: var(--surface); border-radius: var(--radius-xs);
  }
  .radio__box { border-radius: 50%; }
  .check__box::after {
    content: ""; position: absolute; inset-inline-start: 5.5px; inset-block-start: 1.5px; width: 5px; height: 10px; border: solid var(--on-accent); border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0.6); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
  }
  .radio__box::after {
    content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--on-accent);
    transform: scale(0.4); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
  }
  .check__input:checked + .check__box, .check__input:indeterminate + .check__box, .radio__input:checked + .radio__box { background: var(--accent-fill); border-color: var(--accent-fill); }
  .check__input:checked + .check__box::after { opacity: 1; transform: rotate(45deg) scale(1); }
  .check__input:indeterminate + .check__box::after { opacity: 1; inset-inline-start: 3.5px; inset-block-start: 7.5px; width: 9px; height: 0; border-width: 0 0 2px 0; transform: none; }
  .radio__input:checked + .radio__box::after { opacity: 1; transform: scale(1); }
  .check:hover .check__box, .radio:hover .radio__box, .check.is-hover .check__box, .radio.is-hover .radio__box { border-color: var(--ink-2); }
  .check:hover .check__input:checked + .check__box, .radio:hover .radio__input:checked + .radio__box { border-color: var(--accent-fill); }
  .check:active .check__box, .radio:active .radio__box, .check.is-active .check__box, .radio.is-active .radio__box { transform: scale(var(--scale-press)); }
  .check__input:focus-visible + .check__box, .radio__input:focus-visible + .radio__box, .check.is-focus .check__box, .radio.is-focus .radio__box { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
  .check__input[aria-invalid="true"] + .check__box, .radio__input[aria-invalid="true"] + .radio__box { border-color: var(--danger); }
  .check__input:disabled, .radio__input:disabled { cursor: not-allowed; }
  .check__input:disabled + .check__box, .radio__input:disabled + .radio__box, .check__input:disabled ~ .check__label, .radio__input:disabled ~ .radio__label { opacity: 0.45; }
  .check__label, .radio__label { min-width: 0; }
  .check__hint { display: block; color: var(--muted); font-size: var(--text-caption); }
  .check.is-focus, .radio.is-focus, .switch.is-focus { outline: none; }
  .choice-list { display: grid; gap: var(--space-2); }

  /* Choice card: a radio or checkbox presented as a selectable card (edition, factor) */
  .choice-card {
    position: relative; display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4); border: var(--bw) solid var(--line-strong);
    border-radius: var(--radius-card); background: var(--surface); cursor: pointer;
  }
  .choice-card:hover { border-color: var(--control-border); }
  .choice-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--surface); }
  .choice-card:has(input:focus-visible) { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
  .choice-card__body { display: grid; gap: 2px; min-width: 0; }
  .choice-card__title { font-weight: var(--weight-semibold); }
  .choice-card__desc { color: var(--muted); font-size: var(--text-small); }

  /* Switch. Markup: label.switch > input.switch__input[role=switch] + span.switch__track > span.switch__thumb + span.switch__label */
  .switch { position: relative; display: inline-flex; align-items: center; gap: var(--space-3); min-height: var(--target-min); cursor: pointer; font-size: var(--text-ui-density); }
  .switch__input { position: absolute; inset-block-start: 0; inset-inline-start: 0; width: 44px; height: 26px; margin: 0; opacity: 0; cursor: pointer; }
  .switch__track {
    position: relative; flex: none; width: 44px; height: 26px; border-radius: var(--radius-pill); background: var(--control-border);
  }
  .switch__track::before {
    content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--accent-fill); opacity: 0; transition: opacity var(--dur-base) var(--ease-out);
  }
  .switch__thumb {
    position: absolute; inset-block-start: 2px; inset-inline-start: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--on-accent);
    box-shadow: var(--shadow-thumb); transition: transform var(--dur-spring) var(--ease-spring);
  }
  .switch__input:checked ~ .switch__track::before { opacity: 1; }
  .switch__input:checked ~ .switch__track .switch__thumb { transform: translateX(18px); }
  .switch:active .switch__thumb, .switch.is-active .switch__thumb { width: 26px; }
  .switch__input:focus-visible ~ .switch__track, .switch.is-focus .switch__track { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
  .switch__input:disabled { cursor: not-allowed; }
  .switch__input:disabled ~ .switch__track, .switch__input:disabled ~ .switch__label { opacity: 0.45; }
  .switch__label { min-width: 0; }
  [dir="rtl"] .switch__input:checked ~ .switch__track .switch__thumb { transform: translateX(-18px); }

  /* File drop (support bundles). Markup: label.dropzone > input.dropzone__input + icon + text */
  .dropzone {
    position: relative; display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-6) var(--space-5); text-align: center; cursor: pointer;
    border: var(--bw-strong) dashed var(--control-border); border-radius: var(--radius-card); background: var(--surface);
  }
  .dropzone:hover, .dropzone.is-hover { border-color: var(--ink-2); background: var(--surface-2); }
  .dropzone.is-dragover, .dropzone.is-focus, .dropzone:has(.dropzone__input:focus-visible) { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
  .dropzone.is-focus, .dropzone:has(.dropzone__input:focus-visible) { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
  .dropzone__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
  .dropzone__title { font-weight: var(--weight-semibold); }
  .dropzone__hint { color: var(--muted); font-size: var(--text-small); }
  /* muted on accent-soft is 4.45:1 in light (app prototype gap 1): the tinted states use ink-2 */
  .dropzone.is-dragover .dropzone__hint, .dropzone.is-focus .dropzone__hint, .dropzone:has(.dropzone__input:focus-visible) .dropzone__hint { color: var(--ink-2); }
  .dropzone--error { border-color: var(--danger); }
  .dropzone[aria-disabled="true"], .dropzone:has(.dropzone__input:disabled) { opacity: 0.5; cursor: not-allowed; }

  /* OTP code input: six digits, paste-aware (components.js), autocomplete one-time-code */
  .otp { display: flex; align-items: center; gap: var(--space-2); width: 100%; max-width: 22rem; }
  .otp__digit {
    flex: 1 1 0; min-width: 0; max-width: 3.5rem; height: 56px; padding: 0; text-align: center; font-size: 1.5rem; font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums; border: var(--bw) solid var(--control-border); border-radius: var(--radius-ctl); background: var(--surface); color: var(--ink);
    appearance: none; -webkit-appearance: none;
  }
  .otp__digit:hover { border-color: var(--ink-2); }
  .otp__digit:focus { outline: var(--focus-width) solid var(--focus); outline-offset: 0; border-color: var(--focus); box-shadow: var(--ring-accent); }
  .otp__sep { flex: none; width: 8px; height: 2px; background: var(--control-border); border-radius: 1px; }
  .otp--error .otp__digit { border-color: var(--danger); border-width: var(--bw-strong); animation: shake var(--dur-base) var(--ease-inout); }
  .otp__digit:disabled { background: var(--surface-3); opacity: 0.6; }
  @keyframes shake { 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

  @media (forced-colors: active) {
    .control, .otp__digit, .check__box, .radio__box, .switch__track, .dropzone { border-color: ButtonText; forced-color-adjust: none; background: Canvas; color: CanvasText; }
    .control:focus, .otp__digit:focus { outline-color: Highlight; border-color: Highlight; }
    .check__input:checked + .check__box, .radio__input:checked + .radio__box, .check__input:indeterminate + .check__box { background: Highlight; border-color: Highlight; }
    .check__box::after { border-color: HighlightText; }
    .radio__box::after { background: HighlightText; }
    .switch__track::before { background: Highlight; }
    .switch__thumb { background: ButtonText; box-shadow: none; }
    .switch__input:checked ~ .switch__track .switch__thumb { background: HighlightText; }
    .control:disabled, .check__input:disabled + .check__box, .switch__input:disabled ~ .switch__track { border-color: GrayText; color: GrayText; }
    .choice-card:has(input:checked) { border: 2px solid Highlight; box-shadow: none; }
    .dropzone.is-dragover { border-color: Highlight; }
  }
  @media (prefers-reduced-motion: reduce) { .otp--error .otp__digit { animation: none; } .switch:active .switch__thumb { width: 22px; } }
  :root[data-motion="reduce"] .otp--error .otp__digit { animation: none; }
}

/* =============================================================================
   CARDS, STAT, CHIPS, BADGE, AVATAR, KEY-VALUE, CODE AND HASH DISPLAY
   ============================================================================= */
@layer components {
  .card {
    position: relative; isolation: isolate; display: flex; flex-direction: column; min-width: 0;
    background: var(--surface); border: var(--bw) solid var(--hair); border-radius: var(--radius-card); box-shadow: var(--shadow-1); color: var(--ink);
  }
  .card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-block-end: 1px solid var(--hair); }
  .card__title { font-size: var(--text-ui-density); font-weight: var(--weight-semibold); line-height: 1.3; }
  .card__body { padding: var(--space-5); display: grid; gap: var(--space-3); align-content: start; flex: 1; }
  .card__footer { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-block-start: 1px solid var(--hair); background: var(--surface-2); border-end-start-radius: inherit; border-end-end-radius: inherit; }
  .card--flat { box-shadow: none; border-color: var(--line); }
  .card--tint { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
  /* muted on accent-soft is 4.45:1 in light; secondary text inside a tint uses ink-2 */
  .card--tint .muted, .card--tint .caption, .card--tint .field__hint { color: var(--ink-2); }
  .card--navy { background: var(--grad-navy-hero); border-color: var(--navy-line); color: var(--on-navy); --ink: var(--on-navy); --ink-2: var(--on-navy-2); --muted: var(--on-navy-2); --link: var(--navy-accent); }
  .card--pad-lg .card__body { padding: var(--space-6); }
  .card--interactive { transition: transform var(--dur-base) var(--ease-out); }
  .card--interactive::before {
    content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; box-shadow: var(--shadow-2); opacity: 0; transition: opacity var(--dur-base) var(--ease-out); pointer-events: none;
  }
  .card--interactive:hover, .card--interactive.is-hover { transform: translateY(-2px); }
  .card--interactive:hover::before, .card--interactive.is-hover::before { opacity: 1; }
  .card--interactive:active, .card--interactive.is-active { transform: translateY(0) scale(var(--scale-press)); }
  .card--interactive:has(.card__link:focus-visible) { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
  .card__link { color: inherit; text-decoration: none; font-weight: var(--weight-semibold); }
  .card__link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
  .card__link:focus-visible { outline: none; }
  .card--disabled { opacity: 0.55; pointer-events: none; }
  @media (forced-colors: active) { .card { border: 1px solid CanvasText; } .card--interactive:hover { border-color: Highlight; } }

  .stat { display: grid; gap: var(--space-1); }
  .stat__label { font-size: var(--text-small); color: var(--ink-2); font-weight: var(--weight-medium); }
  .stat__value { font-size: var(--text-h2); line-height: 1.1; letter-spacing: var(--track-h2); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
  .stat__meta { font-size: var(--text-caption); color: var(--muted); }

  /* Chips: status chips use rating colors ONLY for ratings and status, always with text and an icon shape */
  .chip {
    display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--radius-pill); white-space: nowrap; vertical-align: middle;
    background: var(--surface-3); color: var(--ink-2); font-size: var(--text-caption); font-weight: var(--weight-medium); line-height: 1; letter-spacing: 0;
  }
  .chip .icon { width: 14px; height: 14px; margin-inline-start: -2px; stroke-width: 1.75; }
  /* A long chip (for example a confidence statement) wraps inside its column instead of running past a phone screen */
  .chip { max-width: 100%; }
  @media (max-width: 40em) { .chip:not(.chip--filter) { white-space: normal; height: auto; min-height: 24px; padding-block: 4px; line-height: 1.35; } }
  .chip--success { background: var(--success-soft); color: var(--success-ink); }
  .chip--warning { background: var(--warning-soft); color: var(--warning-ink); }
  .chip--danger { background: var(--danger-soft); color: var(--danger-ink); }
  .chip--info { background: var(--info-soft); color: var(--info-ink); }
  .chip--accent { background: var(--accent-soft); color: var(--link); }
  .chip--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
  .chip--solid.chip--success { background: var(--success); color: var(--surface); }
  .chip--solid.chip--warning { background: var(--warning); color: var(--surface); }
  .chip--solid.chip--danger { background: var(--danger); color: var(--surface); }
  .chip--solid.chip--info { background: var(--info); color: var(--surface); }
  .chip--dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
  .chip--lg { height: 28px; padding: 0 12px; font-size: var(--text-small); }
  .chip--mono { font-family: var(--font-mono); font-size: var(--text-micro); }
  /* Interactive chips: filter toggles and removable tokens */
  .chip--filter { position: relative; isolation: isolate; height: 32px; padding: 0 12px; border: var(--bw) solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; font-family: inherit; }
  .chip--filter::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; background: var(--ink); opacity: 0; z-index: -1; transition: opacity var(--dur-fast) var(--ease-out); pointer-events: none; }
  .chip--filter:hover::before, .chip--filter.is-hover::before { opacity: 0.05; }
  .chip--filter[aria-pressed="true"], .chip--filter.is-selected { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
  .chip--filter:disabled { opacity: 0.45; cursor: not-allowed; }
  .chip__remove { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-inline-end: -6px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; padding: 0; }
  .chip__remove:hover { background: var(--line); }
  @media (forced-colors: active) {
    .chip { border: 1px solid CanvasText; }
    .chip--filter[aria-pressed="true"] { border: 2px solid Highlight; }
    .chip--solid { forced-color-adjust: none; background: CanvasText; color: Canvas; }
  }

  .badge {
    display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill);
    background: var(--accent-fill); color: var(--on-accent); font-size: var(--text-micro); font-weight: var(--weight-semibold); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: 0;
  }
  .badge--neutral { background: var(--surface-3); color: var(--ink-2); }
  .badge--dot { min-width: 8px; width: 8px; height: 8px; padding: 0; }
  @media (forced-colors: active) { .badge { border: 1px solid CanvasText; } }

  .avatar {
    position: relative; display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
    background: var(--surface-3); color: var(--ink-2); font-size: var(--text-micro); font-weight: var(--weight-semibold); letter-spacing: 0; text-transform: uppercase; user-select: none;
  }
  .avatar--accent { background: var(--accent-soft); color: var(--link); }
  .avatar--sm { width: 24px; height: 24px; font-size: 10px; }
  .avatar--lg { width: 48px; height: 48px; font-size: var(--text-small); }
  .avatar--xl { width: 72px; height: 72px; font-size: var(--text-h4); }
  .avatar > img { width: 100%; height: 100%; object-fit: cover; }
  .avatar__status { position: absolute; inset-inline-end: 0; inset-block-end: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--success); border: 2px solid var(--surface); }
  .avatar-group { display: inline-flex; }
  .avatar-group > .avatar { box-shadow: 0 0 0 2px var(--surface); }
  .avatar-group > .avatar + .avatar { margin-inline-start: -8px; }
  @media (forced-colors: active) { .avatar { border: 1px solid CanvasText; } }

  /* Key-value list. Markup: dl.kv > div.kv__row > dt + dd */
  .kv { display: grid; margin: 0; }
  .kv__row { display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr); gap: var(--space-4); padding-block: var(--space-3); border-block-end: 1px solid var(--hair); align-items: baseline; }
  .kv__row:last-child { border-block-end: 0; }
  .kv dt { color: var(--muted); font-size: var(--text-small); }
  .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-size: var(--text-ui-density); }
  .kv--stacked .kv__row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  @media (max-width: 30em) { .kv__row { grid-template-columns: minmax(0, 1fr); gap: 2px; } }

  /* Code and hash display with copy */
  .code-block { border: var(--bw) solid var(--line); border-radius: var(--radius-md); background: var(--surface-2); overflow: hidden; }
  .code-block__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 6px 6px 6px var(--space-4); border-block-end: 1px solid var(--line); color: var(--ink-2); font-size: var(--text-caption); }
  .code-block__pre { margin: 0; padding: var(--space-4); overflow-x: auto; font-family: var(--font-mono); font-size: var(--text-mono); line-height: 1.6; color: var(--ink); tab-size: 2; }
  .hash {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 4px 2px 10px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--ink);
    font-family: var(--font-mono); font-size: var(--text-mono); letter-spacing: 0; vertical-align: middle;
  }
  .hash__value { min-width: 0; overflow-wrap: anywhere; word-break: break-all; line-height: 1.5; padding-block: 3px; }
  .hash__chunk { display: inline-block; margin-inline-end: 0.5ch; }
  .hash--block { display: flex; width: 100%; padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); border-radius: var(--radius-md); align-items: flex-start; }
  .hash__copy { flex: none; }
  .copy-btn { position: relative; isolation: isolate; display: inline-grid; place-items: center; width: var(--ctl-h-sm); height: var(--ctl-h-sm); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); cursor: pointer; padding: 0; }
  .copy-btn::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--ink); opacity: 0; z-index: -1; transition: opacity var(--dur-fast) var(--ease-out); }
  .copy-btn:hover::before, .copy-btn.is-hover::before { opacity: 0.08; }
  .copy-btn:active::before { opacity: 0.16; }
  .copy-btn .icon--done { display: none; color: var(--success-ink); }
  .copy-btn.is-copied .icon--copy { display: none; }
  .copy-btn.is-copied .icon--done { display: inline-block; }
  .copy-btn:disabled { opacity: 0.4; cursor: not-allowed; }
  /* Revealed secret: masked by default, auto-hides after 30 s (APP-39) */
  .mask { font-family: var(--font-mono); letter-spacing: 0.12em; color: var(--muted); user-select: none; }
}

/* =============================================================================
   TABS, SEGMENTED CONTROL, THEME TOGGLE
   ============================================================================= */
@layer components {
  .tabs { display: flex; gap: var(--space-5); border-block-end: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    position: relative; flex: none; display: inline-flex; align-items: center; gap: var(--space-2); min-height: calc(var(--ctl-h) + 4px); padding: 0 2px; border: 0; background: transparent;
    color: var(--ink-2); font-size: var(--text-ui-density); font-weight: var(--weight-medium); white-space: nowrap; cursor: pointer; scroll-snap-align: start;
  }
  .tab::after {
    content: ""; position: absolute; inset-inline: 0; inset-block-end: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent);
    transform: scaleX(0); transition: transform var(--dur-fast) var(--ease-out);
  }
  .tab:hover, .tab.is-hover { color: var(--ink); }
  .tab:hover::after, .tab.is-hover::after { transform: scaleX(0.4); background: var(--line-strong); }
  .tab[aria-selected="true"] { color: var(--ink); font-weight: var(--weight-semibold); }
  .tab[aria-selected="true"]::after { transform: scaleX(1); background: var(--accent); }
  .tab:active, .tab.is-active { color: var(--link); }
  .tab:disabled, .tab[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }
  .tab:focus-visible { outline-offset: -2px; border-radius: var(--radius-xs); }
  .tabpanel { padding-block-start: var(--space-5); }
  .tabpanel[hidden] { display: none; }
  .tabs--pill { border: 0; gap: var(--space-1); padding: 3px; border-radius: var(--radius-pill); background: var(--surface-3); width: max-content; max-width: 100%; }
  .tabs--pill .tab { min-height: calc(var(--ctl-h) - 6px); padding: 0 var(--space-4); border-radius: var(--radius-pill); isolation: isolate; }
  .tabs--pill .tab::after { inset: 0; height: auto; border-radius: inherit; background: var(--surface-raised); box-shadow: var(--shadow-1); transform: none; opacity: 0; z-index: -1; transition: opacity var(--dur-fast) var(--ease-out); }
  .tabs--pill .tab:hover::after { opacity: 0.5; transform: none; background: var(--surface-raised); }
  .tabs--pill .tab[aria-selected="true"]::after { opacity: 1; background: var(--surface-raised); transform: none; }
  .tab__count { font-size: var(--text-micro); font-weight: var(--weight-semibold); padding: 1px 6px; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--ink-2); }
  @media (forced-colors: active) {
    .tab[aria-selected="true"]::after { background: Highlight; height: 3px; }
    .tabs--pill .tab[aria-selected="true"] { border: 2px solid Highlight; }
    .tabs--pill .tab::after { display: none; }
  }

  .segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-md); background: var(--surface-3); max-width: 100%; }
  .segmented__item { position: relative; display: inline-flex; min-width: 0; }
  .segmented__input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
  .segmented__label {
    position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: calc(var(--ctl-h) - 6px); min-width: var(--target-min);
    padding: 0 var(--space-4); border-radius: calc(var(--radius-md) - 3px); color: var(--ink-2); font-size: var(--text-ui-density); font-weight: var(--weight-medium); white-space: nowrap;
  }
  .segmented__label::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--surface-raised); box-shadow: var(--shadow-1); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .segmented__item:hover .segmented__label { color: var(--ink); }
  .segmented__input:checked + .segmented__label { color: var(--ink); }
  .segmented__input:checked + .segmented__label::before { opacity: 1; }
  .segmented__input:focus-visible + .segmented__label { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }
  .segmented__input:disabled + .segmented__label { opacity: 0.4; }
  .segmented--sm .segmented__label { min-height: calc(var(--ctl-h-sm) - 6px); padding: 0 var(--space-3); font-size: var(--text-small); }
  .segmented--block { display: flex; width: 100%; } .segmented--block .segmented__item { flex: 1; } .segmented--block .segmented__label { width: 100%; }
  @media (forced-colors: active) {
    .segmented { border: 1px solid ButtonText; }
    .segmented__label::before { display: none; }
    .segmented__input:checked + .segmented__label { border: 2px solid Highlight; }
  }

  .theme-toggle { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-pill); background: var(--surface-3); }
  .theme-toggle__btn {
    position: relative; isolation: isolate; display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer;
  }
  .theme-toggle__btn::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--surface-raised); box-shadow: var(--shadow-1); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .theme-toggle__btn:hover { color: var(--ink); }
  .theme-toggle__btn[aria-pressed="true"] { color: var(--ink); }
  .theme-toggle__btn[aria-pressed="true"]::before { opacity: 1; }
  .theme-toggle--on-navy { background: var(--white-12); }
  .theme-toggle--on-navy .theme-toggle__btn { color: var(--on-navy-2); }
  .theme-toggle--on-navy .theme-toggle__btn::before { background: var(--white-22); box-shadow: none; }
  .theme-toggle--on-navy .theme-toggle__btn[aria-pressed="true"] { color: var(--on-navy); }
  @media (forced-colors: active) { .theme-toggle { border: 1px solid ButtonText; } .theme-toggle__btn::before { display: none; } .theme-toggle__btn[aria-pressed="true"] { border: 2px solid Highlight; } }
}

/* =============================================================================
   ANNOTATION BADGE (L30). Numbered callouts that mirror the red numbered marks in the application
   familiarization guides. It is NOT a rating, a status, a button or a link, and a badge always carries
   its number. This is the only place --annotation and --on-annotation may be used (stylelint rule
   sectra/status-colors-only).
   ============================================================================= */
@layer components {
  .annotation {
    display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%;
    background: var(--annotation); color: var(--on-annotation); font-size: var(--text-caption); font-weight: var(--weight-semibold);
    line-height: 1; font-style: normal; font-variant-numeric: tabular-nums; letter-spacing: 0; box-shadow: 0 0 0 3px var(--white);
  }
  .annotation--sm { width: 24px; height: 24px; box-shadow: none; }
  .annotation-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2) var(--space-5); counter-reset: annotation; }
  @media (min-width: 48em) { .annotation-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  .annotation-list > li { counter-increment: annotation; display: flex; gap: var(--space-3); align-items: center; min-height: 28px; color: var(--ink); font-size: var(--text-small); font-weight: var(--weight-medium); }
  .annotation-list > li::before {
    content: counter(annotation); flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
    background: var(--annotation); color: var(--on-annotation); font-size: var(--text-caption); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums;
  }
  @media (forced-colors: active) {
    .annotation, .annotation-list > li::before { forced-color-adjust: none; background: Highlight; color: HighlightText; box-shadow: none; }
  }
}

/* =============================================================================
   TABLES: dense, compact and comfortable; sticky header; sortable; selection;
   row menu; pagination; card reflow on narrow containers (the ledger at 390 px)
   Markup: div.table-wrap > table.table (+ .table--dense|compact|comfortable|reflow)
   ============================================================================= */
@layer components {
  .table-wrap {
    container: table / inline-size; position: relative; overflow: auto; max-height: var(--table-max-h, none);
    background: var(--surface); border: var(--bw) solid var(--line); border-radius: var(--radius-card);
  }
  .table-wrap--flush { border-radius: 0; border-inline: 0; }
  .table-wrap--scroll { --table-max-h: 20rem; }
  .table-wrap--tall { --table-max-h: 32rem; }
  .table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-ui-density); line-height: var(--lh-ui); letter-spacing: var(--track-ui); }
  .table--comfortable { --row-h: 48px; --text-ui-density: 0.9375rem; }
  .table--compact { --row-h: 36px; --row-pad: 8px; --text-ui-density: 0.875rem; }
  .table--dense { --row-h: 28px; --row-pad: 4px; --text-ui-density: 0.8125rem; }
  .table caption { caption-side: top; text-align: start; padding: var(--space-4) var(--space-4) var(--space-3); font-weight: var(--weight-semibold); border-block-end: 1px solid var(--hair); }
  .table th, .table td { height: var(--row-h); padding: var(--row-pad) var(--space-4); text-align: start; vertical-align: middle; border-block-end: 1px solid var(--hair); }
  .table thead th {
    position: sticky; inset-block-start: 0; z-index: var(--z-raised); background: var(--surface-2); color: var(--ink-2); border-block-end: 1px solid var(--line);
    font-size: var(--text-caption); font-weight: var(--weight-semibold); white-space: nowrap; letter-spacing: 0;
  }
  .table tbody tr:last-child > * { border-block-end: 0; }
  .table tbody tr:hover > *, .table tbody tr.is-hover > * { background: var(--surface-2); }
  .table tbody tr:active > *, .table tbody tr.is-active > * { background: var(--surface-3); }
  .table tbody tr[aria-selected="true"] > *, .table tbody tr.is-selected > * { background: var(--accent-soft); }
  .table tbody tr[aria-selected="true"] > :first-child, .table tbody tr.is-selected > :first-child { box-shadow: inset 3px 0 0 var(--accent); }
  .table tbody tr.is-new > * { position: relative; }
  /* muted on accent-soft (selected and new rows) is 4.45:1 in light: secondary cell text uses ink-2 there */
  .table tbody tr.is-new .cell-muted, .table tbody tr[aria-selected="true"] .cell-muted, .table tbody tr.is-selected .cell-muted { color: var(--ink-2); }
  .table tbody tr.is-new > *::after { content: ""; position: absolute; inset: 0; background: var(--highlight); pointer-events: none; animation: live-row var(--dur-live) var(--ease-out) both; }
  .table tbody tr[aria-disabled="true"] > * { opacity: 0.5; }
  .table tbody tr:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: -2px; }
  .table .num, .table th.num { text-align: end; font-variant-numeric: tabular-nums; }
  .table .cell-mono { font-family: var(--font-mono); font-size: var(--text-mono); letter-spacing: 0; white-space: nowrap; }
  .table .cell-muted { color: var(--muted); }
  .table .cell-check { width: 44px; padding-inline-end: 0; }
  .table .cell-actions { width: 1%; white-space: nowrap; text-align: end; padding-inline-start: 0; }
  .table .cell-truncate { max-width: 20rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table td.cell-wrap { white-space: normal; }
  @keyframes live-row { from { opacity: 1; } to { opacity: 0; } }

  /* Sortable header: button inside th[aria-sort]. Icons are server-rendered per state. */
  .th-sort {
    display: inline-flex; align-items: center; gap: 4px; margin-inline-start: -6px; padding: 0 6px; min-height: var(--target-min); border: 0; border-radius: var(--radius-xs); background: transparent;
    color: inherit; font: inherit; font-weight: inherit; cursor: pointer; white-space: nowrap;
  }
  .th-sort:hover { color: var(--ink); background: var(--surface-3); }
  .th-sort .icon { width: 14px; height: 14px; color: var(--muted); }
  th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort { color: var(--ink); }
  th[aria-sort="ascending"] .icon, th[aria-sort="descending"] .icon { color: var(--accent); }
  th.num .th-sort { margin-inline-start: 0; margin-inline-end: -6px; flex-direction: row-reverse; }

  /* Loading rows and empty/error rows */
  .table__state td { height: auto; padding: var(--space-8) var(--space-5); text-align: center; }
  .table__skeleton td { height: var(--row-h); }
  .table__note td { height: auto; padding: var(--space-3) var(--space-4); }

  .table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-block-end: 1px solid var(--hair); background: var(--surface); }
  .table-toolbar__spacer { flex: 1; }
  .table-toolbar__selection { font-size: var(--text-small); font-weight: var(--weight-medium); }
  .table-wrap:has(+ .table-footer) { border-end-start-radius: 0; border-end-end-radius: 0; border-block-end: 0; }
  .table-wrap + .table-footer { border: var(--bw) solid var(--line); border-block-start-color: var(--line); border-end-start-radius: var(--radius-card); border-end-end-radius: var(--radius-card); }
  .table-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-block-start: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: var(--text-small); }

  /* Bulk action bar (appears with a selection) */
  .bulk-bar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); background: var(--accent-soft); border-block-end: 1px solid var(--hair); font-size: var(--text-small); }
  .bulk-bar[hidden] { display: none; }

  /* Card reflow: below 40rem of container width, rows become cards (ledger at 390 px) */
  @container table (max-width: 40rem) {
    .table--reflow, .table--reflow tbody, .table--reflow tr, .table--reflow td { display: block; width: 100%; }
    .table--reflow thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .table--reflow tr { padding: var(--space-3) var(--space-4); border-block-end: 1px solid var(--hair); position: relative; }
    .table--reflow tbody tr:last-child { border-block-end: 0; }
    .table--reflow td { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); height: auto; padding: 6px 0; border: 0; text-align: end; background: transparent !important; box-shadow: none !important; }
    .table--reflow td::before { content: attr(data-label); flex: none; font-family: var(--font-sans); letter-spacing: 0; color: var(--muted); font-size: var(--text-caption); font-weight: var(--weight-medium); text-align: start; }
    .table--reflow td.cell-check::before, .table--reflow td.cell-actions::before { content: none; }
    .table--reflow .cell-actions { justify-content: flex-end; width: 100%; padding: 4px 0 0; }
    .table--reflow .cell-check { width: auto; padding: 0; justify-content: flex-start; }
    .table--reflow .cell-truncate { max-width: none; }
    .table--reflow tr:hover, .table--reflow tr.is-hover { background: var(--surface-2); }
    .table--reflow tbody tr.is-new > *::after { display: none; }
    .table--reflow tbody tr.is-new::after { content: ""; position: absolute; inset: 0; background: var(--highlight); pointer-events: none; animation: live-row var(--dur-live) var(--ease-out) both; }
    .table--reflow tr[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
    .table-footer { flex-direction: column; align-items: stretch; }
  }
  @media (forced-colors: active) {
    .table th, .table td { border-block-end: 1px solid CanvasText; }
    .table tbody tr[aria-selected="true"] > * { forced-color-adjust: none; background: Highlight; color: HighlightText; }
    .table tbody tr[aria-selected="true"] a, .table tbody tr[aria-selected="true"] .icon, .table tbody tr[aria-selected="true"] .cell-muted { color: HighlightText; }
  }
  @media (prefers-reduced-motion: reduce) { .table tbody tr.is-new > *::after, .table--reflow tbody tr.is-new::after { animation: none; opacity: 0; } }
  :root[data-motion="reduce"] .table tbody tr.is-new > *::after, :root[data-motion="reduce"] .table--reflow tbody tr.is-new::after { animation: none; opacity: 0; }

  /* Live-row reduced variant: a static "New" tag is rendered by the app next to the row (plan 11.5.1) */
  .row-tag-new { display: none; margin-inline-start: var(--space-2); }
  @media (prefers-reduced-motion: reduce) { .is-new .row-tag-new { display: inline-flex; } }
  :root[data-motion="reduce"] .is-new .row-tag-new { display: inline-flex; }

  /* Pagination */
  .pagination { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
  .pagination__item {
    position: relative; isolation: isolate; display: inline-grid; place-items: center; min-width: var(--ctl-h-sm); height: var(--ctl-h-sm); padding: 0 var(--space-2); border: 0; border-radius: var(--radius-ctl);
    background: transparent; color: var(--ink-2); font-size: var(--text-small); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; text-decoration: none; cursor: pointer;
  }
  .pagination__item::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--ink); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .pagination__item:hover::before, .pagination__item.is-hover::before { opacity: 0.06; }
  .pagination__item:active::before { opacity: 0.12; }
  .pagination__item:hover { color: var(--ink); text-decoration: none; }
  .pagination__item[aria-current="page"] { background: var(--accent-soft); color: var(--ink); font-weight: var(--weight-semibold); box-shadow: inset 0 0 0 1px var(--accent); }
  .pagination__item[aria-disabled="true"], .pagination__item:disabled { opacity: 0.4; pointer-events: none; }
  .pagination__gap { min-width: var(--ctl-h-sm); text-align: center; color: var(--muted); }
  .pagination__summary { color: var(--ink-2); font-size: var(--text-small); font-variant-numeric: tabular-nums; }
  .pagination__size { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-small); color: var(--ink-2); }
  @media (forced-colors: active) { .pagination__item[aria-current="page"] { border: 2px solid Highlight; box-shadow: none; } }

  /* Filter bar: search, segmented status filter, chips, clear, export */
  .filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
  .filter-bar__search { flex: 1 1 14rem; max-width: 24rem; min-width: 0; }
  .filter-bar__spacer { flex: 1 1 auto; }
  .filter-bar__applied { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); width: 100%; }
  .filter-bar__label { font-size: var(--text-small); color: var(--muted); }
}

/* =============================================================================
   NAVIGATION: brand, public header with mega-menu, mobile nav, footer,
   My Sectra sidebar, Staff Console rail, app shell and top bar, breadcrumbs
   ============================================================================= */
@layer components {
  /* Brand lockup: white tile with the reticle, wordmark "Sectra" + blue "TEK", attribution beneath.
     The mark is used on white, light grey and navy only and is never recolored. */
  .brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; border-radius: var(--radius-sm); }
  .brand:hover { color: var(--ink); text-decoration: none; }
  .brand__mark { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--logo-tile); box-shadow: 0 0 0 1px var(--glass-line); forced-color-adjust: none; }
  .brand__mark .icon { width: 28px; height: 28px; stroke: none; fill: none; }
  .brand__mark .brand__img { display: block; width: 30px; height: 30px; object-fit: contain; }
  .brand__text { display: grid; line-height: 1; }
  .brand__word { font-size: 1.25rem; font-weight: var(--weight-bold); letter-spacing: -0.03em; }
  .brand__word b { color: var(--accent); font-weight: inherit; }
  .brand__by { margin-block-start: 3px; font-size: 0.6875rem; font-weight: var(--weight-regular); letter-spacing: 0; color: var(--muted); }
  .band--navy .brand, .on-navy .brand, .site-footer__attribution .brand { color: var(--on-navy); }
  .band--navy .brand__word b, .on-navy .brand__word b, .site-footer__attribution .brand__word b { color: var(--navy-blue); }
  .band--navy .brand__by, .on-navy .brand__by, .site-footer__attribution .brand__by { color: var(--on-navy-2); }
  .brand--compact .brand__by { display: none; }

  /* Public header */
  .site-header {
    position: sticky; inset-block-start: 0; z-index: var(--z-header); view-transition-name: site-header;
    background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-block-end: 1px solid var(--glass-line);
  }
  .site-header__bar { display: flex; align-items: center; gap: var(--space-5); height: var(--header-h); }
  .site-header__nav { display: none; flex: 1; justify-content: center; }
  .site-header__actions { display: flex; align-items: center; gap: var(--space-2); margin-inline-start: auto; flex: none; }
  .site-header__actions .btn--outline-hide { display: none; }
  .site-header__menu-btn { display: inline-grid; }
  @media (min-width: 64em) {
    .site-header__nav { display: flex; }
    .site-header__menu-btn { display: none; }
    .site-header__actions .btn--outline-hide { display: inline-flex; }
  }
  .nav-primary { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; }
  .nav-primary__link {
    position: relative; isolation: isolate; display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-pill);
    background: transparent; color: var(--ink); font-size: var(--text-ui); font-weight: var(--weight-medium); letter-spacing: var(--track-ui); text-decoration: none; cursor: pointer;
  }
  .nav-primary__link::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--ink); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .nav-primary__link:hover::before, .nav-primary__link.is-hover::before, .nav-primary__link[aria-expanded="true"]::before { opacity: 0.06; }
  .nav-primary__link:hover { color: var(--ink); text-decoration: none; }
  .nav-primary__link[aria-current="page"] { color: var(--link); }
  html[data-scroll-lock] { overflow: hidden; }
  .nav-primary__link .icon { width: 14px; height: 14px; transition: transform var(--dur-fast) var(--ease-out); }
  .nav-primary__link[aria-expanded="true"] .icon { transform: rotate(180deg); }

  .mega {
    position: absolute; inset-inline: 0; inset-block-start: 100%; background: var(--surface); border-block-end: 1px solid var(--line); box-shadow: var(--shadow-2);
    opacity: 0; visibility: hidden; transform: translateY(calc(var(--shift-sm) * -0.66));
    transition: opacity calc(var(--dur-base) * var(--exit-ratio)) var(--ease-in), transform calc(var(--dur-base) * var(--exit-ratio)) var(--ease-in), visibility 0s linear calc(var(--dur-base) * var(--exit-ratio));
  }
  .nav-primary__item:has([aria-expanded="true"]) .mega, .mega.is-open {
    opacity: 1; visibility: visible; transform: none;
    transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out), visibility 0s;
  }
  .mega__inner { display: grid; gap: var(--space-6); padding-block: var(--space-6); grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.2fr); }
  .mega__group { display: grid; gap: var(--space-1); align-content: start; }
  .mega__title { margin: 0 0 var(--space-2); font-size: var(--text-micro); letter-spacing: var(--track-eyebrow); text-transform: uppercase; color: var(--muted); font-weight: var(--weight-semibold); }
  .mega__link {
    position: relative; isolation: isolate; display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-2) var(--space-3); margin-inline: calc(var(--space-3) * -1); border-radius: var(--radius-md); color: var(--ink); text-decoration: none;
  }
  .mega__link::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--ink); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .mega__link:hover::before, .mega__link.is-hover::before { opacity: 0.05; }
  .mega__link:hover { color: var(--ink); text-decoration: none; }
  .mega__label { font-weight: var(--weight-semibold); font-size: var(--text-ui); line-height: 1.3; display: block; }
  .mega__desc { display: block; font-size: var(--text-small); color: var(--muted); line-height: 1.4; }
  .mega__feature { align-self: stretch; }
  @media (max-width: 79.99em) { .mega__inner { grid-template-columns: repeat(3, minmax(0, 1fr)); } .mega__feature { display: none; } }
  @media (forced-colors: active) { .mega { border: 1px solid CanvasText; } .nav-primary__link[aria-expanded="true"] { border: 1px solid Highlight; } .nav-primary__link[aria-current="page"] { text-decoration: underline; } }

  /* Theme cycle button (header): shows the icon of the theme you will get */
  .theme-cycle .icon--sun { display: none; }
  :root[data-theme="dark"] .theme-cycle .icon--sun { display: inline-block; }
  :root[data-theme="dark"] .theme-cycle .icon--moon { display: none; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-cycle .icon--sun { display: inline-block; }
    :root:not([data-theme="light"]) .theme-cycle .icon--moon { display: none; }
  }

  /* Mobile navigation panel (below the header) */
  .mobile-nav {
    position: fixed; inset-inline: 0; inset-block: var(--header-h) 0; z-index: var(--z-dropdown); overflow-y: auto; padding: var(--space-4) var(--gutter) var(--space-8);
    background: var(--surface); color: var(--ink);
  }
  .mobile-nav[hidden] { display: none; }
  .mobile-nav__list { list-style: none; margin: 0; padding: 0; display: grid; }
  .mobile-nav__link, .mobile-nav summary {
    display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0; border-block-end: 1px solid var(--hair); color: var(--ink);
    font-size: var(--text-h4); font-weight: var(--weight-semibold); letter-spacing: var(--track-h4); text-decoration: none; cursor: pointer; list-style: none;
  }
  .mobile-nav summary::-webkit-details-marker { display: none; }
  .mobile-nav details[open] summary .icon { transform: rotate(180deg); }
  .mobile-nav details > div { display: grid; padding-block: var(--space-2) var(--space-4); }
  .mobile-nav details a { display: flex; min-height: 44px; align-items: center; color: var(--ink-2); text-decoration: none; font-size: var(--text-body); }
  .mobile-nav__actions { display: grid; gap: var(--space-3); padding-block-start: var(--space-5); }

  /* Footer: five columns, newsletter, social, attribution band (navy) */
  .site-footer { background: var(--surface); color: var(--ink-2); border-block-start: 1px solid var(--line); font-size: var(--text-small); }
  .site-shell { min-height: 100vh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  .site-footer--slim { padding-block: var(--space-5); }
  .site-footer__grid { display: grid; gap: var(--space-6) var(--space-5); padding-block: var(--space-8); grid-template-columns: repeat(2, minmax(0, 1fr)); }
  @media (min-width: 48em) { .site-footer__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
  @media (min-width: 64em) { .site-footer__grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
  .site-footer__title { margin: 0 0 var(--space-3); font-size: var(--text-small); font-weight: var(--weight-semibold); color: var(--ink); }
  .site-footer__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
  .site-footer__list a { display: inline-flex; align-items: center; min-height: var(--target-min); color: var(--ink-2); text-decoration: none; }
  .site-footer__list a:hover { color: var(--link); text-decoration: underline; }
  .site-footer__news { display: grid; gap: var(--space-4); padding-block: var(--space-6); border-block-start: 1px solid var(--line); }
  @media (min-width: 48em) { .site-footer__news { grid-template-columns: minmax(0, 1fr) minmax(0, 28rem); align-items: center; } }
  .site-footer__social { display: flex; gap: var(--space-1); }
  .site-footer__attribution { background: var(--navy); color: var(--on-navy-2); padding-block: var(--space-6); font-size: var(--text-caption); --focus: var(--focus-on-navy); --link: var(--navy-accent); }
  .site-footer__attribution a { color: var(--on-navy); }
  .site-footer__attribution-inner { display: grid; gap: var(--space-4); align-items: center; }
  @media (min-width: 48em) { .site-footer__attribution-inner { grid-template-columns: auto 1fr; gap: var(--space-6); } }

  /* App shell (My Sectra, Staff Console) */
  .app-shell { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; background: var(--canvas); }
  @media (min-width: 48em) { .app-shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); } }
  @media (min-width: 80em) { .app-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); } .app-shell--rail { grid-template-columns: var(--rail-w) minmax(0, 1fr); } }
  .app-shell > .sidebar { display: none; }
  @media (min-width: 48em) { .app-shell > .sidebar { display: flex; } }
  .app-main { min-width: 0; display: flex; flex-direction: column; }
  .app-content { padding: var(--space-5) var(--gutter) var(--space-8); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); align-content: start; max-width: var(--content-wide); width: 100%; margin-inline: auto; }
  .page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
  .page-head__title { font-size: var(--text-h2); line-height: var(--lh-h2); letter-spacing: var(--track-h2); font-weight: var(--weight-semibold); }
  .page-head__sub { color: var(--ink-2); margin-block-start: var(--space-1); font-size: var(--text-ui-density); }

  .topbar {
    position: sticky; inset-block-start: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: var(--space-3); min-height: var(--topbar-h); padding: 0 var(--gutter);
    background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-block-end: 1px solid var(--glass-line);
  }
  .topbar__spacer { flex: 1; }
  .topbar > nav { min-width: 0; flex: 0 1 auto; overflow: hidden; }
  .topbar .breadcrumbs { flex-wrap: nowrap; }
  .topbar > :not(nav):not(.topbar__spacer) { flex: none; }
  .topbar__menu-btn { display: inline-grid; }
  @media (min-width: 48em) { .topbar__menu-btn { display: none; } }
  .palette-trigger {
    position: relative; isolation: isolate; display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--ctl-h-sm); width: min(100%, 22rem); padding: 0 var(--space-3);
    border: var(--bw) solid var(--line-strong); border-radius: var(--radius-ctl); background: var(--surface); color: var(--muted); font-size: var(--text-small); cursor: pointer; text-align: start;
  }
  .palette-trigger::before { content: ""; position: absolute; inset: -1px; z-index: -1; border-radius: inherit; background: var(--ink); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .palette-trigger:hover::before { opacity: 0.04; }
  .palette-trigger__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .palette-trigger .kbd { margin-inline-start: auto; }
  @media (max-width: 47.99em) { .palette-trigger { width: auto; } .palette-trigger__label, .palette-trigger .kbd { display: none; } }

  /* My Sectra sidebar. At 768-1279 px it collapses to the icon rail automatically. */
  .sidebar {
    position: sticky; inset-block-start: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4) var(--space-3);
    background: var(--surface); border-inline-end: 1px solid var(--hair); overflow-y: auto; overflow-x: hidden; z-index: var(--z-sticky);
  }
  .sidebar__brand { padding: var(--space-1) var(--space-2); }
  .sidebar__org {
    position: relative; isolation: isolate; display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: var(--space-2); border: var(--bw) solid var(--hair); border-radius: var(--radius-md); background: var(--surface-2);
    color: var(--ink); text-align: start; cursor: pointer;
  }
  .sidebar__org::before { content: ""; position: absolute; inset: -1px; z-index: -1; border-radius: inherit; background: var(--ink); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .sidebar__org:hover::before { opacity: 0.05; }
  .sidebar__org-text { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
  .sidebar__org-name { font-size: var(--text-small); font-weight: var(--weight-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar__org-sub { font-size: var(--text-micro); color: var(--muted); }
  .sidebar__nav { display: grid; gap: 2px; list-style: none; margin: 0; padding: 0; }
  .sidebar__section { margin: var(--space-4) var(--space-3) var(--space-1); font-size: var(--text-micro); font-weight: var(--weight-semibold); letter-spacing: var(--track-eyebrow); text-transform: uppercase; color: var(--muted); }
  .sidebar__spacer { flex: 1; }
  .sidebar__footer { display: grid; gap: var(--space-2); }

  .nav-item {
    position: relative; isolation: isolate; display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-ctl);
    color: var(--ink-2); font-size: var(--text-ui); font-weight: var(--weight-medium); letter-spacing: var(--track-ui); text-decoration: none; cursor: pointer; border: 0; background: transparent; width: 100%; text-align: start;
  }
  .nav-item::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--ink); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .nav-item:hover, .nav-item.is-hover { color: var(--ink); text-decoration: none; }
  .nav-item:hover::before, .nav-item.is-hover::before { opacity: 0.05; }
  .nav-item:active::before, .nav-item.is-active::before { opacity: 0.1; }
  .nav-item[aria-current="page"], .nav-item[aria-current="true"] { color: var(--ink); font-weight: var(--weight-semibold); }
  .nav-item[aria-current="page"]::before, .nav-item[aria-current="true"]::before { background: var(--accent-soft); opacity: 1; }
  .nav-item[aria-current="page"] > .icon { color: var(--accent); }
  .nav-item[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }
  .nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-item .badge { margin-inline-start: auto; }
  .nav-item:focus-visible { outline-offset: -2px; }

  /* Rail mode: icons only, labels remain for assistive technology, tooltip on hover and focus.
     Automatic between 768 and 1279 px; explicit with .sidebar--rail (Staff Console, 5.2). */
  @media (min-width: 48em) and (max-width: 79.99em) {
    .sidebar { align-items: center; padding-inline: var(--space-2); overflow: visible; }
    .sidebar .brand__text, .sidebar .sidebar__org-text, .sidebar .sidebar__org > .icon, .sidebar .sidebar__section, .sidebar .nav-item .badge { display: none; }
    .sidebar .sidebar__org { width: auto; padding: var(--space-1); border-color: transparent; background: transparent; }
    .sidebar .sidebar__nav { width: 100%; justify-items: center; }
    .sidebar .nav-item { width: 44px; height: 44px; padding: 0; justify-content: center; }
    .sidebar .nav-item__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .sidebar .nav-item[data-tip]::after {
      content: attr(data-tip); position: absolute; inset-inline-start: calc(100% + 10px); inset-block-start: 50%; transform: translate(-4px, -50%); padding: 6px 10px; border-radius: var(--radius-sm);
      background: var(--inverse-bg); color: var(--inverse-fg); font-size: var(--text-caption); white-space: nowrap; opacity: 0; visibility: hidden; pointer-events: none; z-index: var(--z-tooltip);
      transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), visibility 0s linear var(--dur-fast);
    }
    .sidebar .nav-item[data-tip]:hover::after, .sidebar .nav-item[data-tip]:focus-visible::after { opacity: 1; visibility: visible; transform: translate(0, -50%); transition-delay: 0s; }
  }
  .sidebar.sidebar--rail { align-items: center; padding-inline: var(--space-2); overflow: visible; }
  .sidebar.sidebar--rail .brand__text, .sidebar.sidebar--rail .sidebar__org-text, .sidebar.sidebar--rail .sidebar__org > .icon, .sidebar.sidebar--rail .sidebar__section, .sidebar.sidebar--rail .nav-item .badge { display: none; }
  .sidebar.sidebar--rail .sidebar__org { width: auto; padding: var(--space-1); border-color: transparent; background: transparent; }
  .sidebar.sidebar--rail .sidebar__nav { width: 100%; justify-items: center; }
  .sidebar.sidebar--rail .nav-item { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .sidebar.sidebar--rail .nav-item__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .sidebar.sidebar--rail .nav-item[data-tip]::after {
    content: attr(data-tip); position: absolute; inset-inline-start: calc(100% + 10px); inset-block-start: 50%; transform: translate(-4px, -50%); padding: 6px 10px; border-radius: var(--radius-sm);
    background: var(--inverse-bg); color: var(--inverse-fg); font-size: var(--text-caption); white-space: nowrap; opacity: 0; visibility: hidden; pointer-events: none; z-index: var(--z-tooltip);
    transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), visibility 0s linear var(--dur-fast);
  }
  .sidebar.sidebar--rail .nav-item[data-tip]:hover::after, .sidebar.sidebar--rail .nav-item[data-tip]:focus-visible::after { opacity: 1; visibility: visible; transform: translate(0, -50%); transition-delay: 0s; }
  @media (forced-colors: active) {
    .sidebar, .topbar, .site-header { border-color: CanvasText; }
    .nav-item[aria-current="page"] { border: 2px solid Highlight; }
    .nav-item[aria-current="page"]::before { display: none; }
  }

  /* Environment ribbon (non-production, Staff Console 5.1) and elevation pill */
  .env-ribbon { display: flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--env-ribbon-h); padding: 0 var(--gutter); background: var(--warning-soft); color: var(--warning-ink); border-block-end: 1px solid var(--warning); font-family: var(--font-mono); font-size: var(--text-micro); letter-spacing: 0.06em; text-transform: uppercase; font-weight: var(--weight-medium); }
  @media (forced-colors: active) { .env-ribbon { border-block-end: 2px solid CanvasText; } }
  .elevation-pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--link); font-size: var(--text-caption); font-weight: var(--weight-medium); white-space: nowrap; }
  @media (max-width: 29.99em) { .elevation-pill__label { display: none; } .topbar { gap: var(--space-2); } .topbar .sse > .sse__state { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } }
  .elevation-pill__time { font-variant-numeric: tabular-nums; font-family: var(--font-mono); letter-spacing: 0; }
  .elevation-pill.is-expiring { background: var(--warning-soft); color: var(--warning-ink); }
  @media (forced-colors: active) { .elevation-pill { border: 1px solid CanvasText; } }

  /* Breadcrumbs. Markup: nav[aria-label=Breadcrumb] > ol.breadcrumbs > li.breadcrumbs__item > a */
  .breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; font-size: var(--text-small); color: var(--muted); }
  .breadcrumbs__item { display: inline-flex; align-items: center; min-width: 0; }
  .breadcrumbs__item + .breadcrumbs__item::before { content: ""; flex: none; width: 6px; height: 6px; margin-inline: 8px 6px; border-block-start: 1.5px solid var(--muted); border-inline-end: 1.5px solid var(--muted); transform: rotate(45deg); }
  .breadcrumbs a { display: inline-flex; align-items: center; min-height: var(--target-min); color: var(--ink-2); text-decoration: none; border-radius: var(--radius-xs); }
  .breadcrumbs a:hover { color: var(--link); text-decoration: underline; }
  .breadcrumbs [aria-current="page"] { color: var(--ink); font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  @media (max-width: 47.99em) { .breadcrumbs__item--collapse { display: none; } }
}

/* =============================================================================
   OVERLAYS: dialog, sheet, step-up dialog, idle-timeout warning, menu and popover,
   tooltip, command palette, toast, banner
   Dialogs use the native <dialog> (focus trap, Escape, inert background, top layer).
   Enter: opacity + transform (spring). Exit: 70 percent of the enter duration, ease-in.
   ============================================================================= */
@layer components {
  .dialog {
    padding: 0; margin: auto; border: var(--bw) solid var(--line); border-radius: var(--radius-xl); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3);
    width: min(32rem, calc(100vw - 2 * var(--space-4))); max-width: none; max-height: min(88dvh, 46rem); overflow: hidden; flex-direction: column;
    opacity: 0; transform: translateY(var(--shift-sm)) scale(var(--scale-enter));
    transition:
      opacity calc(var(--dur-slow) * var(--exit-ratio)) var(--ease-in), transform calc(var(--dur-slow) * var(--exit-ratio)) var(--ease-in),
      display calc(var(--dur-slow) * var(--exit-ratio)) allow-discrete, overlay calc(var(--dur-slow) * var(--exit-ratio)) allow-discrete;
  }
  .dialog[open] {
    display: flex; opacity: 1; transform: none;
    transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-spring), display var(--dur-slow) allow-discrete, overlay var(--dur-slow) allow-discrete;
  }
  @starting-style { .dialog[open] { opacity: 0; transform: translateY(var(--shift-sm)) scale(var(--scale-enter)); } }
  .dialog::backdrop {
    background: var(--scrim); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: 0;
    transition: opacity calc(var(--dur-slow) * var(--exit-ratio)) var(--ease-in), display calc(var(--dur-slow) * var(--exit-ratio)) allow-discrete, overlay calc(var(--dur-slow) * var(--exit-ratio)) allow-discrete;
  }
  .dialog[open]::backdrop { opacity: 1; transition: opacity var(--dur-slow) var(--ease-out), display var(--dur-slow) allow-discrete, overlay var(--dur-slow) allow-discrete; }
  @starting-style { .dialog[open]::backdrop { opacity: 0; } }
  /* Inline panel: the dialog surface rendered in the page flow (documentation, visual tests, empty-page prompts). Not modal. */
  .dialog--inline { display: flex; position: static; opacity: 1; transform: none; margin: 0; width: min(32rem, 100%); max-height: none; box-shadow: var(--shadow-2); transition: none; }
  .dialog--sm { width: min(26rem, calc(100vw - 2 * var(--space-4))); }
  .dialog--lg { width: min(44rem, calc(100vw - 2 * var(--space-4))); }
  .dialog__header { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-3); }
  .dialog__title { flex: 1; min-width: 0; font-size: var(--text-h4); line-height: var(--lh-h4); letter-spacing: var(--track-h4); font-weight: var(--weight-semibold); margin: 0; }
  .dialog__close { margin: calc(var(--space-1) * -1) calc(var(--space-2) * -1) 0 0; }
  .dialog__body { padding: 0 var(--space-5) var(--space-5); overflow-y: auto; display: grid; gap: var(--space-4); color: var(--ink-2); font-size: var(--text-ui); line-height: var(--lh-ui); }
  .dialog__body > * { min-width: 0; }
  .dialog__body strong { color: var(--ink); }
  .dialog__footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-3); padding: var(--space-4) var(--space-5); background: var(--surface-2); border-block-start: 1px solid var(--hair); }
  .dialog__footer--stack { flex-direction: column; align-items: stretch; }
  .dialog__footer .dialog__aside { margin-inline-end: auto; color: var(--muted); font-size: var(--text-caption); }
  @media (forced-colors: active) { .dialog { border: 2px solid CanvasText; } .dialog::backdrop { background: transparent; } }

  /* Sheet: slides in from the end edge; from the bottom on phones */
  .sheet { margin: 0 0 0 auto; width: min(30rem, 100vw); height: 100vh; height: 100dvh; max-height: none; border-radius: var(--radius-xl) 0 0 var(--radius-xl); border-inline-end: 0; transform: translateX(var(--shift-lg)); }
  .sheet--start { margin: 0 auto 0 0; border-radius: 0 var(--radius-xl) var(--radius-xl) 0; transform: translateX(calc(var(--shift-lg) * -1)); border-inline-start: 0; border-inline-end: var(--bw) solid var(--line); }
  .sheet[open] { transform: none; }
  @starting-style { .sheet[open] { transform: translateX(var(--shift-lg)); } .sheet--start[open] { transform: translateX(calc(var(--shift-lg) * -1)); } }
  .sheet--wide { width: min(44rem, 100vw); }
  .sheet .dialog__body { flex: 1; }
  @media (max-width: 47.99em) {
    .sheet:not(.sheet--start) { margin: auto 0 0 0; width: 100vw; height: auto; max-height: 92dvh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; border-inline: 0; border-block-end: 0; transform: translateY(var(--shift-lg)); }
    .sheet:not(.sheet--start)[open] { transform: none; }
    @starting-style { .sheet:not(.sheet--start)[open] { transform: translateY(var(--shift-lg)); } }
  }

  /* Secure context line: states exactly what is being approved (APP-12, APP-39) */
  .secure-context { display: grid; gap: var(--space-2); padding: var(--space-4); border: var(--bw) solid var(--line); border-radius: var(--radius-md); background: var(--surface-2); color: var(--ink); }
  .secure-context__action { font-weight: var(--weight-semibold); }
  .secure-context__rows { display: grid; gap: var(--space-1); font-size: var(--text-small); color: var(--ink-2); }
  .secure-context__row { display: flex; gap: var(--space-3); justify-content: space-between; align-items: baseline; }
  .secure-context__row dt { color: var(--muted); flex: none; }
  .secure-context__row dd { margin: 0; text-align: end; min-width: 0; overflow-wrap: anywhere; }
  .stepup-head { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); }
  .countdown { font-variant-numeric: tabular-nums; font-family: var(--font-mono); letter-spacing: 0; font-weight: var(--weight-medium); color: var(--ink); }
  .countdown--xl { font-family: var(--font-sans); font-size: var(--text-h1); line-height: 1; letter-spacing: var(--track-h1); font-weight: var(--weight-semibold); }
  .countdown.is-low { color: var(--warning-ink); }

  /* Menu (native popover) and rich popover. components.js positions them against the invoker. */
  .menu, .popover {
    margin: 0; inset: auto; position: fixed; min-width: 12rem; max-width: min(24rem, calc(100vw - 2 * var(--space-4))); padding: 6px; overflow: auto;
    border: var(--bw) solid var(--line); border-radius: var(--radius-md); background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow-2);
    opacity: 0; transform: translateY(-4px) scale(0.98); transform-origin: top left;
    transition: opacity calc(var(--dur-base) * var(--exit-ratio)) var(--ease-in), transform calc(var(--dur-base) * var(--exit-ratio)) var(--ease-in), display calc(var(--dur-base) * var(--exit-ratio)) allow-discrete, overlay calc(var(--dur-base) * var(--exit-ratio)) allow-discrete;
  }
  .menu:popover-open, .popover:popover-open {
    opacity: 1; transform: none;
    transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-spring), display var(--dur-base) allow-discrete, overlay var(--dur-base) allow-discrete;
  }
  @starting-style { .menu:popover-open, .popover:popover-open { opacity: 0; transform: translateY(-4px) scale(0.98); } }
  .menu.is-above, .popover.is-above { transform-origin: bottom left; }
  /* Inline panels: a menu or popover shown in the page flow (documentation, visual tests). Not a popover. */
  .menu--inline, .popover--inline { position: static; opacity: 1; transform: none; transition: none; display: block; width: max-content; }
  .popover { padding: var(--space-4); width: 20rem; }
  .menu__label { padding: 6px 10px 4px; font-size: var(--text-micro); letter-spacing: var(--track-eyebrow); text-transform: uppercase; color: var(--muted); font-weight: var(--weight-semibold); }
  .menu__sep { height: 1px; margin: 6px 4px; background: var(--hair); border: 0; }
  .menu__item {
    position: relative; isolation: isolate; display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 36px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: transparent;
    color: var(--ink); font-size: var(--text-ui); text-align: start; text-decoration: none; cursor: pointer;
  }
  .menu__item::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--ink); opacity: 0; transition: opacity var(--dur-instant) var(--ease-out); }
  .menu__item:hover::before, .menu__item.is-hover::before, .menu__item:focus-visible::before { opacity: 0.07; }
  .menu__item:active::before { opacity: 0.14; }
  .menu__item:hover { color: var(--ink); text-decoration: none; }
  .menu__item:focus-visible { outline-offset: -2px; }
  .menu__item .icon { color: var(--ink-2); }
  .menu__item--danger .icon { color: var(--danger); }
  .menu__item[aria-disabled="true"], .menu__item:disabled { opacity: 0.4; pointer-events: none; }
  .menu__item .kbd { margin-inline-start: auto; }
  .menu__hint { margin-inline-start: auto; color: var(--muted); font-size: var(--text-caption); }
  @media (forced-colors: active) { .menu, .popover { border: 1px solid CanvasText; } .menu__item:focus-visible { outline: 2px solid Highlight; } }

  /* Tooltip (WCAG 1.4.13: dismissable with Escape, hoverable, persistent while focused) */
  .tooltip-host { position: relative; display: inline-flex; }
  .tooltip {
    position: absolute; inset-inline-start: 50%; inset-block-end: calc(100% + 8px); z-index: var(--z-tooltip); width: max-content; max-width: 16rem; padding: 6px 10px; border-radius: var(--radius-sm);
    background: var(--inverse-bg); color: var(--inverse-fg); font-size: var(--text-caption); line-height: 1.4; font-weight: var(--weight-regular); letter-spacing: 0; text-align: start; text-transform: none;
    opacity: 0; visibility: hidden; transform: translate(-50%, 4px);
    transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), visibility 0s linear var(--dur-fast);
  }
  .tooltip::before { content: ""; position: absolute; inset-inline: 0; inset-block-start: 100%; height: 10px; }
  .tooltip-host:hover > .tooltip, .tooltip-host:focus-within > .tooltip, .tooltip-host.is-open > .tooltip { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
  .tooltip-host[data-dismissed] > .tooltip { opacity: 0; visibility: hidden; }
  .tooltip--below { inset-block-end: auto; inset-block-start: calc(100% + 8px); transform: translate(-50%, -4px); }
  .tooltip--below::before { inset-block-start: auto; inset-block-end: 100%; }
  .tooltip-host:hover > .tooltip--below, .tooltip-host:focus-within > .tooltip--below, .tooltip-host.is-open > .tooltip--below { transform: translate(-50%, 0); }
  .tooltip--start { inset-inline-start: auto; inset-inline-end: calc(100% + 8px); inset-block-end: auto; inset-block-start: 50%; transform: translate(4px, -50%); }
  .tooltip--start::before { inset: 0 -10px 0 auto; width: 10px; height: auto; }
  .tooltip-host:hover > .tooltip--start, .tooltip-host:focus-within > .tooltip--start, .tooltip-host.is-open > .tooltip--start { transform: translate(0, -50%); }
  @media (forced-colors: active) { .tooltip { border: 1px solid CanvasText; background: Canvas; color: CanvasText; } }

  /* Command palette (Ctrl/Cmd+K or "/"). Actions run through the same endpoints and step-up sheet (APP-37). */
  .palette { width: min(40rem, calc(100vw - 2 * var(--space-4))); margin: 12vh auto auto; max-height: 70dvh; }
  /* the inline palette (documentation, visual tests) must not depend on the viewport height */
  .dialog--inline.palette { width: min(40rem, 100%); margin: 0; max-height: none; }
  .dialog--inline .palette__list { max-height: 20rem; }
  .palette__field { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-4); min-height: 56px; border-block-end: 1px solid var(--hair); color: var(--muted); }
  .palette__input { flex: 1; min-width: 0; height: 56px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: var(--text-lead); font-family: inherit; letter-spacing: var(--track-body); }
  .palette__input::placeholder { color: var(--muted); opacity: 1; }
  .palette__field:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }
  .palette__list { list-style: none; margin: 0; padding: var(--space-2); overflow-y: auto; max-height: 50dvh; display: grid; gap: 2px; align-content: start; }
  .palette__group { padding: var(--space-3) var(--space-3) var(--space-1); font-size: var(--text-micro); letter-spacing: var(--track-eyebrow); text-transform: uppercase; color: var(--muted); font-weight: var(--weight-semibold); }
  .palette__item { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-3); border-radius: var(--radius-md); color: var(--ink); font-size: var(--text-ui); cursor: pointer; }
  .palette__item .icon { color: var(--ink-2); }
  .palette__item:hover, .palette__item.is-hover { background: var(--surface-3); }
  .palette__item[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
  .palette__item[aria-selected="true"] .palette__hint { color: var(--ink-2); }
  .palette__hint { margin-inline-start: auto; font-size: var(--text-caption); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
  .palette__empty { padding: var(--space-6) var(--space-4); text-align: center; color: var(--muted); }
  .palette__footer { display: flex; flex-wrap: wrap; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-block-start: 1px solid var(--hair); background: var(--surface-2); font-size: var(--text-caption); color: var(--muted); }
  .palette__footer span { display: inline-flex; align-items: center; gap: 6px; }
  @media (forced-colors: active) { .palette__item[aria-selected="true"] { outline: 2px solid Highlight; outline-offset: -2px; box-shadow: none; } }

  /* Banner: info, success, warning, danger; inline or full width. Always icon + text. */
  .banner {
    --tone: var(--info); display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: var(--bw) solid color-mix(in srgb, var(--tone) 35%, transparent);
    border-radius: var(--radius-md); background: var(--info-soft); color: var(--ink); font-size: var(--text-ui); line-height: var(--lh-ui);
  }
  .banner--info { --tone: var(--info); background: var(--info-soft); }
  .banner--success { --tone: var(--success); background: var(--success-soft); }
  .banner--warning { --tone: var(--warning); background: var(--warning-soft); }
  .banner--danger { --tone: var(--danger); background: var(--danger-soft); }
  .banner--neutral { --tone: var(--control-border); background: var(--surface-3); }
  .banner__icon { flex: none; margin-block-start: 1px; color: var(--tone); }
  .banner__body { flex: 1; min-width: 0; display: grid; gap: 2px; }
  .banner__title { font-weight: var(--weight-semibold); }
  .banner__text { color: var(--ink-2); }
  .banner__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-block-start: var(--space-2); }
  .banner__close { flex: none; margin: calc(var(--space-1) * -1) calc(var(--space-2) * -1) calc(var(--space-1) * -1) 0; }
  .banner--page { border-radius: 0; border-inline: 0; border-block-start: 0; padding-inline: var(--gutter); }
  .banner--sticky { position: sticky; inset-block-start: var(--banner-offset, 0px); z-index: var(--z-sticky); }
  .banner[hidden] { display: none; }
  @media (forced-colors: active) { .banner { border: 2px solid CanvasText; } }

  /* Toast: polite live region, undo within 8 s (Staff Console), icon + text, never the only channel */
  .toast-region {
    position: fixed; inset-inline: 0; inset-block-end: var(--space-4); z-index: var(--z-toast); display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
    padding-inline: var(--space-4); pointer-events: none;
  }
  .toast {
    position: relative; overflow: hidden; pointer-events: auto; display: flex; align-items: center; gap: var(--space-3); width: min(30rem, 100%); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
    border-radius: var(--radius-md); background: var(--inverse-bg); color: var(--inverse-fg); box-shadow: var(--shadow-3); font-size: var(--text-ui); line-height: var(--lh-ui);
    animation: toast-in var(--dur-spring) var(--ease-spring) both;
  }
  .toast.is-leaving { animation: toast-out calc(var(--dur-base) * var(--exit-ratio)) var(--ease-in) both; }
  .toast__icon { flex: none; }
  .toast__text { flex: 1; min-width: 0; }
  .toast__action {
    flex: none; min-height: var(--ctl-h-sm); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--inverse-accent); font-weight: var(--weight-semibold); font-size: var(--text-ui); cursor: pointer;
  }
  .toast__action:hover { text-decoration: underline; }
  .toast__close { flex: none; display: inline-grid; place-items: center; width: var(--ctl-h-sm); height: var(--ctl-h-sm); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--inverse-fg); cursor: pointer; opacity: 0.8; }
  .toast__close:hover { opacity: 1; }
  .toast :focus-visible { outline-color: var(--inverse-accent); }
  .toast--undo::after { content: ""; position: absolute; inset-inline: 0; inset-block-end: 0; height: 3px; background: var(--inverse-accent); transform-origin: left center; animation: toast-timer var(--dur-undo) linear forwards; }
  [dir="rtl"] .toast--undo::after { transform-origin: right center; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(var(--shift-lg)) scale(var(--scale-enter)); } to { opacity: 1; transform: none; } }
  @keyframes toast-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(var(--shift-sm)); } }
  @keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
  @media (forced-colors: active) { .toast { border: 2px solid CanvasText; } .toast--undo::after { background: Highlight; } }
  @media (prefers-reduced-motion: reduce) { .toast--undo::after { animation: none; display: none; } }
  :root[data-motion="reduce"] .toast--undo::after { animation: none; display: none; }
}

/* =============================================================================
   FEEDBACK AND STATE: spinner, skeleton, progress, empty state, error state with
   request id, stream indicator, live-region announcer, timeline, stepper, file list,
   accordion, reveal-with-reason, typed-phrase confirmation, device code
   ============================================================================= */
@layer components {
  .spinner {
    display: inline-block; flex: none; width: 1em; height: 1em; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%;
    animation: spin var(--dur-spin) linear infinite; vertical-align: -0.125em;
  }
  .spinner--lg { width: 28px; height: 28px; border-width: 3px; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-inline-end-color: currentColor; border-style: dotted; } }
  :root[data-motion="reduce"] .spinner { animation: none; border-inline-end-color: currentColor; border-style: dotted; }

  /* Skeleton: appears only after 200 ms, pulses opacity only; reduced motion: static, no pulse.
     Skeletons match the final layout (CLS <= 0.02). Hold at least --skeleton-min once shown (script rule). */
  .skeleton { display: block; border-radius: var(--radius-sm); background: var(--surface-3); opacity: 0; animation: sk-in var(--dur-fast) var(--ease-out) var(--skeleton-delay) forwards, sk-pulse var(--dur-pulse) var(--ease-inout) calc(var(--skeleton-delay) + var(--dur-fast)) infinite; }
  .skeleton--text { height: 0.9em; margin-block: 0.35em; }
  .skeleton--title { height: 1.4em; width: 55%; }
  .skeleton--circle { border-radius: 50%; aspect-ratio: 1; }
  .skeleton--block { height: 6rem; border-radius: var(--radius-card); }
  .skeleton--w-25 { width: 25%; } .skeleton--w-40 { width: 40%; } .skeleton--w-60 { width: 60%; } .skeleton--w-80 { width: 80%; }
  .skeleton-stack { display: grid; gap: var(--space-2); }
  @keyframes sk-in { to { opacity: 1; } }
  @keyframes sk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
  @media (prefers-reduced-motion: reduce) { .skeleton { animation: sk-in var(--dur-fade-reduced) linear var(--skeleton-delay) forwards; } }
  :root[data-motion="reduce"] .skeleton { animation: sk-in var(--dur-fade-reduced) linear var(--skeleton-delay) forwards; }
  @media (forced-colors: active) { .skeleton { border: 1px solid GrayText; } }

  /* Progress: native <progress>, no inline width needed */
  .progress {
    appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 8px; border: 0; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--accent); overflow: hidden;
  }
  .progress::-webkit-progress-bar { background: var(--surface-3); border-radius: var(--radius-pill); }
  .progress::-webkit-progress-value { background: var(--accent); border-radius: var(--radius-pill); }
  .progress::-moz-progress-bar { background: var(--accent); border-radius: var(--radius-pill); }
  .progress--success { color: var(--success); } .progress--success::-webkit-progress-value { background: var(--success); } .progress--success::-moz-progress-bar { background: var(--success); }
  .progress--danger { color: var(--danger); } .progress--danger::-webkit-progress-value { background: var(--danger); } .progress--danger::-moz-progress-bar { background: var(--danger); }
  .progress--thin { height: 4px; }
  .progress-field { display: grid; gap: 6px; }
  .progress-field__row { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-small); color: var(--ink-2); font-variant-numeric: tabular-nums; }
  .progress-bar-indeterminate { position: relative; height: 4px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
  .progress-bar-indeterminate::after { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 40%; border-radius: inherit; background: var(--accent); animation: indeterminate var(--dur-indeterminate) var(--ease-inout) infinite; }
  @keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
  @media (prefers-reduced-motion: reduce) { .progress-bar-indeterminate::after { animation: none; transform: translateX(75%); } }
  :root[data-motion="reduce"] .progress-bar-indeterminate::after { animation: none; transform: translateX(75%); }
  @media (forced-colors: active) {
    .progress, .progress-bar-indeterminate { forced-color-adjust: none; background: Canvas; border: 1px solid ButtonText; }
    .progress::-webkit-progress-bar { background: Canvas; } .progress::-webkit-progress-value { background: Highlight; } .progress::-moz-progress-bar { background: Highlight; }
    .progress-bar-indeterminate::after { background: Highlight; }
  }

  /* Empty state and error state */
  .empty { display: grid; justify-items: center; align-content: center; gap: var(--space-3); padding: var(--space-8) var(--space-5); text-align: center; }
  .empty--compact { padding: var(--space-6) var(--space-4); }
  .empty--left { justify-items: start; text-align: start; }
  .empty__title { font-size: var(--text-h4); line-height: var(--lh-h4); font-weight: var(--weight-semibold); letter-spacing: var(--track-h4); }
  .empty__text { max-width: 36rem; color: var(--ink-2); font-size: var(--text-ui); line-height: var(--lh-ui); }
  .empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); margin-block-start: var(--space-2); }
  .error-state { display: grid; justify-items: center; align-content: center; gap: var(--space-3); padding: var(--space-8) var(--space-5); text-align: center; }
  .request-id { display: inline-flex; align-items: center; gap: var(--space-2); padding: 2px 4px 2px 12px; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--ink-2); font-size: var(--text-caption); }
  /* ink-2, not muted: muted on surface-3 is below 4.5:1 in light (found by axe; not in the Phase 0 table) */
  .request-id__label { color: var(--ink-2); }
  .request-id__value { font-family: var(--font-mono); letter-spacing: 0; color: var(--ink); user-select: all; }

  /* Stream (SSE) connection indicator: text first, icon and dot second. Set data-state on .sse. */
  .sse { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-caption); color: var(--ink-2); white-space: nowrap; }
  .sse__dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
  .sse__state { display: none; }
  .sse[data-state="live"] .sse__state--live, .sse[data-state="updating"] .sse__state--updating, .sse[data-state="reconnecting"] .sse__state--reconnecting,
  .sse[data-state="polling"] .sse__state--polling, .sse[data-state="offline"] .sse__state--offline { display: inline; }
  .sse[data-state="live"] .sse__dot { background: var(--success); }
  .sse[data-state="live"] .sse__dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--success); animation: sse-pulse var(--dur-beacon) var(--ease-out) infinite; }
  .sse[data-state="updating"] .sse__dot { background: var(--accent); }
  .sse[data-state="reconnecting"] .sse__dot { background: transparent; border: 2px solid var(--warning); }
  .sse[data-state="polling"] .sse__dot { background: var(--info); border-radius: 2px; transform: rotate(45deg); }
  .sse[data-state="offline"] .sse__dot { background: transparent; border: 2px solid var(--danger); }
  .sse[data-state="offline"] .sse__dot::after { content: ""; position: absolute; inset-inline: -2px; inset-block-start: 50%; height: 2px; margin-block-start: -2px; background: var(--danger); transform: rotate(-45deg); }
  @keyframes sse-pulse { from { transform: scale(1); opacity: 0.55; } to { transform: scale(2.6); opacity: 0; } }
  @media (prefers-reduced-motion: reduce) { .sse[data-state="live"] .sse__dot::after { animation: none; display: none; } }
  :root[data-motion="reduce"] .sse[data-state="live"] .sse__dot::after { animation: none; display: none; }
  @media (forced-colors: active) { .sse__dot { forced-color-adjust: none; background: CanvasText; } .sse[data-state="reconnecting"] .sse__dot, .sse[data-state="offline"] .sse__dot { background: Canvas; border-color: CanvasText; } }

  /* Live-region announcer: one polite summary, never one announcement per row. Visible only in the gallery. */
  .announcer { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .announcer--visible { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; white-space: normal; padding: var(--space-3) var(--space-4); border: 1px dashed var(--control-border); border-radius: var(--radius-md); background: var(--surface-2); font-family: var(--font-mono); font-size: var(--text-caption); color: var(--ink-2); }

  /* Timeline: activation history, ticket events, request status. State is shape + text, not color alone. */
  .timeline { list-style: none; margin: 0; padding: 0; display: grid; }
  .timeline__item { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-3); padding-block-end: var(--space-5); }
  .timeline__item:last-child { padding-block-end: 0; }
  .timeline__item::before { content: ""; position: absolute; inset-inline-start: 13px; inset-block: 28px 0; width: 2px; background: var(--line); }
  .timeline__item:last-child::before { display: none; }
  .timeline__marker { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 2px solid var(--control-border); color: var(--ink-2); }
  .timeline__marker .icon { width: 14px; height: 14px; stroke-width: 2; }
  .timeline__item--done .timeline__marker { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
  .timeline__item--done::before { background: var(--accent); }
  .timeline__item--current .timeline__marker { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
  .timeline__item--current .timeline__marker::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
  .timeline__item--failed .timeline__marker { border-color: var(--danger); color: var(--danger); }
  .timeline__item--pending { color: var(--muted); }
  .timeline__item--pending .timeline__marker { border-style: dashed; }
  .timeline__title { font-weight: var(--weight-semibold); font-size: var(--text-ui); line-height: 1.3; padding-block-start: 3px; }
  .timeline__time { font-size: var(--text-caption); color: var(--muted); font-variant-numeric: tabular-nums; }
  .timeline__text { margin-block-start: 2px; font-size: var(--text-small); color: var(--ink-2); }
  @media (forced-colors: active) { .timeline__item--done .timeline__marker { forced-color-adjust: none; background: Highlight; border-color: Highlight; color: HighlightText; } .timeline__item::before { background: CanvasText; } }

  /* Stepper (wizard): ol.stepper > li.stepper__item[aria-current=step] */
  .stepper { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--space-2); counter-reset: step; }
  .stepper__item { flex: 1; min-width: 0; display: grid; gap: var(--space-2); counter-increment: step; }
  .stepper__bar { height: 4px; border-radius: var(--radius-pill); background: var(--surface-3); }
  .stepper__item--done .stepper__bar, .stepper__item[aria-current="step"] .stepper__bar { background: var(--accent); }
  .stepper__label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-small); color: var(--muted); min-width: 0; }
  .stepper__label::before { content: counter(step); display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--control-border); font-size: var(--text-micro); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; color: var(--ink-2); }
  .stepper__item--done .stepper__label { color: var(--ink-2); }
  .stepper__label { position: relative; }
  .stepper__item--done .stepper__label::before { content: ""; background: var(--accent-fill); border-color: var(--accent-fill); }
  .stepper__item--done .stepper__label::after { content: ""; position: absolute; inset-inline-start: 8px; inset-block-start: 50%; width: 5px; height: 9px; border: solid var(--on-accent); border-width: 0 2px 2px 0; transform: translateY(-64%) rotate(45deg); }
  .stepper__item[aria-current="step"] .stepper__label { color: var(--ink); font-weight: var(--weight-semibold); }
  .stepper__item[aria-current="step"] .stepper__label::before { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
  .stepper__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  @media (max-width: 47.99em) { .stepper__item:not([aria-current="step"]) .stepper__text { display: none; } .stepper__item[aria-current="step"] { flex: 3; } }
  @media (forced-colors: active) { .stepper__bar { background: GrayText; } .stepper__item--done .stepper__bar, .stepper__item[aria-current="step"] .stepper__bar { background: Highlight; } .stepper__item--done .stepper__label::before { forced-color-adjust: none; background: Highlight; } }

  /* File list (support bundles, attachments) */
  .file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
  .file-list__item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); padding: var(--space-3); border: var(--bw) solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
  .file-list__name { font-weight: var(--weight-medium); font-size: var(--text-ui); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .file-list__meta { font-size: var(--text-caption); color: var(--muted); display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); align-items: center; }
  .file-list__item--error { border-color: var(--danger); }
  .file-list__item .progress { grid-column: 2 / -1; }

  /* Accordion on native <details> */
  .accordion { border-block-end: 1px solid var(--line); }
  .accordion:first-child { border-block-start: 1px solid var(--line); }
  .accordion__summary {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 56px; padding: var(--space-2) 0; list-style: none; cursor: pointer;
    font-size: var(--text-lead); font-weight: var(--weight-medium); color: var(--ink); letter-spacing: var(--track-body);
  }
  .accordion__summary::-webkit-details-marker { display: none; }
  .accordion__summary .icon { transition: transform var(--dur-base) var(--ease-out); color: var(--ink-2); }
  .accordion[open] > .accordion__summary .icon { transform: rotate(180deg); }
  .accordion__panel { padding-block-end: var(--space-5); max-width: var(--measure); color: var(--ink-2); }
  .accordion[open] > .accordion__panel { animation: enter var(--dur-base) var(--ease-out) both; }
  .accordion__summary:hover { color: var(--link); }
  .accordion__summary:focus-visible { outline-offset: -2px; border-radius: var(--radius-xs); }

  /* Reveal with reason (staff PII, serials): masked by default, a reason is recorded, auto-hides */
  .reveal-field { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
  .reveal-field__value { font-family: var(--font-mono); font-size: var(--text-mono); letter-spacing: 0; min-width: 0; overflow-wrap: anywhere; }
  .reveal-field__value--masked { color: var(--muted); letter-spacing: 0.12em; user-select: none; }
  .reveal-field__timer { font-size: var(--text-caption); color: var(--muted); font-variant-numeric: tabular-nums; }
  .reveal-field [data-state-revealed], .reveal-field.is-revealed [data-state-masked] { display: none; }
  .reveal-field.is-revealed [data-state-revealed] { display: inline-flex; }

  /* Typed-phrase confirmation for irreversible actions */
  .confirm-phrase { display: grid; gap: var(--space-2); }
  .confirm-phrase__phrase { display: inline-block; padding: 2px 8px; border-radius: var(--radius-xs); background: var(--surface-3); color: var(--ink); font-family: var(--font-mono); font-size: var(--text-mono); letter-spacing: 0; user-select: all; }
  .consequence { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--danger-soft); color: var(--ink); font-size: var(--text-small); }
  .consequence .icon { color: var(--danger); margin-block-start: 1px; }
  .consequence strong { color: var(--danger-ink); }
  @media (forced-colors: active) { .consequence { border: 2px solid CanvasText; } }

  /* Device code (approve an activation) */
  .device-code { display: block; padding: var(--space-4) var(--space-5); border: var(--bw) solid var(--line-strong); border-radius: var(--radius-card); background: var(--surface-2); text-align: center; font-family: var(--font-mono); font-size: clamp(1.5rem, 1.1rem + 2vw, 2.25rem); font-weight: var(--weight-medium); letter-spacing: 0.18em; font-variant-numeric: tabular-nums; color: var(--ink); user-select: all; }
}

/* =============================================================================
   MESSAGE (ticket thread, live conversation). Optimistic send shows "Sending..." and
   reverts visibly on failure (APP-38).
   ============================================================================= */
@layer components {
  .thread { display: grid; gap: var(--space-4); align-content: start; }
  .message { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--space-3); align-items: start; }
  .message__bubble { display: grid; gap: 4px; padding: var(--space-3) var(--space-4); border-radius: var(--radius-card); border-start-start-radius: var(--radius-xs); background: var(--surface-2); border: var(--bw) solid var(--hair); font-size: var(--text-ui); line-height: var(--lh-ui); min-width: 0; overflow-wrap: anywhere; }
  .message__meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); align-items: baseline; font-size: var(--text-caption); color: var(--muted); }
  .message__author { font-weight: var(--weight-semibold); color: var(--ink); }
  .message--own { grid-template-columns: minmax(0, 1fr) 32px; }
  .message--own .avatar { order: 2; }
  .message--own .message__bubble { background: var(--accent-soft); border-color: transparent; border-start-start-radius: var(--radius-card); border-start-end-radius: var(--radius-xs); }
  .message--sending .message__bubble { opacity: 0.7; }
  .message--failed .message__bubble { border-color: var(--danger); background: var(--danger-soft); }
  .message__status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-caption); }
  .message--failed .message__status { color: var(--danger-ink); font-weight: var(--weight-medium); }
  @media (forced-colors: active) { .message__bubble { border: 1px solid CanvasText; } .message--failed .message__bubble { border-width: 2px; } }
}

/* =============================================================================
   PAGE PATTERNS: hero, section head, device frame, inline form, page state (error
   pages), auth card. Small, reusable shells so prototypes do not invent their own.
   ============================================================================= */
@layer components {
  .hero { position: relative; overflow: hidden; padding-block: clamp(4rem, 3rem + 6vw, 8rem) clamp(3rem, 2rem + 4vw, 6rem); }
  .hero__inner { display: grid; gap: var(--space-6); justify-items: start; }
  .hero--center .hero__inner { justify-items: center; text-align: center; }
  .hero__title { max-width: 16ch; }
  .hero--center .hero__title { max-width: 18ch; }
  .hero__lead { max-width: 40rem; font-size: var(--text-lead); line-height: var(--lh-lead); color: var(--ink-2); }
  .hero__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
  .hero__media { margin-block-start: var(--space-5); width: 100%; }
  .section-head { display: grid; gap: var(--space-3); max-width: 44rem; margin-block-end: var(--space-7); }
  .section-head--center { margin-inline: auto; text-align: center; justify-items: center; }

  /* Device frame: the product's own interface is the hero (11.1). Window chrome is neutral grey. */
  .device { overflow: hidden; border: var(--bw) solid var(--line-strong); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-3); }
  .device__bar { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 var(--space-4); background: var(--surface-2); border-block-end: 1px solid var(--hair); }
  .device__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
  .device__title { margin-inline: auto; padding-inline-end: 42px; font-size: var(--text-micro); color: var(--muted); }
  .device__screen { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; background: var(--surface-3); object-fit: cover; }
  .device--tablet { padding: 12px; border: 0; border-radius: 34px; background: var(--navy-2); box-shadow: var(--shadow-3), inset 0 0 0 1px var(--navy-line); }
  .device--tablet .device__screen { border-radius: 22px; aspect-ratio: 16 / 10; }
  .device--tablet .device__bar { display: none; }
  @media (forced-colors: active) { .device { border: 2px solid CanvasText; } }

  .inline-form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-start; }
  .inline-form .field { flex: 1 1 14rem; }

  /* Error and status pages (404, 403, 500, maintenance, session ended, stream down) */
  .page-state { min-height: 0; display: grid; place-items: center; padding: var(--space-8) var(--gutter); }
  .page-state__inner { width: 100%; max-width: 34rem; display: grid; gap: var(--space-4); justify-items: start; }
  .page-state__code { font-family: var(--font-mono); font-size: var(--text-caption); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: var(--weight-medium); }
  .page-state__title { font-size: var(--text-h1); line-height: var(--lh-h1); letter-spacing: var(--track-h1); font-weight: var(--weight-semibold); text-wrap: balance; }
  .page-state__text { color: var(--ink-2); font-size: var(--text-lead); line-height: var(--lh-lead); max-width: 30rem; }
  .page-state__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-block-start: var(--space-2); }
  .page-state__help { margin-block-start: var(--space-5); padding-block-start: var(--space-5); border-block-start: 1px solid var(--line); width: 100%; display: grid; gap: var(--space-3); font-size: var(--text-small); color: var(--ink-2); }
  .page-state__links { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
  .page-state__links a { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--ctl-h-sm); }

  .auth-card { width: 100%; max-width: 26rem; margin-inline: auto; display: grid; gap: var(--space-5); padding: var(--space-6); background: var(--surface); border: var(--bw) solid var(--hair); border-radius: var(--radius-xl); box-shadow: var(--shadow-2); }
  .auth-card--wide { max-width: 34rem; }
  .auth-shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--canvas); }
  .auth-shell__main { display: grid; place-items: center; padding: var(--space-7) var(--gutter); }
  .auth-shell__head, .auth-shell__foot { padding: var(--space-4) var(--gutter); display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
  .auth-shell__foot { font-size: var(--text-caption); color: var(--muted); }
  @media (forced-colors: active) { .auth-card { border: 2px solid CanvasText; } }
}

/* =============================================================================
   UTILITIES (kept minimal; spacing belongs to layout components)
   ============================================================================= */
@layer utilities {
  .text-center { text-align: center; }
  .text-end { text-align: end; }
  .w-full { width: 100%; }
  .mt-0 { margin-block-start: 0; } .mt-2 { margin-block-start: var(--space-2); } .mt-4 { margin-block-start: var(--space-4); } .mt-6 { margin-block-start: var(--space-6); } .mt-8 { margin-block-start: var(--space-8); }
  .mb-0 { margin-block-end: 0; }
  .hide-sm { } @media (max-width: 47.99em) { .hide-sm { display: none !important; } }
  .show-sm { display: none !important; } @media (max-width: 47.99em) { .show-sm { display: revert !important; } }
  .hide-xs { } @media (max-width: 29.99em) { .hide-xs { display: none !important; } }
  .hide-lg { } @media (min-width: 64em) { .hide-lg { display: none !important; } }
  .inline-block { display: inline-block; }
  .relative { position: relative; }
}

/* Print: readable documents (price sheet, security-at-a-glance, request ids) */
@media print {
  .site-header, .sidebar, .topbar, .toast-region, .skip-link, .dialog { display: none !important; }
  body { background: var(--white); color: var(--black); }
}

