/* ==========================================================================
   BEAMERY DESIGN SYSTEM – CSS Custom Properties & Utility Classes
   Ground truth for prototyping, aligned to BeameryHQ/lib-design-system
   (packages/theme). WCAG 2.2 AA compliant on light backgrounds.
   Version 2 (2026-10-26): component classes carry lib-design-system names.
   v1 (../styles.css) is frozen for prototypes made before this date.
   ========================================================================== */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* --- Design Tokens ---
   Naming: --color-* are PRIMITIVES (lib-design-system baseColors).
   Semantic aliases (text/borders/backgrounds/controls/forms/outlines)
   follow packages/theme/src/colors.ts. Components consume semantics. */
:root {
  /* Primitives: brand */
  --color-brand-navy:          #150E3F;
  --color-brand-deep-lavender: #7E4BBC;
  --color-brand-orange:        #F15852;

  /* Primitives: neutrals */
  --color-neutral-900: #1F1F23;
  --color-neutral-800: #484851;
  --color-neutral-750: #5B5B67;
  --color-neutral-700: #6C6C7A;
  --color-neutral-600: #A0A0AB;
  --color-neutral-500: #BCBCC3;
  --color-neutral-400: #DBDBE0;
  --color-neutral-300: #E7E7E9;
  --color-neutral-200: #F1F1F3;
  --color-neutral-100: #F6F6F7;
  --color-neutral-0:   #FFFFFF;

  /* Primitives: indigos (brand primary ramp) */
  --color-indigo-900: #2222C3;
  --color-indigo-800: #391EE6;
  --color-indigo-500: #492FF4;
  --color-indigo-200: #D7D7FE;
  --color-indigo-100: #EBEBFE;

  /* Primitives: greens */
  --color-green-900: #064C1D;
  --color-green-800: #095D25;
  --color-green-500: #06742B;
  --color-green-200: #B1F6BD;
  --color-green-100: #D1FFD9;

  /* Primitives: yellows */
  --color-yellow-800: #704D00;
  --color-yellow-750: #885E00;
  --color-yellow-500: #FFBF00;
  --color-yellow-200: #FFE38D;
  --color-yellow-150: #FFEAAB;
  --color-yellow-100: #FFF1C7;
  --color-yellow-50:  #FFF8E3;

  /* Primitives: reds */
  --color-red-900: #860329;
  --color-red-800: #9E002D;
  --color-red-500: #BF0338;
  --color-red-400: #E70545;
  --color-red-200: #FFCCD2;
  --color-red-100: #FFE6E9;
  --color-red-50:  #FFF2F4;

  /* Semantic: text */
  --text-default:          var(--color-neutral-900);
  --text-secondary:        var(--color-neutral-700);
  --text-secondary-ongray: var(--color-neutral-750);
  --text-on-dark:          var(--color-neutral-0);
  --text-primary:          var(--color-indigo-500);
  --text-primary-active:   var(--color-indigo-900);
  --text-error:            var(--color-red-500);
  --text-warning:          var(--color-yellow-800);
  --text-warning-subtle:   var(--color-yellow-750);
  --text-success:          var(--color-green-500);

  /* Semantic: forms */
  --forms-label:                 var(--color-neutral-900);
  --forms-placeholder:           var(--color-neutral-700);
  --forms-placeholder-active:    var(--color-neutral-700);
  --forms-placeholder-ongray:    var(--color-neutral-750);

  /* Semantic: borders */
  --border-default:             var(--color-neutral-400);
  --border-form:                var(--color-neutral-700);   /* resting control border */
  --border-form-active:         var(--color-neutral-900);   /* hover/active border */
  --border-primary:             var(--color-indigo-500);
  --border-primary-active:      var(--color-indigo-900);
  --border-primary-subtle:      var(--color-indigo-200);
  --border-error:               var(--color-red-500);
  --border-error-subtle:        var(--color-red-200);
  --border-warning-subtle:      var(--color-yellow-150);
  --border-warning-subtle-hover:var(--color-yellow-750);

  /* Semantic: backgrounds */
  --bg-default:           var(--color-neutral-100);
  --bg-ongray:            var(--color-neutral-0);
  --bg-secondary:         var(--color-neutral-200);
  --bg-secondary-ongray:  var(--color-neutral-300);
  --bg-accent:            var(--color-indigo-100);
  --bg-accent-hover:      var(--color-indigo-200);
  --bg-success:           var(--color-green-100);
  --bg-warning:           var(--color-yellow-100);
  --bg-warning-subtle:    var(--color-yellow-50);
  --bg-error:             var(--color-red-100);
  --bg-error-subtle:      var(--color-red-50);
  --bg-dark:              var(--color-neutral-900);

  /* Semantic: controls (fills) */
  --control-primary:          var(--color-indigo-500);
  --control-primary-hover:    var(--color-indigo-800);
  --control-primary-active:   var(--color-indigo-900);
  --control-secondary:        var(--color-neutral-200);
  --control-secondary-hover:  var(--color-neutral-400);
  --control-secondary-active: var(--color-neutral-500);
  --control-destructive:        var(--color-red-500);
  --control-destructive-hover:  var(--color-red-800);
  --control-destructive-active: var(--color-red-900);
  --control-activation:         var(--color-green-500);
  --control-activation-hover:   var(--color-green-800);
  --control-activation-active:  var(--color-green-900);

  /* Semantic: outlines */
  --outline-focus: var(--color-indigo-500);

  /* Back-compat aliases used by filter / SC prototypes (--neutral-*, --brand-*) */
  --neutral-900: var(--color-neutral-900);
  --neutral-800: var(--color-neutral-800);
  --neutral-750: var(--color-neutral-750);
  --neutral-700: var(--color-neutral-700);
  --neutral-600: var(--color-neutral-600);
  --neutral-500: var(--color-neutral-500);
  --neutral-400: var(--color-neutral-400);
  --neutral-300: var(--color-neutral-300);
  --neutral-200: var(--color-neutral-200);
  --neutral-100: var(--color-neutral-100);
  --neutral-0:   var(--color-neutral-0);
  --brand-primary:        var(--color-indigo-500);
  --brand-primary-hover:  var(--color-indigo-800);
  --brand-primary-active: var(--color-indigo-900);
  --indigo-100: var(--color-indigo-100);
  --indigo-200: var(--color-indigo-200);
  --error:       var(--color-red-500);
  --error-light: var(--color-red-100);
  --control-keyline:       var(--border-form);
  --control-keyline-hover: var(--border-form-active);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --font-size-xs:  12px;
  --font-size-sm:  14px;
  --font-size-base:16px;
  --font-size-lg:  18px;
  --font-size-xl:  20px;
  --font-size-2xl: 24px;

  /* Spacing (4px grid) */
  --space-0:   0;
  --space-1:   4px;
  --space-2:   8px;
  --space-3:   12px;
  --space-4:   16px;
  --space-6:   24px;
  --space-8:   32px;
  --space-10:  40px;
  --space-18:  72px;

  /* Control height (lib-design-system sizes.x8) */
  --control-height: 32px;
  --chip-height: 28px;
  --chip-height-sm: 24px;

  /* Radii (lib-design-system radii x1 / x1_5 / x2) */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Shadows */
  --shadow-card:   0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
  --shadow-btn-primary:     0 2px 4px rgba(73,47,244,0.31);
  --shadow-btn-activation:  0 2px 4px rgba(6,116,43,0.31);
  --shadow-btn-destructive: 0 2px 4px rgba(191,3,56,0.31);
  --shadow-popover: 0 8px 16px rgba(31, 31, 35, 0.12);

  /* Focus ring – 2px white inset + 2px primary. The accessibility floor. */

  /* Stacking — tooltips above app chrome (top nav 100), bulk bars, panels */
  --z-tooltip: 1100;
  --focus-ring: 0 0 0 2px var(--color-neutral-0), 0 0 0 4px var(--outline-focus);

  /* Select chevron (neutral-900) */
  --ds-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M13.5306 6.53061L8.5306 11.5306C8.46092 11.6005 8.37813 11.656 8.28696 11.6939C8.1958 11.7317 8.09806 11.7512 7.99935 11.7512C7.90064 11.7512 7.8029 11.7317 7.71173 11.6939C7.62057 11.656 7.53778 11.6005 7.4681 11.5306L2.4681 6.53061C2.3272 6.38972 2.24805 6.19862 2.24805 5.99936C2.24805 5.80011 2.3272 5.60901 2.4681 5.46811C2.60899 5.32722 2.80009 5.24806 2.99935 5.24806C3.19861 5.24806 3.3897 5.32722 3.5306 5.46811L7.99997 9.93749L12.4693 5.46749C12.6102 5.32659 12.8013 5.24744 13.0006 5.24744C13.1999 5.24744 13.391 5.32659 13.5318 5.46749C13.6727 5.60838 13.7519 5.79948 13.7519 5.99874C13.7519 6.198 13.6727 6.38909 13.5318 6.52999L13.5306 6.53061Z' fill='%231F1F23'/%3E%3C/svg%3E");
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--text-default);
  line-height: 1.6;
  background: var(--bg-default);
}

/* --- Visually hidden (screen-reader only) --- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Typography --- */
h1, .heading-1 { font-size: var(--font-size-2xl); font-weight: 800; line-height: 36px; color: var(--text-default); }
.page-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  margin: 0;
  padding-top: 16px;
}
.page-title__logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: var(--text-default);
}
.page-title__suffix {
  flex: 1;
  min-width: 0;
}
h2, .heading-2 { font-size: var(--font-size-xl);  font-weight: 700; line-height: 32px; color: var(--text-default); }
h3, .heading-3 { font-size: var(--font-size-base);  font-weight: 700; line-height: 24px; color: var(--text-default); }
h4, .heading-4 { font-size: var(--font-size-sm);  font-weight: 700; line-height: 24px; color: var(--text-default); }
h5, .heading-5 { font-size: var(--font-size-xs);  font-weight: 700; line-height: 20px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.25px; }

.text-body       { font-size: var(--font-size-sm); color: var(--text-default); line-height: 20px; }
.text-body-em    { font-size: var(--font-size-sm); color: var(--text-default); font-weight: 600; line-height: 20px; }
.text-small      { font-size: var(--font-size-xs); color: var(--text-default); line-height: 20px; }
.text-secondary  { font-size: var(--font-size-sm); color: var(--text-secondary); line-height: 1.6; }
.text-label      { font-size: var(--font-size-sm); font-weight: 500; color: var(--text-default); }
.link       { font-size: var(--font-size-sm); color: var(--text-primary); cursor: pointer; text-decoration: none; }
.link:hover { color: var(--control-primary-hover); text-decoration: underline; }
.text-error      { font-size: var(--font-size-sm); color: var(--text-error); }
.text-success    { font-size: var(--font-size-sm); color: var(--text-success); }

/* --- Layout --- */
.stack-column { display: flex; flex-direction: column; }
.stack-row { display: flex; flex-direction: row; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }
.items-center   { align-items: center; }
.justify-end    { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }

