/*
 * skeuomorph/ui — theme, light model and materials.
 *
 * This file is the single source of truth. The site imports it from
 * styles/globals.css and scripts/build-registry.mts turns it (plus ./parts/*.css)
 * into the "skeuomorph" registry:style item:
 *   :root            -> cssVars.light
 *   .dark            -> cssVars.dark
 *   @theme inline    -> cssVars.theme
 *   everything else  -> css (@utility, @keyframes, @media, @supports, @property)
 *
 * Rules for component authors (see /tmp/skeu-research/principles.md):
 *   - No hex values in TSX. Use the semantic utilities (bg-card, text-foreground,
 *     shadow-raised, rounded-ios ...), the scale utilities (bg-aqua-600,
 *     text-ruby-600 ...) or var(--token) for anything defined in :root below.
 *   - Theme-namespace tokens (colors, ease-*, animate-*, text-*, font-*) are
 *     used through their utility (ease-out-quart, animate-barber, text-ui),
 *     never as var(--ease-...), because @theme inline does not emit variables.
 *   - One light, straight overhead: every shadow has x = 0.
 *   - Never transition-all; never animate background-image or box-shadow on gels.
 *   - Focus: the `focus-ring` utility. Never outline-none (use outline-hidden).
 */

/* parts/buttons.css */
/* skeuomorph/ui — buttons family recipes. Inlined into the "skeuomorph" registry style. */

/*
 * Button, ButtonGroup, Toggle, ToggleGroup (segmented control), Kbd, Badge, Spinner.
 * Spec: principles.md §4.1 Buttons, §4.5 Segmented, §4.9 Badges, §5 Motion.
 * Every shadow keeps 4 layers (+ the appended focus halo) so states can swap
 * without changing layer counts. Press-in is 0ms; only bezels ease the release.
 */

