/*
 * GIANT design system
 *
 * The design system is a set of `style-*` attributes. Each attribute is one
 * design decision and owns a fixed set of CSS properties, so an element can
 * only ever have one value per decision:
 *
 *   <card style-surface="raised" style-pad="large" style-radius="medium">
 *   <button style-tone="danger" style-emphasis="solid">
 *
 * This file is the single source of truth. giant.compiler.js reads every
 * [style-x="y"] selector below and generates the TypeScript unions in
 * giant.d.ts, so adding a selector here adds it to the types.
 *
 * Scale words (shared by every scale):
 *   none xsmall small medium large xlarge xxlarge
 *
 * Attributes and the properties they own:
 *   style-layout      display, flex-direction, flex-wrap, place-items (defaults for align/justify)
 *   style-align       align-items        (overrides style-layout's default)
 *   style-justify     justify-content    (overrides style-layout's default)
 *   style-gap         gap
 *   style-pad         padding            (both axes)
 *   style-pad-block   padding-block      (combines with style-pad, either order)
 *   style-pad-inline  padding-inline     (combines with style-pad, either order)
 *   style-position    position
 *   style-inset       inset
 *   style-layer       z-index
 *   style-overflow    overflow
 *   style-width       inline-size        (full | fit | the size scale small..xxlarge)
 *   style-max-width   max-inline-size    (size scale, or "prose" for a readable line length)
 *   style-max-height  max-block-size     (size scale, or "screen")
 *   style-size        inline-size + block-size, flex: none (square boxes: avatars, icons)
 *   style-flex        flex               (grow | none)
 *   style-height      block-size
 *   style-ratio       aspect-ratio
 *   style-margin      margin
 *   style-radius      border-radius
 *   style-border      border-width, border-style, border-color (default)
 *   style-divider     one border side    (top | bottom | start | end), colour follows tone
 *   style-surface     background-color, box-shadow
 *   style-tone        color, and sets the tone used by style-emphasis (inherited)
 *   style-emphasis    background-color, color, border-color, interactive states
 *                     ("field" is the emphasis for text inputs, selects and textareas;
 *                      "knob" for switch/slider thumbs: halo on hover, squeeze on press)
 *   style-interactive cursor, user-select, pointer-events, touch-action, opacity ("disabled" for non-buttons)
 *   style-visibility  visibility / opacity / visually-hidden clipping
 *   style-text        font-size
 *   style-weight      font-weight
 *   style-font        font-family
 *   style-leading     --leading: the space added to each element's own font size
 *                     (line-height is calc(1em + var(--leading)) on every element)
 *   style-tracking    letter-spacing
 *   style-case        text-transform
 *   style-text-align  text-align
 *   style-wrap        white-space, text-overflow, text-wrap, overflow-wrap
 *   style-decoration  text-decoration
 *   style-fit         object-fit
 *   style-motion      transition, animation
 *
 * Runtime values (a computed width, a chart colour) may still use the `style`
 * attribute, but only with the variables from the giant.tokens layer:
 *   style: { width: `${pct}%`, fill: 'var(--series-2)' }
 *
 * Radius: small for controls and chips (buttons, inputs, badges, tabs), medium for
 * containers (cards, menus, dialogs, toasts), round only for pills and circles.
 *
 * Tone inherits: put style-tone="danger" on a container and every
 * style-emphasis inside it picks up the danger colours.
 *
 * Colour model: every derived colour is a seed at some alpha
 * (color-mix(in oklch, var(--tone) 12%, transparent)), never a mix with the
 * page background. Translucent colours composite correctly over any surface,
 * in light and dark, so each tone needs one seed and no light/dark variants.
 * Only --bg, --fg and --raised are opaque, scheme-aware colours.
 *
 * Theming: override the seed variables in the giant.tokens layer
 * (--bg, --fg, --accent, --success, --warning, --danger, --space-*, ...).
 */

@layer giant.tokens, giant.base, giant.system;