.page-bg       { min-height: 100vh; background: var(--bg-default); }
.container     { max-width: 1280px; margin: 0 auto; padding: var(--space-6); }
.container-sm  { max-width: 448px; margin: 0 auto; }
.container-md  { max-width: 672px; margin: 0 auto; }

.grid      { display: grid; gap: var(--space-4); }
.grid-2    { grid-template-columns: repeat(2, 1fr); }
.grid-3    { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* --- Card --- */
.card {
  background: var(--bg-ongray);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.card-compact { padding: var(--space-4); }

/* --- Buttons ---
   Height: 32px (sizes.x8). `.button-sm` is 28px — matches chip height for inline
   rows (filter panels, chip toolbars). Secondary family carries a resting 1px
   border (borders.form), rendered as an inset box-shadow so geometry never
   shifts. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-height);
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  line-height: 1;
}
.button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.button:disabled, .button[disabled] { opacity: 0.5; cursor: not-allowed; }

.button-primary {
  background: var(--control-primary);
  color: var(--text-on-dark);
  box-shadow: var(--shadow-btn-primary);
}
.button-primary:hover  { background: var(--control-primary-hover); }
.button-primary:active { background: var(--control-primary-active); }

.button-secondary {
  background: var(--control-secondary);
  color: var(--text-default);
  box-shadow: inset 0 0 0 1px var(--border-default);
}
.button-secondary:hover  { background: var(--control-secondary-hover);  box-shadow: inset 0 0 0 1px var(--border-form-active); }
.button-secondary:active { background: var(--control-secondary-active); box-shadow: inset 0 0 0 1px var(--border-form-active); }
.button-secondary:focus-visible { box-shadow: inset 0 0 0 1px var(--border-form-active), var(--focus-ring); }
/* Select pickers are form controls: they keep the resting form border. */
.button-secondary.select-picker-trigger:not(:hover, :active, :focus-visible) { box-shadow: inset 0 0 0 1px var(--border-form); }

.button-secondary-accent {
  background: var(--bg-accent);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--border-primary-subtle);
}
.button-secondary-accent:hover  { background: var(--control-primary-hover); color: var(--text-on-dark); box-shadow: none; }
.button-secondary-accent:active { background: var(--control-primary-active); color: var(--text-on-dark); box-shadow: none; }

.button-subtle {
  background: transparent;
  color: var(--text-default);
}
.button-subtle:hover  { background: var(--control-secondary-hover); }
.button-subtle:active { background: var(--control-secondary-active); }

.button-activation {
  background: var(--control-activation);
  color: var(--text-on-dark);
  box-shadow: var(--shadow-btn-activation);
}
.button-activation:hover  { background: var(--control-activation-hover); }
.button-activation:active { background: var(--control-activation-active); }

.button-primary-destructive {
  background: var(--control-destructive);
  color: var(--text-on-dark);
  box-shadow: var(--shadow-btn-destructive);
}
.button-primary-destructive:hover  { background: var(--control-destructive-hover); }
.button-primary-destructive:active { background: var(--control-destructive-active); }

.button-secondary-destructive {
  background: var(--bg-error);
  color: var(--text-error);
  box-shadow: inset 0 0 0 1px var(--border-error-subtle);
}
.button-secondary-destructive:hover { background: var(--control-destructive-hover); color: var(--text-on-dark); box-shadow: none; }

.button-full { width: 100%; }

.button-sm {
  height: var(--chip-height);
  min-height: var(--chip-height);
  padding: 0 var(--space-3);
  font-size: var(--font-size-xs);
}
.button-sm.button-icon-only {
  width: var(--chip-height);
  padding: 0;
}
/* 24px, level with .chip-sm and the pill variant in dense filter rows. */
.button-xs {
  height: var(--chip-height-sm);
  min-height: var(--chip-height-sm);
  padding: 0 var(--space-2);
  font-size: var(--font-size-xs);
  gap: var(--space-1);
}
.button-xs.button-icon-only {
  width: var(--chip-height-sm);
  padding: 0;
}
.button-xs .button-icon,
.button-xs svg.button-icon { width: 12px; height: 12px; }

.button-icon,
svg.button-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.button-icon-only {
  padding: 0 var(--space-2);
}

/* Buttons section addition – lib-design-system variant="secondaryOnGray",
   which FileUploaderControl uses inside its drop zone. Fill is
   controls.secondaryOnGray (neutral-300, same value as --bg-secondary-ongray). */
.button-secondary-on-gray {
  background: var(--bg-secondary-ongray);
  color: var(--text-default);
  box-shadow: inset 0 0 0 1px var(--border-form);
}
.button-secondary-on-gray:hover  { background: var(--control-secondary-hover);  box-shadow: inset 0 0 0 1px var(--border-form-active); }
.button-secondary-on-gray:active { background: var(--control-secondary-active); box-shadow: inset 0 0 0 1px var(--border-form-active); }
.button-secondary-on-gray:focus-visible { box-shadow: inset 0 0 0 1px var(--border-form-active), var(--focus-ring); }

/* --- Inputs ---
   Grey-fill control (controls.secondary) with a visible resting border
   (borders.form). Hover darkens fill + border; focus goes white with the
   primary border + focus ring. */
.input {
  width: 100%;
  height: var(--control-height);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-form);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--text-default);
  background: var(--control-secondary);
  transition: border-color 0.15s, background-color 0.15s;
  line-height: 1.5;
}
.input::placeholder { color: var(--forms-placeholder); opacity: 1; }
.input-ongray::placeholder { color: var(--forms-placeholder-ongray); opacity: 1; }
.input:hover {
  background: var(--control-secondary-hover);
  border-color: var(--border-form-active);
}
.input:focus {
  outline: none;
  background: var(--bg-ongray);
  border-color: var(--border-primary);
  box-shadow: var(--focus-ring);
}
.input-error,
.input-error:hover { border-color: var(--border-error); }
.input-error:focus {
  border-color: var(--border-error);
  box-shadow: 0 0 0 2px var(--color-neutral-0), 0 0 0 4px var(--border-error);
}
.input:disabled {
  background: var(--control-secondary);
  border-color: var(--border-form);
  cursor: not-allowed;
  opacity: 0.5;
}
/* Read-only display variant — NOT disabled: full-contrast text, subtle border,
   white fill, no hover affordance. Use for showing values the user can read/copy
   but not edit. */
.input[readonly],
.input[readonly]:hover {
  background: var(--bg-ongray);
  border-color: var(--border-default);
  color: var(--text-default);
  cursor: default;
}
.input[readonly]:focus {
  background: var(--bg-ongray);
  border-color: var(--border-default);
  box-shadow: var(--focus-ring);
}

/* Search input variant – leading icon inside the field */
.input-search-wrap { position: relative; width: 100%; }
.input-search-wrap .input-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--forms-placeholder);
  pointer-events: none;
}
.input-search-wrap .input { padding-left: 34px; }

/* --- TextArea ---
   Compose with .input – <textarea class="input text-area"> – so every .input
   state (hover, focus, error, disabled, read-only) applies unchanged. This
   block only lifts the fixed 32px height. Matches lib-design-system TextArea:
   3 rows, 24px line height, vertical resize. */
.text-area {
  display: block;
  height: auto;
  min-height: var(--control-height);
  line-height: 24px;
  resize: vertical;
}
.text-area-resize-none { resize: none; }

/* --- CharacterCounter ---
   Remaining-character count under an Input or TextArea – lib-design-system
   CharacterCounter (Paragraph smallCompact, secondary). The visible text is
   aria-hidden; DS.initCharacterCounter adds a debounced polite live region. */
.character-counter {
  margin: 0;
  font-size: var(--font-size-xs);
  line-height: 18px;
  color: var(--text-secondary);
}

/* --- Form Elements --- */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.label { font-size: var(--font-size-sm); font-weight: 500; color: var(--forms-label); }
.field:has(.input-error) .label,
.field:has([aria-invalid="true"]) .label {
  color: var(--text-error);
}
.field-required { color: var(--text-error); }
.field-description  { font-size: var(--font-size-xs); line-height: 20px; color: var(--text-secondary); }
.field-error { font-size: var(--font-size-xs); line-height: 20px; color: var(--text-error); }

/* --- Select ---
   Secondary-control family (same chrome as .button-secondary): inset border, grey fill,
   chevron. Base styles apply to .select and filter-prototype aliases. */
.select,
.qualifier-select,
.modal-select,
.status-select {
  width: auto;
  max-width: 100%;
  height: var(--control-height);
  padding: var(--space-1) var(--space-8) var(--space-1) var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-default);
  background-color: var(--control-secondary);
  background-image: var(--ds-select-chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  box-shadow: inset 0 0 0 1px var(--border-form);
  appearance: none;
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s;
  align-self: flex-start;
  flex: 0 0 auto;
}
.select:hover,
.qualifier-select:hover,
.modal-select:hover,
.status-select:hover {
  background-color: var(--control-secondary-hover);
  box-shadow: inset 0 0 0 1px var(--border-form-active);
}
.select:active,
.qualifier-select:active,
.modal-select:active,
.status-select:active {
  background-color: var(--control-secondary-active);
  box-shadow: inset 0 0 0 1px var(--border-form-active);
}
.select:focus-visible,
.qualifier-select:focus-visible,
.modal-select:focus-visible,
.status-select:focus-visible {
  outline: none;
  background-color: var(--control-secondary);
  box-shadow: inset 0 0 0 1px var(--border-form-active), var(--focus-ring);
}
.select:disabled,
.qualifier-select:disabled,
.modal-select:disabled,
.status-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.select-full { width: 100%; }

/* --- List panels ---
   Shared floating list chrome for action menus and searchable pickers (typeahead).
   Items are text-only by default; add .menu-box__icon only for critical actions. */
.menu-box-host,
.search-input-wrap,
.input-search-wrap {
  position: relative;
}
.menu-box-host--inline {
  display: inline-block;
  width: auto;
}
.menu-box-host--select {
  display: block;
  width: 100%;
}
.menu-box-host--select > .button {
  width: 100%;
  justify-content: space-between;
}
.menu-box-host--select .select-picker__value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-weight: 300;
}
.menu-box-host--select-inline .select-picker__value {
  flex: 0 1 auto;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  text-align: left;
  font-weight: 300;
}
.select-picker__value.is-empty-muted {
  color: var(--text-secondary);
}
.menu-box-host--select-inline {
  display: inline-block;
  width: auto;
  max-width: 100%;
  vertical-align: middle;
  align-self: flex-start;
}
.menu-box-host--select-inline > .select-picker-trigger {
  width: auto;
}
.menu-box-host--select-inline > .menu-box {
  right: auto;
  width: max-content;
  min-width: 100%;
}

/* Select picker triggers — tighter insets than default .button (16px → 12px left, 8px right) */
.button.select-picker-trigger:not(.select-picker-trigger--chip) {
  padding-left: var(--space-3);
  padding-right: var(--space-2);
}