:root {
  /* Red gel, held down: darker and more saturated (P6). White label on band 6.9. */
  --gel-red-pressed-hi: #c4444a;
  --gel-red-pressed-band: #a8222a;
  --gel-red-pressed-lo: #8c1016;
  --gel-red-pressed-glow: #a8343a;
  --gel-red-pressed-edge: #4d080c;

  /* Unselected segment, held down: the clear gel goes one step darker. */
  --segment-pressed-hi: #e4e4e4;
  --segment-pressed-band: #d2d2d2;
  --segment-pressed-lo: #c6c6c6;
  --segment-pressed-glow: #e6e6e6;
  --segment-divider: #b3b3b3;

  /* Disabled gel: grey, flat, no contact shadow. Label #757575 = 3.76 on #e8e8e8. */
  --gel-disabled-hi: #f6f6f6;
  --gel-disabled-band: #eeeeee;
  --gel-disabled-lo: #e6e6e6;
  --gel-disabled-glow: #f4f4f4;
  --gel-disabled-edge: #a8a8a8;
  --gel-disabled-fg: #757575;
  --disabled-fg: #757575;
  /* Disabled but selected segment: a flat, darker, pressed-in grey so the
     selection survives disabling. Label #5c5c5c = 3.45 on #bababa. */
  --gel-disabled-on-hi: #d9d9d9;
  --gel-disabled-on-band: #c8c8c8;
  --gel-disabled-on-lo: #bababa;
  --gel-disabled-on-glow: #d2d2d2;
  --gel-disabled-on-fg: #5c5c5c;

  /* Ghost / toggle / recessed tints. */
  --tint-hover: rgb(0 0 0 / 0.05);
  --tint-pressed: rgb(0 0 0 / 0.12);
  --recessed-hover: rgb(0 0 0 / 0.08);
  --recessed-selected: #5f6b7c;

  /* iOS bar button edges [S Dojo]. */
  --bar-button-ios-edges: #2f3740 #405a7e #375073 #3a4755;

  /* Keycap (Kbd): a light key with an engraved legend. */
  --keycap: linear-gradient(#fdfdfd, #ececec 60%, #e2e2e2);
  --keycap-edge: #a3a3a3 #8f8f8f #6e6e6e;
  --keycap-fg: #1a1a1a;
  --keycap-relief: 0 1px 0 rgb(255 255 255 / 0.75);

  /* Notification badge (iOS, horizon 50%). White bold on band #c43137 = 5.47. */
  --badge-red: linear-gradient(#d65a60, #c43137 50%, #a8141b 50%, #b8242a);
  --badge-green: linear-gradient(#4c9c4c, #2f8433 50%, #1b6b20 50%, #237a28);
  --badge-amber: linear-gradient(#ffd36b, #f4b63e 50%, #f0a92a 50%, #f4b63e);
  --badge-ring: #ffffff;
  --badge-count: #5f6b7c;
  --badge-count-edge: #4a5468;

  /* Invalid control (aria-invalid): ruby edge + ruby focus ring. */
  --control-invalid: #c4161c;
}

.dark {
  --segment-pressed-hi: #5a5a5a;
  --segment-pressed-band: #464646;
  --segment-pressed-lo: #383838;
  --segment-pressed-glow: #4c4c4c;
  --segment-divider: #141414;

  --gel-disabled-hi: #3e3e3e;
  --gel-disabled-band: #383838;
  --gel-disabled-lo: #333333;
  --gel-disabled-glow: #3a3a3a;
  --gel-disabled-edge: #1e1e1e;
  --gel-disabled-fg: #8a8a8a;
  --disabled-fg: #8a8a8a;
  --gel-disabled-on-hi: #2a2a2a;
  --gel-disabled-on-band: #242424;
  --gel-disabled-on-lo: #1e1e1e;
  --gel-disabled-on-glow: #262626;
  --gel-disabled-on-fg: #a0a0a0;

  --tint-hover: rgb(255 255 255 / 0.06);
  --tint-pressed: rgb(0 0 0 / 0.35);
  --recessed-hover: rgb(255 255 255 / 0.08);
  --recessed-selected: #4a5468;

  --keycap: linear-gradient(#585858, #474747 60%, #3c3c3c);
  --keycap-edge: #1e1e1e #161616 #0a0a0a;
  --keycap-fg: #f2f2f2;
  --keycap-relief: 0 -1px 0 rgb(0 0 0 / 0.6);

  --badge-ring: #f2f2f2;
  --badge-count: #4a5468;
  --badge-count-edge: #2a313c;

  --control-invalid: #e07a7f;
}

/* ============ GEL STATES ============ */

/* Red gel while held (destructive). */
@utility gel-red-pressed {
  --gel-hi: var(--gel-red-pressed-hi);
  --gel-band: var(--gel-red-pressed-band);
  --gel-lo: var(--gel-red-pressed-lo);
  --gel-glow: var(--gel-red-pressed-glow);
  --gel-edge-top: var(--gel-red-pressed-edge);
  --gel-edge-side: var(--gel-red-pressed-edge);
  --gel-edge-bottom: var(--gel-red-pressed-edge);
}

/* Clear gel while held, for unselected segments (grey, not blue). */
@utility gel-segment-pressed {
  --gel-hi: var(--segment-pressed-hi);
  --gel-band: var(--segment-pressed-band);
  --gel-lo: var(--segment-pressed-lo);
  --gel-glow: var(--segment-pressed-glow);
}

/* A disabled gel turns grey, flat and shallow — never pale blue (§4.1). */
@utility gel-disabled {
  --gel-hi: var(--gel-disabled-hi);
  --gel-band: var(--gel-disabled-band);
  --gel-lo: var(--gel-disabled-lo);
  --gel-glow: var(--gel-disabled-glow);
  --gel-edge-top: var(--gel-disabled-edge);
  --gel-edge-side: var(--gel-disabled-edge);
  --gel-edge-bottom: var(--gel-disabled-edge);
  --gel-fg: var(--gel-disabled-fg);
  --gel-fg-shadow: none;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.2), 0 0 #0000, 0 0 #0000, 0 0 #0000, var(--focus-halo, 0 0 #0000);
}

/* A disabled segment that is still selected: grey like gel-disabled, but
   darker and pressed in, so the selection stays readable (§4.5, §6.4). */
@utility gel-disabled-on {
  --gel-hi: var(--gel-disabled-on-hi);
  --gel-band: var(--gel-disabled-on-band);
  --gel-lo: var(--gel-disabled-on-lo);
  --gel-glow: var(--gel-disabled-on-glow);
  --gel-edge-top: var(--gel-disabled-edge);
  --gel-edge-side: var(--gel-disabled-edge);
  --gel-edge-bottom: var(--gel-disabled-edge);
  --gel-fg: var(--gel-disabled-on-fg);
  --gel-fg-shadow: none;
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.22), 0 0 #0000, 0 0 #0000, 0 0 #0000, var(--focus-halo, 0 0 #0000);
}

/* Error state for buttons, toggles, segments and badges (aria-invalid).
   Recolours the edge on every recipe (gel edges are variables) and the focus ring. */
@utility control-invalid {
  --gel-edge-top: var(--control-invalid);
  --gel-edge-side: var(--control-invalid);
  --gel-edge-bottom: var(--control-invalid);
  --focus-ring: var(--control-invalid);
  border-color: var(--control-invalid);
}

/* ============ BEZEL STATES ============ */

/* Bezel held down: inner shadow + 1px travel, same layer count as --raised. */
@utility bezel-pressed {
  background-image: var(--bezel-pressed);
  box-shadow: var(--pressed), var(--focus-halo, 0 0 #0000);
  translate: 0 1px;
}

/* Brushed-metal keycap button (variant="metal"). Material fixed in both themes. */
@utility metal-button {
  border-width: 1px;
  border-style: solid;
  border-color: var(--color-platinum-600);
  /* A soft sheen over the brushed grain keeps the legend readable at control size. */
  background: linear-gradient(rgb(255 255 255 / 0.3), rgb(255 255 255 / 0.1)), var(--material-metal);
  color: var(--color-platinum-950);
  text-shadow: var(--text-engrave);
  box-shadow: var(--raised), var(--focus-halo, 0 0 #0000);
}

@utility metal-button-pressed {
  background: linear-gradient(rgb(0 0 0 / 0.1), rgb(0 0 0 / 0.04)), var(--material-metal);
  box-shadow: var(--pressed), var(--focus-halo, 0 0 #0000);
  translate: 0 1px;
}

/* iOS bar button (variant="ios"): darkened stops, white bold embossed label. */
@utility bar-button-ios {
  border-width: 1px;
  border-style: solid;
  border-color: var(--bar-button-ios-edges);
  background-color: #3c5d8f;
  background-image: var(--bar-button-ios);
  color: #ffffff;
  text-shadow: var(--text-emboss);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18), 0 0 #0000, 0 1px 0 rgb(255 255 255 / 0.3), 0 0 #0000, var(--focus-halo, 0 0 #0000);
}

@utility bar-button-ios-pressed {
  background-color: #243f6c;
  background-image: var(--bar-button-ios-pressed);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.45), inset 0 0 0 1px rgb(0 0 0 / 0.1), 0 1px 0 rgb(255 255 255 / 0.3), 0 0 #0000, var(--focus-halo, 0 0 #0000);
}

/* Leopard scope-bar button (variant="recessed"), selected / held state. */
@utility recessed-selected {
  background-color: var(--recessed-selected);
  color: #ffffff;
  text-shadow: var(--text-emboss);
  /* No weight change: selecting or pressing must never shift the bar's layout. */
  box-shadow: var(--pressed), var(--focus-halo, 0 0 #0000);
}

/* Ghost / toggle textured button held or on. */
@utility tint-pressed {
  background-color: var(--tint-pressed);
  box-shadow: var(--pressed), var(--focus-halo, 0 0 #0000);
}

/* ============ PULSE (opt-in throbbing default button) ============ */
/* The ::after repeats the gel with lifted stops; only its opacity animates.
   It sits under the label (isolation + z-index -1) so the label never washes out. */
[data-slot="button"][data-pulse] {
  isolation: isolate;
}

[data-slot="button"][data-pulse]:not(:disabled):not([aria-disabled="true"])::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: -1;
  pointer-events: none;
  background-image: linear-gradient(
    180deg,
    color-mix(in oklab, var(--gel-hi), #ffffff 35%) 0,
    color-mix(in oklab, var(--gel-band), #ffffff 30%) var(--_b),
    color-mix(in oklab, var(--gel-lo), #ffffff 28%) var(--_b),
    color-mix(in oklab, var(--gel-glow), #ffffff 30%) 100%
  );
  opacity: 0;
}

/* The throb only exists when motion is welcome; reduced motion = a still gel. */
@media (prefers-reduced-motion: no-preference) {
  [data-slot="button"][data-pulse]:not(:disabled):not([aria-disabled="true"])::after {
    animation: gel-pulse 0.8s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
  }
}

/* Stops (glow gone) while it, or anything in its container, is held down.
   Selectors repeat the :not() chain so they outrank the animation rule. */
[data-slot="button"][data-pulse]:not(:disabled):not([aria-disabled="true"]):is(:active, [data-pressed])::after,
:has(> [data-slot="button"]:is(:active, [data-pressed]))
  > [data-slot="button"][data-pulse]:not(:disabled):not([aria-disabled="true"])::after {
  animation: none;
  opacity: 0;
}

/* ============ SEGMENTED CONTROL (ToggleGroup, spacing 0) ============ */

/* iOS bar segmented (variant="ios"). Selected is pressed in. */
@utility segment-ios {
  border-width: 1px;
  border-style: solid;
  border-color: var(--bar-button-ios-edges);
  background-color: #3c5d8f;
  background-image: var(--bar-button-ios);
  color: #ffffff;
  text-shadow: var(--text-emboss);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18), 0 0 #0000, 0 1px 0 rgb(255 255 255 / 0.3), 0 0 #0000, var(--focus-halo, 0 0 #0000);
}

@utility segment-ios-on {
  background-color: #243f6c;
  background-image: var(--bar-button-ios-pressed);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.45), inset 0 0 0 1px rgb(0 0 0 / 0.1), 0 1px 0 rgb(255 255 255 / 0.3), 0 0 #0000, var(--focus-halo, 0 0 #0000);
}

/* ============ KBD ============ */
@utility keycap {
  border-width: 1px;
  border-style: solid;
  border-color: var(--keycap-edge);
  background-image: var(--keycap);
  color: var(--keycap-fg);
  text-shadow: var(--keycap-relief);
  box-shadow: inset 0 1px 0 var(--rim-strong), inset 0 -1px 0 rgb(0 0 0 / 0.06), 0 1px 0 var(--contact), 0 2px 0 var(--contact-2);
}

/* ============ BADGES ============ */
@utility badge-notify {
  border: 2px solid var(--badge-ring);
  background-color: #c43137;
  background-image: var(--badge-red);
  background-origin: border-box;
  color: #ffffff;
  text-shadow: var(--text-emboss);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 0 #0000, 0 0 #0000, 0 0 #0000, var(--focus-halo, 0 0 #0000);
}

@utility badge-success {
  --badge-red: var(--badge-green);
  background-color: #2f8433;
}

@utility badge-warning {
  --badge-red: var(--badge-amber);
  background-color: #f4b63e;
  color: #3d2a00;
  text-shadow: 0 1px 0 rgb(255 255 255 / 0.35);
}

@utility badge-count {
  border: 1px solid var(--badge-count-edge);
  background-color: var(--badge-count);
  color: #ffffff;
  text-shadow: var(--text-emboss);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.12), 0 1px 0 var(--lip), 0 0 #0000, 0 0 #0000, var(--focus-halo, 0 0 #0000);
}

@utility badge-plaque {
  border: 1px solid var(--color-platinum-600);
  background: var(--material-metal);
  color: var(--color-platinum-950);
  text-shadow: var(--text-engrave);
  box-shadow: inset 0 1px 0 var(--rim-strong), 0 1px 0 var(--lip), 0 0 #0000, 0 0 #0000, var(--focus-halo, 0 0 #0000);
}

/* ============ SPINNER (Aqua asynchronous indicator: 12 spokes, hard steps) ============ */
@utility animate-spinner-aqua {
  animation: spinner-aqua 1s steps(12, end) infinite;

  /* Status stays visible; it just ticks slower. */
  @media (prefers-reduced-motion: reduce) {
    animation-duration: 2.4s;
  }
}

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

/* ============ FORCED COLOURS ============ */
@media (forced-colors: active) {
  [data-slot="toggle"][data-state="on"],
  [data-slot="toggle-group-item"][data-state="on"],
  [data-slot="button"][data-variant="recessed"][aria-pressed="true"] {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
  [data-slot="kbd"],
  [data-slot="badge"] {
    border: 1px solid CanvasText;
  }
  [data-slot="button"][data-pulse]::after {
    display: none;
  }
}

/* parts/fields.css */
/* skeuomorph/ui — fields family recipes. Inlined into the "skeuomorph" registry style. */

:root {
  /* Invalid well: red edge + appended 2px halo (spec §4.2). The well is never tinted. */
  --field-invalid: #c4161c;
  --field-invalid-halo: 0 0 0 2px rgb(196 22 28 / 0.25);

  /* Disabled label text (exempt from 1.4.3; 3.76 on the window, ≥ 3 target). */
  --field-disabled-fg: #757575;

  /* Pop-up placeholder on the clear gel. */
  --popup-placeholder: #5f5f5f;

  /* Fallback stops for the pop-up's blue arrow cap (browsers without relative
     colour syntax). The cap sits inside a gel-clear trigger, so it cannot read
     --gel-*; these are captured where the accent is declared. `.dark` repeats
     them because `.dark` may sit below <html> (e.g. /view?theme=dark), where
     :root-resolved values would stay light. */
  --popup-cap-base-hi: var(--gel-hi);
  --popup-cap-base-band: var(--gel-band);
  --popup-cap-base-lo: var(--gel-lo);
  --popup-cap-base-glow: var(--gel-glow);
  --popup-cap-base-edge-top: var(--gel-edge-top);
  --popup-cap-edge-side: var(--gel-edge-side);
  --popup-cap-edge-bottom: var(--gel-edge-bottom);

  /* iPhone OS search bar tray (lighter than the nav bar). */
  --search-bar-ios: linear-gradient(#cdd5de 0%, #b8c3d0 50%, #aebbca 50%, #a3b2c3 100%);
  --search-bar-ios-edge-top: #e6ebf0;
  --search-bar-ios-edge-bottom: #7c8a9c;

  /* Search clear button (14px grey circle with a white ×). #8a8a8a is 3.4:1
     on the white well and carries the white glyph at 3.4:1 (SC 1.4.11). */
  --search-clear: #8a8a8a;
  --search-clear-hover: #7a7a7a;
  --search-clear-pressed: #6e6e6e;

  /* Combobox token chips (Mail-style address tokens). */
  --chip: #dde9f7;
  --chip-edge: #a9c3e0;
  --chip-fg: #102a4c;
}

.dark {
  --field-invalid: #e07a7f;
  --field-invalid-halo: 0 0 0 2px rgb(224 122 127 / 0.35);
  --popup-placeholder: #c8c8c8;
  --field-disabled-fg: #8a8a8a;

  --popup-cap-base-hi: var(--gel-hi);
  --popup-cap-base-band: var(--gel-band);
  --popup-cap-base-lo: var(--gel-lo);
  --popup-cap-base-glow: var(--gel-glow);
  --popup-cap-base-edge-top: var(--gel-edge-top);
  --popup-cap-edge-side: var(--gel-edge-side);
  --popup-cap-edge-bottom: var(--gel-edge-bottom);

  --search-bar-ios: linear-gradient(#4a4f57 0%, #3a3f47 50%, #30353d 50%, #2a2e35 100%);
  --search-bar-ios-edge-top: rgb(255 255 255 / 0.12);
  --search-bar-ios-edge-bottom: #0a0a0a;

  --search-clear: #8a8a8a;
  --search-clear-hover: #9a9a9a;
  --search-clear-pressed: #a7a7a7;

  --chip: #1d4f99;
  --chip-edge: #2a63c4;
  --chip-fg: #ffffff;
}

/* Invalid inset well. Compose with `well`: aria-invalid:field-invalid.
   The focus halo stays on top so the focus ring still reads. */
@utility field-invalid {
  border-color: var(--field-invalid);
  box-shadow: var(--well), var(--focus-halo, 0 0 #0000), var(--field-invalid-halo);
}

/* Invalid pop-up (gel) trigger: red edge + the same 2px halo as an invalid
   well, so Select / NativeSelect do not signal errors with a hairline alone. */
@utility popup-invalid {
  border-color: var(--field-invalid);
  box-shadow: var(--raised), var(--focus-halo, 0 0 #0000), var(--field-invalid-halo);
}

/* Focus ring for a composite well (InputGroup, combobox chips): the ring is
   drawn on the container while its inner control is focused. */
@utility focus-ring-within {
  &:has([data-slot="input-group-control"]:focus-visible),
  &:has([data-slot="combobox-chip-input"]:focus-visible) {
    outline: var(--focus-width) solid var(--focus-ring);
    outline-offset: var(--focus-offset);
    --focus-halo: 0 0 0 var(--focus-offset) var(--focus-ring-inner);
  }
}

/* Active OTP cell: the §6.2 two-colour ring (the hidden input owns focus, so
   the cell that will receive the next character carries it). */
@utility otp-active {
  z-index: 10;
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: var(--focus-offset);
  box-shadow: 0 0 0 var(--focus-offset) var(--focus-ring-inner);
}

/* The blue gel arrow cap of an Aqua pop-up / combo box. Position and radius
   are set by the component; width scales with --control-h (22px at 21 native).
   Stops are derived from --primary on the cap itself, so accent themes scoped
   to a subtree reach it even though the trigger body is a clear gel. */
@utility popup-cap {
  --_h: var(--control-h, var(--control-default));
  --_b: round(down, calc((var(--_h) - 2px) * var(--gel-horizon)), 1px);
  --popup-cap-hi: var(--popup-cap-base-hi);
  --popup-cap-band: var(--popup-cap-base-band);
  --popup-cap-lo: var(--popup-cap-base-lo);
  --popup-cap-glow: var(--popup-cap-base-glow);
  --popup-cap-edge-top: var(--popup-cap-base-edge-top);
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: round(calc(var(--_h) * 0.6 + 2px), 2px);
  border-width: 1px;
  border-style: solid;
  border-color: var(--popup-cap-edge-top) var(--popup-cap-edge-side) var(--popup-cap-edge-bottom);
  background-color: var(--popup-cap-lo);
  background-image: linear-gradient(180deg, var(--popup-cap-hi) 0, var(--popup-cap-band) var(--_b), var(--popup-cap-lo) var(--_b), color-mix(in oklab, var(--popup-cap-lo) 65%, var(--popup-cap-glow)) calc(var(--_b) + (100% - var(--_b)) * 0.55), var(--popup-cap-glow) 100%);
  background-clip: padding-box;
  box-shadow: var(--bevel-raised);
  color: #000000;

  @supports (color: oklch(from red l c h)) {
    --popup-cap-hi: oklch(from var(--primary) calc(l + 0.29) calc(c * 0.31) calc(h - 9));
    --popup-cap-band: oklch(from var(--primary) calc(l + 0.196) calc(c * 0.51) calc(h - 11));
    --popup-cap-lo: oklch(from var(--primary) calc(l + 0.111) calc(c * 0.68) calc(h - 11));
    --popup-cap-glow: oklch(from var(--primary) calc(l + 0.37) calc(c * 0.34) calc(h - 45));
    --popup-cap-edge-top: oklch(from var(--primary) calc(l - 0.173) calc(c * 0.84) calc(h + 7));

    &:where(.dark, .dark *) {
      --popup-cap-hi: oklch(from var(--primary) calc(l + 0.22) calc(c * 0.35) calc(h - 9));
      --popup-cap-glow: oklch(from var(--primary) calc(l + 0.24) calc(c * 0.3) calc(h - 40));
    }
  }

  /* Like every other gel under prefers-contrast: the gloss is flattened. */
  @media (prefers-contrast: more) {
    --popup-cap-hi: var(--popup-cap-band);
  }
}

/* The cap "acquires" the deeper pressed blue while its control is held. */
@utility popup-cap-pressed {
  --popup-cap-hi: var(--gel-pressed-hi);
  --popup-cap-band: var(--gel-pressed-band);
  --popup-cap-lo: var(--gel-pressed-lo);
  --popup-cap-glow: var(--gel-pressed-glow);
  --popup-cap-edge-top: var(--color-aqua-900);
}

/* Error marker: a 12px red gel bead with a "!" so errors are not signalled by
   colour alone. Combine with `gel gel-red`. */
@utility field-error-badge {
  --control-h: 12px;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  border-radius: 9999px;
  font-size: var(--text-mini);
  line-height: 1;
  font-weight: 700;
}

/* An invalid pop-up keeps a continuous red outer edge across its blue cap. */
[aria-invalid="true"] > .popup-cap,
[aria-invalid="true"] + .popup-cap {
  border-block-color: var(--field-invalid);
  border-inline-end-color: var(--field-invalid);
}

@media (forced-colors: active) {
  [data-slot="input"],
  [data-slot="textarea"],
  [data-slot="input-group"],
  [data-slot="native-select"],
  [data-slot="search-bar-input"],
  [data-slot="combobox-chips"],
  [data-slot="input-otp-group"] {
    border: 1px solid ButtonText;
  }
  .popup-cap {
    border-color: ButtonText;
    forced-color-adjust: auto;
  }
  /* The group draws the ring; the bare inner control must not add a second one. */
  [data-slot="input-group-control"]:focus-visible,
  [data-slot="combobox-chip-input"]:focus-visible {
    outline: none;
  }
  /* Choice card: a visible edge, and a heavier Highlight edge when checked. */
  [data-slot="field-label"]:has(> [data-slot="field"]) {
    border-color: ButtonText;
  }
  [data-slot="field-label"]:has(> [data-slot="field"]):has([data-state="checked"]) {
    border-color: Highlight;
    outline: 1px solid Highlight;
  }
  [data-slot="input-otp-slot"][data-active="true"] {
    outline-color: Highlight;
  }
}

@media (prefers-contrast: more) {
  :root {
    --search-clear: #6e6e6e;
    --search-clear-hover: #5f5f5f;
    --search-clear-pressed: #4d4d4d;
  }
  .dark {
    --search-clear: #a7a7a7;
    --search-clear-hover: #b5b5b5;
    --search-clear-pressed: #c8c8c8;
  }
}

/* parts/choice.css */
/* skeuomorph/ui — choice family recipes. Inlined into the "skeuomorph" registry style. */
/*
 * Checkbox, radio, switch, slider, progress (spec §4.3, §4.4).
 * Base tokens (--check-well, --knob, --switch-on/off, --track, --progress-*,
 * --barber) live in skeuomorph.css; this file adds the family-only extras and
 * the recipes that are too long to read as class strings.
 */

:root {
  /* Checkbox / radio */
  --check-well-pressed: linear-gradient(#9c9c9c, #c6c6c6 50%, #e8e8e8);
  --check-lip: 0 1px 0 var(--lip);
  --check-disabled-well: linear-gradient(#e2e2e2, #ececec 50%, #f6f6f6);
  --check-disabled-edge: #a8a8a8;
  --check-disabled-fg: #757575;

  /* Switch (iOS 5–6) */
  --switch-edge-top: #767676;
  --switch-edge-side: #8a8a8a;
  --switch-edge-bottom: #a0a0a0;
  --switch-inner: inset 0 1px 2px rgb(0 0 0 / 0.35);
  --switch-knob-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  --switch-on-fg: #ffffff;
  --switch-off-shadow: var(--text-engrave);
  --switch-on-shadow: var(--text-emboss);
  --switch-glyph-shadow: 0 -1px 0 rgb(0 0 0 / 0.5);
  --switch-knob-pressed: linear-gradient(#d4d4d4, #b2b2b2);
  --switch-disabled-on: linear-gradient(#a4a4a4 0%, #b6b6b6 50%, #bcbcbc 50%, #c6c6c6 100%);
  --switch-disabled-on-fg: #f6f6f6;
  --switch-disabled-off-fg: #8e8e8e;
  --switch-disabled-knob: linear-gradient(#f8f8f8, #e8e8e8);
  --switch-disabled-knob-edge: #b0b0b0;
  --switch-disabled-edge: #a8a8a8;
  --switch-disabled-edge-bottom: #bcbcbc;

  /* Slider */
  --slider-specular: radial-gradient(ellipse 70% 45% at 50% 25%, rgb(255 255 255 / 0.9), transparent 70%);
  --slider-range-inner: inset 0 1px 1px rgb(0 0 0 / 0.25);
  --slider-disabled-range: linear-gradient(#c4c4c4, #b0b0b0 50%, #a2a2a2 50%, #bdbdbd);

  /* Progress */
  --progress-under: 0 1px 0 rgb(0 0 0 / 0.12), 0 2px 0 rgb(0 0 0 / 0.06), 0 3px 0 rgb(0 0 0 / 0.03);
  --progress-fill-edge-bottom: #a3a3a3;
  --progress-barber: var(--barber);
}

.dark {
  --check-well-pressed: linear-gradient(#0e0e0e, #1c1c1c 50%, #2a2a2a);
  --check-disabled-well: linear-gradient(#262626, #2a2a2a 50%, #303030);
  --check-disabled-edge: #555555;
  --check-disabled-fg: #8a8a8a;

  --switch-edge-top: #0a0a0a;
  --switch-edge-side: #141414;
  --switch-edge-bottom: #1e1e1e;
  --switch-inner: inset 0 1px 2px rgb(0 0 0 / 0.6);
  --switch-knob-shadow: 0 1px 2px rgb(0 0 0 / 0.6);
  --switch-off-shadow: var(--text-emboss);
  --switch-knob-pressed: linear-gradient(#6a6a6a, #444444);
  --switch-disabled-on: linear-gradient(#383838 0%, #404040 50%, #444444 50%, #4a4a4a 100%);
  --switch-disabled-on-fg: #8a8a8a;
  --switch-disabled-off-fg: #666666;
  --switch-disabled-knob: linear-gradient(#585858, #4a4a4a);
  --switch-disabled-knob-edge: #222222;
  --switch-disabled-edge: #1c1c1c;
  --switch-disabled-edge-bottom: #262626;

  --slider-specular: radial-gradient(ellipse 70% 45% at 50% 25%, rgb(255 255 255 / 0.35), transparent 70%);
  --slider-range-inner: inset 0 1px 1px rgb(0 0 0 / 0.5);
  --slider-disabled-range: linear-gradient(#5a5a5a, #4a4a4a 50%, #404040 50%, #4a4a4a);

  --progress-under: 0 1px 0 rgb(255 255 255 / 0.06), 0 0 #0000, 0 0 #0000;
  --progress-fill-edge-bottom: #1a3f80;
  /* Barber pole dimmed so the white stripes don't glare on the dark window. */
  --progress-barber: linear-gradient(180deg, rgb(255 255 255 / 0.3) 0 12%, rgb(255 255 255 / 0.35) 25%, rgb(255 255 255 / 0) 50%, rgb(140 220 255 / 0.2) 100%), repeating-linear-gradient(-45deg, #2f7fd8 0 2.83px, #5b9be0 4.24px, #a9c6e6 5.66px, #c2d6ec 6.36px 8.49px, #8fb6e2 9.9px, #4590dc 11.31px);
}

/* ---------- Checkbox / radio ---------- */

/* Unchecked concave well. Checked state swaps to `gel` in the component. */
@utility check-well {
  border-width: 1px;
  border-style: solid;
  border-color: var(--check-edge);
  background-color: var(--card);
  background-image: var(--check-well);
  background-clip: padding-box;
  box-shadow: var(--check-lip), var(--focus-halo, 0 0 #0000);
}

/* Held unchecked: the well goes darker (press-in is instant). */
@utility check-well-pressed {
  background-image: var(--check-well-pressed);
}

/* Disabled: grey and flat, never pale blue. Wins over `gel` by coming later. */
@utility check-disabled {
  border-color: var(--check-disabled-edge);
  background-image: var(--check-disabled-well);
  box-shadow: none;
  color: var(--check-disabled-fg);
  text-shadow: none;
}

/* ---------- Switch ---------- */

/* The track is a well: light lip below, focus halo appended (never replaced). */
@utility switch-track {
  box-shadow: 0 1px 0 var(--lip), var(--focus-halo, 0 0 #0000);
}

/* Cut-in track edge drawn above the sliding strip. */
@utility switch-edge {
  border-width: 1px;
  border-style: solid;
  border-color: var(--switch-edge-top) var(--switch-edge-side) var(--switch-edge-bottom) var(--switch-edge-side);
  box-shadow: var(--switch-inner);
}

/* One strip [ON | knob | OFF]; the ON paint runs under the knob to its centre. */
@utility switch-strip {
  background-image: var(--switch-on), var(--switch-off);
  background-size: 50% 100%, 100% 100%;
  background-position: left top, left top;
  background-repeat: no-repeat;

  &:where([dir="rtl"], [dir="rtl"] *) {
    background-position: right top, left top;
  }
}

@utility switch-knob {
  border-width: 1px;
  border-style: solid;
  border-color: var(--knob-edge);
  background-image: var(--knob);
  background-clip: padding-box;
  box-shadow: var(--switch-knob-shadow);
}

/* ON / OFF label size: iOS 5-6 switch caption (bold 15px, set solid). */
@utility text-ios-switch {
  font-size: 15px;
  line-height: 1;
}

/* Disabled: re-points the switch tokens at flat greys; children follow. */
@utility switch-disabled {
  --switch-on: var(--switch-disabled-on);
  --switch-on-fg: var(--switch-disabled-on-fg);
  --switch-off-fg: var(--switch-disabled-off-fg);
  --switch-on-shadow: none;
  --switch-off-shadow: none;
  --switch-glyph-shadow: none;
  --knob: var(--switch-disabled-knob);
  --knob-edge: var(--switch-disabled-knob-edge);
  --switch-knob-shadow: none;
  --switch-edge-top: var(--switch-disabled-edge);
  --switch-edge-side: var(--switch-disabled-edge);
  --switch-edge-bottom: var(--switch-disabled-edge-bottom);
  --switch-inner: inset 0 1px 1px rgb(0 0 0 / 0.12);
}

/* ---------- Slider ---------- */

@utility slider-track {
  border-width: 1px;
  border-style: solid;
  border-color: var(--track-edge);
  background-image: var(--track);
  background-clip: padding-box;
  box-shadow: var(--well);
}

/* Blue gel at a 50% horizon, sized for a 4px inner track (horizon on a whole px). */
@utility slider-range {
  background-color: var(--gel-lo);
  background-image: linear-gradient(180deg, var(--gel-hi) 0, var(--gel-band) 2px, var(--gel-lo) 2px, var(--gel-glow) 100%);
  box-shadow: var(--slider-range-inner);

  &[data-orientation="vertical"] {
    background-image: linear-gradient(90deg, var(--gel-hi) 0, var(--gel-band) 2px, var(--gel-lo) 2px, var(--gel-glow) 100%);
  }
}

/* ---------- Progress ---------- */

@utility progress-track {
  background-color: var(--muted);
  background-image: var(--progress-track);
  box-shadow: inset 0 1px 0 var(--progress-track-edge), inset 0 0 0 1px rgb(var(--shade) / 0.12), var(--progress-under);
}

@utility progress-fill {
  background-color: var(--gel-lo);
  background-image: var(--progress-fill);
  box-shadow: inset 0 1px 0 var(--progress-fill-edge), inset 0 -1px 0 var(--progress-fill-edge-bottom);
}

@utility progress-barber {
  background-color: var(--gel-lo);
  background-image: var(--progress-barber);
  background-size: 100% 100%, 16px 100%;
  box-shadow: inset 0 1px 0 var(--progress-fill-edge), inset 0 -1px 0 var(--progress-fill-edge-bottom);
}

/* ---------- Preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  [data-slot="switch-strip"],
  [data-slot="switch-thumb"] {
    transition-duration: 0ms;
  }
  [data-slot="progress"][data-indeterminate] [data-slot="progress-indicator"] {
    animation: none;
  }
}

@media (forced-colors: active) {
  [data-slot="checkbox"],
  [data-slot="radio-group-item"],
  [data-slot="slider-track"],
  [data-slot="switch-edge"] {
    border-color: ButtonText;
  }
  [data-slot="checkbox"][data-state="checked"],
  [data-slot="checkbox"][data-state="indeterminate"],
  [data-slot="radio-group-item"][data-state="checked"] {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
  [data-slot="switch"][data-state="checked"] [data-slot="switch-thumb"],
  [data-slot="slider-thumb"] {
    background: Highlight;
    forced-color-adjust: none;
  }
  [data-slot="progress"] {
    border: 1px solid CanvasText;
  }
}

/* parts/surfaces.css */
/* skeuomorph/ui — surfaces family recipes. Inlined into the "skeuomorph" registry style.
 *
 * Cards, alerts, disclosure, tables, scroll areas, avatars and iOS grouped
 * lists. Everything here is "seated" (P8): set into the page with a hairline
 * and a light lip below, never lifted with a soft drop shadow.
 */

:root {
  /* Group box (Mac "NSBox"): faint fill + hairline, radius 5. */
  --group-box: rgb(0 0 0 / 0.04);
  --group-box-edge: rgb(0 0 0 / 0.12);

  /* Aqua scroller: concave track, 1px edge. Thumb reuses the gel tokens. */
  --scroll-track-v: linear-gradient(90deg, #c8c8c8, #f2f2f2 55%, #e6e6e6);
  --scroll-track-h: linear-gradient(180deg, #c8c8c8, #f2f2f2 55%, #e6e6e6);
  --scroll-track-edge: #a0a0a0;

  /* Avatar: hairline + rim drawn over the image, fallback plate. */
  --avatar-edge: rgb(0 0 0 / 0.28);
  --avatar-fallback: linear-gradient(#ececec, #cdcdcd);
  --avatar-fallback-fg: #4a4a4a;
  --avatar-fallback-relief: 0 1px 0 rgb(255 255 255 / 0.75);

  /* Skeleton: a translucent plate (reads on the page and on cards alike)
   * with a faint inner top edge. */
  --skeleton: rgb(0 0 0 / 0.09);
  --skeleton-edge: rgb(0 0 0 / 0.06);

  /* Mac table frame: a mid-grey hairline, lighter than --input so it reads
   * as a seated surface edge rather than a field border. */
  --table-frame: #a0a0a0;
  --table-header-pressed: linear-gradient(
    #e2e2e2,
    #cdcdcd 50%,
    #c4c4c4 50%,
    #d2d2d2
  );

  /* iOS grouped table (Settings). The classic pinstripe page is the core
   * --material-pinstripe-ios token; the core has no dark value for it, so the
   * dark stripes live here (applied with dark: since core :root loads later
   * and would win a same-specificity .dark override). */
  --group-ios-pinstripe-dark: repeating-linear-gradient(
    90deg,
    #1b1e23 0 4px,
    #1f2228 4px 7px
  );
  --group-ios-page-ios6:
    linear-gradient(90deg, transparent 70%, #d4d9e3 70%) 0 0 / 8px 8px, #d7dce5;
  --group-ios-lip: rgb(255 255 255 / 0.8);
  --group-ios-chevron: #808080;
  --group-ios-pressed-fg: #ffffff;
}

.dark {
  --group-box: rgb(0 0 0 / 0.18);
  --group-box-edge: rgb(255 255 255 / 0.08);

  --scroll-track-v: linear-gradient(90deg, #161616, #2a2a2a 55%, #232323);
  --scroll-track-h: linear-gradient(180deg, #161616, #2a2a2a 55%, #232323);
  --scroll-track-edge: #0a0a0a;

  --avatar-edge: rgb(0 0 0 / 0.6);
  --avatar-fallback: linear-gradient(#4a4a4a, #333333);
  --avatar-fallback-fg: #e0e0e0;
  --avatar-fallback-relief: 0 -1px 0 rgb(0 0 0 / 0.5);

  --skeleton: rgb(255 255 255 / 0.08);
  --skeleton-edge: rgb(0 0 0 / 0.35);

  --table-frame: rgb(0 0 0 / 0.6);
  --table-header-pressed: linear-gradient(
    #2a2a2a,
    #222222 50%,
    #1c1c1c 50%,
    #222222
  );

  --group-ios-page-ios6:
    linear-gradient(90deg, transparent 70%, #20242b 70%) 0 0 / 8px 8px, #1d2026;
  --group-ios-lip: rgb(255 255 255 / 0.06);
  --group-ios-chevron: #8a8a8a;
}

/* Aqua scroller thumb: a gel pill shaded across its SHORT axis (the gel rotated
 * 90deg for vertical bars), hard specular horizon at 40% of the thickness,
 * snapped to a whole pixel. Recolours with --primary / .theme-graphite. */
@utility scroll-thumb {
  --_t: var(--scroll-thumb-t, 13px);
  --_b: round(down, calc((var(--_t) - 2px) * var(--gel-horizon)), 1px);
  border-width: 1px;
  border-style: solid;
  border-color: color-mix(in oklab, var(--gel-edge-top) 75%, var(--gel-lo));
  border-radius: 9999px;
  background-color: var(--gel-lo);
  background-image: linear-gradient(
    var(--scroll-thumb-dir, 90deg),
    var(--gel-hi) 0,
    var(--gel-band) var(--_b),
    var(--gel-lo) var(--_b),
    color-mix(in oklab, var(--gel-lo) 65%, var(--gel-glow))
      calc(var(--_b) + (100% - var(--_b)) * 0.55),
    var(--gel-glow) 100%
  );
  background-clip: padding-box;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.18);
}

/* Skeleton breathing: a subtle opacity step, never a sweep. */
@keyframes skeleton-breathe {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.55;
  }
}

@utility skeleton-pulse {
  animation: skeleton-breathe 1s cubic-bezier(0.45, 0, 0.55, 1) infinite
    alternate;

  @media (prefers-reduced-motion: reduce) {
    animation: none;
  }
}

@utility material-group-ios6 {
  background: var(--group-ios-page-ios6);
}

@media (forced-colors: active) {
  [data-slot="table-row"][data-state="selected"],
  [data-slot="list-group-item"][data-selected="true"] {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
  [data-slot="card"],
  [data-slot="alert"],
  [data-slot="list-group-section"],
  [data-slot="table-container"] {
    border-color: CanvasText;
  }
  [data-slot="scroll-area-thumb"] {
    background: ButtonText;
  }
  /* Translucent plates are flattened to Canvas; draw them in GrayText so
   * loading placeholders stay visible. */
  [data-slot="skeleton"] {
    background: GrayText;
    forced-color-adjust: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --group-box-edge: rgb(0 0 0 / 0.4);
    --avatar-edge: rgb(0 0 0 / 0.5);
  }
}

/* parts/menus.css */
/* skeuomorph/ui — menus family recipes. Inlined into the "skeuomorph" registry style. */

/*
 * Shared menu recipes (spec §4.7). DropdownMenu, ContextMenu, Menubar, Command
 * and Select content all compose the same utilities, so every menu in the
 * library is pixel-identical:
 *
 *   menu-surface    the floating sheet: white .95, 1px hairline, radius 5, float shadow, 4px block padding
 *   menu-item       24px row, 20px check column at the start, 16px at the end, blue highlight
 *   menu-indicator  the check / radio glyph cell inside the check column
 *   menu-separator  1px line, 5px margin-block
 *   menu-label      section header row
 *   menu-shortcut   right-aligned key equivalent (⇧⌘P)
 *   menu-motion     150ms opacity + scale(.97) in, 100ms fade out (opacity only under reduced motion)
 *
 * Tooltips use help-tag + help-tag-motion; popovers / hover cards use
 * popover-surface (data-variant="hud" for the HUD panel) with menu-motion.
 *
 * Tunables (set on an ancestor): --menu-item-ps, --menu-item-pe, --menu-item-h.
 */

:root {
  --menu-foreground: #1a1a1a;
  --menu-edge: rgb(0 0 0 / 0.25);
  --menu-rim: rgb(255 255 255 / 0.6);
  /* Float 2 minus its 1px spread ring: the real 1px border is the hairline. */
  --menu-shadow: 0 1px 1px rgb(var(--shade) / 0.1), 0 4px 8px rgb(var(--shade) / 0.14), 0 8px 16px rgb(var(--shade) / 0.12);
  --menu-highlight-foreground: #ffffff;
  --menu-highlight-destructive: linear-gradient(#c43137, #a8141b); /* white 5.47 / 7.55 */
  --menu-destructive: #c4161c; /* 6.04 on white */
  --menu-disabled: #8a8a8a; /* exempt; 3.45 on white */
  --menu-label: #5f5f5f; /* 6.39 on white */
  --menu-icon: #5f5f5f;

  /* Menubar strip: light top chrome (Tiger/Leopard menu bar). */
  --menubar: linear-gradient(#fbfbfb, #e9e9e9 50%, #dfdfdf 50%, #e6e6e6);
  --menubar-edge: #9a9a9a;
  --menubar-edge-bottom: #7a7a7a;

  /* Mac help tag. */
  --help-tag-foreground: #000000; /* 20.37 on #feffca */
  --help-tag-edge: rgb(0 0 0 / 0.2);
  --help-tag-shadow: 0 2px 4px rgb(0 0 0 / 0.3);

  /* Popover surface (opaque). */
  --popover-edge: rgb(0 0 0 / 0.25);
}

.dark {
  --menu-foreground: #f2f2f2;
  --menu-edge: rgb(0 0 0 / 0.7);
  --menu-rim: rgb(255 255 255 / 0.08);
  --menu-highlight-destructive: linear-gradient(#c43137, #a8141b);
  --menu-destructive: #e07a7f; /* 5.0 on #262626 */
  --menu-disabled: #7a7a7a;
  --menu-shadow: 0 1px 1px rgb(0 0 0 / 0.3), 0 4px 8px rgb(0 0 0 / 0.3), 0 8px 16px rgb(0 0 0 / 0.25);
  --menu-label: #a3a3a3; /* 6.3 on #262626 */
  --menu-icon: #a3a3a3;

  --menubar: linear-gradient(#4a4a4a, #3a3a3a 50%, #323232 50%, #2e2e2e);
  --menubar-edge: #141414;
  --menubar-edge-bottom: #0a0a0a;

  --help-tag-foreground: #f2f2f2; /* on #3a3a2a: 11.9 */
  --help-tag-edge: rgb(0 0 0 / 0.7);
  --help-tag-shadow: 0 2px 4px rgb(0 0 0 / 0.5);

  --popover-edge: rgb(0 0 0 / 0.7);
}

/* ---------- Surface ---------- */
@utility menu-surface {
  @apply font-aqua text-ui;
  /* Translucent tint over an opaque base: content behind a menu never ghosts
     through its rows. */
  background-color: var(--popover);
  background-image: linear-gradient(var(--menu-surface), var(--menu-surface));
  color: var(--menu-foreground);
  border: 1px solid var(--menu-edge);
  border-radius: 5px;
  padding-block: 4px;
  padding-inline: 0;
  box-shadow: inset 0 1px 0 var(--menu-rim), var(--menu-shadow);
  /* Menus never inherit a page's text shadow or letter-spacing. */
  text-shadow: none;

  /* Pull-downs hang from the menubar: square top, no top edge (the bar's
     bottom edge is the hairline), only the bottom corners rounded. */
  &[data-slot="menubar-content"][data-side="bottom"] {
    border-top-width: 0;
    border-start-start-radius: 0;
    border-start-end-radius: 0;
  }
}

/* ---------- Menubar strip ---------- */
@utility menubar {
  @apply font-aqua text-ui;
  display: flex;
  align-items: stretch;
  height: 24px;
  padding-inline: 4px;
  border: 1px solid var(--menubar-edge);
  border-bottom-color: var(--menubar-edge-bottom);
  border-radius: 4px;
  background-color: var(--background);
  background-image: var(--menubar);
  color: var(--menu-foreground);
  box-shadow: inset 0 1px 0 var(--menu-rim), 0 1px 0 var(--lip);
}

@utility menubar-trigger {
  @apply font-aqua text-ui;
  display: flex;
  align-items: center;
  padding-inline: 10px;
  color: var(--menu-foreground);
  cursor: default;
  user-select: none;
  outline: 2px solid transparent;
  outline-offset: 2px;

  /* Blue only while its menu is open. Radix marks a merely focused trigger
     data-highlighted (and refocuses it after a menu closes), so that state
     gets the keyboard focus ring instead of the open-menu fill. */
  &[data-state="open"] {
    background-image: var(--menu-highlight);
    color: var(--menu-highlight-foreground);
  }
  &:focus-visible:not([data-state="open"]) {
    outline: var(--focus-width) solid var(--focus-ring);
    outline-offset: -2px;
  }
  &[data-disabled] {
    color: var(--menu-disabled);
  }

  @media (forced-colors: active) {
    &[data-state="open"] {
      background: Highlight;
      color: HighlightText;
      forced-color-adjust: none;
    }
    &:focus-visible:not([data-state="open"]) {
      outline: 2px solid Highlight;
      outline-offset: -2px;
    }
  }
}

/* ---------- Rows ---------- */
@utility menu-item {
  @apply font-aqua text-ui;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--menu-item-h, 24px);
  padding-block: 2px;
  padding-inline: var(--menu-item-ps, 20px) var(--menu-item-pe, 16px);
  border-radius: 0;
  color: var(--menu-foreground);
  cursor: default;
  user-select: none;
  outline: 2px solid transparent;
  outline-offset: 2px;
  /* Long labels wrap inside fixed-width menus rather than being clipped. */
  overflow-wrap: anywhere;

  /* Defaults are fully wrapped in :where() (zero specificity) so consumer
     classes such as h-5 w-5 or text-* on an icon always win. */
  :where(&) :where(svg) {
    pointer-events: none;
    flex-shrink: 0;
  }
  :where(&) :where(svg:not([class*="size-"])) {
    width: 16px;
    height: 16px;
  }
  :where(&) :where(svg:not([class*="text-"])) {
    color: var(--menu-icon);
  }

  &[data-variant="destructive"] {
    color: var(--menu-destructive);
  }
  &[data-variant="destructive"] svg:not([class*="text-"]) {
    color: currentColor;
  }

  /* Highlight: full-width blue gradient, no radius, white text, 0ms. */
  &[data-highlighted],
  &[data-selected="true"],
  &[data-slot$="sub-trigger"][data-state="open"] {
    background-image: var(--menu-highlight);
    color: var(--menu-highlight-foreground);
  }
  &[data-highlighted] svg:not([class*="text-"]),
  &[data-selected="true"] svg:not([class*="text-"]),
  &[data-slot$="sub-trigger"][data-state="open"] svg:not([class*="text-"]) {
    color: currentColor;
  }
  &[data-variant="destructive"][data-highlighted],
  &[data-variant="destructive"][data-selected="true"] {
    background-image: var(--menu-highlight-destructive);
    color: var(--menu-highlight-foreground);
  }

  /* cmdk writes data-disabled="false" on enabled rows. */
  &[data-disabled]:not([data-disabled="false"]) {
    color: var(--menu-disabled);
    pointer-events: none;
  }
  &[data-disabled]:not([data-disabled="false"]) svg:not([class*="text-"]) {
    color: currentColor;
  }

  @media (forced-colors: active) {
    &[data-highlighted],
    &[data-selected="true"],
    &[data-slot$="sub-trigger"][data-state="open"] {
      background: Highlight;
      color: HighlightText;
      forced-color-adjust: none;
    }
    &[data-disabled]:not([data-disabled="false"]) {
      color: GrayText;
    }
  }
}

/* Check / radio glyph cell, centred in the 20px start column. */
@utility menu-indicator {
  position: absolute;
  inset-inline-start: 4px;
  top: 50%;
  translate: 0 -50%;
  display: flex;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: currentColor;
}

@utility menu-separator {
  height: 1px;
  margin-block: 5px;
  margin-inline: 0;
  border: 0;
  background-color: var(--menu-separator);
}

@utility menu-label {
  @apply font-aqua text-small;
  display: flex;
  align-items: center;
  min-height: 20px;
  padding-block: 3px 1px;
  padding-inline: var(--menu-item-ps, 20px) var(--menu-item-pe, 16px);
  font-weight: 700;
  color: var(--menu-label);
  cursor: default;
  user-select: none;
}

@utility menu-shortcut {
  @apply font-aqua text-ui;
  margin-inline-start: auto;
  padding-inline-start: 24px;
  color: var(--menu-shortcut);
  letter-spacing: 0.04em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;

  :is([data-highlighted], [data-selected="true"], [data-slot$="sub-trigger"][data-state="open"]) > & {
    color: var(--menu-highlight-foreground);
  }
  :is([data-disabled]:not([data-disabled="false"])) > & {
    color: var(--menu-disabled);
  }
}

/* ---------- Popover / hover card ---------- */
@utility popover-surface {
  @apply font-aqua text-ui;
  background-color: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--popover-edge);
  border-radius: 6px;
  box-shadow: inset 0 1px 0 var(--menu-rim), var(--menu-shadow);

  /* variant="hud": Aqua HUD panel, smoked black .78 (opaque under reduced
     transparency), white text 11.73:1, white rim. No blur. */
  &[data-variant="hud"] {
    --menu-rim: rgb(255 255 255 / 0.12);
    --muted-foreground: var(--hud-muted);
    --foreground: var(--hud-foreground);
    --popover-foreground: var(--hud-foreground);
    --border: rgb(255 255 255 / 0.15);
    /* HUD wells are smoked too (white-on-white text otherwise). */
    --card: rgb(0 0 0 / 0.35);
    --card-foreground: var(--hud-foreground);
    --input: rgb(255 255 255 / 0.28);
    --input-top: rgb(255 255 255 / 0.2);
    --placeholder: var(--hud-muted);
    --focus-ring: #5ea2ff;
    --focus-ring-inner: #000000;
    --menu-separator: rgb(255 255 255 / 0.15);
    background-color: var(--hud);
    color: var(--hud-foreground);
    border-color: var(--hud-edge);
  }
}

/* ---------- Tooltip (Mac help tag) ---------- */
@utility help-tag {
  @apply font-aqua text-small;
  background-color: var(--help-tag);
  color: var(--help-tag-foreground);
  border: 1px solid var(--help-tag-edge);
  border-radius: 0;
  box-shadow: var(--help-tag-shadow);
  text-shadow: none;
}

/* ---------- Motion (spec §5) ---------- */
@keyframes menu-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}

@keyframes menu-fade-in {
  from {
    opacity: 0;
  }
}

@keyframes menu-fade-out {
  to {
    opacity: 0;
  }
}

@utility menu-motion {
  &[data-state="open"] {
    animation: menu-in 150ms cubic-bezier(0.23, 1, 0.32, 1);
  }
  &[data-state="closed"] {
    animation: menu-fade-out 100ms ease-in forwards;
  }
  @media (prefers-reduced-motion: reduce) {
    &[data-state="open"] {
      animation: menu-fade-in 100ms ease-out;
    }
  }
}

/* Tooltips: 100ms fade in, no scale; vanish instantly. */
@utility help-tag-motion {
  &[data-state="delayed-open"],
  &[data-state="instant-open"] {
    animation: menu-fade-in 100ms ease-out;
  }
}

/* ---------- Command: search field well (NSSearchField pill) ---------- */
@utility menu-search {
  @apply font-aqua text-ui;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding-inline: 8px 10px;
  border-width: 1px;
  border-style: solid;
  border-color: var(--input-top) var(--input) var(--input);
  border-radius: 9999px;
  background-color: var(--card);
  color: var(--foreground);
  box-shadow: var(--well), var(--focus-halo, 0 0 #0000);

  &:has(input:focus-visible) {
    outline: var(--focus-width) solid var(--focus-ring);
    outline-offset: var(--focus-offset);
    --focus-halo: 0 0 0 var(--focus-offset) var(--focus-ring-inner);
  }
  & svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    color: var(--placeholder);
  }
  & input::placeholder {
    color: var(--placeholder);
  }
}

/* parts/windows.css */
/* skeuomorph/ui — windows family recipes. Inlined into the "skeuomorph" registry style. */

/*
 * Dialog, AlertDialog, Sheet, Drawer, Sonner (Toaster).
 * Spec: principles.md §4.8 Dialogs/sheets/alerts, §4.12 Toasts, §5 Motion.
 * Overlays float (P8): they are the only family that uses --window.
 * No blur anywhere (D9). Never brushed metal on dialogs or sheets (P9).
 */

:root {
  /* Mac sheet: tucked under the title bar / top edge. */
  --sheet-tuck: inset 0 6px 6px -6px rgb(0 0 0 / 0.4);
  --sheet-edge: #515151;

  /* UIAlertView (iOS). Near-opaque so content behind never competes with the message. */
  --alert-ios-fill: rgb(35 50 96 / 0.95);
  --alert-ios-gloss: radial-gradient(ellipse 150% 60% at 50% 0, rgb(255 255 255 / 0.12), transparent 61%);
  --alert-ios-border: #bac1d3;
  --alert-ios-border-top: #eaeaf2;
  --alert-ios-backdrop: radial-gradient(rgb(0 0 0 / 0.4), rgb(0 0 0 / 0.7));
  --alert-ios-button-edge: #273a52;
  /* The cancel button sits one step darker, like UIKit's cancelButtonIndex. */
  --alert-ios-cancel: linear-gradient(#5c6a85 0%, #3a4a6b 50%, #2e3d5d 50%, #33435f 100%);
  --alert-ios-cancel-pressed: linear-gradient(#3e4a63 0%, #26334e 50%, #1e2a43 50%, #222f48 100%);
  --alert-ios-pressed-inset: inset 0 1px 3px rgb(0 0 0 / 0.5);
  --alert-ios-button-rim: inset 0 1px 0 rgb(255 255 255 / 0.25), 0 1px 0 rgb(255 255 255 / 0.12);

  /* iOS action sheet tray: --bar-ios-black at alpha .85, gloss band 22px. White text >= 5.74. */
  --action-sheet-tray: linear-gradient(rgb(255 255 255 / 0.16), rgb(255 255 255 / 0.05) 22px, transparent 22px), rgb(0 0 0 / 0.85);
  --action-sheet-edge: #000000;
  --action-sheet-rim: inset 0 1px 0 rgb(255 255 255 / 0.18), 0 -1px 0 rgb(0 0 0 / 0.4);
  /* Default (white gel) and cancel (smoke gel) action-sheet buttons [S Dojo]. */
  --action-sheet-default-hi: #ffffff;
  --action-sheet-default-band: #f2f2f2;
  --action-sheet-default-lo: #e2e2e2;
  --action-sheet-default-glow: #d5d5d5;
  --action-sheet-default-edge: #1a1a1a;
  --action-sheet-cancel-hi: #6d6f74;
  --action-sheet-cancel-band: #5a5c62;
  --action-sheet-cancel-lo: #4f5157;
  --action-sheet-cancel-glow: #61656f;
  --action-sheet-cancel-edge: #000000;
  /* Any action-sheet button turns blue gel while held, white legend (UIKit highlight). */
  --action-sheet-pressed-hi: #8fb1e6;
  --action-sheet-pressed-band: #4c82d8;
  --action-sheet-pressed-lo: #2f6ccf;
  --action-sheet-pressed-glow: #4f8fe8;
  --action-sheet-pressed-edge: #0d1f3d;
  --action-sheet-font: var(--font-ios);

  /* Drawer (vaul): iOS sheet grabber. */
  --drawer-grabber: rgb(0 0 0 / 0.22);
  --drawer-grabber-lip: 0 1px 0 rgb(255 255 255 / 0.7);

  /* Smoke gel: the clear gel's dark recipe, for controls that sit on HUD glass in both themes. */
  --gel-smoke-hi: #6a6a6a;
  --gel-smoke-band: #555555;
  --gel-smoke-lo: #464646;
  --gel-smoke-glow: #5e5e5e;
  --gel-smoke-edge-top: #0a0a0a;
  --gel-smoke-edge-side: #141414;
  --gel-smoke-edge-bottom: #000000;

  /* Growl Smoke toast. Panel = --hud (rgb(0 0 0/.78)): white 11.73, --hud-muted 8.31. */
  --toast-shadow: inset 0 1px 0 rgb(255 255 255 / 0.15), 0 0 0 1px rgb(0 0 0 / 0.11), 0 3px 7px rgb(0 0 0 / 0.1), 0 8px 20px rgb(0 0 0 / 0.18);
  --toast-destructive-edge: #e07a7f;
  --toast-led-green: radial-gradient(circle at 50% 35%, #b6f0a8 0, #4cc23e 45%, #1b6b20 100%);
  --toast-led-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.35), 0 0 4px #7cc27c;
}

.dark {
  --sheet-edge: #0a0a0a;
  --drawer-grabber: rgb(255 255 255 / 0.22);
  --drawer-grabber-lip: 0 1px 0 rgb(0 0 0 / 0.5);
  --toast-shadow: inset 0 1px 0 rgb(255 255 255 / 0.15), 0 0 0 1px rgb(255 255 255 / 0.08), 0 3px 7px rgb(0 0 0 / 0.3), 0 8px 20px rgb(0 0 0 / 0.4);
}

/* Smoke (dark clear) gel for buttons on HUD glass. Pair with `gel`. */
@utility gel-smoke {
  --gel-hi: var(--gel-smoke-hi);
  --gel-band: var(--gel-smoke-band);
  --gel-lo: var(--gel-smoke-lo);
  --gel-glow: var(--gel-smoke-glow);
  --gel-edge-top: var(--gel-smoke-edge-top);
  --gel-edge-side: var(--gel-smoke-edge-side);
  --gel-edge-bottom: var(--gel-smoke-edge-bottom);
  --gel-fg: #ffffff;
  --gel-fg-shadow: var(--text-emboss);
  --rim: rgb(255 255 255 / 0.18);
  --contact: rgb(0 0 0 / 0.5);
  --contact-2: rgb(0 0 0 / 0.15);
}

/* iOS action sheet tray (Sheet side="bottom"). White text over any backdrop. */
@utility action-sheet-tray {
  background: var(--action-sheet-tray);
  border-top: 1px solid var(--action-sheet-edge);
  box-shadow: var(--action-sheet-rim);
  color: #ffffff;
  --muted-foreground: var(--hud-muted);

  & [data-slot="label"] {
    color: #ffffff;
    text-shadow: var(--text-emboss);
  }
}

/*
 * iOS action sheet buttons: applied to SheetFooter on side="bottom".
 * Reskins the Button gels in place (44-46px, inset 20, 8 apart, radius 8).
 * Buttons are matched by data-variant + data-size because SheetClose asChild
 * replaces their data-slot.
 */
@utility action-sheet {
  & [data-variant][data-size] {
    --control-h: 46px;
    --gel-horizon: 0.5;
    width: 100%;
    height: 46px;
    border-radius: 8px;
    font-family: var(--action-sheet-font);
    font-size: 19px;
    line-height: 24px;
    font-weight: 700;
  }
  & [data-variant][data-size]:not([data-variant="destructive"]) {
    --gel-hi: var(--action-sheet-default-hi);
    --gel-band: var(--action-sheet-default-band);
    --gel-lo: var(--action-sheet-default-lo);
    --gel-glow: var(--action-sheet-default-glow);
    --gel-edge-top: var(--action-sheet-default-edge);
    --gel-edge-side: var(--action-sheet-default-edge);
    --gel-edge-bottom: var(--action-sheet-default-edge);
    --gel-fg: #000000;
    --gel-fg-shadow: 0 1px 0 rgb(255 255 255 / 0.6);
  }
  & [data-variant][data-size]:is([data-variant="outline"], [data-variant="secondary"], [data-variant="ghost"]) {
    --gel-hi: var(--action-sheet-cancel-hi);
    --gel-band: var(--action-sheet-cancel-band);
    --gel-lo: var(--action-sheet-cancel-lo);
    --gel-glow: var(--action-sheet-cancel-glow);
    --gel-edge-top: var(--action-sheet-cancel-edge);
    --gel-edge-side: var(--action-sheet-cancel-edge);
    --gel-edge-bottom: var(--action-sheet-cancel-edge);
    --gel-fg: #ffffff;
    --gel-fg-shadow: var(--text-emboss);
    --bezel: linear-gradient(var(--action-sheet-cancel-hi), var(--action-sheet-cancel-band) 50%, var(--action-sheet-cancel-lo) 50%, var(--action-sheet-cancel-glow));
    --bezel-pressed: linear-gradient(var(--action-sheet-cancel-lo), var(--action-sheet-cancel-band));
    --bezel-edge: var(--action-sheet-cancel-edge);
    color: #ffffff;
    text-shadow: var(--text-emboss);
  }
  /*
   * The overrides above out-rank Button's own active:/disabled: utilities, so
   * the held and disabled looks are restated here, after them.
   */
  & [data-variant][data-size]:not([data-variant="destructive"]):is(:active, [data-pressed]) {
    --gel-hi: var(--action-sheet-pressed-hi);
    --gel-band: var(--action-sheet-pressed-band);
    --gel-lo: var(--action-sheet-pressed-lo);
    --gel-glow: var(--action-sheet-pressed-glow);
    --gel-edge-top: var(--action-sheet-pressed-edge);
    --gel-edge-side: var(--action-sheet-pressed-edge);
    --gel-edge-bottom: var(--action-sheet-pressed-edge);
    --gel-fg: #ffffff;
    --gel-fg-shadow: var(--text-emboss);
    --bezel: linear-gradient(var(--action-sheet-pressed-hi), var(--action-sheet-pressed-band) 50%, var(--action-sheet-pressed-lo) 50%, var(--action-sheet-pressed-glow));
    --bezel-pressed: var(--bezel);
    --bezel-edge: var(--action-sheet-pressed-edge);
    color: #ffffff;
    text-shadow: var(--text-emboss);
  }
  & [data-variant][data-size]:is(:disabled, [aria-disabled="true"]) {
    --gel-hi: var(--gel-disabled-hi);
    --gel-band: var(--gel-disabled-band);
    --gel-lo: var(--gel-disabled-lo);
    --gel-glow: var(--gel-disabled-glow);
    --gel-edge-top: var(--gel-disabled-edge);
    --gel-edge-side: var(--gel-disabled-edge);
    --gel-edge-bottom: var(--gel-disabled-edge);
    --gel-fg: var(--gel-disabled-fg);
    --gel-fg-shadow: none;
    --bezel: linear-gradient(var(--gel-disabled-hi), var(--gel-disabled-band) 50%, var(--gel-disabled-lo) 50%, var(--gel-disabled-glow));
    --bezel-edge: var(--gel-disabled-edge);
    color: var(--gel-disabled-fg);
    text-shadow: none;
    box-shadow: none;
  }
}

/* Growl Smoke toast panel (Sonner, unstyled mode). */
@utility toast-growl {
  /* Sonner injects unlayered CSS; these few overrides must win over it. */
  outline: none !important;
  transition-property: transform, opacity, height !important;
  transition-duration: 200ms !important;
  transition-timing-function: cubic-bezier(0.25, 1, 0.5, 1) !important;

  &:focus-visible {
    outline: var(--focus-width) solid var(--focus-ring) !important;
    outline-offset: var(--focus-offset) !important;
  }
  /* Enter from 4px, not from a full toast height. */
  &[data-y-position="top"]:not([data-mounted="true"]) {
    --y: translateY(-4px) !important;
  }
  &[data-y-position="bottom"]:not([data-mounted="true"]) {
    --y: translateY(4px) !important;
  }
  &[data-removed="true"] {
    transition-duration: 300ms !important;
    transition-timing-function: cubic-bezier(0.55, 0, 1, 0.45) !important;
  }
  &[data-removed="true"][data-front="true"][data-swipe-out="false"] {
    --y: translateY(calc(var(--lift) * -4px)) !important;
  }
  &[data-swiping="true"] {
    transition: none !important;
  }
  /* Collapsed stack: only the front toast shows its content. */
  &[data-expanded="false"][data-front="false"] > * {
    opacity: 0;
  }
  & > * {
    transition: opacity 200ms;
  }

  /*
   * Sonner's theme="dark" and richColors rules are unlayered and not gated by
   * data-styled, so they would repaint the panel, the close bead and the body
   * copy. Pin the Growl materials. (richColors is not supported: the panel is
   * HUD glass for every type; the type shows through the icon.)
   */
  &[data-rich-colors="true"] {
    background-color: var(--hud) !important;
    border-color: var(--hud-edge) !important;
    color: var(--hud-foreground) !important;
  }
  &[data-rich-colors="true"][data-type="error"] {
    border-inline-start-color: var(--toast-destructive-edge) !important;
  }
  & [data-description] {
    color: var(--hud-muted) !important;
  }
  & [data-close-button] {
    background-color: var(--gel-lo) !important;
    background-image: linear-gradient(180deg, var(--gel-hi) 0, var(--gel-band) var(--_b), var(--gel-lo) var(--_b), color-mix(in oklab, var(--gel-lo) 65%, var(--gel-glow)) calc(var(--_b) + (100% - var(--_b)) * 0.55), var(--gel-glow) 100%) !important;
    background-clip: padding-box !important;
    border-color: var(--gel-edge-top) var(--gel-edge-side) var(--gel-edge-bottom) !important;
    color: var(--gel-fg) !important;
  }

  @media (prefers-reduced-motion: reduce) {
    transition-property: opacity !important;
    & > * {
      transition: none;
    }
  }
}

/* Opacity-only fallbacks for reduced motion (§5). */
@keyframes windows-fade-in {
  from {
    opacity: 0;
  }
}

@keyframes windows-fade-out {
  to {
    opacity: 0;
  }
}

/*
 * Sheet and AlertDialog carry their fallback in their class strings (callers
 * may replace data-slot, e.g. Sidebar's mobile sheet). Vaul animates through
 * its own unlayered CSS, so the drawer needs this override.
 */
@media (prefers-reduced-motion: reduce) {
  [data-vaul-drawer][data-state="open"] {
    animation-name: windows-fade-in !important;
    animation-duration: 150ms !important;
  }
  [data-vaul-drawer][data-state="closed"] {
    animation-name: windows-fade-out !important;
    animation-duration: 150ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --alert-ios-fill: #233260;
    --action-sheet-tray: linear-gradient(#3a3a3a, #262626 22px, #262626 22px), #262626;
  }
}

@media (forced-colors: active) {
  [data-slot="dialog-content"],
  [data-slot="alert-dialog-content"],
  [data-slot="sheet-content"],
  [data-slot="drawer-content"],
  [data-sonner-toast] {
    border: 1px solid CanvasText;
  }
}

/* parts/navigation.css */
/* skeuomorph/ui — navigation family recipes. Inlined into the "skeuomorph" registry style. */

/*
 * Tokens for tabs (segmented control), navigation menu (toolbar triggers),
 * the iOS navigation bar and the source-list sidebar. Light values are the
 * defaults; .dark re-points them at the "Graphite HUD" recipe.
 */
:root {
  /* Aqua segmented control. Dividers are 1px #b3b3b3 [M]. */
  --tabs-divider: #b3b3b3;
  --tabs-divider-selected: #3d5a8a;
  /* Unselected segment held down: the clear gel goes one step darker. */
  --tabs-pressed-hi: #e4e4e4;
  --tabs-pressed-band: #d2d2d2;
  --tabs-pressed-lo: #c6c6c6;
  --tabs-pressed-glow: #e6e6e6;

  /* iOS bar segmented control + bar buttons. */
  --navbar-button-edge-top: #2f3740;
  --navbar-button-edge-side: #405a7e;
  --navbar-button-edge-bottom: #375073;
  --navbar-button-lip: rgb(255 255 255 / 0.3);
  /* "Done" style: white 13px bold, worst under glyph ≈ #4171c9 = 4.69. */
  --navbar-button-done: linear-gradient(#5d87cf 0%, #2f66c6 50%, #1f56b8 50%, #2860c4 100%);
  --navbar-button-done-pressed: linear-gradient(#3e68b0 0%, #204f9f 50%, #17448f 50%, #1d4c9a 100%);
  --navbar-button-done-edge: #1a2f7f;

  /* iOS navigation bar (light = classic blue-grey; dark = Black Opaque). */
  --navbar-ios: var(--bar-ios);
  /* Solid fallback (prefers-contrast: more drops the gradient). */
  --navbar-ios-solid: #52698b;
  --navbar-ios-edge-top: var(--bar-ios-edge-top);
  --navbar-ios-edge-bottom: var(--bar-ios-edge-bottom);
  --navbar-ios-shadow: 0 1px 3px rgb(0 0 0 / 0.35);
  --navbar-button-ios: var(--bar-button-ios);
  --navbar-button-ios-pressed: var(--bar-button-ios-pressed);

  /* Mac toolbar (textured / ghost) triggers. */
  --toolbar-hover: rgb(0 0 0 / 0.05);
  --toolbar-pressed: rgb(0 0 0 / 0.12);

  /* Source list. */
  --source-list-hover: rgb(0 0 0 / 0.05);
  --source-list-icon: #4c566c;
  --source-list-badge: #5f6b7c; /* white 5.41 [V] */
  --source-list-badge-fg: #ffffff;
  --source-list-badge-selected: #ffffff;
  --source-list-badge-selected-fg: #1d4f99;
}

.dark {
  --tabs-divider: #141414;
  --tabs-divider-selected: #1a2f7f;
  --tabs-pressed-hi: #5a5a5a;
  --tabs-pressed-band: #464646;
  --tabs-pressed-lo: #383838;
  --tabs-pressed-glow: #4c4c4c;

  --navbar-ios: var(--bar-ios-black);
  --navbar-ios-solid: #1b1b1b;
  --navbar-ios-edge-top: #6a6a6a;
  --navbar-ios-edge-bottom: #000000;
  --navbar-ios-shadow: 0 1px 3px rgb(0 0 0 / 0.6);
  /* white 13px bold on the worst stop #4a4a4a = 8.86 [V] */
  --navbar-button-ios: linear-gradient(#5e5e5e 0%, #3e3e3e 50%, #2c2c2c 50%, #343434 100%);
  --navbar-button-ios-pressed: linear-gradient(#3a3a3a 0%, #262626 50%, #181818 50%, #1e1e1e 100%);
  --navbar-button-edge-top: #000000;
  --navbar-button-edge-side: #111111;
  --navbar-button-edge-bottom: #0a0a0a;
  --navbar-button-lip: rgb(255 255 255 / 0.12);

  --toolbar-hover: rgb(255 255 255 / 0.06);
  --toolbar-pressed: rgb(0 0 0 / 0.35);

  --source-list-hover: rgb(255 255 255 / 0.05);
  --source-list-icon: #a3acbd;
  --source-list-badge: #4a5468;
  --source-list-badge-selected: #f2f2f2;
  --source-list-badge-selected-fg: #1d4f99;
}

/* ============ Tabs: Aqua segmented control ============ */

/*
 * One segment. Outer ends are pills, inner joints square, 1px dividers.
 * Every segment carries the same border widths in every state: no layout shift.
 * Unselected = clear gel, selected = blue gel with a black label (Mac dialect).
 * Pair with the `gel` utility; this utility only reassigns gel vars + geometry.
 */
@utility tabs-segment {
  --control-h: var(--control-default);
  position: relative;
  height: var(--control-h);
  border-inline-start-width: 0;
  border-inline-end-width: 0;
  border-radius: 0;

  &:first-child {
    border-inline-start-width: 1px;
    border-start-start-radius: 9999px;
    border-end-start-radius: 9999px;
  }
  &:last-child {
    border-inline-end-width: 1px;
    border-start-end-radius: 9999px;
    border-end-end-radius: 9999px;
  }
  &:not(:first-child) {
    border-inline-start-width: 1px;
    border-inline-start-color: var(--tabs-divider);
  }

  /* Unselected: clear gel. */
  &[data-state="inactive"] {
    --gel-hi: var(--gel-clear-hi);
    --gel-band: var(--gel-clear-band);
    --gel-lo: var(--gel-clear-lo);
    --gel-glow: var(--gel-clear-glow);
    --gel-edge-top: var(--gel-clear-edge-top);
    --gel-edge-side: var(--gel-clear-edge-side);
    --gel-edge-bottom: var(--gel-clear-edge-bottom);
    --gel-fg: var(--gel-clear-fg);
  }

  /* Selected joints take the darker blue divider on both sides. */
  &[data-state="active"]:not(:first-child),
  &[data-state="active"] + &:not(:first-child) {
    border-inline-start-color: var(--tabs-divider-selected);
  }

  /* Press is instant: unselected goes one step darker, selected deepens. */
  &[data-state="inactive"]:active:not(:disabled) {
    --gel-hi: var(--tabs-pressed-hi);
    --gel-band: var(--tabs-pressed-band);
    --gel-lo: var(--tabs-pressed-lo);
    --gel-glow: var(--tabs-pressed-glow);
  }
  &[data-state="active"]:active:not(:disabled) {
    --gel-hi: var(--gel-pressed-hi);
    --gel-band: var(--gel-pressed-band);
    --gel-lo: var(--gel-pressed-lo);
    --gel-glow: var(--gel-pressed-glow);
    --gel-edge-top: var(--color-aqua-900);
    --gel-edge-side: var(--gel-pressed-edge-side);
    --gel-edge-bottom: var(--gel-pressed-edge-bottom);
    --gel-fg: #000000;
  }

  /* Disabled goes grey and flat, never pale blue (§4.1, §6.4). A disabled
     selected segment stays darker and pressed in, so the selection survives
     (same tokens as the disabled segmented control in buttons.css). */
  &:disabled:not([data-variant="ios"]) {
    --gel-hi: var(--gel-disabled-hi);
    --gel-band: var(--gel-disabled-band);
    --gel-lo: var(--gel-disabled-lo);
    --gel-glow: var(--gel-disabled-glow);
    --gel-edge-top: var(--gel-disabled-edge);
    --gel-edge-side: var(--gel-disabled-edge);
    --gel-edge-bottom: var(--gel-disabled-edge);
    --gel-fg: var(--gel-disabled-fg);
    --gel-fg-shadow: none;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.2), 0 0 #0000, 0 0 #0000, 0 0 #0000, var(--focus-halo, 0 0 #0000);
  }
  &[data-state="active"]:disabled:not([data-variant="ios"]) {
    --gel-hi: var(--gel-disabled-on-hi);
    --gel-band: var(--gel-disabled-on-band);
    --gel-lo: var(--gel-disabled-on-lo);
    --gel-glow: var(--gel-disabled-on-glow);
    --gel-fg: var(--gel-disabled-on-fg);
    box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.22), 0 0 #0000, 0 0 #0000, 0 0 #0000, var(--focus-halo, 0 0 #0000);
  }
  &[data-state="active"]:disabled:not([data-variant="ios"], :first-child),
  &[data-state="active"]:disabled:not([data-variant="ios"]) + &:not(:first-child) {
    border-inline-start-color: var(--tabs-divider);
  }

  &:focus-visible {
    z-index: 1;
  }

  /* ---- iOS bar segmented (variant="ios") ---- */
  &[data-variant="ios"] {
    --control-h: 30px;
    border-color: var(--navbar-button-edge-top) var(--navbar-button-edge-side)
      var(--navbar-button-edge-bottom);
    background-color: transparent;
    background-image: var(--navbar-button-ios);
    color: #ffffff;
    text-shadow: var(--text-emboss);
    box-shadow:
      inset 0 1px 0 rgb(255 255 255 / 0.18),
      0 1px 0 var(--navbar-button-lip),
      var(--focus-halo, 0 0 #0000);
  }
  &[data-variant="ios"]:first-child {
    border-start-start-radius: 5px;
    border-end-start-radius: 5px;
  }
  &[data-variant="ios"]:last-child {
    border-start-end-radius: 5px;
    border-end-end-radius: 5px;
  }
  &[data-variant="ios"]:not(:first-child),
  &[data-variant="ios"][data-state="active"] + &:not(:first-child) {
    border-inline-start-color: var(--navbar-button-edge-top);
  }
  &[data-variant="ios"][data-state="active"],
  &[data-variant="ios"]:active:not(:disabled) {
    background-image: var(--navbar-button-ios-pressed);
    box-shadow:
      inset 0 1px 2px rgb(0 0 0 / 0.45),
      0 1px 0 var(--navbar-button-lip),
      var(--focus-halo, 0 0 #0000);
  }
  &[data-variant="ios"]:disabled {
    color: rgb(255 255 255 / 0.5);
  }

  @media (forced-colors: active) {
    &[data-state="active"] {
      background: Highlight;
      color: HighlightText;
      forced-color-adjust: none;
    }
  }
}

/* Optional Aqua tab pane: the segmented control straddles its top edge, so
   centre the list when a pane is present (base layer: className wins). */
@layer base {
  [data-slot="tabs"]:has(> .tabs-pane) > [data-slot="tabs-list"] {
    align-self: center;
  }
}

/* Optional Aqua tab pane: the segmented control straddles its top edge. */
@utility tabs-pane {
  background-color: var(--pane);
  border: 1px solid var(--pane-edge);
  border-top-color: rgb(0 0 0 / 0.32);
  border-radius: 4px;
  margin-top: calc(var(--control-default) / -2 - 0.5rem);
  padding: calc(var(--control-default) / 2 + 12px) 20px 20px;
}

/* ============ Navigation menu: Mac toolbar (textured) trigger ============ */

@utility toolbar-trigger {
  background-color: transparent;
  box-shadow:
    0 0 #0000,
    0 0 #0000,
    0 0 #0000,
    0 0 #0000,
    var(--focus-halo, 0 0 #0000);

  @media (hover: hover) {
    &:hover {
      background-color: var(--toolbar-hover);
    }
  }
  &[data-state="open"],
  &:active:not(:disabled) {
    background-color: var(--toolbar-pressed);
    box-shadow: var(--pressed), var(--focus-halo, 0 0 #0000);
  }
}

/* ============ iOS navigation bar ============ */

@utility navbar-ios {
  height: 44px;
  background-color: var(--navbar-ios-solid);
  background-image: var(--navbar-ios);
  border-top: 1px solid var(--navbar-ios-edge-top);
  border-bottom: 1px solid var(--navbar-ios-edge-bottom);
  box-shadow: var(--navbar-ios-shadow);
  color: #ffffff;

  @media (prefers-contrast: more) {
    background-image: none;
  }
}

/* Bordered bar button (UIBarButtonItemStyleBordered). Press is instant. */
@utility navbar-button-ios {
  height: 30px;
  border-radius: 5px;
  border-width: 1px;
  border-style: solid;
  border-color: var(--navbar-button-edge-top) var(--navbar-button-edge-side)
    var(--navbar-button-edge-bottom);
  background-image: var(--navbar-button-ios);
  color: #ffffff;
  text-shadow: var(--text-emboss);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.18),
    0 1px 0 var(--navbar-button-lip),
    var(--focus-halo, 0 0 #0000);

  &:active:not(:disabled) {
    background-image: var(--navbar-button-ios-pressed);
    box-shadow:
      inset 0 1px 2px rgb(0 0 0 / 0.45),
      0 1px 0 var(--navbar-button-lip),
      var(--focus-halo, 0 0 #0000);
  }
}

/* Done style (blue). Combine with navbar-button-ios. */
@utility navbar-button-ios-done {
  border-color: var(--navbar-button-done-edge);
  background-image: var(--navbar-button-done);

  &:active:not(:disabled) {
    background-image: var(--navbar-button-done-pressed);
  }
}

/*
 * Back button: a bar button with a pointed start edge. The button itself is
 * unclipped (so the shared focus-ring outline is visible); a child face
 * [data-navbar-back-face] carries the drop-shadow lip, and its ::before /
 * ::after paint the clipped edge colour and the face 1px inside it. Flipped
 * under RTL.
 */
@utility navbar-back-ios {
  --_point: 12px;
  position: relative;
  isolation: isolate;
  height: 30px;
  padding-inline: calc(var(--_point) + 2px) 8px;
  color: #ffffff;
  text-shadow: var(--text-emboss);
  background: none;
  border-start-end-radius: 5px;
  border-end-end-radius: 5px;

  & > [data-navbar-back-face] {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    /* Same 1px light lip as navbar-button-ios (clip-path would eat a box-shadow). */
    filter: drop-shadow(0 1px 0 var(--navbar-button-lip));
  }
  & > [data-navbar-back-face]::before,
  & > [data-navbar-back-face]::after {
    content: "";
    position: absolute;
  }
  & > [data-navbar-back-face]::before {
    inset: 0;
    background-color: var(--navbar-button-edge-top);
    border-start-end-radius: 5px;
    border-end-end-radius: 5px;
    clip-path: polygon(var(--_point) 0, 100% 0, 100% 100%, var(--_point) 100%, 0 50%);
  }
  & > [data-navbar-back-face]::after {
    inset: 1px;
    background-image: var(--navbar-button-ios);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18);
    border-start-end-radius: 4px;
    border-end-end-radius: 4px;
    clip-path: polygon(calc(var(--_point) - 1px) 0, 100% 0, 100% 100%, calc(var(--_point) - 1px) 100%, 0 50%);
  }

  &:active:not(:disabled) > [data-navbar-back-face]::after {
    background-image: var(--navbar-button-ios-pressed);
    box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.45);
  }

  &:where(:dir(rtl), [dir="rtl"] *) {
    border-radius: 0;
    border-start-start-radius: 5px;
    border-end-start-radius: 5px;
  }
  &:where(:dir(rtl), [dir="rtl"] *) > [data-navbar-back-face]::before {
    clip-path: polygon(0 0, calc(100% - var(--_point)) 0, 100% 50%, calc(100% - var(--_point)) 100%, 0 100%);
  }
  &:where(:dir(rtl), [dir="rtl"] *) > [data-navbar-back-face]::after {
    clip-path: polygon(0 0, calc(100% - var(--_point) + 1px) 0, 100% 50%, calc(100% - var(--_point) + 1px) 100%, 0 100%);
  }

  @media (forced-colors: active) {
    border: 1px solid ButtonText;
    & > [data-navbar-back-face] {
      display: none;
    }
  }
}

/* ============ Source list (sidebar) selection ============ */

@utility source-list-selected {
  background-image: var(--source-list-sel);
  box-shadow: inset 0 1px 0 var(--source-list-sel-top), var(--focus-halo, 0 0 #0000);
  color: #ffffff;
  font-weight: 700;

  @media (forced-colors: active) {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
}

/* parts/data.css */
/* skeuomorph/ui — data family recipes. Inlined into the "skeuomorph" registry style. */

/* ---------- Calendar (iCal mini-month) + Chart tokens ---------- */
:root {
  /* Disabled day label: readable, never faded twice (4.6:1 on white). */
  --calendar-disabled: #757575;
  /* Today marker: a 1px inset box, like iCal's mini-month (≥ 3:1 UI). */
  --calendar-today: #6e6e6e;
  /* Range band: the pale selection tint; the gel ends must out-shout it. */
  --calendar-range: var(--accent);
  --calendar-range-foreground: var(--accent-foreground);
  /* Chart chrome borrows the Mac table: hairline dividers + alt-row cursor. */
  --chart-grid: #dedede;
  --chart-axis: #b3b3b3;
  /* Hover column: a translucent alt-row tint so the hairline grid shows through. */
  --chart-cursor: rgb(42 99 196 / 0.08);
  --chart-swatch-edge: rgb(0 0 0 / 0.22);
  --chart-swatch-gloss: linear-gradient(rgb(255 255 255 / 0.4), rgb(255 255 255 / 0.12) 50%, rgb(255 255 255 / 0) 50%);
}

.dark {
  --calendar-disabled: #8a8a8a;
  --calendar-today: #a3a3a3;
  /* Dark --accent is a saturated blue; quiet it so the gel ends lead. */
  --calendar-range: color-mix(in oklab, var(--accent) 45%, var(--card));
  --calendar-range-foreground: var(--foreground);
  --chart-grid: #3a3a3a;
  --chart-axis: #5a5a5a;
  --chart-cursor: rgb(94 162 255 / 0.1);
  --chart-swatch-edge: rgb(0 0 0 / 0.6);
  --chart-swatch-gloss: linear-gradient(rgb(255 255 255 / 0.25), rgb(255 255 255 / 0.06) 50%, rgb(255 255 255 / 0) 50%);
}

/* Today: 1px inset box + bold numeral. Never on top of a selected gel. */
@utility calendar-today {
  box-shadow: inset 0 0 0 1px var(--calendar-today);
  font-weight: 700;
}

/* Focus for pop-up dropdowns whose native <select> is an invisible overlay. */
@utility calendar-focus-within {
  &:has(:focus-visible) {
    outline: var(--focus-width) solid var(--focus-ring);
    outline-offset: var(--focus-offset);
    --focus-halo: 0 0 0 var(--focus-offset) var(--focus-ring-inner);
  }
}

/* Legend / tooltip colour chip: a tiny gel (hairline edge + hard gloss). */
@utility chart-swatch {
  background-image: var(--chart-swatch-gloss);
  box-shadow: inset 0 0 0 1px var(--chart-swatch-edge);
}

@media (forced-colors: active) {
  [data-slot="calendar"] [data-today="true"] {
    outline: 1px solid CanvasText;
    outline-offset: -1px;
  }
  [data-slot="calendar"] [data-selected="true"] {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
  [data-slot="chart-swatch"] {
    forced-color-adjust: none;
  }
}

@custom-variant dark (&:is(.dark *));

/* ============ STATIC SCALES + TAILWIND MAPPING ============ */
@theme inline {
  /* Aqua blue: 300/400/500/glow are measured Leopard gel stops. */
  --color-aqua-50: #f0f6fd;
  --color-aqua-100: #dde9f7;
  --color-aqua-200: #bcd3ee;
  --color-aqua-300: #a9c3e0;
  --color-aqua-400: #7aa7d5;
  --color-aqua-500: #508dc9;
  --color-aqua-600: #2a63c4;
  --color-aqua-700: #0a5fc2;
  --color-aqua-800: #1d4f99;
  --color-aqua-900: #1a2f7f;
  --color-aqua-950: #0e244b;
  --color-aqua-glow: #b0e4f1;

  /* Graphite (Aqua "Graphite" appearance). */
  --color-graphite-50: #f4f5f7;
  --color-graphite-100: #e3e6ea;
  --color-graphite-200: #c9d0da;
  --color-graphite-300: #a9b4c3;
  --color-graphite-400: #9aa6b6;
  --color-graphite-500: #7d899a;
  --color-graphite-600: #5f6b7c;
  --color-graphite-700: #4a5468;
  --color-graphite-800: #3c4656;
  --color-graphite-900: #2a313c;
  --color-graphite-glow: #d5dce6;

  /* Platinum neutrals (Leopard window chrome). */
  --color-platinum-50: #f6f6f6;
  --color-platinum-100: #ececec;
  --color-platinum-200: #e8e8e8;
  --color-platinum-300: #d1d1d1;
  --color-platinum-400: #a7a7a7;
  --color-platinum-500: #8a8a8a;
  --color-platinum-600: #6e6e6e;
  --color-platinum-700: #5f5f5f;
  --color-platinum-800: #494949;
  --color-platinum-900: #2b2b2b;
  --color-platinum-950: #1a1a1a;

  /* Ruby (destructive gel). Named so it never overrides Tailwind's red. */
  --color-ruby-50: #fdeeee;
  --color-ruby-100: #f8d3d4;
  --color-ruby-200: #efa6a9;
  --color-ruby-300: #e07a7f;
  --color-ruby-400: #d65a60;
  --color-ruby-500: #c43137;
  --color-ruby-600: #c4161c;
  --color-ruby-700: #a8141b;
  --color-ruby-800: #8c1016;
  --color-ruby-900: #4d080c;

  /* Jade (success gel, LEDs). */
  --color-jade-50: #edf7ed;
  --color-jade-100: #d3ecd3;
  --color-jade-200: #a9d8a9;
  --color-jade-300: #7cc27c;
  --color-jade-400: #4c9c4c;
  --color-jade-500: #2f8433;
  --color-jade-600: #237a28;
  --color-jade-700: #1b6b20;
  --color-jade-800: #155418;
  --color-jade-900: #0e3b11;

  /* Honey (warning gel, always a dark label). */
  --color-honey-50: #fff8e6;
  --color-honey-100: #ffeebd;
  --color-honey-200: #ffe08a;
  --color-honey-300: #ffd36b;
  --color-honey-400: #f4b63e;
  --color-honey-500: #f0a92a;
  --color-honey-600: #d68a12;
  --color-honey-700: #a8680a;
  --color-honey-800: #7a4b06;
  --color-honey-900: #3d2a00;

  /* Type: Aqua scale (13 system / 11 small / 10 mini / 12 view) + iOS 17/20. */
  --font-aqua: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-ios: "Helvetica Neue", Helvetica, Arial, sans-serif;
  /* Body copy in consumer apps reads in the Aqua system face. */
  --font-sans: var(--font-aqua);
  --text-mini: 10px;
  --text-mini--line-height: 13px;
  --text-small: 11px;
  --text-small--line-height: 14px;
  --text-view: 12px;
  --text-view--line-height: 16px;
  --text-ui: 13px;
  --text-ui--line-height: 17px;
  --text-ios-row: 17px;
  --text-ios-row--line-height: 22px;
  --text-ios-title: 20px;
  --text-ios-title--line-height: 24px;

  /* Easings. */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-ios-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-in-out-quad: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-in-quad: cubic-bezier(0.55, 0, 1, 0.45);
  --ease-switch: cubic-bezier(0.3, 1.3, 0.6, 1);

  /* Loops and entrances (keyframes below). */
  --animate-gel-pulse: gel-pulse 0.8s cubic-bezier(0.45, 0, 0.55, 1) infinite
    alternate;
  --animate-barber: barber 0.6s linear infinite;
  --animate-shimmer: unlock-shimmer 2.6s linear infinite;
  --animate-alert-pop: alert-pop 300ms both;
  --animate-sheet-up: sheet-up 380ms cubic-bezier(0.32, 0.72, 0, 1) both;
  --animate-sheet-down: sheet-down 300ms cubic-bezier(0.25, 1, 0.5, 1) both;

  /* Radii: sm 2, md 4, lg 6, xl 10 + the iOS 5px control radius. */
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-ios: 5px;

  /* shadcn semantic colors. */
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-success: var(--success);
  --color-success-foreground: var(--success-foreground);
  --color-warning: var(--warning);
  --color-warning-foreground: var(--warning-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --color-link: var(--link);
  --color-placeholder: var(--placeholder);
  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);
  --color-sidebar: var(--sidebar);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-ring: var(--sidebar-ring);

  /* Light model composites (Tier 3 — components use only these). */
  --shadow-raised: var(--raised);
  --shadow-pressed: var(--pressed);
  --shadow-well: var(--well);
  --shadow-seated: var(--seated);
  --shadow-float: var(--float);
  --shadow-window: var(--window);
  --shadow-glass: var(--glass);
}

/* Registered so a focused container never haloes its children. */
@property --focus-halo {
  syntax: "*";
  inherits: false;
}

/* ============ SEMANTIC + RECIPE TOKENS (light: "Aqua / Leopard") ============ */
:root {
  --radius: 6px;

  /* shadcn semantic */
  --background: #e8e8e8;
  --foreground: #1a1a1a;
  --card: #ffffff;
  --card-foreground: #1a1a1a;
  --popover: #f6f6f6;
  --popover-foreground: #1a1a1a;
  --primary: #2a63c4;
  --primary-foreground: #ffffff;
  --secondary: #ececec;
  --secondary-foreground: #1a1a1a;
  --muted: #e1e1e1;
  --muted-foreground: #5f5f5f;
  --accent: #dde9f7;
  --accent-foreground: #1a1a1a;
  --destructive: #c4161c;
  --destructive-foreground: #ffffff;
  --success: #1b6b20;
  --success-foreground: #ffffff;
  --warning: #7a4b06;
  --warning-foreground: #ffffff;
  --border: rgb(0 0 0 / 0.18);
  --input: #7f7f7f;
  --input-top: #6e6e6e;
  --ring: #0a5fc2;
  --link: #0a5fc2;
  --placeholder: #6e6e6e;
  --selection-row: #2a63c4;
  --selection-row-unfocused: #d4d4d4;
  --row-alt: #edf3fe;
  --help-tag: #feffca;
  --chart-1: #2a63c4;
  --chart-2: #508dc9;
  --chart-3: #2f8433;
  --chart-4: #f0a92a;
  --chart-5: #5f6b7c;
  --sidebar: #d6dde5;
  --sidebar-foreground: #1a1a1a;
  --sidebar-primary: #2a63c4;
  --sidebar-primary-foreground: #ffffff;
  --sidebar-accent: #c2c9d4;
  --sidebar-accent-foreground: #1a1a1a;
  --sidebar-border: rgb(0 0 0 / 0.18);
  --sidebar-ring: #0a5fc2;

  /* Light primitives (Tier 1). */
  --shade: 0 0 0;
  --rim: rgb(255 255 255 / 0.45);
  --rim-strong: rgb(255 255 255 / 0.8);
  --lip: rgb(255 255 255 / 0.65);
  --contact: rgb(var(--shade) / 0.22);
  --contact-2: rgb(var(--shade) / 0.04);
  --inner: rgb(var(--shade) / 0.28);

  /* Bevels (Tier 2, inner only). */
  --bevel-raised: inset 0 1px 0 var(--rim), inset 0 -1px 0 rgb(var(--shade) / 0.06);
  --bevel-inset: inset 0 1px 2px var(--inner), inset 0 0 0 1px rgb(var(--shade) / 0.06);
  --bevel-glass: inset 0 1px 0 rgb(255 255 255 / 0.15), inset 0 0 0 1px rgb(255 255 255 / 0.06);

  /* Elevations (Tier 2, outer only; x = 0 always). */
  --elev-contact: 0 1px 0 var(--contact), 0 2px 0 var(--contact-2);
  --elev-float-2: 0 0 0 1px rgb(var(--shade) / 0.18), 0 1px 1px rgb(var(--shade) / 0.1), 0 4px 8px rgb(var(--shade) / 0.14), 0 8px 16px rgb(var(--shade) / 0.12);
  --elev-float-3: 0 0 0 1px rgb(var(--shade) / 0.22), 0 1px 1px rgb(var(--shade) / 0.12), 0 6px 14px rgb(var(--shade) / 0.2), 0 16px 40px rgb(var(--shade) / 0.35);

  /* Composites (Tier 3). Each is 4 layers so any two states interpolate. */
  --raised: var(--bevel-raised), var(--elev-contact);
  --pressed: inset 0 1px 3px rgb(var(--shade) / 0.35), inset 0 0 0 1px rgb(var(--shade) / 0.08), 0 1px 0 rgb(255 255 255 / 0.5), 0 0 #0000;
  --well: var(--bevel-inset), 0 1px 0 var(--lip), 0 0 #0000;
  --seated: 0 1px 0 rgb(255 255 255 / 0.7), 0 0 0 1px rgb(var(--shade) / 0.14), 0 0 #0000, 0 0 #0000;
  --float: var(--elev-float-2);
  --window: var(--elev-float-3);
  --glass: var(--bevel-glass), 0 1px 0 rgb(0 0 0 / 0.4), 0 0 #0000;

  /* Gel — Mac dialect defaults (blue). Variants reassign these. */
  --gel-horizon: 0.4;
  --gel-hi: #a9c3e0;
  --gel-band: #7aa7d5;
  --gel-lo: #508dc9;
  --gel-glow: #b0e4f1;
  --gel-edge-top: #1a2f7f;
  --gel-edge-side: #4b6a9a;
  --gel-edge-bottom: #5a5a5a;
  --gel-fg: #000000;
  --gel-fg-shadow: none;
  --gel-pressed-hi: #82a7d1;
  --gel-pressed-band: #4f8cca;
  --gel-pressed-lo: #397fc7;
  --gel-pressed-glow: #78bfdb;
  --gel-pressed-edge-side: #3d5a8a;
  --gel-pressed-edge-bottom: #474747;

  --gel-clear-hi: #fcfcfc;
  --gel-clear-band: #efefef;
  --gel-clear-lo: #e2e2e2;
  --gel-clear-glow: #ffffff;
  --gel-clear-edge-top: #494949;
  --gel-clear-edge-side: #7a7a7a;
  --gel-clear-edge-bottom: #626262;
  --gel-clear-fg: #000000;

  --gel-red-hi: #d65a60;
  --gel-red-band: #c43137;
  --gel-red-lo: #a8141b;
  --gel-red-glow: #c8484e;
  --gel-red-edge: #5e0a0e;
  --gel-green-hi: #4c9c4c;
  --gel-green-band: #2f8433;
  --gel-green-lo: #1b6b20;
  --gel-green-glow: #3f9a44;
  --gel-green-edge: #0e3b11;
  --gel-amber-hi: #ffd36b;
  --gel-amber-band: #f4b63e;
  --gel-amber-lo: #f0a92a;
  --gel-amber-glow: #ffd98a;
  --gel-amber-edge: #7a4b06;
  --gel-graphite-hi: #c9d0da;
  --gel-graphite-band: #a9b4c3;
  --gel-graphite-lo: #7d899a;
  --gel-graphite-glow: #d5dce6;
  --gel-graphite-edge: #3c4656;

  /* iOS chrome (WCAG-tuned stops). */
  --bar-ios: linear-gradient(#94a7c2 0%, #6a819f 50%, #61799a 50%, #52698b 100%);
  --bar-ios-edge-top: #cdd5df;
  --bar-ios-edge-bottom: #2d3642;
  --bar-button-ios: linear-gradient(#7890b4 0%, #4a6a99 50%, #3c5d8f 50%, #41629a 100%);
  --bar-button-ios-pressed: linear-gradient(#4f6890 0%, #2e4a78 50%, #243f6c 50%, #2a4673 100%);
  --bar-button-ios-edge: #2f3740;
  --bar-ios-black: linear-gradient(#4b4b4b 0%, #2b2b2b 50%, #1b1b1b 50%, #000 100%);
  --tabbar-ios: linear-gradient(#2d2d2d 0%, #141414 50%, #000 50%, #000 100%);
  --row-ios-selected: linear-gradient(#1a74d8, #015fe6);
  --group-ios-border: #adaaad;
  --group-ios-header: #454e62;
  --group-ios-value: #385487;

  /* Mac chrome (10.6). */
  --chrome-unified: linear-gradient(#d1d1d1, #a7a7a7);
  --chrome-unified-inactive: linear-gradient(#eeeeee, #d8d8d8);
  --chrome-separator: #515151;
  --chrome-separator-inactive: #999999;
  --chrome-top-highlight: #dcdcdc;
  --source-list: #d6dde5;
  --source-list-inactive: #e8e8e8;
  --source-list-header: #4c566c;
  --source-list-sel: linear-gradient(#3570cf, #1f58b8);
  --source-list-sel-top: #4a80d4;
  --source-list-sel-unfocused: linear-gradient(#c2c9d4, #a9b3c2);
  --menu-surface: rgb(255 255 255 / 0.95);
  --menu-highlight: linear-gradient(#3570cf, #1f5fc8);
  --menu-separator: #e3e3e3;
  --menu-shortcut: #5f5f5f;
  --table-header: linear-gradient(#ffffff, #e8e8e8 50%, #dedede 50%, #ececec);
  --table-header-edge: #b3b3b3;
  --table-divider: #c8c8c8;
  --pane: rgb(0 0 0 / 0.04);
  --pane-edge: rgb(0 0 0 / 0.22);
  --hud: rgb(0 0 0 / 0.78);
  --hud-foreground: #ffffff;
  --hud-muted: #d9d9d9;
  --hud-edge: rgb(255 255 255 / 0.15);
  --overlay: rgb(0 0 0 / 0.35);
  --window-body: #ececec;

  /* Bezel (square "gradient button", outline variant). */
  --bezel: linear-gradient(#ffffff, #e6e6e6);
  --bezel-pressed: linear-gradient(#d4d4d4, #e2e2e2);
  --bezel-edge: #7a7a7a;

  /* Wells & tracks. */
  --track: linear-gradient(#b5b5b5, #e6e6e6);
  --track-edge: #727272;
  --check-well: linear-gradient(#b7b7b7, #dcdcdc 50%, #fdfdfd);
  --check-edge: #727272;
  --knob: linear-gradient(#fefefe, #d8d8d8);
  --knob-edge: #8a8a8a;
  --switch-on: linear-gradient(#0058a6 0%, #0a6fd0 50%, #1670cc 50%, #2677d0 75%, #5a9fe0 100%);
  --switch-off: linear-gradient(#cecece 0%, #eeeeee 50%, #f8f8f8 50%, #fdfdfd 100%);
  --switch-off-fg: #5f5f5f;
  --progress-track: linear-gradient(#d2d2d2, #e7e7e7 25%, #d9d9d9 45%, #f0f0f0, #f8f8f8);
  --progress-track-edge: #a3a3a3;
  --progress-fill: linear-gradient(180deg, rgb(255 255 255 / 0.45) 0 12%, rgb(255 255 255 / 0.55) 25%, rgb(255 255 255 / 0) 50%, rgb(140 220 255 / 0.5) 100%), repeating-linear-gradient(90deg, #3d8be4 0 2px, #4f97e9 5px, #3c8ce4 10px, #3282de 13px, #3d8be4 16px);
  --progress-fill-edge: #2159b9;
  --barber: linear-gradient(180deg, rgb(255 255 255 / 0.45) 0 12%, rgb(255 255 255 / 0.55) 25%, rgb(255 255 255 / 0) 50%, rgb(140 220 255 / 0.3) 100%), repeating-linear-gradient(-45deg, #3995fd 0 2.83px, #78b7fd 4.24px, #e0eefe 5.66px, #fefefe 6.36px 8.49px, #bcdbfe 9.9px, #55a5fd 11.31px);

  /* Materials (whole regions only, never inside controls). */
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --noise-opacity: 0.05;
  --material-pinstripe: repeating-linear-gradient(180deg, #ececec 0 2px, #f2f2f2 2px 4px);
  --material-pinstripe-ios: repeating-linear-gradient(90deg, #c5ccd4 0 4px, #cbd2d9 4px 7px);
  --material-metal: repeating-linear-gradient(90deg, rgb(255 255 255 / 0) 0 5px, rgb(255 255 255 / 0.08) 6px 7px), repeating-linear-gradient(90deg, rgb(0 0 0 / 0) 0 2px, rgb(0 0 0 / 0.03) 3px), repeating-linear-gradient(90deg, rgb(255 255 255 / 0) 0 11px, rgb(255 255 255 / 0.15) 12px 13px), linear-gradient(180deg, #c8c8c8 0%, #e6e6e6 47%, #c8c8c8 53%, #b2b2b2 100%);
  --material-linen: repeating-linear-gradient(0deg, rgb(255 255 255 / 0.025) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgb(0 0 0 / 0.05) 0 1px, transparent 1px 2px), radial-gradient(ellipse at 50% 0%, #4b4f57, #2c2f34 80%);

  /* Text relief. */
  --text-engrave: 0 1px 0 rgb(255 255 255 / 0.75);
  --text-emboss: 0 -1px 0 rgb(0 0 0 / 0.5);

  /* Control heights (shadcn names) + native Aqua density. */
  --control-xs: 24px;
  --control-sm: 32px;
  --control-default: 36px;
  --control-lg: 40px;
  --control-native-regular: 21px;
  --control-native-small: 17px;
  --control-native-mini: 14px;
  --hit-min: 24px;
  --hit-coarse: 44px;

  /* Focus: 2px solid outline + 2px inner gap ring via --focus-halo. */
  --focus-ring: #0a5fc2;
  --focus-ring-inner: #ffffff;
  --focus-width: 2px;
  --focus-offset: 2px;

  /* Motion. */
  --dur-press: 0ms;
  --dur-release: 120ms;
  --dur-tooltip: 100ms;
  --dur-menu: 150ms;
  --dur-switch: 220ms;
  --dur-alert-in: 300ms;
  --dur-alert-out: 150ms;
  --dur-sheet-in: 380ms;
  --dur-sheet-out: 280ms;
  --dur-toast-in: 200ms;
  --dur-toast-out: 300ms;
  --dur-spring-back: 280ms;
}

/* ============ .dark — "Graphite HUD": dim the light, keep the objects ============ */
.dark {
  --background: #2b2b2b;
  --foreground: #f2f2f2;
  --card: #1e1e1e;
  --card-foreground: #f2f2f2;
  --popover: #262626;
  --popover-foreground: #f2f2f2;
  --primary: #2a63c4;
  --primary-foreground: #ffffff;
  --secondary: #3a3a3a;
  --secondary-foreground: #f2f2f2;
  --muted: #333333;
  --muted-foreground: #a3a3a3;
  --accent: #1d4f99;
  --accent-foreground: #ffffff;
  --destructive: #e07a7f;
  --destructive-foreground: #1a1a1a;
  --success: #7cc27c;
  --success-foreground: #0e3b11;
  --warning: #ffd36b;
  --warning-foreground: #3d2a00;
  --border: rgb(255 255 255 / 0.1);
  --input: #8a8a8a;
  --input-top: #8a8a8a;
  --ring: #5ea2ff;
  --link: #5ea2ff;
  --placeholder: #8a8a8a;
  --row-alt: #252a33;
  --selection-row: #2a63c4;
  --selection-row-unfocused: #4a4a4a;
  --help-tag: #3a3a2a;
  --chart-1: #5ea2ff;
  --chart-2: #508dc9;
  --chart-3: #7cc27c;
  --chart-4: #ffd36b;
  --chart-5: #a3a3a3;
  --sidebar: #232831;
  --sidebar-foreground: #f2f2f2;
  --sidebar-primary: #2a63c4;
  --sidebar-primary-foreground: #ffffff;
  --sidebar-accent: #3a414d;
  --sidebar-accent-foreground: #f2f2f2;
  --sidebar-border: rgb(255 255 255 / 0.1);
  --sidebar-ring: #5ea2ff;

  --rim: rgb(255 255 255 / 0.15);
  --rim-strong: rgb(255 255 255 / 0.3);
  --lip: rgb(255 255 255 / 0.06);
  --contact: rgb(0 0 0 / 0.6);
  --contact-2: rgb(0 0 0 / 0.2);
  --inner: rgb(0 0 0 / 0.6);
  --pressed: inset 0 1px 3px rgb(0 0 0 / 0.6), inset 0 0 0 1px rgb(0 0 0 / 0.2), 0 1px 0 rgb(255 255 255 / 0.06), 0 0 #0000;
  --seated: 0 1px 0 rgb(255 255 255 / 0.06), 0 0 0 1px rgb(0 0 0 / 0.6), 0 0 #0000, 0 0 #0000;

  --gel-hi: #90aac6;
  --gel-band: #729fcc;
  --gel-lo: #508dc9;
  --gel-glow: #89b9c9;
  --gel-edge-bottom: #141414;
  --gel-clear-hi: #6a6a6a;
  --gel-clear-band: #555555;
  --gel-clear-lo: #464646;
  --gel-clear-glow: #5e5e5e;
  --gel-clear-edge-top: #141414;
  --gel-clear-edge-side: #1e1e1e;
  --gel-clear-edge-bottom: #0a0a0a;
  --gel-clear-fg: #ffffff;

  --chrome-unified: linear-gradient(#4a4a4a, #2e2e2e);
  --chrome-unified-inactive: linear-gradient(#3a3a3a, #2e2e2e);
  --chrome-separator: #141414;
  --chrome-top-highlight: rgb(255 255 255 / 0.08);
  --source-list: #232831;
  --source-list-inactive: #262626;
  --source-list-header: #a3acbd;
  --source-list-sel-unfocused: linear-gradient(#4a4a4a, #3a3a3a);
  --menu-surface: rgb(38 38 38 / 0.97);
  --menu-separator: #3a3a3a;
  --menu-shortcut: #a3a3a3;
  --table-header: linear-gradient(#3a3a3a, #2e2e2e 50%, #282828 50%, #2e2e2e);
  --table-header-edge: #141414;
  --table-divider: #3a3a3a;
  --pane: rgb(255 255 255 / 0.03);
  --pane-edge: rgb(0 0 0 / 0.6);
  --overlay: rgb(0 0 0 / 0.55);
  --window-body: #2b2b2b;

  --bezel: linear-gradient(#4a4a4a, #383838);
  --bezel-pressed: linear-gradient(#2a2a2a, #333333);
  --bezel-edge: #141414;
  --track: linear-gradient(#141414, #2a2a2a);
  --track-edge: #0a0a0a;
  --check-well: linear-gradient(#1a1a1a, #2a2a2a 50%, #3a3a3a);
  --check-edge: #8a8a8a;
  --knob: linear-gradient(#8a8a8a, #5a5a5a);
  --knob-edge: #141414;
  --switch-off: linear-gradient(#1a1a1a 0%, #2a2a2a 50%, #333333 50%, #3a3a3a 100%);
  --switch-off-fg: #a3a3a3;
  --progress-track: linear-gradient(#141414, #222222 45%, #2a2a2a);
  --progress-track-edge: #0a0a0a;

  --group-ios-border: #141414;
  --group-ios-header: #a3acbd;
  --group-ios-value: #8fb0e8;

  --focus-ring: #5ea2ff;
  --focus-ring-inner: #000000;
  --noise-opacity: 0.04;
}

/* ============ THEME RECOLOUR: derive gels from --primary ============ */
@supports (color: oklch(from red l c h)) {
  :root,
  .dark {
    --gel-hi: oklch(from var(--primary) calc(l + 0.29) calc(c * 0.31) calc(h - 9));
    --gel-band: oklch(from var(--primary) calc(l + 0.196) calc(c * 0.51) calc(h - 11));
    --gel-lo: oklch(from var(--primary) calc(l + 0.111) calc(c * 0.68) calc(h - 11));
    --gel-glow: oklch(from var(--primary) calc(l + 0.37) calc(c * 0.34) calc(h - 45));
    --gel-edge-top: oklch(from var(--primary) calc(l - 0.173) calc(c * 0.84) calc(h + 7));
    --gel-pressed-hi: oklch(from var(--primary) calc(l + 0.2) calc(c * 0.45) calc(h - 9));
    --gel-pressed-band: oklch(from var(--primary) calc(l + 0.11) calc(c * 0.7) calc(h - 10));
    --gel-pressed-lo: oklch(from var(--primary) calc(l + 0.07) calc(c * 0.8) calc(h - 9));
    --gel-pressed-glow: oklch(from var(--primary) calc(l + 0.25) calc(c * 0.5) calc(h - 35));
  }
  .dark {
    --gel-hi: oklch(from var(--primary) calc(l + 0.22) calc(c * 0.35) calc(h - 9));
    --gel-glow: oklch(from var(--primary) calc(l + 0.24) calc(c * 0.3) calc(h - 40));
  }
}

/* Optional accent theme: Aqua "Graphite". */
.theme-graphite {
  --primary: #5f6b7c;
  --ring: #0a5fc2;
}

/* ============ RECIPE UTILITIES ============ */

/* Gel bead. Size it with --control-h; the horizon snaps to a whole pixel. */
@utility gel {
  --_h: var(--control-h, var(--control-default));
  --_b: round(down, calc((var(--_h) - 2px) * var(--gel-horizon)), 1px);
  border-width: 1px;
  border-style: solid;
  border-color: var(--gel-edge-top) var(--gel-edge-side) var(--gel-edge-bottom);
  background-color: var(--gel-lo);
  background-image: linear-gradient(180deg, var(--gel-hi) 0, var(--gel-band) var(--_b), var(--gel-lo) var(--_b), color-mix(in oklab, var(--gel-lo) 65%, var(--gel-glow)) calc(var(--_b) + (100% - var(--_b)) * 0.55), var(--gel-glow) 100%);
  background-clip: padding-box;
  color: var(--gel-fg);
  text-shadow: var(--gel-fg-shadow);
  box-shadow: var(--raised), var(--focus-halo, 0 0 #0000);
}

@utility gel-clear {
  --gel-hi: var(--gel-clear-hi);
  --gel-band: var(--gel-clear-band);
  --gel-lo: var(--gel-clear-lo);
  --gel-glow: var(--gel-clear-glow);
  --gel-edge-top: var(--gel-clear-edge-top);
  --gel-edge-side: var(--gel-clear-edge-side);
  --gel-edge-bottom: var(--gel-clear-edge-bottom);
  --gel-fg: var(--gel-clear-fg);
}

/* Also what a pressed clear button becomes (it "acquires color"). */
@utility gel-pressed {
  --gel-hi: var(--gel-pressed-hi);
  --gel-band: var(--gel-pressed-band);
  --gel-lo: var(--gel-pressed-lo);
  --gel-glow: var(--gel-pressed-glow);
  --gel-edge-top: var(--color-aqua-900);
  --gel-edge-side: var(--gel-pressed-edge-side);
  --gel-edge-bottom: var(--gel-pressed-edge-bottom);
  --gel-fg: #000000;
}

@utility gel-red {
  --gel-hi: var(--gel-red-hi);
  --gel-band: var(--gel-red-band);
  --gel-lo: var(--gel-red-lo);
  --gel-glow: var(--gel-red-glow);
  --gel-edge-top: var(--gel-red-edge);
  --gel-edge-side: var(--gel-red-edge);
  --gel-edge-bottom: var(--gel-red-edge);
  --gel-fg: #ffffff;
  --gel-fg-shadow: var(--text-emboss);
}

@utility gel-green {
  --gel-hi: var(--gel-green-hi);
  --gel-band: var(--gel-green-band);
  --gel-lo: var(--gel-green-lo);
  --gel-glow: var(--gel-green-glow);
  --gel-edge-top: var(--gel-green-edge);
  --gel-edge-side: var(--gel-green-edge);
  --gel-edge-bottom: var(--gel-green-edge);
  --gel-fg: #ffffff;
  --gel-fg-shadow: var(--text-emboss);
}

@utility gel-amber {
  --gel-hi: var(--gel-amber-hi);
  --gel-band: var(--gel-amber-band);
  --gel-lo: var(--gel-amber-lo);
  --gel-glow: var(--gel-amber-glow);
  --gel-edge-top: var(--gel-amber-edge);
  --gel-edge-side: var(--gel-amber-edge);
  --gel-edge-bottom: var(--gel-amber-edge);
  --gel-fg: #3d2a00;
  --gel-fg-shadow: none;
}

@utility gel-graphite {
  --gel-hi: var(--gel-graphite-hi);
  --gel-band: var(--gel-graphite-band);
  --gel-lo: var(--gel-graphite-lo);
  --gel-glow: var(--gel-graphite-glow);
  --gel-edge-top: var(--gel-graphite-edge);
  --gel-edge-side: var(--gel-graphite-edge);
  --gel-edge-bottom: var(--gel-graphite-edge);
  --gel-fg: #000000;
}

/* iOS dialect: horizon at 50% and embossed white labels on darkened stops. */
@utility gel-ios {
  --gel-horizon: 0.5;
}

/* Inset well: text fields, tracks, switch track. Never a top rim light. */
@utility well {
  background-color: var(--card);
  border-width: 1px;
  border-style: solid;
  border-color: var(--input-top) var(--input) var(--input);
  box-shadow: var(--well), var(--focus-halo, 0 0 #0000);
}

/* Square bevel ("gradient button"). Press: pressed shadow + 1px travel. */
@utility bezel {
  border-width: 1px;
  border-style: solid;
  border-color: var(--bezel-edge);
  background-image: var(--bezel);
  box-shadow: var(--raised), var(--focus-halo, 0 0 #0000);
}

/* Floating surface: menus, popovers, selects. */
@utility float {
  background-color: var(--menu-surface);
  border: 1px solid rgb(0 0 0 / 0.25);
  box-shadow: var(--float);
}

/* Two-colour focus indicator (W3C C40). The halo is appended, never replaces. */
@utility focus-ring {
  &:focus-visible {
    outline: var(--focus-width) solid var(--focus-ring);
    outline-offset: var(--focus-offset);
    --focus-halo: 0 0 0 var(--focus-offset) var(--focus-ring-inner);
  }
}

@utility engrave {
  text-shadow: var(--text-engrave);
}

@utility emboss {
  text-shadow: var(--text-emboss);
}

@utility material-pinstripe {
  background: var(--material-pinstripe);
}

@utility material-pinstripe-ios {
  background: var(--material-pinstripe-ios);
}

@utility material-metal {
  background: var(--material-metal);
}

@utility material-linen {
  background: var(--material-linen);
}

@utility noise {
  position: relative;

  &::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: var(--noise) 0 0 / 200px;
    opacity: var(--noise-opacity);
    mix-blend-mode: multiply;
    border-radius: inherit;
  }
}

/* Expands the hit area to 24px (44px on coarse pointers) without changing size. */
@utility hit {
  position: relative;

  &::before {
    content: "";
    position: absolute;
    inset: min(0px, calc((100% - var(--hit-min)) / 2));
  }

  @media (pointer: coarse) {
    &::before {
      inset: min(0px, calc((100% - var(--hit-coarse)) / 2));
    }
  }
}

/* Pressables: no tap highlight, no callout, no double-tap zoom delay. */
@utility pressable {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ============ KEYFRAMES ============ */
@keyframes gel-pulse {
  from {
    opacity: 0;
  }
  to {
    opacity: 0.55;
  }
}

@keyframes barber {
  from {
    background-position-x: 0;
  }
  to {
    background-position-x: 16px;
  }
}

@keyframes unlock-shimmer {
  0% {
    background-position: 100% 0;
  }
  77% {
    background-position: 0 0;
  }
  100% {
    background-position: 0 0;
  }
}

@keyframes alert-pop {
  0% {
    transform: scale(0.7);
    opacity: 0;
    animation-timing-function: cubic-bezier(0.25, 1, 0.5, 1);
  }
  45% {
    transform: scale(1.08);
    opacity: 1;
    animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
  }
  75% {
    transform: scale(0.97);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}

@keyframes sheet-down {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: none;
  }
}

/* ============ ACCESSIBILITY PREFERENCES ============ */
@media (forced-colors: active) {
  [data-slot="button"],
  [data-slot="select-trigger"],
  [data-slot="toggle"],
  [data-slot="toggle-group-item"],
  [data-slot="tabs-trigger"] {
    border: 1px solid ButtonText;
  }
  :focus-visible {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
  [data-slot="switch"][data-state="checked"],
  [data-slot="checkbox"][data-state="checked"],
  [data-slot="radio-group-indicator"],
  [data-slot="progress-indicator"],
  [data-slot="slider-range"] {
    background: Highlight;
    forced-color-adjust: none;
  }
  [data-highlighted],
  [aria-selected="true"] {
    background: Highlight;
    color: HighlightText;
  }
  .noise::after {
    display: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --noise-opacity: 0;
    --border: rgb(0 0 0 / 0.45);
    --input: #5f5f5f;
    --input-top: #4d4d4d;
  }
  [data-slot] {
    --gel-hi: var(--gel-band);
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --hud: #383838;
    --menu-surface: #f6f6f6;
  }
  .dark {
    --menu-surface: #262626;
  }
}