@layer giant.tokens {
  :root {
    color-scheme: light dark;

    /* seeds: every colour in the system is derived from these */
    --bg: light-dark(oklch(98.5% 0 0), oklch(20% 0 0));
    --fg: light-dark(oklch(20% 0 0), oklch(96% 0 0));
    --raised: light-dark(oklch(100% 0 0), oklch(24% 0 0));
    --accent: oklch(58% 0.17 250);
    --success: oklch(58% 0.14 150);
    --warning: oklch(80% 0.15 80);
    --danger: oklch(57% 0.2 25);

    --border: color-mix(in oklch, var(--fg) 14%, transparent);
    --muted: color-mix(in oklch, var(--fg) 4%, transparent);

    --space-none: 0;
    --space-xsmall: 0.25rem;
    --space-small: 0.5rem;
    --space-medium: 1rem;
    --space-large: 1.5rem;
    --space-xlarge: 2rem;
    --space-xxlarge: 3rem;

    --size-xsmall: 1rem;
    --size-small: 1.5rem;
    --size-medium: 2.5rem;
    --size-large: 4rem;

    --measure-small: 16rem;
    --measure-medium: 24rem;
    --measure-large: 32rem;
    --measure-xlarge: 48rem;
    --measure-xxlarge: 64rem;

    --radius-small: 0.25rem;
    --radius-medium: 0.5rem;
    --radius-large: 1rem;

    --shadow-small: 0 1px 2px oklch(0% 0 0 / 0.08), 0 1px 3px oklch(0% 0 0 / 0.06);
    --shadow-large: 0 10px 30px oklch(0% 0 0 / 0.16), 0 2px 6px oklch(0% 0 0 / 0.08);

    --font-sans: 'body', system-ui, sans-serif;
    --font-serif: 'title', Georgia, serif;
    --font-mono: 'mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --leading: 0.5rem;

    --duration-fast: 120ms;
    --duration-normal: 200ms;

    /* data visualisation series (charts) */
    --series-1: oklch(60% 0.15 250);
    --series-2: oklch(65% 0.15 160);
    --series-3: oklch(72% 0.15 80);
    --series-4: oklch(60% 0.18 25);
    --series-5: oklch(58% 0.15 300);
    --series-6: oklch(65% 0.1 200);

    /* default tone for everything not inside a style-tone */
    --tone: var(--fg);
    --tone-on: var(--bg);
    --tone-border-alpha: 14%;
  }
}

@layer giant.base {
  /* on every element, so 1em is always the element's own font size (an em line-height inherits as a fixed length) */
  *, *::before, *::after { box-sizing: border-box; line-height: calc(1em + var(--leading)); }

  html { text-size-adjust: none; }

  /* style-layout sets display; keep the native hidden attribute authoritative */
  [hidden]:not([hidden="until-found"]) { display: none !important; }

  body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--fg);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
  }

  h1, h2, h3, h4 { text-wrap: balance; --leading: 0.25rem; }
  p { text-wrap: pretty; }
  img, svg, video, canvas { display: block; max-width: 100%; }

  button, input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    color: inherit;
    background-color: transparent;
    border: 0 solid var(--border);
  }

  :focus-visible { outline: 2px solid color-mix(in oklch, var(--fg) 60%, transparent); outline-offset: 2px; }
  :focus:not(:focus-visible) { outline: none; }
  /* an invisible native input layered over a custom control comes first; the indicator after it shows its focus */
  [style-visibility="invisible"]:focus-visible + [aria-hidden="true"] { outline: 2px solid color-mix(in oklch, var(--fg) 60%, transparent); outline-offset: 2px; }
  table { border-collapse: collapse; border-spacing: 0; }
  ::selection { background-color: color-mix(in oklch, var(--accent) 25%, transparent); }

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

/* Padding axes are non-inheriting so style-pad-inline on a parent never leaks into a child. */
@property --_pad-block { syntax: '<length-percentage>'; inherits: false; initial-value: 0px; }
@property --_pad-inline { syntax: '<length-percentage>'; inherits: false; initial-value: 0px; }
/* hover/press tint strength: registered so it can transition (gradients can't); the colour is built in the gradient */
@property --_tint { syntax: '<percentage>'; inherits: false; initial-value: 0%; }

/*
 * Rules are ordered on purpose. Where two attributes touch the same property,
 * the later one wins and the overlap is intentional:
 * style-align and style-justify override style-layout's defaults, and
 * style-emphasis overrides the colours from style-border, style-surface and style-tone.
 */