/* Action menu triggers with trailing caret — match select picker caret inset */
.menu-box-host > .button.button-secondary:not(.select-picker-trigger):not(.button-icon-only):has(> .button-icon:last-child) {
  padding-right: var(--space-2);
}

/* Chip select picker — 28px pill trigger matching .chip; for inline filter rows */
.menu-box-host--select-chip {
  display: inline-block;
  width: auto;
  max-width: 100%;
  vertical-align: middle;
  align-self: flex-start;
}
.menu-box-host--select-chip > .select-picker-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  height: var(--chip-height);
  min-height: var(--chip-height);
  padding: 0 var(--space-3);
  border-radius: 9999px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 400;
  line-height: 1;
  background: var(--bg-ongray);
  color: var(--text-default);
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: none;
}
.menu-box-host--select-chip > .select-picker-trigger:hover {
  background: var(--bg-secondary);
  border-color: var(--border-form-active);
}
.menu-box-host--select-chip > .select-picker-trigger:active {
  background: var(--bg-secondary-ongray);
  border-color: var(--border-form-active);
}
.menu-box-host--select-chip > .select-picker-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.menu-box-host--select-chip .select-picker__value {
  flex: 0 1 auto;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  text-align: left;
  font-weight: 400;
}
.menu-box-host--select-chip .select-picker-trigger .button-icon {
  width: 12px;
  height: 12px;
  color: var(--text-secondary);
}
.menu-box-host--select-chip > .menu-box {
  right: auto;
  width: max-content;
  min-width: 100%;
}

/* Pill select picker (candidate for prod) — 24px neutral pill trigger for the condition type in a filter row.
   Tone is data-tone="warning" | "error" on the host: only all of and none of take a colour. */
.menu-box-host--select-pill {
  display: inline-block;
  width: auto;
  max-width: 100%;
  vertical-align: middle;
  align-self: center;
}
.menu-box-host--select-pill > .button.select-picker-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  width: auto;
  height: var(--chip-height-sm);
  min-height: var(--chip-height-sm);
  padding: 0 var(--space-2);
  border: 0;
  border-radius: 9999px;
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  font-weight: 400;
  line-height: 1;
  background: var(--bg-secondary-ongray);
  color: var(--text-default);
  box-shadow: none;
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s;
}
.menu-box-host--select-pill > .select-picker-trigger:is(:hover, [aria-expanded="true"]) { background: var(--color-neutral-400); }
.menu-box-host--select-pill > .select-picker-trigger:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.menu-box-host--select-pill[data-tone="warning"] > .select-picker-trigger { background: var(--bg-warning); color: var(--text-warning); }
.menu-box-host--select-pill[data-tone="warning"] > .select-picker-trigger:is(:hover, [aria-expanded="true"]) { background: var(--color-yellow-150); }
.menu-box-host--select-pill[data-tone="error"] > .select-picker-trigger { background: var(--bg-error); color: var(--text-error); }
.menu-box-host--select-pill[data-tone="error"] > .select-picker-trigger:is(:hover, [aria-expanded="true"]) { background: var(--color-red-200); }
.menu-box-host--select-pill .select-picker__value { flex: 0 1 auto; overflow: visible; text-overflow: clip; white-space: nowrap; text-align: left; font-weight: 400; }
.menu-box-host--select-pill .select-picker-trigger .button-icon { width: 12px; height: 12px; color: inherit; }
.menu-box-host--select-pill > .menu-box { right: auto; width: max-content; min-width: 100%; }

/* Blank "Any …" picker (candidate for prod) — outlined 24px pill with a caret; opens a menu, not a listbox. */
.any-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: var(--chip-height-sm);
  padding: 0 var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: 9999px;
  background: var(--bg-ongray);
  color: var(--text-default);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.any-pill:hover { background: var(--bg-secondary); border-color: var(--border-form-active); }
.any-pill:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.any-pill .button-icon { width: 12px; height: 12px; color: var(--text-secondary); }

/* Labeled select picker — prefix label inside trigger (“Sort by:” + value; empty → “Any …”) */
.menu-box-host--select-labeled {
  display: block;
  width: 100%;
}
.menu-box-host--select-labeled > .button {
  width: 100%;
  justify-content: space-between;
}
.menu-box-host--select-labeled-inline {
  display: inline-block;
  width: auto;
  max-width: 100%;
  vertical-align: middle;
  align-self: flex-start;
}
.menu-box-host--select-labeled-inline > .select-picker-trigger {
  width: auto;
}
.menu-box-host--select-labeled-inline > .menu-box {
  right: auto;
  width: max-content;
  min-width: 100%;
}
.select-picker__display {
  display: flex;
  align-items: baseline;
  gap: 0.25em;
  min-width: 0;
}
.menu-box-host--select-labeled .select-picker__display {
  flex: 1;
  overflow: hidden;
}
.menu-box-host--select-labeled-inline .select-picker__display {
  flex: 0 1 auto;
  overflow: visible;
}
.select-picker__prefix {
  font-weight: 500;
  flex-shrink: 0;
}
.menu-box-host--select-labeled .select-picker__value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-weight: 300;
}
.menu-box-host--select-labeled-inline .select-picker__value {
  flex: 0 1 auto;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  text-align: left;
  font-weight: 300;
}
.menu-box-host--select-labeled.is-empty .select-picker__prefix,
.menu-box-host--select-labeled-inline.is-empty .select-picker__prefix {
  display: none;
}
.menu-box-host--select-labeled.is-empty .select-picker__value,
.menu-box-host--select-labeled-inline.is-empty .select-picker__value {
  font-weight: 500;
}

select.select-picker-native {
  display: none !important;
}

.menu-box,
.autocomplete-results {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 100%;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-ongray);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  padding: var(--space-1);
}
.menu-box-host--inline > .menu-box {
  right: auto;
  min-width: 12rem;
}
.autocomplete-results {
  max-height: 180px;
}
.menu-box[hidden],
.autocomplete-results[hidden] {
  display: none;
}

.menu-box__item[hidden],
.autocomplete-option[hidden] {
  display: none !important;
}

.menu-box__item,
.autocomplete-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 28px;
  padding: 5px var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-default);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  line-height: 1.4;
}
.menu-box__item:hover,
.menu-box__item.is-active,
.autocomplete-option:hover,
.autocomplete-option.is-active {
  background: var(--bg-secondary);
}
/* Selected option, as production: primary text and a trailing check, no fill. Hover alone fills. */
.menu-box__item[aria-selected="true"] {
  color: var(--text-primary);
}
.menu-box__check {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-left: auto;
  visibility: hidden;
}
.menu-box__item[aria-selected="true"] .menu-box__check {
  visibility: visible;
}
.menu-box__item:focus-visible,
.autocomplete-option:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.menu-box__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.menu-box__divider {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: var(--space-1) 0;
}

.menu-box__empty,
.autocomplete-empty {
  padding: 6px var(--space-2);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* --- Chips ---
   Value chip: resting border borders.default; hover darkens the border to
   formActive with a subtle fill; selected goes accent + indigo-900. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--chip-height);
  padding: 0 var(--space-3);
  border-radius: 9999px;
  font-size: var(--font-size-sm);
  font-weight: 400;
  line-height: 1;
  background: var(--bg-ongray);
  color: var(--text-default);
  border: 1px solid var(--border-default);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
/* Dense filter rows and compact toolbars. 24px is the SC 2.5.8 floor.
   Same modifier on value chips, radio chips, and checkbox chips. */
.chip-sm {
  height: var(--chip-height-sm);
  padding: 0 var(--space-2);
  font-size: var(--font-size-xs);
  gap: 4px;
}
.chip:hover {
  background: var(--bg-secondary);
  border-color: var(--border-form-active);
}
.chip:active {
  background: var(--bg-secondary-ongray);
  border-color: var(--border-form-active);
}
.chip:focus-visible,
.chip:focus-within {
  outline: none;
  box-shadow: var(--focus-ring);
}
.chip.selected {
  background: var(--bg-accent);
  color: var(--text-primary-active);
  border-color: var(--border-primary-active);
}
.chip.selected:hover,
.chip-check:has(.chip-input:checked):hover { background: var(--bg-accent-hover); }
.chip-check:has(.chip-input:checked) {
  background: var(--bg-accent);
  color: var(--text-primary-active);
  border-color: var(--border-primary-active);
}
.chip .chip-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
}
.chip .chip-close:hover { color: var(--text-default); opacity: 1; }
.chip .chip-close svg { width: 12px; height: 12px; }
/* Removable-chip affordance (filter prototypes): hovering a chip whose only
   action is removal previews the destructive outcome with errorSubtle colours. */
.chip.removable:hover {
  background: var(--bg-ongray);
  border-color: var(--text-error);
  color: var(--text-error);
}
.chip.removable:hover .chip-close { color: var(--text-error); }

/* Chip wrapping a native checkbox or radio (selected = checked state). */
.chip-check { position: relative; }
.chip-check .chip-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.field-set {
  border: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.field-set + .field-set { margin-top: var(--space-4); }
.field-set legend {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--forms-label);
  margin-bottom: var(--space-2);
  padding: 0;
}
.chip-check-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* --- Split chip – Candidate for prod ---
   One 24px pill holding a value, its qualifier picker and a ×, with a divider before each of the last two
   (Location + radius, Language + proficiency). Spec: 2026-10-inclusions-exclusions/split-chip-spec-0.1.html.
   Markup:  <span class="chip-split" role="group" aria-label="{value}, {qualifier}">
              <span class="tooltip__bubble" aria-hidden="true">{value}</span>
              <span class="chip-split__value">{value}</span>
              <select class="select select-picker-chip" aria-label="{Qualifier} for {value}">…</select>
              <button type="button" class="chip-split__remove" aria-label="Remove {value}, {qualifier}">…</button>
            </span>
   The picker segment is the chip Select, restyled only by its parent. DS.markSplitChips sets [data-truncated]
   so the tooltip shows only for a truncated value. --split-line recolours the outline and dividers. */
.chip-split {
  --split-line: var(--border-default);
  position: relative;
  display: inline-flex;
  align-items: stretch;
  box-sizing: border-box;
  max-width: 100%;
  height: var(--chip-height-sm);
  border: 1px solid var(--split-line);
  border-radius: 9999px;
  background: var(--bg-ongray);
  color: var(--text-default);
  font-size: var(--font-size-xs);
  line-height: 1;
  transition: border-color .15s, color .15s;
}
/* The value gives way first. The truncating box needs a full line of height, or overflow: hidden crops descenders. */
.chip-split__value {
  align-self: center;
  min-width: 0;
  padding: 0 var(--space-2);
  line-height: 1.5;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The picker and the × reach over the pill's 1px outline, so each target is the full 24px (WCAG 2.5.8). */
.chip-split > .menu-box-host--select-chip {
  flex: none;
  align-self: stretch;
  width: auto;
  max-width: none;
  margin-block: -1px;
  border-left: 1px solid var(--split-line);
}
.chip-split > .menu-box-host--select-chip > .select-picker-trigger {
  height: 100%;
  min-height: 0;
  padding: 0 var(--space-2);
  gap: 4px;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: inherit;
  color: inherit;
}
/* The fill reaches over the outline, so the hover redraws the top and bottom lines inside it. */
.chip-split > .menu-box-host--select-chip > .select-picker-trigger:is(:hover, :active, [aria-expanded="true"]) { background: var(--bg-secondary); box-shadow: inset 0 1px var(--split-line), inset 0 -1px var(--split-line); }
/* Pressed and open take the chip Select's pressed fill, a step darker than hover. */
.chip-split > .menu-box-host--select-chip > .select-picker-trigger:is(:active, [aria-expanded="true"]) { background: var(--bg-secondary-ongray); }
/* Hover, pressed and open darken the whole outline, dividers included, so the lines drawn over the fill match the
   rest of the pill. The outline always follows --split-line, whatever a .chip hover rule says. */
.chip-split:has(> .menu-box-host--select-chip > .select-picker-trigger:is(:hover, :active, [aria-expanded="true"])) { --split-line: var(--border-form); }
.chip-split:is(:hover, :active) { border-color: var(--split-line); }
.chip-split > .menu-box-host--select-chip > .select-picker-trigger:focus-visible { box-shadow: var(--focus-ring); }
.chip-split__remove {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: var(--chip-height-sm);
  margin-block: -1px;
  padding: 0 2px 0 0;
  border: 0;
  border-left: 1px solid var(--split-line);
  border-radius: 0 9999px 9999px 0;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}
.chip-split__remove svg { width: 12px; height: 12px; }
.chip-split__remove:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* Pointing at the value or the ×, or focusing the ×, previews what goes: the value and its qualifier together.
   The qualifier segment is the one part that does not remove. */
.chip-split:has(.chip-split__value:hover, .chip-split__remove:is(:hover, :focus-visible)) { --split-line: var(--text-error); color: var(--text-error); }
.chip-split:has(.chip-split__value:hover, .chip-split__remove:is(:hover, :focus-visible)) :is(.chip-split__remove, .select-picker-trigger .button-icon, .select-picker-trigger .select-picker__value) { color: var(--text-error); }
/* A qualifier at its null option ("Any proficiency") is drawn quieter than one that narrows. */
.chip-split--unqualified > .menu-box-host--select-chip > .select-picker-trigger .select-picker__value { color: var(--text-secondary); }
/* The full value in the tooltip bubble, only when truncated: on pointing at the value, or while focus is on the
   qualifier or the ×, so the keyboard reaches it without a tab stop of its own. */
.chip-split > .tooltip__bubble { left: 0; transform: none; max-width: min(288px, 80vw); text-align: left; }
.chip-split[data-truncated]:is(:has(.chip-split__value:hover), :focus-within) > .tooltip__bubble {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.12s ease 0.4s, visibility 0s;
}

/* --- Connector chips (AND / OR / IS / IS NOT) ---
   Full spec in Filter System/connector-chip-spec.md.
   11px/700. All pairings ≥ 4.5:1. Locked variant: same colours,
   cursor not-allowed, not focusable, no hover response. */
.connector {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background-color .12s, border-color .12s, color .12s;
}
.connector.or, .connector.is {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
}
.connector.or:hover, .connector.is:hover {
  background: var(--bg-secondary-ongray);
  border-color: var(--border-form);
  color: var(--text-default);
}
.connector.and {
  background: var(--bg-warning-subtle);
  border: 1px solid var(--border-warning-subtle);
  color: var(--text-warning-subtle);
}
.connector.and:hover { border-color: var(--border-warning-subtle-hover); }
.connector.not, .connector.is-not {
  background: var(--bg-error-subtle);
  border: 1px solid var(--border-error-subtle);
  color: var(--text-error);
}
.connector.not:hover, .connector.is-not:hover { border-color: var(--border-error); }
.connector:not(.locked):focus-visible {
  outline: 2px solid var(--outline-focus);
  outline-offset: 2px;
}
/* Locked: cursor affordance only – hover/active re-pin the resting colours */
.connector.locked { cursor: not-allowed; }
.connector.or.locked:hover, .connector.or.locked:active,
.connector.is.locked:hover, .connector.is.locked:active {
  background: var(--bg-secondary);
  border-color: var(--border-default);
  color: var(--text-secondary);
}
.connector.and.locked:hover, .connector.and.locked:active {
  background: var(--bg-warning-subtle);
  border-color: var(--border-warning-subtle);
  color: var(--text-warning-subtle);
}
.connector.not.locked:hover, .connector.not.locked:active,
.connector.is-not.locked:hover, .connector.is-not.locked:active {
  background: var(--bg-error-subtle);
  border-color: var(--border-error-subtle);
  color: var(--text-error);
}

/* --- Checkbox (single) ---
   16×16 box, 4px radius – matches lib-design-system Checkbox. */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  line-height: 20px;
  color: var(--text-default);
  cursor: pointer;
  user-select: none;
}
.checkbox-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.checkbox-box {
  position: relative;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 1px solid var(--border-form);
  border-radius: var(--radius-sm);
  background: var(--color-neutral-0);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s, background-color 0.12s;
}
.checkbox-box svg {
  width: 12px;
  height: 12px;
  color: var(--text-on-dark);
  opacity: 0;
  transition: opacity 0.12s;
}
.checkbox:hover .checkbox-input:not(:checked):not(:disabled) + .checkbox-box {
  border-color: var(--border-primary);
}
.checkbox-input:checked + .checkbox-box {
  border-color: var(--border-primary-active);
  background: var(--control-primary-active);
}
.checkbox-input:checked + .checkbox-box svg { opacity: 1; }
.checkbox-input:focus-visible + .checkbox-box { box-shadow: var(--focus-ring); }
.checkbox-input:disabled + .checkbox-box {
  opacity: 0.5;
  cursor: not-allowed;
}
.checkbox-input:disabled ~ .checkbox-label {
  opacity: 0.5;
  cursor: not-allowed;
}
.checkbox:has(.checkbox-input:disabled) { cursor: not-allowed; }

/* --- Toggle ---
   Off track is neutral-700 (≥3:1 against both the page and the white thumb);
   On is brand primary. State is conveyed by thumb position + track colour
   + icon – three non-colour-alone cues (SC 1.4.1). */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  cursor: pointer;
  user-select: none;
}
.toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--color-neutral-700);
  border-radius: 9999px;
  transition: background-color 0.2s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--color-neutral-0);
  border-radius: 9999px;
  transition: transform 0.2s;
  z-index: 1;
}
.toggle-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  color: var(--color-neutral-0);
}
.toggle-icon svg { width: 12px; height: 12px; }
.toggle-icon-check { left: 5px; opacity: 0; }
.toggle-icon-close { right: 5px; opacity: 1; }
.toggle-input:checked + .toggle-track { background: var(--control-primary); }
.toggle-input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle-input:checked + .toggle-track .toggle-icon-check { opacity: 1; }
.toggle-input:checked + .toggle-track .toggle-icon-close { opacity: 0; }
.toggle-input:focus-visible + .toggle-track { box-shadow: var(--focus-ring); }
.toggle-input:disabled + .toggle-track { opacity: 0.5; cursor: not-allowed; }

/* Compact / dense toggle size (exploration – not yet in lib-design-system).
   Match default thumb:track ratio (~75% height, equal inset). Hit target ≥24×24
   via padding on the label – never on the track, or the thumb looks undersized. */
.toggle-track--xs {
  width: 36px;
  height: 16px;
}
.toggle-track--xs .toggle-thumb {
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
}
.toggle-track--xs .toggle-icon {
  width: 12px;
  height: 12px;
}
.toggle-track--xs .toggle-icon svg { width: 12px; height: 12px; }
.toggle-track--xs .toggle-icon-check { left: 2px; }
.toggle-track--xs .toggle-icon-close { right: 2px; }
.toggle-input:checked + .toggle-track--xs .toggle-thumb { transform: translateX(20px); }

/* Hit padding on the control, not the track – keeps the painted pill true-to-size */
.toggle--compact-hit {
  min-height: 24px;
  align-items: center;
}
.toggle--compact-hit:has(.toggle-track--xs) {
  padding-block: 4px; /* 16 + 8 = 24 */
}

/* Toggle with description – matches the lib-design-system Toggle `description`
   prop. The description sits outside the <label> so it reaches the input as
   aria-describedby rather than bloating its accessible name, and is indented
   to start under the label text, not the track. */
.toggle-field { display: flex; flex-direction: column; gap: 2px; }
.toggle-description {
  margin: 0;
  padding-left: calc(44px + var(--space-2));
  max-width: calc(76ch + 44px + var(--space-2));
  font-size: var(--font-size-xs);
  line-height: 20px;
  color: var(--text-secondary);
}

/* --- Pills (status labels) --- */
.pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: 9999px;
  font-size: var(--font-size-xs);
  font-weight: 400;
  white-space: nowrap;
}
/* A leading icon sits at 12px so it reads as a peer of the 12px label. */
.pill > .ds-icon,
.badge > .ds-icon { width: 12px; height: 12px; }
.pill-accent, .pill-primary, .badge-accent, .badge-primary { background: var(--bg-accent); color: var(--text-primary); }
.pill-success, .badge-success { background: var(--bg-success); color: var(--text-success); }
.pill-error,   .badge-error   { background: var(--bg-error); color: var(--text-error); }
.pill-warning, .badge-warning { background: var(--bg-warning); color: var(--text-warning); }
/* Production's neutral pill: neutral-300 fill, default text. */
.pill-neutral, .badge-neutral { background: var(--bg-secondary-ongray); color: var(--text-default); }

/* --- Divider --- */
.divider {
  border: none;
  border-top: 1px solid var(--color-neutral-300);
  margin: var(--space-4) 0;
}

/* --- Alerts --- */
.notification {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}
.notification-error   { background: var(--bg-error);   color: var(--text-error); }
.notification-success { background: var(--bg-success); color: var(--text-success); }
.notification-warning { background: var(--bg-warning); color: var(--text-warning); }
.notification-icon    { flex-shrink: 0; width: 20px; height: 20px; }
.notification-body    { flex: 1; }
.notification-title   { font-weight: 600; margin-bottom: var(--space-1); }
.notification-accent  { background: var(--bg-accent);  color: var(--text-primary); }
.notification-info    { background: var(--bg-secondary-ongray); color: var(--text-default); }

/* --- Toast: a floating, dismissible notification --- */
.toast-region {
  position: fixed;
  inset: auto var(--toast-inset-end, 0) var(--toast-offset, var(--space-2)) var(--toast-inset-start, 0);
  width: auto;
  height: auto;
  margin: 0;
  padding: 0 var(--space-4);
  border: 0;
  background: none;
  overflow: visible;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}