@layer giant.system {

  /* ---------- layout ---------- */
  [style-layout="block"] { display: block; }
  [style-layout="inline-block"] { display: inline-block; }
  [style-layout="stack"] { display: flex; flex-direction: column; }
  [style-layout="row"] { display: flex; flex-direction: row; align-items: center; }
  [style-layout="cluster"] { display: flex; flex-wrap: wrap; align-items: center; }
  [style-layout="inline"] { display: inline-flex; align-items: center; justify-content: center; }
  [style-layout="center"] { display: grid; place-items: center; }
  [style-layout="grid"] { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(16rem, 100%), 1fr)); }

  [style-align="start"] { align-items: start; }
  [style-align="center"] { align-items: center; }
  [style-align="end"] { align-items: end; }
  [style-align="stretch"] { align-items: stretch; }
  [style-align="baseline"] { align-items: baseline; }

  [style-justify="start"] { justify-content: start; }
  [style-justify="center"] { justify-content: center; }
  [style-justify="end"] { justify-content: end; }
  [style-justify="between"] { justify-content: space-between; }
  [style-justify="around"] { justify-content: space-around; }

  [style-position="relative"] { position: relative; }
  [style-position="absolute"] { position: absolute; }
  [style-position="fixed"] { position: fixed; }
  [style-position="sticky"] { position: sticky; }

  [style-inset="fill"] { inset: 0; }
  [style-inset="top"] { inset-block-start: 0; }
  [style-inset="bottom"] { inset-block-end: 0; }

  [style-layer="base"] { z-index: 0; }
  [style-layer="raised"] { z-index: 10; }
  [style-layer="overlay"] { z-index: 100; }
  [style-layer="modal"] { z-index: 1000; }
  /* above modals: toasts and other app-wide notices */
  [style-layer="top"] { z-index: 10000; }

  [style-overflow="visible"] { overflow: visible; }
  [style-overflow="hidden"] { overflow: hidden; }
  [style-overflow="auto"] { overflow: auto; }
  [style-overflow="clip"] { overflow: clip; }

  /* ---------- spacing ---------- */
  [style-gap="none"] { gap: var(--space-none); }
  [style-gap="xsmall"] { gap: var(--space-xsmall); }
  [style-gap="small"] { gap: var(--space-small); }
  [style-gap="medium"] { gap: var(--space-medium); }
  [style-gap="large"] { gap: var(--space-large); }
  [style-gap="xlarge"] { gap: var(--space-xlarge); }
  [style-gap="xxlarge"] { gap: var(--space-xxlarge); }

  [style-pad], [style-pad-block], [style-pad-inline] {
    padding-block: var(--_pad-block);
    padding-inline: var(--_pad-inline);
  }

  [style-pad="none"] { --_pad-block: var(--space-none); --_pad-inline: var(--space-none); }
  [style-pad="xsmall"] { --_pad-block: var(--space-xsmall); --_pad-inline: var(--space-xsmall); }
  [style-pad="small"] { --_pad-block: var(--space-small); --_pad-inline: var(--space-small); }
  [style-pad="medium"] { --_pad-block: var(--space-medium); --_pad-inline: var(--space-medium); }
  [style-pad="large"] { --_pad-block: var(--space-large); --_pad-inline: var(--space-large); }
  [style-pad="xlarge"] { --_pad-block: var(--space-xlarge); --_pad-inline: var(--space-xlarge); }
  [style-pad="xxlarge"] { --_pad-block: var(--space-xxlarge); --_pad-inline: var(--space-xxlarge); }

  /* the axis attributes come after style-pad, so they always refine it */
  [style-pad-block="none"] { --_pad-block: var(--space-none); }
  [style-pad-block="xsmall"] { --_pad-block: var(--space-xsmall); }
  [style-pad-block="small"] { --_pad-block: var(--space-small); }
  [style-pad-block="medium"] { --_pad-block: var(--space-medium); }
  [style-pad-block="large"] { --_pad-block: var(--space-large); }
  [style-pad-block="xlarge"] { --_pad-block: var(--space-xlarge); }
  [style-pad-block="xxlarge"] { --_pad-block: var(--space-xxlarge); }

  [style-pad-inline="none"] { --_pad-inline: var(--space-none); }
  [style-pad-inline="xsmall"] { --_pad-inline: var(--space-xsmall); }
  [style-pad-inline="small"] { --_pad-inline: var(--space-small); }
  [style-pad-inline="medium"] { --_pad-inline: var(--space-medium); }
  [style-pad-inline="large"] { --_pad-inline: var(--space-large); }
  [style-pad-inline="xlarge"] { --_pad-inline: var(--space-xlarge); }
  [style-pad-inline="xxlarge"] { --_pad-inline: var(--space-xxlarge); }

  /* ---------- size ---------- */
  [style-width="full"] { inline-size: 100%; }
  [style-width="fit"] { inline-size: fit-content; }
  [style-width="small"] { inline-size: var(--measure-small); }
  [style-width="medium"] { inline-size: var(--measure-medium); }
  [style-width="large"] { inline-size: var(--measure-large); }
  [style-width="xlarge"] { inline-size: var(--measure-xlarge); }
  [style-width="xxlarge"] { inline-size: var(--measure-xxlarge); }

  [style-max-width="small"] { max-inline-size: var(--measure-small); }
  [style-max-width="medium"] { max-inline-size: var(--measure-medium); }
  [style-max-width="large"] { max-inline-size: var(--measure-large); }
  [style-max-width="xlarge"] { max-inline-size: var(--measure-xlarge); }
  [style-max-width="xxlarge"] { max-inline-size: var(--measure-xxlarge); }
  [style-max-width="prose"] { max-inline-size: 65ch; }

  [style-max-height="small"] { max-block-size: var(--measure-small); }
  [style-max-height="medium"] { max-block-size: var(--measure-medium); }
  [style-max-height="large"] { max-block-size: var(--measure-large); }
  [style-max-height="screen"] { max-block-size: 100dvh; }

  [style-size="xsmall"] { inline-size: var(--size-xsmall); block-size: var(--size-xsmall); flex: none; }
  [style-size="small"] { inline-size: var(--size-small); block-size: var(--size-small); flex: none; }
  [style-size="medium"] { inline-size: var(--size-medium); block-size: var(--size-medium); flex: none; }
  [style-size="large"] { inline-size: var(--size-large); block-size: var(--size-large); flex: none; }

  [style-flex="grow"] { flex: 1 1 0; min-inline-size: 0; }
  [style-flex="none"] { flex: none; }

  [style-height="full"] { block-size: 100%; }
  [style-height="screen"] { min-block-size: 100dvh; }

  [style-margin="none"] { margin: 0; }
  [style-margin="auto"] { margin: auto; }
  [style-margin="inline-auto"] { margin-inline: auto; }

  [style-ratio="square"] { aspect-ratio: 1; }
  [style-ratio="video"] { aspect-ratio: 16 / 9; }

  /* ---------- shape ---------- */
  [style-radius="none"] { border-radius: 0; }
  [style-radius="small"] { border-radius: var(--radius-small); }
  [style-radius="medium"] { border-radius: var(--radius-medium); }
  [style-radius="large"] { border-radius: var(--radius-large); }
  [style-radius="round"] { border-radius: 9999px; }

  /* border colour follows the nearest style-tone (neutral by default) */
  [style-border] { border-style: solid; border-color: color-mix(in oklch, var(--tone) var(--tone-border-alpha), transparent); }
  [style-border="none"] { border-style: none; }
  [style-border="thin"] { border-width: 1px; }
  [style-border="thick"] { border-width: 2px; }
  [style-border="dashed"] { border-width: 1px; border-style: dashed; }

  /* ---------- surface ---------- */
  [style-surface="base"] { background-color: var(--bg); }
  [style-surface="muted"] { background-color: var(--muted); }
  [style-surface="raised"] { background-color: var(--raised); box-shadow: var(--shadow-small); }
  [style-surface="overlay"] { background-color: var(--raised); box-shadow: var(--shadow-large); }
  /* modal backdrop: a dark veil in both schemes */
  [style-surface="scrim"] { background-color: oklch(0% 0 0 / 0.4); backdrop-filter: blur(2px); }

  /* ---------- tone ---------- */
  /* Tone sets --tone/--tone-on (inherited) and the element's text colour. */
  [style-tone="neutral"] { --tone-border-alpha: 14%; --tone: var(--fg); --tone-on: var(--bg); }
  [style-tone="muted"] { --tone-border-alpha: 14%; --tone: color-mix(in oklch, var(--fg) 55%, transparent); --tone-on: var(--bg); }
  [style-tone="accent"] { --tone-border-alpha: 45%; --tone: var(--accent); --tone-on: oklch(99% 0 0); }
  [style-tone="success"] { --tone-border-alpha: 45%; --tone: var(--success); --tone-on: oklch(99% 0 0); }
  [style-tone="warning"] { --tone-border-alpha: 45%; --tone: var(--warning); --tone-on: oklch(22% 0.03 80); }
  [style-tone="danger"] { --tone-border-alpha: 45%; --tone: var(--danger); --tone-on: oklch(99% 0 0); }

  [style-tone] { color: color-mix(in oklch, var(--tone) 85%, var(--fg)); }

  /* ---------- emphasis ---------- */
  /* Colours are computed here, on the element, so they follow the nearest style-tone. */
  [style-emphasis="solid"] {
    background-color: var(--tone);
    color: var(--tone-on);
    border-color: var(--tone);
  }
  [style-emphasis="soft"] {
    background-color: color-mix(in oklch, var(--tone) 10%, transparent);
    color: color-mix(in oklch, var(--tone) 85%, var(--fg));
    border-color: transparent;
  }
  [style-emphasis="outline"] {
    background-color: transparent;
    color: color-mix(in oklch, var(--tone) 85%, var(--fg));
    border-color: color-mix(in oklch, var(--tone) 30%, transparent);
  }
  [style-emphasis="ghost"] {
    background-color: transparent;
    color: color-mix(in oklch, var(--tone) 85%, var(--fg));
    border-color: transparent;
  }
  a[style-emphasis]:not([style-emphasis="link"]) { text-decoration: none; }
  [style-emphasis="link"] {
    background-color: transparent;
    color: color-mix(in oklch, var(--tone) 85%, var(--fg));
    border-color: transparent;
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

  [style-emphasis="field"] {
    background-color: var(--raised);
    color: var(--fg);
    border-color: color-mix(in oklch, var(--tone) max(var(--tone-border-alpha), 22%), transparent);
    transition: border-color var(--duration-fast) ease, outline-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
  }
  [style-emphasis="field"]::placeholder { color: color-mix(in oklch, var(--fg) 45%, transparent); }
  [style-emphasis="field"]:hover:not(:disabled, [aria-disabled="true"]) {
    border-color: color-mix(in oklch, var(--tone) 40%, transparent);
    box-shadow: 0 0 0 4px color-mix(in oklch, var(--tone) 8%, transparent);
  }
  /* a field container draws the ring, so controls inside it (a ghost input in a group) don't add a second one */
  [style-emphasis="field"] :focus-visible { outline: none; }
  [style-emphasis="field"]:is(:focus-visible, :focus-within) {
    outline: 2px solid color-mix(in oklch, var(--tone) 60%, transparent);
    outline-offset: 1px;
  }

  /* after emphasis, so a divider keeps its colour on a ghost row */
  [style-divider] { --_divider: 1px solid color-mix(in oklch, var(--tone) var(--tone-border-alpha), transparent); }
  [style-divider="top"] { border-block-start: var(--_divider); }
  [style-divider="bottom"] { border-block-end: var(--_divider); }
  [style-divider="start"] { border-inline-start: var(--_divider); }
  [style-divider="end"] { border-inline-end: var(--_divider); }

  /* interactive states: any emphasised control gets hover, press, focus and disabled */
  :is(button, a[href], summary, label, [role="button"], [role="menuitem"], [role="menuitemcheckbox"],
      [role="menuitemradio"], [role="option"], [role="tab"], [role="treeitem"], tr)[style-emphasis]:not([style-emphasis="field"]) {
    cursor: pointer;
    user-select: none;
    background-image: linear-gradient(color-mix(in oklch, currentColor var(--_tint), transparent) 0 0);
    transition:
      background-color var(--duration-fast) ease,
      color var(--duration-fast) ease,
      border-color var(--duration-fast) ease,
      --_tint var(--duration-fast) ease,
      box-shadow var(--duration-fast) ease,
      scale var(--duration-fast) cubic-bezier(0.2, 0, 0.2, 1);
  }
  :is(button, a[href], summary, label, [role="button"], [role="menuitem"], [role="menuitemcheckbox"],
      [role="menuitemradio"], [role="option"], [role="tab"], [role="treeitem"], tr)[style-emphasis]:not([style-emphasis="field"]):is(:hover, [data-highlighted]):not(:disabled, [aria-disabled="true"]) {
    --_tint: 10%;
  }
  :is(button, a[href], summary, label, [role="button"], [role="menuitem"], [role="menuitemcheckbox"],
      [role="menuitemradio"], [role="option"], [role="tab"], [role="treeitem"], tr)[style-emphasis]:not([style-emphasis="field"]):active:not(:disabled, [aria-disabled="true"]) {
    --_tint: 18%;
  }
  /*
   * Hover halo: the same 4px low-opacity ring in the element's tone marks everything
   * clickable or editable: buttons, fields (inputs, dropdowns), knobs and checkbox/radio indicators.
   */
  :is(button:not([role]), [role="button"])[style-emphasis]:not([style-emphasis="field"], [style-emphasis="link"]):hover:not(:disabled, [aria-disabled="true"]) {
    box-shadow: 0 0 0 4px color-mix(in oklch, var(--tone) 8%, transparent);
  }
  /* only plain buttons get the press scale (not switch tracks, tabs or menu items) */
  :is(button:not([role]), [role="button"])[style-emphasis]:not([style-emphasis="field"]):active:not(:disabled, [aria-disabled="true"]) {
    scale: 0.97;
  }

  /* the thumb of a switch or slider: a halo while its control is hovered, a squeeze while pressed */
  [style-emphasis="knob"] {
    background-color: var(--raised);
    border-color: color-mix(in oklch, var(--tone) 25%, transparent);
    box-shadow: var(--shadow-small);
    transition: translate var(--duration-fast) cubic-bezier(0.2, 0, 0.2, 1), scale var(--duration-fast) cubic-bezier(0.2, 0, 0.2, 1), box-shadow var(--duration-fast) ease;
  }
  :is(button, [style-interactive="clickable"], [style-interactive="drag"]):hover:not(:disabled) [style-emphasis="knob"] {
    box-shadow: 0 0 0 4px color-mix(in oklch, var(--tone) 8%, transparent), var(--shadow-small);
  }
  :is(button, [style-interactive="clickable"], [style-interactive="drag"]):active:not(:disabled) [style-emphasis="knob"] {
    scale: 0.85;
  }
  /* checkbox and radio indicators: stronger border and a halo while the control is hovered.
     No :has() here: it is checked against every element on every DOM change and stalls large pages. */
  [role="checkbox"] > [aria-hidden="true"][style-border],
  [style-visibility="invisible"] + [aria-hidden="true"][style-border] {
    transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
  }
  [role="checkbox"]:not([aria-disabled="true"]):hover > [aria-hidden="true"][style-border],
  [style-visibility="invisible"]:not(:disabled):hover + [aria-hidden="true"][style-border] {
    box-shadow: 0 0 0 4px color-mix(in oklch, var(--tone) 8%, transparent);
  }
  [role="checkbox"]:not([aria-disabled="true"]):hover > [aria-hidden="true"][style-border]:not([style-emphasis="solid"]),
  [style-visibility="invisible"]:not(:disabled):hover + [aria-hidden="true"][style-border]:not([style-emphasis="solid"]) {
    border-color: color-mix(in oklch, var(--tone) 45%, transparent);
  }

  [style-emphasis]:focus-visible {
    outline: 2px solid color-mix(in oklch, var(--tone) 60%, transparent);
    outline-offset: 2px;
  }
  [style-emphasis]:is(:disabled, [aria-disabled="true"]) {
    opacity: 0.5;
    cursor: not-allowed;
  }

  [style-interactive="clickable"] { cursor: pointer; user-select: none; }
  [style-interactive="static"] { cursor: default; user-select: none; }
  [style-interactive="inert"] { pointer-events: none; user-select: none; }
  [style-interactive="disabled"] { opacity: 0.5; cursor: not-allowed; }
  [style-interactive="precise"] { cursor: crosshair; user-select: none; }
  [style-interactive="drag"] { touch-action: none; user-select: none; }

  [style-visibility="hidden"] { visibility: hidden; }
  /* invisible but still receives pointer events, e.g. a native input layered over a custom control */
  [style-visibility="invisible"] { opacity: 0; }
  /* removed visually, kept for screen readers and form validation */
  [style-visibility="screen-reader"] {
    position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }

  /* ---------- typography ---------- */
  [style-text="xsmall"] { font-size: 0.75rem; }
  [style-text="small"] { font-size: 0.875rem; }
  [style-text="medium"] { font-size: 1rem; }
  [style-text="large"] { font-size: 1.25rem; }
  [style-text="xlarge"] { font-size: 1.5rem; }
  [style-text="xxlarge"] { font-size: 2rem; }

  [style-weight="regular"] { font-weight: 400; }
  [style-weight="medium"] { font-weight: 500; }
  [style-weight="semibold"] { font-weight: 600; }
  [style-weight="bold"] { font-weight: 700; }

  [style-font="sans"] { font-family: var(--font-sans); }
  [style-font="serif"] { font-family: var(--font-serif); }
  [style-font="mono"] { font-family: var(--font-mono); }

  [style-leading="tight"] { --leading: 0.25rem; }
  [style-leading="normal"] { --leading: 0.5rem; }
  [style-leading="loose"] { --leading: 0.875rem; }

  [style-tracking="tight"] { letter-spacing: -0.025em; }
  [style-tracking="normal"] { letter-spacing: 0; }
  [style-tracking="wide"] { letter-spacing: 0.05em; }

  [style-case="upper"] { text-transform: uppercase; }
  [style-case="lower"] { text-transform: lowercase; }
  [style-case="title"] { text-transform: capitalize; }

  [style-text-align="start"] { text-align: start; }
  [style-text-align="center"] { text-align: center; }
  [style-text-align="end"] { text-align: end; }

  [style-wrap="nowrap"] { white-space: nowrap; }
  [style-wrap="truncate"] { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  [style-wrap="balance"] { text-wrap: balance; }
  [style-wrap="pretty"] { text-wrap: pretty; }
  [style-wrap="pre"] { white-space: pre; }
  /* preserved whitespace that still breaks long tokens (code, logs, terminals) */
  [style-wrap="pre-wrap"] { white-space: pre-wrap; overflow-wrap: anywhere; }
  [style-wrap="anywhere"] { overflow-wrap: anywhere; }

  [style-decoration="none"] { text-decoration: none; }
  [style-decoration="underline"] { text-decoration: underline; text-underline-offset: 0.2em; }
  [style-decoration="strike"] { text-decoration: line-through; }
  [style-decoration="hover"] { text-underline-offset: 0.2em; }
  [style-decoration="hover"]:hover:not(:disabled) { text-decoration: underline; }

  [style-fit="cover"] { object-fit: cover; }
  [style-fit="contain"] { object-fit: contain; }

  /* ---------- motion ---------- */
  [style-motion="colors"] {
    transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease, border-color var(--duration-fast) ease;
  }
  [style-motion="all"] { transition: all var(--duration-normal) ease; }
  [style-motion="fade-in"] { animation: giant-fade-in var(--duration-normal) ease both; }
  [style-motion="spin"] { animation: giant-spin 0.8s linear infinite; }
  [style-motion="slide-in"] { animation: giant-slide-in var(--duration-normal) cubic-bezier(0.2, 0, 0.2, 1) both; }
  [style-motion="fade-out"] { animation: giant-fade-out var(--duration-normal) ease both; }
  [style-motion="slide-out"] { animation: giant-slide-out var(--duration-normal) cubic-bezier(0.4, 0, 1, 1) both; }
  /* anything sliding in inside a container that is leaving slides back out with it */
  [style-motion="fade-out"] [style-motion="slide-in"] { animation: giant-slide-out var(--duration-normal) cubic-bezier(0.4, 0, 1, 1) both; }

  @keyframes giant-fade-in { from { opacity: 0; } }
  @keyframes giant-spin { to { rotate: 1turn; } }
  @keyframes giant-slide-in { from { opacity: 0; translate: 0 0.5rem; scale: 0.97; } }
  @keyframes giant-fade-out { to { opacity: 0; } }
  @keyframes giant-slide-out { to { opacity: 0; translate: 0 0.5rem; scale: 0.97; } }

  @media (prefers-reduced-motion: reduce) {
    [style-emphasis] { transition: none; scale: none !important; }
    [style-emphasis="knob"] { transition: none; }
  }
}