.toast-region:popover-open { display: flex; }
.notification-toast {
  pointer-events: auto;
  align-items: flex-start;
  max-width: 34rem;
  padding: var(--space-3) var(--space-4);
  border: 1px solid currentColor;
  box-shadow: var(--shadow-popover);
}
@media (prefers-reduced-motion: no-preference) {
  .notification-toast { animation: notification-toast-in 0.18s ease; }
}
@keyframes notification-toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.notification-toast .notification-body { min-width: 0; line-height: 1.45; }
.notification-toast .notification-title { margin-bottom: 0; }
.notification-toast__action {
  display: inline-block;
  margin-top: var(--space-1);
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.notification-toast__close {
  flex-shrink: 0;
  margin: -2px -2px 0 0;
  padding: 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
}
.notification-toast__close:hover { opacity: 1; }
.notification-toast__close svg { display: block; width: 14px; height: 14px; }
.notification-toast__action:focus-visible,
.notification-toast__close:focus-visible { outline: none; box-shadow: var(--focus-ring); opacity: 1; }

/* --- Icons (SVG sprite, currentColor) --- */
.ds-icon { width: 16px; height: 16px; flex-shrink: 0; }
.ds-logo { width: 118px; height: 32px; color: var(--text-default); }
.ds-bexa { width: 32px; height: 32px; color: var(--text-default); }

/* --- Table / DataTable ---------------------------------------------------
   Markup-first: author a real <table class="data-table">; DS.initDataTable()
   progressively enhances it (sorting, expansion, pinning, pagination).
   Mirrors lib-design-system's DataTable capabilities in HTML/CSS terms.

   Per-column opt-in, all on the <th>:
     data-col="key"            → sortable (JS paints aria-sort + indicator)
     data-sort-type="text|number|date"   (default text)
     data-variant="text|numeric|link|emphasisedLink|actions|expansion|custom"
     data-pinned="start"       → sticks to the left on horizontal scroll
   DS.initDataTable() stamps .cell--<variant> / .cell--pinned onto every cell
   in that column, so cells carry no per-row variant markup.

   Row-level classes (authored, not derived):
     .data-table__subrow            → a child row; hidden until its parent expands
     .data-table__subrow-label      → the indented label cell inside a subrow
     .is-acknowledged          → row text drops to text.secondary
   ------------------------------------------------------------------------ */

/* Scroll container. Required whenever a column is pinned. Deliberately carries
   no border or radius — it scrolls, and nothing else. Wrap it in a .card if a
   table wants card chrome. */
.data-table-scroll {
  overflow-x: auto;
  background: var(--bg-ongray);
}

/* --fill: take the remaining height of a flex column parent and scroll inside,
   instead of growing the page. The parent needs `display: flex; flex-direction:
   column; overflow: hidden` and this needs `min-height: 0` or flexbox refuses
   to shrink it below its content. Makes the sticky <thead> actually stick. */
.data-table-scroll--fill {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.data-table {
  width: 100%;
  /* `separate` (not `collapse`) so position:sticky works on pinned cells. */
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-sm);
  background: var(--bg-ongray);
}

.data-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-weight: 400;
  font-size: var(--font-size-xs);
  color: var(--text-secondary-ongray);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--color-neutral-300);
  user-select: none;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
/* Sorting is opt-in: only a th carrying data-col is interactive. */
.data-table th[data-col] { cursor: pointer; }
.data-table th[data-col]:hover { color: var(--text-default); }
.data-table th[data-col]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.data-table th .sort-indicator {
  display: inline-flex;
  align-items: center;
  width: 12px;
  height: 12px;
  margin-left: var(--space-1);
  vertical-align: middle;
  color: var(--text-secondary);
}
.data-table th[aria-sort="ascending"] .sort-indicator,
.data-table th[aria-sort="descending"] .sort-indicator {
  color: var(--control-primary);
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-neutral-300);
  color: var(--text-default);
  background: var(--bg-ongray);
  vertical-align: middle;
}
.data-table tbody tr:last-child > td { border-bottom: none; }
/* --align-top: for tables whose cells wrap, so a two-line message and a
   one-word cell start on the same baseline instead of drifting apart.
   Middle stays the default, matching production. */
.data-table--align-top td { vertical-align: top; }

/* A marker prefacing a cell's primary text. It reads as a glyph on the text's
   line, and an absent marker takes up no space at all — the text closes up.
   A single flex line rather than inline flow: the text is nowrap + ellipsis,
   so in inline flow its max-width claims the whole cell and drops below the
   marker as soon as the column gets narrow. Flex can't wrap, so the marker and
   the text stay on one line at any width and the text ellipsises instead.
   .cell-marker__state carries no styles of its own — it is the markup hook a
   prototype's script rewrites when the row's state flips. Keep it. */
.cell-marker {
  display: flex;
  align-items: center;
  min-width: 0;
}
.cell-marker > a,
.cell-marker > .cell-content { min-width: 0; }
.data-table tbody tr:hover > td { background: var(--bg-default); }

/* ── Column variants (stamped onto cells by DS.initDataTable) ── */
.data-table .cell--numeric,
.data-table th[data-variant="numeric"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.data-table .cell--link a,
.data-table .cell--emphasisedLink a {
  color: var(--text-primary);
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.data-table .cell--emphasisedLink a { font-weight: 600; }
.data-table .cell--link a:hover,
.data-table .cell--emphasisedLink a:hover { text-decoration: underline; }
.data-table .cell--link a:focus-visible,
.data-table .cell--emphasisedLink a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.data-table .cell--actions,
.data-table th[data-variant="actions"] {
  text-align: right;
  white-space: nowrap;
}
.data-table .cell--actions > * + * { margin-left: var(--space-1); }
.data-table .cell--expansion,
.data-table th[data-variant="expansion"] {
  width: 40px;
  padding-right: 0;
  padding-left: var(--space-3);
}

/* ── Pinned columns (offsets computed by DS.initDataTable) ── */
.data-table .cell--pinned { position: sticky; z-index: 1; }
.data-table th.cell--pinned,
.data-table th[data-pinned="start"],
.data-table th[data-pinned="end"] { z-index: 3; }
/* Edge shadow appears only once the table is actually scrolled. */
.data-table-scroll.is-scrolled .cell--pinned-last::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 8px;
  transform: translateX(100%);
  pointer-events: none;
  background: linear-gradient(to right, rgba(31,31,35,0.08), transparent);
}
.data-table .cell--pinned-last { position: sticky; }
/* End-pinned: holds the right edge, so a row action stays reachable when the
   table is wider than the viewport. Needs an opaque fill of its own. */
.data-table .cell--pinned-end { position: sticky; right: 0; z-index: 1; }
.data-table th.cell--pinned-end { z-index: 3; }
.data-table-scroll.is-scrollable-end .cell--pinned-end::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 8px;
  transform: translateX(-100%);
  pointer-events: none;
  background: linear-gradient(to left, rgba(31,31,35,0.08), transparent);
}

/* ── Unread marker — one of three redundant signals ──
   An unread row carries a dot inline before the record name, default-colour
   text, and a check button; an acknowledged row has no dot, secondary text,
   and a flag button that puts it back to unread. The dot is therefore never
   the sole carrier of state, and the marker holds .visually-hidden text in both
   states so it reaches a screen reader rather than only a sighted user. */
.data-table__unread {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: var(--control-primary);
  /* Sits on the text's vertical centre; when absent, the text closes up.
     No reserved slot, no gutter. */
  vertical-align: middle;
}
.cell-marker .data-table__unread { margin-right: var(--space-2); }
/* ── Row action revealed on hover or focus ──
   opacity (not display/visibility) so the control keeps its place in the tab
   order and the accessibility tree whether or not it is visible. */
.data-table__ack {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--bg-ongray);
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background-color 0.15s, color 0.15s;
}
.data-table__ack svg { width: 16px; height: 16px; }
/* :focus (not :focus-visible) for the reveal — the control must appear for any
   focus, keyboard or programmatic; :focus-visible governs the ring only. */
.data-table tbody tr:hover .data-table__ack,
.data-table tbody tr:focus-within .data-table__ack,
.data-table__ack:focus { opacity: 1; }
.data-table__ack:hover { background: var(--control-secondary-hover); color: var(--text-default); }
.data-table__ack:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* The control is a toggle: check to acknowledge, flag to reinstate unread.
   Acknowledging is progress-tracking with no other undo, so it has to be
   reversible. Both directions share this class and differ only by icon. */
/* No hover on touch: a hover-only control would be unreachable there. */
@media (hover: none) {
  .data-table__ack { opacity: 1; }
}

/* ── Cell content: single-line, ellipsised, tooltip carries the full value ── */
.cell-content {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-content--wrap { white-space: normal; overflow: visible; }
.cell-sub {
  display: block;
  margin-top: 2px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}
/* Small secondary line inside a cell — identifiers, codes, timestamps. These
   are content, so they stay in the body face; monospace is for code samples
   (<code>), not for data a user reads. */
.cell-small {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}
/* Click-to-copy identifier — quiet until hovered. */
.cell-copy {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 100%;
  padding: 2px var(--space-1);
  margin: -2px calc(var(--space-1) * -1);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  /* A <button> does not inherit font-family, so state it or the browser
     substitutes its own UA face. */
  font-family: inherit;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
}
.cell-copy > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-copy svg { width: 12px; height: 12px; opacity: 0; flex-shrink: 0; }
.cell-copy:hover { background: var(--control-secondary); color: var(--text-default); }
.cell-copy:hover svg { opacity: 0.7; }
.cell-copy:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cell-copy.is-copied { color: var(--text-success); }
.cell-copy.is-copied svg { opacity: 1; }

/* ── Expansion toggle ── */
.data-table__expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-default);
  cursor: pointer;
}
.data-table__expand:hover { background: var(--control-secondary); }
.data-table__expand:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.data-table__expand svg { width: 16px; height: 16px; }

/* ── Subrows — the child attempts of an expanded parent ── */
.data-table__subrow[hidden] { display: none; }
.data-table__subrow > td {
  background: var(--bg-default);
  color: var(--text-secondary);
}
.data-table tbody tr.data-table__subrow:hover > td { background: var(--bg-secondary); }
.data-table__subrow-label {
  padding-left: var(--space-10) !important;
  color: var(--text-default);
}

/* ── Unread rows read at full contrast throughout ──
   Secondary text inside a row is reserved to *mean* acknowledged, so the utility
   classes that are secondary by default (.cell-sub, .cell-small, .cell-copy) go
   back to default colour on an unread row — otherwise a row of mono identifiers
   reads as half-acknowledged and the signal stops being legible.
   Subrows keep their de-emphasis: they are history, not unread items. */
.data-table tbody tr:not(.data-table__subrow):not(.is-acknowledged) > td,
.data-table tbody tr:not(.data-table__subrow):not(.is-acknowledged) > td .cell-sub,
.data-table tbody tr:not(.data-table__subrow):not(.is-acknowledged) > td .cell-small,
.data-table tbody tr:not(.data-table__subrow):not(.is-acknowledged) > td .cell-copy {
  color: var(--text-default);
}

/* ── Acknowledged rows — recede, without leaving the list ──
   Pills are deliberately left alone: they carry their own meaning, and fading
   them turns one pill into two visual states for the same value. Row state is
   carried by the marker, the text colour and the button. */
.data-table tbody tr.is-acknowledged > td,
.data-table tbody tr.is-acknowledged > td .cell-sub,
.data-table tbody tr.is-acknowledged > td .cell-small { color: var(--text-secondary); }
.data-table tbody tr.is-acknowledged > td a { color: var(--text-secondary); }

/* ── Table toolbar + result count ── */
.data-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.data-table-count { font-size: var(--font-size-sm); color: var(--text-default); }
.data-table-count strong { font-weight: 600; }
/* Right-hand group for controls that shape the result set rather than filter
   it — a page-size select, a show/hide switch. */
.data-table-toolbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* ── Empty state ── */
.data-table__empty {
  padding: var(--space-10) var(--space-4);
  text-align: center;
}
.data-table__empty[hidden] { display: none; }
.data-table__empty-icon {
  width: 32px;
  height: 32px;
  margin: 0 auto var(--space-3);
  color: var(--text-secondary);
}
.data-table__empty-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-default);
  margin-bottom: var(--space-1);
}
.data-table__empty-body {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  max-width: 44ch;
  margin: 0 auto;
}

/* ── Loading skeleton — stands in for the table before first data ── */
.data-table__skeleton[hidden] { display: none; }
.data-table__skeleton .skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-neutral-300);
}
.data-table__skeleton .skeleton-row:last-child { border-bottom: none; }
.skeleton-bar {
  height: 12px;
  flex: 1;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg,
    var(--color-neutral-200) 25%,
    var(--color-neutral-300) 37%,
    var(--color-neutral-200) 63%);
  background-size: 400% 100%;
  animation: ds-skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-bar--sm { flex: 0 0 64px; }
.skeleton-bar--md { flex: 0 0 140px; }
@keyframes ds-skeleton-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ── Infinite scroll — batches load as the list nears its end; no footer.
      Driven by DS.initInfiniteScroll(). From the applicant review build. ── */
.infinite-sentinel {
  flex-shrink: 0;
  width: 100%;
  height: 1px;
  pointer-events: none;
}
.load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 80px;
}
.load-more svg {
  width: 24px;
  height: 24px;
  color: var(--text-secondary);
  animation: ds-spin 0.7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ── Pagination — numbered (offset) or Prev/Next (cursor) ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}
.pagination__status { font-size: var(--font-size-sm); color: var(--text-secondary); }
.pagination__status strong { color: var(--text-default); font-weight: 600; }
.pagination__pages { display: flex; align-items: center; gap: var(--space-1); }
.pagination__page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--control-height);
  height: var(--control-height);
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  font-family: inherit;   /* a <button> does not inherit it */
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-default);
  cursor: pointer;
}
.pagination__page:hover:not(:disabled) { background: var(--control-secondary-hover); }
.pagination__page:active:not(:disabled) { background: var(--control-secondary-active); }
.pagination__page:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.pagination__page:disabled { opacity: 0.45; cursor: not-allowed; }
.pagination__page[aria-current="page"] {
  background: var(--control-primary);
  color: var(--text-on-dark);
}
.pagination__page[aria-current="page"]:hover:not(:disabled),
.pagination__page[aria-current="page"]:active:not(:disabled) { background: var(--control-primary-hover); }
.pagination__ellipsis {
  padding: 0 var(--space-1);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* --- Tooltip — CSS-only, brief plain text, reveals on hover + focus ---
   Markup:  <span class="tooltip"> <trigger> <span class="tooltip__bubble"
   data-position="top|right|bottom|left">…</span> </span>
   The trigger must be focusable. When the tip duplicates an accessible name
   (e.g. an icon button's aria-label) mark the bubble aria-hidden="true";
   otherwise link them with aria-describedby on the trigger. */
.tooltip { position: relative; display: inline-flex; }
.tooltip:hover,
.tooltip:focus-within {
  z-index: var(--z-tooltip);
}
.tooltip__bubble {
  position: absolute;
  z-index: var(--z-tooltip);
  pointer-events: none;
  width: max-content;
  max-width: 220px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-dark);
  color: var(--text-on-dark);
  font-size: var(--font-size-xs);
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  box-shadow: var(--shadow-card);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0s linear 0.12s;
}
.tooltip:hover > .tooltip__bubble,
.tooltip:focus-within > .tooltip__bubble {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.12s ease 0.4s, visibility 0s;   /* ~hover-intent delay */
}
/* Instant reveal — no hover-intent delay. Set data-delay="instant" on .tooltip,
   or use side nav chrome (instant by convention). */
.tooltip[data-delay="instant"]:hover > .tooltip__bubble,
.tooltip[data-delay="instant"]:focus-within > .tooltip__bubble,
.side-nav .tooltip:hover > .tooltip__bubble,
.side-nav .tooltip:focus-within > .tooltip__bubble {
  transition: opacity 0.12s ease, visibility 0s;
}
/* Position — default top. 8px gap from the trigger. */
.tooltip__bubble,
.tooltip__bubble[data-position="top"]    { bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); }
.tooltip__bubble[data-position="bottom"] { top: calc(100% + 8px); bottom: auto; left: 50%; transform: translateX(-50%); }
.tooltip__bubble[data-position="left"]   { right: calc(100% + 8px); left: auto; top: 50%; bottom: auto; transform: translateY(-50%); }
.tooltip__bubble[data-position="right"]  { left: calc(100% + 8px); top: 50%; bottom: auto; transform: translateY(-50%); }

/* Info tip — a 24px icon button that carries detail not worth body copy.
   Wrap in .tooltip and point aria-describedby at the bubble. */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 9999px;
  background: none;
  color: var(--text-secondary);
  cursor: help;
  flex-shrink: 0;
}
.info-tip:hover { color: var(--text-default); background: var(--control-secondary); }
.info-tip:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.info-tip svg { width: 16px; height: 16px; }

/* --- Dialog ---
   Native <dialog class="modal"> opened with showModal(): Escape, focus
   trapping and the top layer come free. scripts.js closes it on a backdrop
   click. Named .modal to match lib-design-system Modal (v1 called it .dialog). */
.modal {
  width: min(440px, calc(100vw - 32px));
  margin: auto; /* the reset zeroes the UA centring */
  padding: var(--space-6);
  border: none;
  border-radius: var(--radius-lg);
  background: var(--bg-ongray);
  color: var(--text-default);
  box-shadow: 0 12px 32px rgba(21, 14, 63, 0.2);
}
.modal:modal { overscroll-behavior: contain; } /* a scroll gesture in the dialog doesn't chain to the page */
.modal::backdrop {
  background: rgba(21, 14, 63, 0.4);
  overflow: hidden; /* ::backdrop isn't a scroll container, so it ignores overscroll-behavior without this */
  overscroll-behavior: contain;
}
.modal__title { font-size: var(--font-size-lg); font-weight: 700; line-height: 28px; }
.modal__body { margin-top: var(--space-2); font-size: var(--font-size-sm); line-height: 20px; overflow-wrap: anywhere; }
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

/* --- Tabs ---
   lib-design-system Tabs (variant underline, tabStyle horizontal.top).
   Markup:  <div class="tabs"> <div class="tabs__list" role="tablist">
   <button class="tabs__tab" role="tab" aria-selected aria-controls>…
   </div> <div class="tabs__panel" role="tabpanel">… </div>
   DS.initTabs() fills ids, aria-controls, the roving tabindex and hidden
   panels; clicks and arrow keys are delegated, so later markup works too.
   The 2px marker sits on the list's 1px rule, 4px below the tab box. */
.tabs { display: flex; flex-direction: column; width: 100%; }
.tabs__list {
  display: flex;
  gap: var(--space-6);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--border-default);
}
.tabs__tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  padding: var(--space-2);
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--text-default);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
  cursor: pointer;
}
.tabs__tab::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(-1 * var(--space-1));
  height: 2px;
  border-radius: 2px 2px 0 0;
  pointer-events: none;
}
.tabs__tab > .pill { line-height: 16px; }
.tabs__tab:hover { color: var(--control-primary); }
.tabs__tab:hover::after { background: var(--control-secondary-hover); }
.tabs__tab[aria-selected="true"] { color: var(--control-primary-active); }
.tabs__tab[aria-selected="true"]::after { background: var(--control-primary-active); }
/* Prod's focussed state: primary text over the grey marker, plus the ring. */
.tabs__tab:focus-visible {
  outline: none;
  color: var(--control-primary);
  box-shadow: var(--focus-ring);
}
.tabs__tab:focus-visible::after { background: var(--control-secondary-hover); }

.tabs__panel:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.tabs__panel[hidden] { display: none !important; }

/* Compact list (exploration – not yet in lib-design-system) for narrow side
   panels: 12px labels, 16px gap. 2 + 20 + 2 keeps the 24px target. */
.tabs__list--compact { gap: var(--space-4); }
.tabs__list--compact .tabs__tab {
  padding: 2px var(--space-1);
  font-size: var(--font-size-xs);
}

/* --- Popover ---
   lib-design-system Popover: a non-modal floating surface anchored to a
   trigger. Native <div class="popover" popover> opened by a button with
   popovertarget: the top layer, light dismiss, Escape and focus return come
   from the browser; scripts.js anchors it below the trigger (bottom-start),
   flipping above when there is no room. For a list of commands use
   .menu-box; for a brief plain-text hint use .tooltip. */
.popover {
  /* The UA centres a popover in the viewport; scripts.js sets top/left. */
  inset: auto;
  margin: 0;
  max-width: min(320px, calc(100vw - 16px));
  padding: var(--space-2) 0;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-ongray);
  color: var(--text-default);
  box-shadow: var(--shadow-popover);
  font-size: var(--font-size-sm);
  line-height: 20px;
  overflow: auto;
}
.popover__body { padding: var(--space-2) var(--space-4); }

/* --- Expandable region ---
   lib-design-system ExpandableRegion as native <details>/<summary>: the
   summary is the toggle (expanded state, Enter/Space and find-in-page come
   free), the label on the left and a 32px caret on the right. White, 6px
   radius, no padding of its own; 16px between header and content when open.
   Height animates where interpolate-size exists, and snaps elsewhere. */
.expandable-region {
  border-radius: var(--radius-md);
  background: var(--bg-ongray);
}
.expandable-region__header {
  display: flex;
  align-items: center;
  border-radius: var(--radius-md);
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.expandable-region__header::-webkit-details-marker { display: none; }
.expandable-region__header:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.expandable-region[open] > .expandable-region__header { margin-bottom: var(--space-4); }
.expandable-region__label {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  padding-right: var(--space-2);
}
/* Drawn as prod's subtle icon-only Button; the summary row is the target. */
.expandable-region__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--control-height);
  height: var(--control-height);
  border-radius: var(--radius-md);
  color: var(--text-default);
  transition: background-color 0.15s;
}
.expandable-region__toggle svg { width: 16px; height: 16px; transition: transform 0.15s; }
.expandable-region__header:hover .expandable-region__toggle { background: var(--control-secondary-hover); }
.expandable-region__header:active .expandable-region__toggle { background: var(--control-secondary-active); }
.expandable-region[open] > .expandable-region__header .expandable-region__toggle svg { transform: rotate(180deg); }
@supports (interpolate-size: allow-keywords) {
  .expandable-region { interpolate-size: allow-keywords; }
  .expandable-region::details-content {
    block-size: 0;
    /* clip, not hidden: the clip margin keeps the focus ring of content
       flush with the edge visible. */
    overflow: clip;
    overflow-clip-margin: var(--space-1);
    transition: block-size 0.15s cubic-bezier(0, 0, 0.2, 1), content-visibility 0.15s allow-discrete;
  }
  .expandable-region[open]::details-content { block-size: auto; }
}

/* --- RadioGroup ---
   Native radios inside a .field-set – matches lib-design-system RadioGroup /
   RadioButton. 16px circle, 1px borders.form at rest; hover and checked go to
   a 2px primary border, checked adds an 8px primary dot. Vertical by default;
   .radio-group-horizontal wraps options in a row. .radio-group-chips is
   variant="chips": each option is a .chip-check pill, horizontal by default. */
.radio-group__options {
  display: flex;
  flex-direction: column;
  row-gap: var(--space-3);
  column-gap: var(--space-4);
}
.radio-group-horizontal .radio-group__options {
  flex-direction: row;
  flex-wrap: wrap;
}
.radio-group > .field-error,
.radio-group > .field-description {
  display: block;
  margin-top: var(--space-2);
}
/* An error replaces the description while it shows. Empty or [hidden] errors don't count. */
.field:has(> .field-error:not([hidden]):not(:empty)) > .field-description,
.radio-group:has(> .field-error:not([hidden]):not(:empty)) > .field-description { display: none; }
.radio-group-error legend { color: var(--text-error); }

.radio-button {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  align-items: center;
  column-gap: var(--space-2);
  row-gap: 2px;
  /* Prod is 20px; 24px keeps each option on the SC 2.5.8 floor on its own. */
  min-height: 24px;
  font-size: var(--font-size-sm);
  line-height: 20px;
  color: var(--text-default);
  cursor: pointer;
  user-select: none;
}
.radio-button-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.radio-button-circle {
  position: relative;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 1px solid var(--border-form);
  border-radius: 50%;
  background: var(--color-neutral-0);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.radio-button-circle::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--control-primary);
  transform: scale(0);
  transition: transform 0.12s;
}
.radio-button:hover .radio-button-input:not(:checked):not(:disabled) + .radio-button-circle {
  border: 2px solid var(--border-primary);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--control-primary) 20%, transparent);
}
.radio-button-input:checked + .radio-button-circle {
  border: 2px solid var(--border-primary);
}
.radio-button-input:checked + .radio-button-circle::after { transform: scale(1); }
.radio-button-input:focus-visible + .radio-button-circle { box-shadow: var(--focus-ring); }
.radio-button-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.radio-button-description {
  grid-column: 2;
  font-size: var(--font-size-xs);
  line-height: 18px;
  color: var(--text-secondary);
}
.radio-button:has(.radio-button-input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Chips variant – options reuse .chip .chip-check with a radio .chip-input. */
.radio-group-chips .radio-group__options {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2);
}
.radio-group-chips.radio-group-vertical .radio-group__options { flex-direction: column; }
.radio-group-chips .chip-check:has(.chip-input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}
.radio-group-chips .chip-check:has(.chip-input:disabled:not(:checked)):hover {
  background: var(--bg-ongray);
  border-color: var(--border-form);
}

/* --- FileUploaderControl ---
   lib-design-system FileUploaderControl (+ its FileDropZone). A visually
   hidden native <input type="file"> keeps focus, keyboard and the OS picker;
   a <label for> styled as a .button is the visible trigger. With a drop zone
   the trigger is .button-secondary-on-gray; without one, .button-subtle.
   The selected-file list is canon-only – prod leaves it to the consumer. */
.file-uploader-control {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}
.file-uploader-control__input:focus-visible + .file-uploader-control__button { box-shadow: var(--focus-ring); }
.file-uploader-control__input:focus-visible + .button-secondary-on-gray {
  box-shadow: inset 0 0 0 1px var(--border-form-active), var(--focus-ring);
}
.file-uploader-control__input:disabled + .file-uploader-control__button {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Drop zone: backgrounds.default at rest, backgrounds.secondary + borders.primary
   while a file is dragged over, borders.error on error (error wins). */
.file-drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-width: 240px;
  padding: var(--space-6) var(--space-4);
  background: var(--bg-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: background-color 0.15s, border-color 0.15s;
}
.file-drop-zone__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
}
.file-drop-zone__text {
  font-size: var(--font-size-sm);
  line-height: 20px;
  color: var(--text-secondary);
}
.file-drop-zone--file-over {
  background: var(--bg-secondary);
  border-color: var(--border-primary);
}
/* Children would fire dragleave on the zone as the pointer crosses them. */
.file-drop-zone--file-over .file-drop-zone__inner { pointer-events: none; }
.file-drop-zone-error,
.file-drop-zone-error.file-drop-zone--file-over { border-color: var(--border-error); }

.file-uploader-control__list {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
.file-uploader-control__list:empty { display: none; }
.file-uploader-control__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  background: var(--bg-ongray);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}
.file-uploader-control__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.file-uploader-control__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.file-uploader-control__size {
  flex-shrink: 0;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}
.file-uploader-control .field-error:empty { display: none; }

/* --- Empty state ---
   lib-design-system EmptyState: optional illustrative icon, heading, content,
   optional actions, centred in a column. Below 480px (breakpoints.desktopMinimum)
   production swaps to Heading 4 / Paragraph smallCompact and tighter spacing. */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.empty-state__icon {
  width: 64px;            /* icons.sizes.illustrative */
  height: 64px;
  flex-shrink: 0;
  margin-bottom: var(--space-6);
  color: inherit;
}
.empty-state__heading {
  margin-bottom: var(--space-3);
  font-size: var(--font-size-xl);
  font-weight: 700;
  line-height: 32px;
  color: var(--text-default);
}
.empty-state__content {
  font-size: var(--font-size-sm);
  line-height: 20px;
  color: var(--text-default);
}
.empty-state__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
}
@media (max-width: 479px) {
  .empty-state__icon { margin-bottom: var(--space-4); }
  .empty-state__heading {
    margin-bottom: var(--space-1);
    font-size: var(--font-size-sm);
    line-height: 24px;
  }
  .empty-state__content { font-size: var(--font-size-xs); line-height: 18px; }
  .empty-state__actions { margin-top: var(--space-4); }
}

/* --- Loading spinner ---
   lib-design-system LoadingSpinner: the Loading icon (#ds-icon-loading, a
   three-quarter arc) turning once every 1.15s on transitions.easing
   'ease-in-out'. Sizes follow icons.sizes: small 12px, standard 16px (default),
   large 24px. Colour inherits. Under prefers-reduced-motion the global block
   stops the turn and leaves the arc; the role="status" text carries the state. */
.loading-spinner {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  animation: ds-spin 1.15s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
.loading-spinner-small { width: 12px; height: 12px; }
.loading-spinner-large { width: 24px; height: 24px; }

/* LoadingCover: large spinner over a Heading 3, 16px apart, centred. */
.loading-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
}

/* --- Match score ---
   lib-design-system MatchScore: read-only stars (#ds-icon-match-score-star), 2px
   apart, then the score to one decimal 8px after. Track neutral-400
   (matchScoreStar.fillDefaultColor), fill text.primary (fillActiveColor),
   caption text.secondary. A star is full when its index <= score, half when
   within 0.5 above it. Sizes follow the fontSize prop: xs (default) 12px stars
   + 12px caption; s 16 + 14; m 16 + 16; l 24 + 20; xl 24 + 24. */
.match-score {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.match-score__stars {
  display: inline-flex;
  gap: 2px;
}
.match-score__star {
  position: relative;
  display: inline-flex;
  color: var(--color-neutral-400);
}
.match-score__star > svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
.match-score__star--full { color: var(--text-primary); }
/* The half star stacks a second, left-clipped star in the fill colour. */
.match-score__star--half > svg + svg {
  position: absolute;
  inset: 0;
  color: var(--text-primary);
  clip-path: inset(0 50% 0 0);
}
.match-score__caption {
  font-size: var(--font-size-xs);
  line-height: 18px;
  color: var(--text-secondary);
}
.match-score-s .match-score__star > svg,
.match-score-m .match-score__star > svg { width: 16px; height: 16px; }
.match-score-l .match-score__star > svg,
.match-score-xl .match-score__star > svg { width: 24px; height: 24px; }
.match-score-s  .match-score__caption { font-size: var(--font-size-sm); }
.match-score-m  .match-score__caption { font-size: var(--font-size-base); }
.match-score-l  .match-score__caption { font-size: var(--font-size-xl); }
.match-score-xl .match-score__caption { font-size: var(--font-size-2xl); }

/* --- Wysiwyg (prototype rich text) ---
   A formatting toolbar of .button-subtle .button-sm .button-icon-only controls
   over a contenteditable editor that takes the .input states (grey fill, form
   border, white + primary border + focus ring on focus). Three rows minimum
   and vertical resize, as production's Wysiwyg. Wired by DS.initWysiwyg(). */
.wysiwyg {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.wysiwyg__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}
.wysiwyg__toolbar .button[aria-pressed="true"] {
  background: var(--bg-accent);
  color: var(--text-primary);
}
.wysiwyg__toolbar .button[aria-pressed="true"]:hover { background: var(--bg-accent-hover); }
.wysiwyg__separator {
  width: 1px;
  height: 16px;
  margin: 0 var(--space-1);
  background: var(--border-default);
}
.wysiwyg__editor {
  min-height: calc(3 * 20px + 2 * var(--space-2) + 2px);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-form);
  border-radius: var(--radius-md);
  background: var(--control-secondary);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  line-height: 20px;
  color: var(--text-default);
  overflow-y: auto;
  overflow-wrap: anywhere;
  resize: vertical;
  cursor: text;
  transition: border-color 0.15s, background-color 0.15s;
}
.wysiwyg__editor:hover {
  background: var(--control-secondary-hover);
  border-color: var(--border-form-active);
}
.wysiwyg__editor:focus {
  outline: none;
  background: var(--bg-ongray);
  border-color: var(--border-primary);
  box-shadow: var(--focus-ring);
}
.wysiwyg__editor:empty::before {
  content: attr(data-placeholder);
  color: var(--forms-placeholder);
  pointer-events: none;
}
.wysiwyg__editor[aria-invalid="true"],
.wysiwyg__editor[aria-invalid="true"]:hover { border-color: var(--border-error); }
.wysiwyg__editor[aria-invalid="true"]:focus {
  border-color: var(--border-error);
  box-shadow: 0 0 0 2px var(--color-neutral-0), 0 0 0 4px var(--border-error);
}
.wysiwyg__editor[aria-disabled="true"],
.wysiwyg__editor[aria-disabled="true"]:hover {
  background: var(--control-secondary);
  border-color: var(--border-form);
  opacity: 0.5;
  cursor: not-allowed;
}
.wysiwyg__editor p + p,
.wysiwyg__editor p + ul, .wysiwyg__editor p + ol,
.wysiwyg__editor ul + p, .wysiwyg__editor ol + p { margin-top: var(--space-2); }
.wysiwyg__editor ul,
.wysiwyg__editor ol { padding-left: var(--space-6); }
.wysiwyg__editor a { color: var(--text-primary); text-decoration: underline; }

/* --- Precision control ---
   Candidate for prod. The per-filter precision slider from AI-assisted
   filters (2026-09-ai-filters/precision-control-states-0.2): a four-point
   radio group, Broadest → Broad → Narrow → Precise, left to right, so the
   filled rail reads as how much constraint is applied. Broadest is the
   absence of a constraint, so it carries no sparkle. Rendered by
   DS.initPrecisionControl; the full spec lives on that page. */
.precision-control { display: flex; flex-direction: column; gap: var(--space-1); width: 100%; min-width: 0; }

/* Symmetric padding so the rail's midline and the dots' centres coincide. */
.precision-control__track { position: relative; display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }

/* Inset by half a dot so the rail ends under the outer dots' centres. */
.precision-control__rail {
  position: absolute; left: 10px; right: 10px; top: 50%; height: 2px;
  transform: translateY(-50%); border-radius: 1px; background: var(--color-indigo-100);
}
.precision-control__fill {
  position: absolute; left: 10px; top: 50%; height: 2px;
  transform: translateY(-50%); border-radius: 1px; background: var(--color-indigo-500);
  transition: width 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.precision-control__point {
  position: relative; z-index: 1; background: none; border: 0; padding: 0;
  width: 20px; height: 20px; cursor: pointer; display: grid; place-items: center;
}
.precision-control__dot {
  width: 20px; height: 20px; border-radius: 50%; background: var(--color-indigo-100);
  display: grid; place-items: center; transition: background-color 0.12s, box-shadow 0.12s;
}
.precision-control__sparkle {
  width: 12px; height: 12px; display: block; color: var(--color-indigo-500);
  transition: color 0.12s; pointer-events: none;
}
.precision-control__point:hover .precision-control__dot {
  background: var(--color-indigo-900); box-shadow: 0 0 0 4px var(--color-indigo-200);
}
.precision-control__point[aria-checked="true"] .precision-control__dot { background: var(--color-indigo-900); }
.precision-control__point:hover .precision-control__sparkle,
.precision-control__point[aria-checked="true"] .precision-control__sparkle { color: var(--color-indigo-100); }

/* Passed points shrink to plain markers: the selection moved through them,
   nothing was generated there, so a sparkle would claim values that don't exist. */
.precision-control__point[data-passed] .precision-control__dot { width: 10px; height: 10px; background: var(--color-indigo-500); }
.precision-control__point[data-passed]:hover .precision-control__dot {
  background: var(--color-indigo-900); box-shadow: 0 0 0 4px var(--color-indigo-200);
}
.precision-control__point[data-off][aria-checked="true"] .precision-control__dot,
.precision-control__track:not(:has([aria-checked="true"])) .precision-control__point[data-off] .precision-control__dot {
  width: 10px; height: 10px;
}
.precision-control__track:not(:has([aria-checked="true"])) .precision-control__point[data-off]:not(:hover) .precision-control__dot {
  background: var(--color-indigo-200);
}
/* The blank Broadest marker is indigo-200 at 1.40:1, under the 3:1 SC 1.4.11
   wants; a 4px indigo-500 core (7.01:1) identifies it without a sparkle. */
.precision-control__track:not(:has([aria-checked="true"])) .precision-control__point[data-off]:not(:hover) .precision-control__dot::after {
  content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--color-indigo-500);
}

.precision-control__point:focus-visible { outline: 2px solid var(--outline-focus); outline-offset: 4px; border-radius: 50%; }

.precision-control__labels { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--font-size-xs); color: var(--text-secondary); }
.precision-control__label { flex: 1 1 0; text-align: center; }
.precision-control__label:first-child { text-align: left; }
.precision-control__label:last-child { text-align: right; }
.precision-control__label[data-on] { color: var(--color-indigo-900); font-weight: 700; }
.precision-control:has(.precision-control__point:nth-of-type(1):hover) .precision-control__label:nth-child(1),
.precision-control:has(.precision-control__point:nth-of-type(2):hover) .precision-control__label:nth-child(2),
.precision-control:has(.precision-control__point:nth-of-type(3):hover) .precision-control__label:nth-child(3),
.precision-control:has(.precision-control__point:nth-of-type(4):hover) .precision-control__label:nth-child(4) {
  color: var(--color-indigo-500); font-weight: 700;
}
/* Narrow containers drop the two middle names; the track never changes. */
.precision-control--compact .precision-control__label:not(:first-child):not(:last-child) { visibility: hidden; }

.precision-control__tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--color-neutral-900); color: var(--color-neutral-0);
  font-size: var(--font-size-xs); line-height: 1.3; text-align: left;
  padding: 6px var(--space-2); border-radius: var(--radius-sm);
  width: max-content; max-width: 216px;
  white-space: normal; pointer-events: none; opacity: 0; transition: opacity 0.12s; z-index: 5;
}
.precision-control__point:hover .precision-control__tip,
.precision-control__point:focus-visible .precision-control__tip { opacity: 1; }
/* Escape dismisses the tooltip with focus staying put (SC 1.4.13). */
.precision-control__point[data-tip-dismissed] .precision-control__tip { opacity: 0 !important; }
.precision-control__point:first-of-type .precision-control__tip { left: 0; transform: none; }
.precision-control__point:last-of-type .precision-control__tip { left: auto; right: 0; transform: none; }

.precision-control__description { margin: 0; font-size: var(--font-size-xs); line-height: 1.45; color: var(--text-secondary); }

/* Unavailable: generation failed. Indigo swaps for neutrals one for one, so
   the shape stays and only the promise goes; points stay focusable
   (aria-disabled) so the tooltip can explain. !important because this
   state outranks the :has() chains above. */
.precision-control--unavailable .precision-control__rail,
.precision-control--unavailable .precision-control__dot {
  background: var(--color-neutral-300) !important; box-shadow: none !important;
}
.precision-control--unavailable .precision-control__sparkle { color: var(--color-neutral-600) !important; }
.precision-control--unavailable .precision-control__point[data-off] .precision-control__dot::after {
  content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--color-neutral-600) !important;
}
.precision-control--unavailable .precision-control__point { cursor: not-allowed; }
.precision-control--unavailable .precision-control__label { color: var(--color-neutral-600) !important; font-weight: 400 !important; }

@media (prefers-reduced-motion: reduce) {
  .precision-control__fill,
  .precision-control__dot,
  .precision-control__sparkle,
  .precision-control__tip { transition: none; }
}

/* ==========================================================================
   APP CHROME
   ========================================================================== */

/* ── Top nav ── */
.nav {
  background: var(--color-brand-navy);
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  flex-shrink: 0;
  z-index: 100;
}

.nav__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text-on-dark);
  flex-shrink: 0;
}
.nav__logo-symbol  { width: 24px; height: 24px; }
.nav__logo-wordmark { width: 88px; height: 24px; }

.nav__search-wrapper {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
}
.nav__search {
  display: flex;
  align-items: center;
  background: var(--control-secondary);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 0 var(--space-2) 0 var(--space-2);
  height: var(--control-height);
  gap: var(--space-2);
  width: 100%;
  transition: border-color 0.15s;
}
.nav__search:focus-within {
  border-color: var(--border-primary);
  background: var(--bg-ongray);
}
.nav__search svg { flex-shrink: 0; color: var(--forms-placeholder); }
.nav__search input {
  border: none;
  background: transparent;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--text-default);
  outline: none;
  width: 100%;
}
.nav__search input::placeholder { color: var(--forms-placeholder); }

.nav__actions { display: flex; align-items: center; gap: var(--space-1); margin-left: auto; }

.nav__icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-on-dark);
  transition: background 0.15s;
}
.nav__icon-btn:hover { background: rgba(255,255,255,0.1); }
.nav__icon-btn:focus-visible { outline: 2px solid rgba(255,255,255,0.5); outline-offset: 2px; }

.nav__user-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-on-dark);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  transition: background 0.15s;
}
.nav__user-btn:hover { background: rgba(255,255,255,0.1); }
.nav__user-btn:focus-visible { outline: 2px solid rgba(255,255,255,0.5); outline-offset: 2px; }

.nav__avatar {
  width: 24px;
  height: 24px;
  background: var(--color-indigo-500);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-on-dark);
  flex-shrink: 0;
}

/* ── Body layout ── */
.app-body { display: flex; flex: 1; overflow: hidden; }

/* ── Side nav ── */
.side-nav {
  width: 56px;
  background: var(--bg-default);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding-top: var(--space-6);
  padding-bottom: var(--space-4);
  gap: 0;
}

.side-nav__section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-2);
  margin-bottom: var(--space-4);
}

.side-nav__section + .side-nav__section {
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-default);
}

.side-nav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--text-default);
  transition: background 0.15s, color 0.15s;
}
.side-nav__link:hover { background: var(--bg-accent); color: var(--color-indigo-500); }
.side-nav__link.active { background: var(--bg-accent); color: var(--color-indigo-500); }
.side-nav__link:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.side-nav__link svg { width: 16px; height: 16px; color: inherit; }

/* ── Settings nav — second-level nav for the Settings area, beside .side-nav ── */
.settings-nav {
  width: 236px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--bg-default);
  border-right: 1px solid var(--color-neutral-300);
  padding: var(--space-6) var(--space-3) var(--space-8);
}
.settings-nav__group + .settings-nav__group { margin-top: var(--space-6); }
.settings-nav__label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  line-height: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}
.settings-nav__link {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-default);
  text-decoration: none;
}
.settings-nav__link:hover { background: var(--bg-secondary); }
.settings-nav__link.active { background: var(--bg-accent); color: var(--text-primary); }
.settings-nav__link:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Main content ── */
.main-content {
  flex: 1;
  overflow: auto;
  padding: var(--space-8);
  background: var(--bg-default);
}

.svg-sprite { display: none; }

/* --- App shell — opt-in full-height body layout (add class="app-shell" to <body>) --- */
.app-shell { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

/* --- Skip link --- */
.skip-link { position: absolute; left: var(--space-2); top: -48px; z-index: 1000; padding: var(--space-2) var(--space-4); background: var(--control-primary); color: var(--text-on-dark); border-radius: var(--radius-md); font-size: var(--font-size-sm); font-weight: 500; text-decoration: none; transition: top 0.15s; }
.skip-link:focus { top: var(--space-2); outline: none; box-shadow: var(--focus-ring); }

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
