/*! Supply UI v1.1.0 — https://www.supply.family/ui/ — MIT licence. Do not edit: compose it, or add files next to it. */
/*
 * Supply UI — the order of the cascade layers, and UI SDK's own layer.
 *
 * UI SDK (the behaviour under the components) adds a little CSS of its own in the ui-sdk layer. The whole kit comes
 * after it, in one layer (supply-ui): tokens, base, components and themes keep their order and specificity inside it,
 * exactly as in one file. A project's own CSS, written outside any layer, beats all of it without !important;
 * Tailwind's layers, declared after this one, beat it too.
 */
@layer ui-sdk, supply-ui;

/* Closed popups that stay in the page are hidden from the first paint, before UI SDK has loaded. */
@layer ui-sdk {
  :where([data-slot][hidden]:not([hidden="until-found"])) {
    display: none !important;
  }
}

@property --gap {
  syntax: "*";
  inherits: false;
}
@property --toast-left {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 100%;
}
@property --fade-start {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
@property --fade-end {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
@view-transition {
  navigation: auto;
}

@layer supply-ui {
/*
 * Supply UI — tokens.
 *
 * The whole look comes from the few "knobs" below. Change a knob (in CSS, or
 * with a slider that sets it on <html>) and every colour, size and corner in
 * the system follows. Never write a colour, size or radius by hand in a
 * component: use a token.
 *
 * Light and dark: light by default. <html data-theme="dark"> is dark, and
 * <html data-theme="auto"> follows the visitor's device.
 *
 * Theme: Simple by default. <html data-ui-style="…"> picks another one (src/css/themes/); it changes only the
 * Material tokens near the end of this file, so every owner choice still applies inside every theme.
 */


:root {
  --ui-dir: 1;
  /* ── Knobs ─────────────────────────────────────────────────────────── */
  /* The brand colour, as its three numbers in OKLCH. From React, <ThemeStyle> sets them from any picked colour. */
  --ui-brand-l: 0.881;    /* how light the brand colour is, 0 (black) – 1 (white) */
  --ui-chroma: 0.2;       /* how strong it is, 0 (a grey, black or white) – 0.3 (vivid) */
  --ui-hue: 122;          /* its hue, 0–360 */
  /* The greys: pure (tint 0), or carrying a little of a hue: warm (70), cool (250) or the brand's own. */
  --ui-grey-hue: 122;
  --ui-tint: 0;           /* how much of that hue lines, quiet fills and text carry, 0 – 0.02. A white page stays white */
  --ui-shade: 0.7;        /* the page behind the cards: 0 (white), 0.7 (soft grey), 1.5 (grey) */
  --ui-page-max: 1120px;  /* how wide the page's content runs: 960px (narrow), 1120px (regular), 1320px (wide), none (full) */
  --ui-radius: 12px;      /* corner radius, 0 (square) – 28px (very round); controls become pills from 20px */
  --ui-density: 1;        /* size of controls, gaps and text, 1 (regular) – 1.3 (large) */
  --ui-motion: 1;         /* animation speed, 0 (none) – 1.5 (slow) */
  --ui-icon-stroke: 1.75; /* line weight of icons beside regular text, 1 (thin) – 2.5 (bold); 1.75 matches Inter's stems */
  /* Icons are as heavy as the text beside them: every rule that sets a font weight sets --ui-icon-weight with it, and
     the icon's line is --ui-icon-stroke times that (Inter's stems: regular 0.091em, medium 0.110em, semibold 0.130em). */
  --ui-icon-medium: 1.2;
  --ui-icon-bold: 1.4;

  color-scheme: light;

  /* ── Fonts ─────────────────────────────────────────────────────────── */
  /* Two font pairs. The theme picks one (`font`: "inter" or "dm"); everything reads --ui-font-sans and --ui-font-mono. */
  --ui-font-inter: var(--font-inter, "Inter Variable"), "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ui-font-reddit-mono: var(--font-reddit-mono, "Reddit Mono Variable"), "Reddit Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ui-font-dm-sans: var(--font-dm-sans, "DM Sans Variable"), "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ui-font-courier-prime: var(--font-courier-prime, "Courier Prime"), "Courier New", ui-monospace, monospace;
  --ui-font-sans: var(--ui-font-inter);
  --ui-font-mono: var(--ui-font-reddit-mono);

  /* ── Type scale (text grows and shrinks half as fast as the controls) ─ */
  --ui-text-scale: calc(0.5 + var(--ui-density) * 0.5);
  --ui-u: calc(1rem * var(--ui-text-scale));              /* one unit for small controls: checkboxes, switches, badges */
  --ui-text-xs: calc(0.75rem * var(--ui-text-scale));     /* 12 */
  --ui-text-sm: calc(0.8125rem * var(--ui-text-scale));   /* 13 */
  --ui-text-base: calc(0.875rem * var(--ui-text-scale));  /* 14: interface text */
  --ui-text-md: calc(1rem * var(--ui-text-scale));        /* 16: reading text */
  --ui-text-lg: calc(1.125rem * var(--ui-text-scale));    /* 18 */
  --ui-text-xl: calc(1.375rem * var(--ui-text-scale));    /* 22 */
  --ui-text-2xl: calc(1.75rem * var(--ui-text-scale));    /* 28 */
  --ui-text-3xl: calc(2.25rem * var(--ui-text-scale));    /* 36 */
  --ui-leading-tight: 1.2;
  --ui-leading: 1.5;
  --ui-weight: 400;
  --ui-weight-medium: 500;
  --ui-weight-bold: 600;
  --ui-weight-heading: 500;  /* titles are large and light, not bold */

  /* ── Space (4px grid, scaled by density) ───────────────────────────── */
  --ui-space-1: calc(4px * var(--ui-density));
  --ui-space-2: calc(8px * var(--ui-density));
  --ui-space-3: calc(12px * var(--ui-density));
  --ui-space-4: calc(16px * var(--ui-density));
  --ui-space-5: calc(20px * var(--ui-density));
  --ui-space-6: calc(24px * var(--ui-density));
  --ui-space-8: calc(32px * var(--ui-density));
  --ui-space-10: calc(40px * var(--ui-density));
  --ui-space-12: calc(48px * var(--ui-density));
  --ui-space-16: calc(64px * var(--ui-density));

  /*
   * Space between blocks (cards in a grid, columns, sections of a page). It shrinks on small
   * screens, and it goes the opposite way to Size: bigger controls take the room, so the gaps
   * between blocks close up; smaller controls leave more air between them.
   */
  --ui-gutter: clamp(calc(0.75rem / var(--ui-density)), 1.7vw, calc(1.25rem / var(--ui-density)));
  --ui-gap-lg: calc(1.5rem / var(--ui-density));   /* between groups in a column */
  --ui-gap-xl: calc(2rem / var(--ui-density));     /* between sections, and the page's own margin */
  /* Between the sections of a public page (a landing page: rooms, reviews, questions). Grows with the window, so a phone
     keeps about 3.5rem and a wide screen about 7rem: each section reads as its own part of the page. */
  --ui-gap-section: clamp(calc(3.5rem / var(--ui-density)), 8vw, calc(7rem / var(--ui-density)));

  /* ── Control heights ───────────────────────────────────────────────── */
  --ui-h-sm: calc(30px * var(--ui-density));
  --ui-h-md: calc(40px * var(--ui-density));
  --ui-h-lg: calc(50px * var(--ui-density));

  /* ── Room inside a container ───────────────────────────────────────── */
  /* Grows with the corner, so text at the top or bottom of a very round card never sits in the curve. */
  --ui-pad: max(var(--ui-space-6), calc(var(--ui-radius-lg) * 0.85));     /* cards */
  --ui-pad-sm: max(var(--ui-space-4), calc(var(--ui-radius-box) * 0.9));  /* toasts, alerts, code */
  --ui-pad-lg: max(var(--ui-space-8), calc(var(--ui-radius-xl) * 0.85));  /* dialogs, large panels */

  /* ── Corners ───────────────────────────────────────────────────────── */
  --ui-radius-sm: calc(var(--ui-radius) * 0.5);   /* menu items, cells, checkboxes */
  --ui-radius-md: var(--ui-radius);               /* buttons, inputs */
  --ui-radius-lg: calc(var(--ui-radius) * 1.4);   /* cards, popups */
  --ui-radius-xl: calc(var(--ui-radius) * 1.8);   /* dialogs, large panels */
  --ui-radius-round: calc(var(--ui-radius) * 2.5); /* avatars, switches, count bubbles, round icon tiles: circles at the default, squarer as Corners goes down */
  --ui-radius-box: min(var(--ui-radius-lg), 1.25rem); /* small boxes that hold a line or two: toasts, alerts, popups, code. Capped, so a short box never turns into a pill */
  --ui-radius-nested: var(--ui-radius-md);        /* a card, list or table that sits inside another card, dialog or panel: one step down from its parent, so the two curves stay in proportion */
  --ui-radius-full: 999px;                         /* only for what is round by nature: radio dots, spinners, status dots, the slider */

  /* ── Motion ────────────────────────────────────────────────────────── */
  --ui-ease: cubic-bezier(0.4, 0, 0.2, 1);        /* fades: an even, visible change */
  --ui-ease-out: cubic-bezier(0.22, 1, 0.36, 1);  /* movement: quick start, long soft landing */
  --ui-dur-fast: calc(240ms * var(--ui-motion));  /* hovers, focus, small state changes */
  --ui-dur: calc(320ms * var(--ui-motion));       /* things that open, close or slide */
  --ui-dur-slow: calc(460ms * var(--ui-motion));  /* large panels, charts */

  /* ── Greys ─────────────────────────────────────────────────────────── */
  /* The page is a soft grey, or exactly white (#ffffff) with --ui-shade at 0; cards sit on it in white; insets step back down. */
  /* How light the page is (light mode). Lines and quiet fills are measured against it, so they stay visible on it. */
  --ui-bg-l: calc(1 - min(var(--ui-shade), 0.7) * 0.026 - max(var(--ui-shade) - 0.7, 0) * 0.0616);  /* soft grey 0.982, grey 0.9325 */
  --ui-bg: light-dark(
    oklch(var(--ui-bg-l) calc(var(--ui-tint) * min(var(--ui-shade) / 0.7, 1)) var(--ui-grey-hue)),
    /* Dark: soft grey (0.7) is 0.145 and grey (1.5) 0.1175, as before soft grey was made lighter in light mode. */
    oklch(calc(0.2 - min(var(--ui-shade), 0.7) * 0.0786 - max(var(--ui-shade) - 0.7, 0) * 0.0344) var(--ui-tint) var(--ui-grey-hue))
  );  /* carries the tint like every other grey; its lightness is set by --ui-shade alone, and white stays exactly white */
  --ui-surface: light-dark(oklch(1 0 0), oklch(0.2 var(--ui-tint) var(--ui-grey-hue)));  /* cards are pure white (#ffffff) in light */
  --ui-surface-2: light-dark(oklch(0.968 var(--ui-tint) var(--ui-grey-hue)), oklch(0.245 var(--ui-tint) var(--ui-grey-hue)));
  /* Pressed, selected, soft buttons: always a step darker than the page, however grey the page is. */
  --ui-surface-3: light-dark(oklch(min(0.93, calc(var(--ui-bg-l) - 0.03 - var(--ui-shade) * 0.012)) var(--ui-tint) var(--ui-grey-hue)), oklch(0.3 var(--ui-tint) var(--ui-grey-hue)));
  /*
   * Lines and dividers are a faint, see-through tint of the text colour, so they adapt to whatever they lie on: the
   * edge of a white card is a hair darker than white, the edge of a peach box a little deeper peach, a divider on a
   * grey inset a little deeper grey. Never a fixed grey that is too dark on light colours or wrong on tinted ones.
   * (A border is painted over its own box's background, so it always takes that colour.) Dark mode: a little more of
   * the light text, so cards and page stay apart.
   */
  --ui-border: light-dark(
    color-mix(in oklab, var(--ui-fg) 7%, transparent),
    color-mix(in oklab, var(--ui-fg) 11%, transparent)
  );
  /* The same line, solid: as --ui-border looks on a card. For a line that must be drawn over a box's own fill (a field). */
  --ui-border-solid: light-dark(
    color-mix(in oklab, var(--ui-fg) 7%, var(--ui-surface)),
    color-mix(in oklab, var(--ui-fg) 11%, var(--ui-surface))
  );
  /* The line on hover: one see-through step up from --ui-border, enough to say "this can be used", never a dark frame. */
  --ui-border-hover: light-dark(
    color-mix(in oklab, var(--ui-fg) 16%, transparent),
    color-mix(in oklab, var(--ui-fg) 22%, transparent)
  );
  /*
   * The edge of a control that is only an edge (a checkbox, a radio, a switch that is off, an empty star, a carousel
   * dot): 3:1 on the card and on the page, so the control can be seen without colour or a label (WCAG 1.4.11).
   */
  --ui-control-edge: light-dark(
    oklch(calc(var(--ui-bg-l) - 0.37) var(--ui-tint) var(--ui-grey-hue)),
    oklch(calc(0.585 + var(--ui-shade) * 0.02) var(--ui-tint) var(--ui-grey-hue))
  );
  --ui-border-strong: light-dark(
    oklch(calc(var(--ui-bg-l) - 0.13 - var(--ui-shade) * 0.035) var(--ui-tint) var(--ui-grey-hue)),
    oklch(calc(0.4 + var(--ui-shade) * 0.03) var(--ui-tint) var(--ui-grey-hue))
  );
  --ui-fg: light-dark(oklch(0.2 var(--ui-tint) var(--ui-grey-hue)), oklch(0.96 var(--ui-tint) var(--ui-grey-hue)));
  --ui-fg-muted: light-dark(oklch(0.47 var(--ui-tint) var(--ui-grey-hue)), oklch(0.74 var(--ui-tint) var(--ui-grey-hue)));
  /* The quietest text (a date in the corner, a day of another month): still 4.5:1 on every surface, as text must be. */
  --ui-fg-subtle: light-dark(oklch(calc(var(--ui-bg-l) - 0.465) var(--ui-tint) var(--ui-grey-hue)), oklch(0.64 var(--ui-tint) var(--ui-grey-hue)));

  /* ── Brand ─────────────────────────────────────────────────────────── */
  /*
   * The brand colour is used as it was picked. Two things are worked out around it: in dark mode it is a step
   * lighter, and a brand without colour (a black, a white, a grey: --ui-chroma near 0) turns over in dark mode,
   * so a black button becomes a white one.
   */
  --ui-mono: clamp(0, (0.02 - var(--ui-chroma)) * 9999, 1);
  /*
   * Between 0.55 and 0.6 of lightness neither white nor black text reaches 4.5:1 on a vivid colour, so a fill there
   * moves to the nearer edge of that band (a step of at most 0.025, too small to see as another colour).
   */
  --ui-lightness: calc(
    var(--ui-brand-l)
    + clamp(0, (var(--ui-brand-l) - 0.55) * 99999, 1) * clamp(0, (0.575 - var(--ui-brand-l)) * 99999, 1) * (0.55 - var(--ui-brand-l))
    + clamp(0, (var(--ui-brand-l) - 0.57499) * 99999, 1) * clamp(0, (0.6 - var(--ui-brand-l)) * 99999, 1) * (0.6 - var(--ui-brand-l))
  );
  --ui-lightness-dark-picked: calc(
    var(--ui-mono) * clamp(0.2, 1.16 - var(--ui-brand-l), 0.96) + (1 - var(--ui-mono)) * min(var(--ui-brand-l) + 0.07, 0.94)
  );
  --ui-lightness-dark: calc(
    var(--ui-lightness-dark-picked)
    + clamp(0, (var(--ui-lightness-dark-picked) - 0.55) * 99999, 1) * clamp(0, (0.575 - var(--ui-lightness-dark-picked)) * 99999, 1) * (0.55 - var(--ui-lightness-dark-picked))
    + clamp(0, (var(--ui-lightness-dark-picked) - 0.57499) * 99999, 1) * clamp(0, (0.6 - var(--ui-lightness-dark-picked)) * 99999, 1) * (0.6 - var(--ui-lightness-dark-picked))
  );
  --ui-primary-chroma: calc(var(--ui-chroma) * (1 - var(--ui-mono)));

  /* The brand colour as a fill: the main action, progress, charts. */
  --ui-primary: light-dark(
    oklch(var(--ui-lightness) var(--ui-primary-chroma) var(--ui-hue)),
    oklch(var(--ui-lightness-dark) var(--ui-primary-chroma) var(--ui-hue))
  );
  /* Text on the filled colour: white on deep colours, black on light ones. */
  --ui-on-primary: light-dark(
    oklch(clamp(0, (0.575 - var(--ui-lightness)) * 99999, 1) 0 0),
    oklch(clamp(0, (0.575 - var(--ui-lightness-dark)) * 99999, 1) 0 0)
  );
  /* The opposite of on-primary: mixed in for hover, so hover always gains contrast. */
  --ui-primary-shade: light-dark(
    oklch(clamp(0, (var(--ui-lightness) - 0.575) * 99999, 1) 0 0),
    oklch(clamp(0, (var(--ui-lightness-dark) - 0.575) * 99999, 1) 0 0)
  );
  --ui-primary-hover: color-mix(in oklab, var(--ui-primary) 88%, var(--ui-primary-shade));
  /*
   * Brand colour as text (a selected tab, a chart line, a badge): never a washed-out version. A light brand (lime,
   * yellow: lighter than 0.8) cannot be darkened into a readable colour without turning olive or mustard, so its text
   * is the ink; a black, white or grey brand is the ink too. A brand with real colour keeps it, deep and vivid.
   * Links are not brand coloured: they are the text colour with an underline (.ui-link, link buttons).
   */
  --ui-brand-text-ink: max(var(--ui-mono), clamp(0, (var(--ui-brand-l) - 0.8) * 999, 1));
  --ui-primary-text: color-mix(
    in oklab,
    var(--ui-fg) calc(var(--ui-brand-text-ink) * 100%),
    light-dark(oklch(0.5 min(calc(var(--ui-chroma) * 1.1), 0.22) var(--ui-hue)), oklch(0.8 min(var(--ui-chroma), 0.16) var(--ui-hue)))
  );
  /* Soft brand background (badges, icon tiles, mentions). */
  --ui-primary-soft: color-mix(
    in oklab,
    var(--ui-surface-3) calc(var(--ui-mono) * 100%),
    light-dark(oklch(0.95 calc(var(--ui-chroma) * 0.22) var(--ui-hue)), oklch(0.27 calc(var(--ui-chroma) * 0.35) var(--ui-hue)))
  );
  --ui-ring: color-mix(in oklab, var(--ui-primary-text) 55%, transparent);
  /*
   * The line around a field in use (and a chosen card): a light see-through step, with a soft halo around it
   * (--ui-focus-halo) instead of a second hard ring. Clear enough to say where the typing goes, never a dark frame.
   */
  --ui-highlight: light-dark(color-mix(in oklab, var(--ui-fg) 30%, transparent), color-mix(in oklab, var(--ui-fg) 38%, transparent));
  --ui-focus-halo: light-dark(color-mix(in oklab, var(--ui-fg) 6%, transparent), color-mix(in oklab, var(--ui-fg) 10%, transparent));

  /*
   * ── Ink: everything chosen or switched on ───────────────────────────
   * A ticked box, a switch that is on, the chosen tab, the selected day: the text colour as a fill, so it reads on
   * any brand colour. Among many rows (a list, a table, the days inside a range) a chosen row takes the quiet fill.
   */
  --ui-ink: var(--ui-fg);
  --ui-on-ink: light-dark(oklch(1 0 0), oklch(0.16 var(--ui-tint) var(--ui-grey-hue)));
  --ui-ink-soft: var(--ui-surface-3);

  /* ── Status (fixed hues: they must mean the same in every theme) ───── */
  /* Danger is a mild orange-red, not a siren red: clear without shouting. */
  --ui-danger: oklch(0.56 0.155 38);
  --ui-on-danger: oklch(1 0 0);
  --ui-danger-text: light-dark(oklch(0.49 0.13 38), oklch(0.8 0.095 42));
  --ui-danger-soft: light-dark(oklch(0.962 0.022 45), oklch(0.275 0.045 38));

  --ui-success: oklch(0.52 0.14 152);
  --ui-on-success: oklch(1 0 0);
  --ui-success-text: light-dark(oklch(0.44 0.12 152), oklch(0.82 0.13 152));
  --ui-success-soft: light-dark(oklch(0.955 0.04 152), oklch(0.26 0.05 152));

  --ui-warning: oklch(0.82 0.16 82);
  --ui-on-warning: oklch(0.2 0 0);
  --ui-warning-text: light-dark(oklch(0.47 0.11 70), oklch(0.85 0.13 85));
  --ui-warning-soft: light-dark(oklch(0.96 0.05 90), oklch(0.28 0.05 80));

  --ui-info: oklch(0.55 0.15 245);
  --ui-on-info: oklch(1 0 0);
  --ui-info-text: light-dark(oklch(0.46 0.14 245), oklch(0.82 0.1 245));
  --ui-info-soft: light-dark(oklch(0.955 0.03 245), oklch(0.27 0.05 245));

  /* ── Depth ─────────────────────────────────────────────────────────── */
  /*
   * Depth is soft: a barely visible contact line where the thing meets the page, and a wide, very faint ambient shadow
   * that lifts it. Never a dark halo. Dark mode needs more, to lift a popup off a dark page.
   */
  --ui-shadow-color: light-dark(oklch(0.2 0.02 var(--ui-grey-hue) / 0.07), oklch(0 0 0 / 0.42));
  --ui-shadow-contact: light-dark(oklch(0.2 0.02 var(--ui-grey-hue) / 0.04), oklch(0 0 0 / 0.3));
  --ui-shadow-sm: 0 1px 2px var(--ui-shadow-contact);
  --ui-shadow-md: 0 1px 2px var(--ui-shadow-contact), 0 6px 18px -8px var(--ui-shadow-color);
  --ui-shadow-lg: 0 1px 3px var(--ui-shadow-contact), 0 16px 36px -14px var(--ui-shadow-color);
  --ui-overlay: light-dark(oklch(0.2 0.01 var(--ui-grey-hue) / 0.4), oklch(0 0 0 / 0.6));

  /*
   * ── Material: what a theme changes ──────────────────────────────────
   * The owner's choices above decide the colours, corners and size. The theme (Simple, and later others such as 3D or
   * Neumorphism) decides what things are made of: their depth, edges and sheen. Components read only these
   * tokens for that, so a theme is one file in src/css/themes/ that sets them (see simple.css there).
   * Values here are Simple: flat layers, soft lines, depth only on what floats.
   * "Nothing" is written 0 0 #0000 for shadows (so a component can add its own ring after it) and none for fills.
   */
  /*
   * A theme may also set the surfaces (--ui-surface, -2, -3): the colour things are made of. Neumorphism makes them
   * the page's own colour. It never sets the page, the greys or the brand: those are the owner's.
   */
  /* The page itself. */
  --ui-page-fill: none;                      /* image layers over the page's colour: a grain */
  /* Cards and panels on the page. */
  --ui-card-border: var(--ui-border);        /* colour of a card's edge */
  --ui-card-shadow: 0 0 #0000;               /* a card's depth */
  --ui-card-raised-shadow: var(--ui-shadow-md); /* the depth of a card that stands out (.ui-card--raised) */
  /* A card inside a panel that scrolls or has its own edge (a sidebar, a dialog, another card): that panel cuts off
     whatever reaches past its padding, so a theme with deep shadows gives these a closer one. */
  --ui-card-inner-shadow: var(--ui-card-shadow);
  --ui-card-fill: none;                      /* image layers over a card's colour: a sheen or a grain */
  /* What floats over the page: menus, popovers, dialogs, drawers, toasts (their depth is --ui-shadow-md and -lg). */
  /* What floats already has depth from its shadow, so its line is only a hint: fainter than the line of a box on the page. */
  --ui-float-border: light-dark(color-mix(in oklab, var(--ui-fg) 4%, transparent), color-mix(in oklab, var(--ui-fg) 9%, transparent));
  /* A bar that stays over the page as it scrolls (SiteHeader) and Cover's panel: solid. The kit never uses see-through
     glass (no backdrop blur): the style check refuses it. */
  --ui-bar-bg: var(--ui-surface);
  /* Buttons. Quiet ones (ghost, link) stay flat in every theme. */
  --ui-control-bg: var(--ui-surface-3);      /* the colour of a plain (secondary) button; hover and press darken it */
  --ui-control-shadow: 0 0 #0000;            /* at rest */
  --ui-control-shadow-hover: var(--ui-control-shadow);
  --ui-control-shadow-active: var(--ui-control-shadow);
  --ui-control-fill: none;                   /* image layers over a button's colour (any colour: use light and dark with alpha) */
  --ui-control-press: 0px;                   /* how far a button moves down while pressed */
  /* Fields: inputs, text areas, code boxes. Their focus ring is added after the shadow. */
  --ui-field-bg: var(--ui-surface-2);
  --ui-field-border: var(--ui-border);
  --ui-field-shadow: 0 0 #0000;
  /* Wells: the ground under something, sunk into the page (tracks, the switch, segmented controls, empty boxes). */
  --ui-well-shadow: 0 0 #0000;
  --ui-well-bg: initial;                     /* left unset, each well keeps its own grey; a theme sets one colour for all */
  --ui-well-border: initial;                 /* the edge of a checkbox or radio; unset keeps --ui-border-strong */
  /* Knobs: what is held and moved (slider and switch thumbs). */
  --ui-knob-bg: oklch(1 0 0);
  --ui-knob-shadow: var(--ui-shadow-sm);
  --ui-knob-border: var(--ui-border-strong); /* the slider thumbs' edge (the switch knob has none) */
  --ui-knob-grow: 1.3; /* how much a slider's thumb grows while the slider is hovered or dragged */
  /* Chosen: everything filled with ink (a ticked box, a switch that is on, the chosen segment). */
  --ui-chosen-shadow: 0 0 #0000;
  --ui-chosen-fill: none;                    /* image layers over the ink */

  /* ── Layers ────────────────────────────────────────────────────────── */
  --ui-z-sticky: 100;
  --ui-z-overlay: 1000;
  --ui-z-popup: 1100;
  --ui-z-toast: 1200;
}

:root[data-theme="light"],
[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"],
[data-theme="dark"] {
  color-scheme: dark;
}

:root[data-theme="auto"],
[data-theme="auto"] {
  color-scheme: light dark;
}

/* The person's own choice (<ColorSchemeSwitch>) wins over the tool's look, on their device. */
:root[data-color-scheme="light"] {
  color-scheme: light;
}

:root[data-color-scheme="dark"] {
  color-scheme: dark;
}

/* On a phone containers give more of their width to the content. */
@media (max-width: 560px) {
  :root {
    --ui-pad: max(var(--ui-space-5), calc(var(--ui-radius-lg) * 0.7));
    --ui-pad-lg: max(var(--ui-space-6), calc(var(--ui-radius-lg) * 0.8));
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --ui-motion: 0;
  }
}

/* Right to left: what moves along the line (a switch's knob) moves the other way. */
[dir="rtl"] {
  --ui-dir: -1;
}

/*
 * More contrast, asked for by the person (prefers-contrast: more): lines are drawn stronger, quiet text comes closer
 * to the text colour, and fields and cells show their edge at rest, not only on hover.
 */
@media (prefers-contrast: more) {
  :root {
    --ui-border: color-mix(in oklab, var(--ui-fg) 30%, transparent);
    --ui-border-hover: color-mix(in oklab, var(--ui-fg) 45%, transparent);
    --ui-fg-muted: color-mix(in oklab, var(--ui-fg) 80%, var(--ui-surface));
    --ui-fg-subtle: color-mix(in oklab, var(--ui-fg) 70%, var(--ui-surface));
    --ui-control-edge: var(--ui-fg-muted);
    --ui-field-border: var(--ui-border-hover);
  }
}

/*
 * Supply UI — base: reset, text styles and layout helpers.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  /* A full-width band (Bleed, Cover) reaches the window's edges with 100vw, which counts the scrollbar: clip that. */
  overflow-x: clip;
  background: var(--ui-bg);
  background-image: var(--ui-page-fill);
  color: var(--ui-fg);
  font-family: var(--ui-font-sans);
  font-size: var(--ui-text-base);
  line-height: var(--ui-leading);
  font-weight: var(--ui-weight);
  --ui-icon-weight: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/*
 * The browser's own pieces inside a field never show as the browser draws them: no blue clear cross, no spinner
 * arrows. A search field's clear button is the kit's (below); a number field's minus and plus are NumberInput's.
 * check-style.mjs stops the build if these rules go missing.
 */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  display: none;
  appearance: none;
}

/*
 * The clear button of every search field, drawn by the kit: a small soft circle with a thin cross in the text's
 * colour and the theme's icon weight. It is still the browser's own button, so it shows only when there is text,
 * clears the field and answers Escape, with nothing to wire. (Firefox has no such button, so it shows none.)
 */
input[type="search"]::-webkit-search-cancel-button {
  --_x: calc(var(--ui-icon-stroke, 1.5) * 0.5px);
  align-self: center;
  width: 1.25rem;
  height: 1.25rem;
  margin: auto 0 auto var(--ui-space-2);
  border-radius: var(--ui-radius-round);
  background:
    linear-gradient(45deg, transparent calc(50% - var(--_x)), var(--ui-fg-muted) 0 calc(50% + var(--_x)), transparent 0) center / 0.5rem 0.5rem no-repeat,
    linear-gradient(-45deg, transparent calc(50% - var(--_x)), var(--ui-fg-muted) 0 calc(50% + var(--_x)), transparent 0) center / 0.5rem 0.5rem no-repeat,
    var(--ui-surface-3);
  cursor: pointer;
  appearance: none;
  transition: background-color var(--ui-dur-fast) var(--ui-ease);
}

input[type="search"]::-webkit-search-cancel-button:hover {
  background-color: var(--ui-border-hover);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

input[type="number"] {
  appearance: textfield;
}

input::-ms-clear {
  display: none;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ui-ring);
  outline-offset: 2px;
}

::selection {
  background: var(--ui-primary-soft);
  color: var(--ui-fg);
}

/* ── Text ──────────────────────────────────────────────────────────── */

.ui-display {
  font-size: var(--ui-text-3xl);
  line-height: var(--ui-leading-tight);
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
  letter-spacing: -0.045em;
}

.ui-title {
  font-size: var(--ui-text-2xl);
  line-height: var(--ui-leading-tight);
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
  letter-spacing: -0.035em;
}

.ui-heading {
  font-size: var(--ui-text-xl);
  line-height: var(--ui-leading-tight);
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
  letter-spacing: -0.03em;
}

.ui-subheading {
  font-size: var(--ui-text-md);
  line-height: 1.35;
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  letter-spacing: -0.005em;
}

.ui-text {
  font-size: var(--ui-text-base);
  line-height: var(--ui-leading);
}

.ui-lead {
  font-size: var(--ui-text-md);
  line-height: var(--ui-leading);
  color: var(--ui-fg-muted);
}

.ui-small {
  font-size: var(--ui-text-sm);
}

.ui-tiny {
  font-size: var(--ui-text-xs);
}

.ui-muted {
  color: var(--ui-fg-muted);
}

.ui-subtle {
  color: var(--ui-fg-subtle);
}

/* Small capital label above a group ("OVERVIEW"). */
.ui-overline {
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ui-fg-muted);
}

/* Numbers, IDs, dates, amounts, code: anything that should line up. */
.ui-mono {
  font-family: var(--ui-font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  /* An amount, a date or a code stays whole: "2026-12-21" never breaks at its hyphens. */
  white-space: nowrap;
}

.ui-code {
  padding: 0.12em 0.4em;
  border-radius: min(var(--ui-radius-sm), 0.375rem);
  /* A light grey: a word of code is marked, not blacked out. */
  background: var(--ui-surface-2);
  font-family: var(--ui-font-mono);
  font-size: 0.875em;
  /* A short piece of code never breaks across lines… */
  white-space: nowrap;
}

/* …but one longer than its line, in running text, wraps rather than run out of a narrow screen (rule 10); each line
   keeps its own grey and corners. */
:is(p, li, dd, figcaption, .ui-prose) .ui-code {
  /* Less above and below than a lone code: two pieces on lines one under the other never touch. */
  padding-block: 0.04em;
  white-space: normal;
  overflow-wrap: anywhere;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* On the bare page (not in a card or a dialog) that grey is the page's own: one step deeper, so the mark shows. */
.ui-code:not(:is(.ui-card, .ui-dialog, .ui-popover, .ui-drawer, .ui-sheet, .ui-inset, .ui-popup, .ui-toast, .ui-alert, .ui-table-wrap) .ui-code) {
  background: var(--ui-surface-3);
}

/* A key: a small flat cap with a fine line under it, sized from the text it sits in. */
.ui-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75em;
  height: 1.75em;
  padding: 0 0.45em;
  border: 1px solid var(--ui-border);
  border-radius: min(var(--ui-radius-sm), 0.375rem);
  background: var(--ui-surface);
  box-shadow: inset 0 -1px 0 var(--ui-border);
  font-family: var(--ui-font-mono);
  font-size: 0.8em;
  line-height: 1;
  color: var(--ui-fg-muted);
  vertical-align: 0.1em;
}

/* A link is the text colour with an underline, never the brand colour: the underline says it is a link. */
.ui-link {
  color: var(--ui-fg);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, currentColor 35%, transparent);
  text-underline-offset: 0.2em;
  transition: text-decoration-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-link:hover {
  text-decoration-color: currentColor;
}

.ui-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A wrapper that takes no box of its own: its child is laid out as if it were not there. */
.ui-contents {
  display: contents;
}

.ui-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Layout ────────────────────────────────────────────────────────── */

/* Vertical stack. Set the gap with --gap or a size class. */
.ui-stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap, var(--ui-space-4));
  min-width: 0;
}

/* Horizontal row that wraps. */
.ui-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap, var(--ui-space-3));
  min-width: 0;
}

.ui-row--between {
  justify-content: space-between;
}

/* Two things at the two ends. When the second wraps under the first (a phone), it starts at the same edge as the
   first: a line on the left and the next on the right is a zigzag, and harder to read than two lines. */

.ui-row--center {
  justify-content: center;
}

.ui-row--nowrap {
  flex-wrap: nowrap;
}

/* Children as tall as the row: a sidebar beside its content, panels side by side. */
.ui-row--stretch {
  align-items: stretch;
}

/* A group of controls at the end of a one-line row keeps its width: the text beside it gives way, the controls never leave the box. */
.ui-row--nowrap > .ui-row--nowrap {
  flex-shrink: 0;
}

/*
 * A gap belongs to the box it is set on. Without this, a page stack's large gap would pass down to every stack, row and
 * grid inside it (cards in a grid spread as far apart as the page's sections, chips wrapping early).
 */

.ui-gap-1 { --gap: var(--ui-space-1); }
.ui-gap-2 { --gap: var(--ui-space-2); }
.ui-gap-3 { --gap: var(--ui-space-3); }
.ui-gap-4 { --gap: var(--ui-space-4); }
/* The two large gaps separate blocks, so they close up as Size grows (see --ui-gutter). */
.ui-gap-6 { --gap: var(--ui-gap-lg); }
.ui-gap-8 { --gap: var(--ui-gap-xl); }
/* Between the sections of a public page. */
.ui-gap-12 { --gap: var(--ui-gap-section); }

/* A short title in a row or a list: a name, a product. */
.ui-strong {
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  color: var(--ui-fg);
}

/* Something that has just come into view (an answer, a result, the next step): it fades and rises in. */
.ui-appear {
  animation: ui-appear var(--ui-dur-slow) var(--ui-ease-out) backwards;
}

@keyframes ui-appear {
  from {
    opacity: 0;
    translate: 0 0.5rem;
  }
}

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

/* A name and a line under it (ItemText): a person and their role, a product and its price. Set tight, so the two read as one. */
.ui-item-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ui-item-title {
  overflow-wrap: break-word;
  color: var(--ui-fg);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: var(--ui-leading-tight);
}

.ui-item-note {
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-sm);
  line-height: var(--ui-leading-tight);
}

/* The heading of a card: the title as large as a subheading, a little more room under it. */
.ui-item-text--lg {
  gap: var(--ui-space-1);
}

.ui-item-text--lg .ui-item-title {
  font-size: var(--ui-text-md);
  letter-spacing: -0.005em;
}

/*
 * Split: a side part and a main part next to each other (a sidebar and its page, a rail and its list), which stack when
 * the box is too narrow for the main part to keep its share (--split-at, half by default). It follows the box it is in,
 * not the window, so it works inside a card as well as on a whole screen.
 */
.ui-split {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap, var(--ui-gutter));
}

.ui-split > :first-child {
  flex-grow: 1;
  flex-basis: var(--side, auto);
}

.ui-split > :last-child {
  flex-grow: 999;
  flex-basis: 0;
  /* Never more than the box: a length ("30rem") would push a phone's page sideways. */
  min-inline-size: min(var(--split-at, 50%), 100%);
}

.ui-grow {
  flex: 1 1 0;
  min-width: 0;
}

/* Responsive grid: as many columns of at least --min as fit. */
.ui-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--min, 240px), 100%), 1fr));
  gap: var(--gap, var(--ui-gutter));
}

/* Items keep their own height instead of growing to the tallest in the row: a form beside a tall picture. */
.ui-grid--top {
  align-items: start;
}

/* Centred page column, as wide as the theme's page width (--ui-page-max). */
.ui-container {
  width: 100%;
  max-width: var(--max, var(--ui-page-max));
  margin-inline: auto;
  padding-inline: var(--ui-space-4);
}

.ui-container--narrow {
  --max: 640px;
}

@media (min-width: 768px) {
  .ui-container {
    padding-inline: var(--ui-space-8);
  }
}

/* App shell: sidebar + main. On a phone the sidebar becomes a top strip. */
.ui-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100dvh;
}

.ui-sidebar {
  display: flex;
  gap: var(--ui-space-2);
  align-items: center;
  padding: var(--ui-space-2) var(--ui-space-4);
  overflow-x: auto;
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
}

.ui-main {
  min-width: 0;
  padding: var(--ui-gap-lg) calc(1rem / var(--ui-density));
}

@media (min-width: 768px) {
  .ui-app {
    grid-template-columns: var(--ui-sidebar-width, 240px) minmax(0, 1fr);
  }

  .ui-sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    gap: var(--ui-space-4);
    padding: var(--ui-space-4) var(--ui-space-3);
    overflow: hidden auto;
    border-bottom: 0;
    border-inline-end: 1px solid var(--ui-border);
  }

  .ui-main {
    padding: var(--ui-gap-xl);
  }
}

/* A screen shown inside a page (Main as="div": an example, a preview, a screen in a dialog): its own height, not the
   window's, and a sidebar that stays in it rather than sticking to the window. */
.ui-app:has(> div.ui-main) {
  min-height: 0;
}

.ui-app:has(> div.ui-main) > .ui-sidebar {
  position: static;
  height: auto;
}

/* Page header: title on the left, actions on the right. */
.ui-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: var(--ui-space-3) var(--ui-space-4);
  margin-bottom: var(--ui-gap-lg);
}

/* On a phone the gaps between groups stay as they are: brought down a step they were the gap inside a group, and
   rows of different things (a trail, steps, tabs, pages) sat squeezed together with no air between them. */
@media (max-width: 560px) {
  .ui-main {
    padding: calc(1.25rem / var(--ui-density)) calc(1rem / var(--ui-density));
  }

  .ui-page-header {
    margin-bottom: calc(1.25rem / var(--ui-density));
  }
}

/*
 * Bleed: a band that runs the full width of the window from inside a Container (a picture behind a hero, a tinted
 * section), while what is in it keeps to the page column through its own Container.
 */
.ui-bleed {
  width: 100vw;
  margin-inline: calc(50% - 50vw);
}

/*
 * SitePage: the header, the page and the footer of a site. The header is a header, not a section: it sits in its own
 * band with the same room above and below it (--ui-site-band), so it reads as centred over the page. The page's
 * sections are a section apart and the footer a section below them.
 */
.ui-site-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  --ui-site-band: var(--ui-space-5);
  min-height: 100svh;
  padding-block: var(--ui-site-band) var(--ui-gap-xl);
}

.ui-site-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--ui-gap-section);
  padding-block: var(--ui-site-band, var(--ui-gap-xl)) var(--ui-gap-section);
}

.ui-site-footer {
  align-self: end;
  padding-top: var(--ui-gap-xl);
  border-top: 1px solid var(--ui-border);
}

/*
 * Codes, amounts, dates and keys read left to right in every language: in a right-to-left page "#c2eb32" or "A-1042"
 * must not be turned round. Their direction comes from what they hold, kept apart from the text around them.
 */
:is(.ui-mono, .ui-num, code, kbd, samp, .ui-kbd) {
  unicode-bidi: plaintext;
}

/*
 * Supply UI — components.
 *
 * Every class works on plain HTML. The React components add the same classes,
 * so the two always look the same. States are matched both ways: the browser's
 * own (:checked, [open], :disabled) and UI SDK's (data-checked, data-open, data-selected…).
 */

/* The parts, in the order they apply. The build puts them together (and into their cascade layer); each file is one component or family. */
/* ── Button ────────────────────────────────────────────────────────── */

.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-2);
  height: var(--ui-h-md);
  padding: 0 var(--ui-space-5);
  border: 1px solid transparent;
  border-radius: var(--ui-radius-md);
  background-color: var(--ui-control-bg);
  background-image: var(--ui-control-fill);
  box-shadow: var(--_depth, var(--ui-control-shadow));
  color: var(--ui-fg);
  font-family: var(--ui-font-sans);
  font-size: var(--ui-text-base);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    border-color var(--ui-dur-fast) var(--ui-ease),
    color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur-fast) var(--ui-ease),
    translate var(--ui-dur-fast) var(--ui-ease);
}

.ui-btn:hover {
  box-shadow: var(--_depth, var(--ui-control-shadow-hover));
  background-color: color-mix(in oklab, var(--ui-control-bg) 90%, var(--ui-fg));
}

.ui-btn:active {
  box-shadow: var(--_depth, var(--ui-control-shadow-active));
  translate: 0 var(--_press, var(--ui-control-press));
  background-color: color-mix(in oklab, var(--ui-control-bg) 80%, var(--ui-fg));
}

.ui-btn:disabled,
.ui-btn[aria-disabled="true"],
.ui-btn[data-disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.ui-btn svg {
  flex: none;
  width: 1.15em;
  height: 1.15em;
}

.ui-btn--primary {
  border-color: transparent;
  background-color: var(--ui-primary);
  color: var(--ui-on-primary);
}

.ui-btn--primary:hover {
  background-color: var(--ui-primary-hover);
}

.ui-btn--primary:active {
  background-color: color-mix(in oklab, var(--ui-primary) 78%, var(--ui-primary-shade));
}

.ui-btn--outline {
  border-color: var(--ui-border-strong);
  background-color: transparent;
}

.ui-btn--outline:hover {
  background-color: var(--ui-surface-2);
}

.ui-btn--ghost {
  border-color: transparent;
  background: transparent;
}

.ui-btn--ghost:hover,
.ui-btn--ghost[data-open] {
  background: var(--ui-surface-3);
}

/*
 * A ghost button with words in it ("Cancel", "Change my vote") keeps a soft fill at rest. Without it the words sit
 * indented by the button's padding, out of line with everything above, and the button only appears on hover.
 * Icon buttons, and buttons that are part of another control (a field, a toolbar, a row of pages, a group), stay clear.
 */
.ui-btn--ghost:not(.ui-btn--icon):not(:is(.ui-input-group, .ui-toolbar, .ui-menubar, .ui-pagination, .ui-btn-group, .ui-segmented, .ui-calendar, .ui-carousel-bar, .ui-tabbar) .ui-btn--ghost) {
  background: var(--ui-surface-2);
}

.ui-btn--ghost:not(.ui-btn--icon):not(:is(.ui-input-group, .ui-toolbar, .ui-menubar, .ui-pagination, .ui-btn-group, .ui-segmented, .ui-calendar, .ui-carousel-bar, .ui-tabbar) .ui-btn--ghost):is(:hover, [data-open]) {
  background: var(--ui-surface-3);
}

.ui-btn--danger {
  border-color: transparent;
  background-color: var(--ui-danger);
  color: var(--ui-on-danger);
}

.ui-btn--danger:hover {
  background-color: color-mix(in oklab, var(--ui-danger) 88%, black);
}

.ui-btn--danger:active {
  background-color: color-mix(in oklab, var(--ui-danger) 78%, black);
}

.ui-btn--outline:active,
.ui-btn--ghost:active {
  background-color: var(--ui-surface-3);
}

.ui-btn--link:active {
  background: none;
}

/* Quiet buttons stay flat in every theme: no depth, no sheen, no press. */
.ui-btn--ghost,
.ui-btn--link {
  --_depth: 0 0 #0000;
  --_press: 0px;
  background-image: none;
}

.ui-btn--link {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ui-fg);
}

.ui-btn--link {
  border-radius: var(--ui-radius-sm);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, currentColor 35%, transparent);
  text-underline-offset: 0.2em;
  transition:
    color var(--ui-dur-fast) var(--ui-ease),
    text-decoration-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-btn--link:hover {
  background: none;
  text-decoration-color: currentColor;
}

.ui-btn--sm {
  height: var(--ui-h-sm);
  padding: 0 var(--ui-space-3);
  font-size: var(--ui-text-sm);
}

.ui-btn--lg {
  height: var(--ui-h-lg);
  padding: 0 var(--ui-space-8);
  font-size: var(--ui-text-md);
}

/* Square button for a single icon. Give it an aria-label. */
.ui-btn--icon {
  width: var(--ui-h-md);
  padding: 0;
}

.ui-btn--icon.ui-btn--sm {
  width: var(--ui-h-sm);
}

.ui-btn--icon.ui-btn--lg {
  width: var(--ui-h-lg);
}

.ui-btn--block {
  width: 100%;
}

/* ── Fields ────────────────────────────────────────────────────────── */

.ui-field {
  display: grid;
  gap: var(--ui-space-2);
  min-width: 0;
}

.ui-label {
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  color: var(--ui-fg);
}

.ui-hint {
  font-size: var(--ui-text-sm);
  color: var(--ui-fg-muted);
}

.ui-error {
  font-size: var(--ui-text-sm);
  color: var(--ui-danger-text);
}

.ui-input {
  display: block;
  box-shadow: var(--ui-field-shadow), 0 0 0 1px transparent;
  width: 100%;
  height: var(--ui-h-md);
  padding: 0 var(--ui-space-4);
  border: 1px solid var(--ui-field-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-field-bg);
  color: var(--ui-fg);
  font-family: var(--ui-font-sans);
  font-size: var(--ui-text-base);
  line-height: 1.4;
  transition:
    border-color var(--ui-dur-fast) var(--ui-ease),
    background-color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur-fast) var(--ui-ease);
}

.ui-input::placeholder {
  color: var(--ui-fg-subtle);
  opacity: 1;
}

.ui-input:hover {
  border-color: var(--ui-border-hover);
}

.ui-input:focus,
.ui-input:focus-visible,
.ui-input[data-open] {
  outline: none;
  border-color: var(--ui-highlight);
  background: var(--ui-surface);
  box-shadow: var(--ui-field-shadow), 0 0 0 3px var(--ui-focus-halo);
}

.ui-input:disabled,
.ui-input[data-disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.ui-input[aria-invalid="true"],
.ui-input[data-invalid] {
  border-color: var(--ui-danger-text);
}

textarea.ui-input {
  height: auto;
  min-height: calc(var(--ui-h-md) * 2.5);
  padding: var(--ui-space-3) var(--ui-space-4);
  border-radius: min(var(--ui-radius-md), 1.25rem);
  /* The corner that holds the grip to make it taller is square, so the grip sits in it, not cut by a curve. */
  border-end-end-radius: 0;
  line-height: var(--ui-leading);
  resize: vertical;
}

/* A touch screen has no grip to pull: the corner is round like the other three. */
@media (pointer: coarse) {
  textarea.ui-input {
    border-end-end-radius: min(var(--ui-radius-md), 1.25rem);
    resize: none;
  }
}

/* The browser's own date and time fields. On an iPhone they keep a width of their own and centre their value, so
   they run out of a narrow box: drawn as the kit's field they take the width they are given, value at the start. */
.ui-input:is([type="date"], [type="time"], [type="datetime-local"], [type="month"], [type="week"]) {
  appearance: none;
  min-width: 0;
}

.ui-input::-webkit-date-and-time-value {
  min-height: 1lh;
  text-align: start;
}

/* The browser's own <select>, drawn to match. */
select.ui-input {
  appearance: none;
  padding-inline-end: var(--ui-space-10);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    right calc(var(--ui-space-4) + 5px) center,
    right var(--ui-space-4) center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* Select trigger (React): a button that looks like an input. */
button.ui-input {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-2);
  text-align: start;
  cursor: pointer;
}

.ui-input--sm {
  height: var(--ui-h-sm);
  font-size: var(--ui-text-sm);
}

.ui-input--lg {
  height: var(--ui-h-lg);
  font-size: var(--ui-text-md);
}

/* Label that wraps a checkbox, radio or switch and its text. */
.ui-check {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-2);
  font-size: var(--ui-text-base);
  cursor: pointer;
}

.ui-check:has(:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Checkbox and radio ────────────────────────────────────────────── */

.ui-checkbox,
.ui-radio {
  appearance: none;
  position: relative;
  display: inline-grid;
  place-content: center;
  flex: none;
  width: calc(1.125 * var(--ui-u));
  height: calc(1.125 * var(--ui-u));
  margin: 0;
  padding: 0;
  border: 1px solid var(--ui-well-border, var(--ui-control-edge));
  background: var(--ui-well-bg, var(--ui-surface));
  box-shadow: var(--ui-well-shadow);
  cursor: pointer;
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    border-color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur-fast) var(--ui-ease);
}

.ui-checkbox {
  border-radius: min(var(--ui-radius-sm), 6px);
}

.ui-radio {
  border-radius: var(--ui-radius-full);
}

.ui-checkbox:hover,
.ui-radio:hover {
  border-color: var(--ui-fg-subtle);
}

.ui-checkbox::after,
.ui-radio::after {
  content: "";
  transform: scale(0);
  transition: transform var(--ui-dur-fast) var(--ui-ease);
  background: var(--ui-on-ink);
}

.ui-checkbox::after {
  width: calc(0.75 * var(--ui-u));
  height: calc(0.75 * var(--ui-u));
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.5 5 9l4.5-6'/%3E%3C/svg%3E") center / contain no-repeat;
}

.ui-checkbox:indeterminate::after,
.ui-checkbox[data-indeterminate]::after {
  mask: none;
  width: calc(0.625 * var(--ui-u));
  height: 2px;
  border-radius: var(--ui-radius-full);
}

.ui-radio::after {
  width: calc(0.5 * var(--ui-u));
  height: calc(0.5 * var(--ui-u));
  border-radius: var(--ui-radius-full);
}

.ui-checkbox:checked,
.ui-checkbox:indeterminate,
.ui-checkbox[data-checked],
.ui-checkbox[data-indeterminate],
.ui-radio:checked,
.ui-radio[data-checked] {
  border-color: transparent;
  box-shadow: var(--ui-chosen-shadow);
  background: var(--ui-chosen-fill) var(--ui-ink);
}

.ui-checkbox:checked::after,
.ui-checkbox:indeterminate::after,
.ui-checkbox[data-checked]::after,
.ui-checkbox[data-indeterminate]::after,
.ui-radio:checked::after,
.ui-radio[data-checked]::after {
  transform: scale(1);
}

/* ── Switch ────────────────────────────────────────────────────────── */

.ui-switch {
  appearance: none;
  position: relative;
  flex: none;
  width: calc(2.25 * var(--ui-u));
  height: calc(1.25 * var(--ui-u));
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-round);
  background: var(--ui-well-bg, var(--ui-control-edge));
  box-shadow: var(--ui-well-shadow);
  cursor: pointer;
  transition:
    background-color var(--ui-dur) var(--ui-ease-out),
    box-shadow var(--ui-dur) var(--ui-ease-out);
}

.ui-switch::before {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: calc(1 * var(--ui-u));
  height: calc(1 * var(--ui-u));
  border-radius: var(--ui-radius-round);
  background: var(--ui-knob-bg);
  box-shadow: var(--ui-knob-shadow);
  transition: transform var(--ui-dur) var(--ui-ease-out);
}

.ui-switch:checked,
.ui-switch[data-checked] {
  background: var(--ui-chosen-fill) var(--ui-ink);
  box-shadow: var(--ui-chosen-shadow);
}

.ui-switch:checked::before,
.ui-switch[data-checked]::before {
  transform: translateX(calc(1 * var(--ui-u) * var(--ui-dir, 1)));
  background: var(--ui-on-ink);
}

.ui-checkbox:disabled,
.ui-radio:disabled,
.ui-switch:disabled {
  cursor: not-allowed;
}

/* ── Range slider ──────────────────────────────────────────────────── */

/* Set --value (0–100) to show the filled part: style="--value: 40". */
.ui-range {
  appearance: none;
  width: 100%;
  height: calc(1.25 * var(--ui-u));
  margin: 0;
  background: none;
  cursor: pointer;
  --_fill: calc(var(--value, 0) * 1%);
}

.ui-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--ui-radius-full);
  box-shadow: var(--ui-well-shadow);
  background: linear-gradient(to right, var(--ui-ink) var(--_fill), var(--ui-well-bg, var(--ui-surface-3)) var(--_fill));
}

.ui-range::-moz-range-track {
  height: 4px;
  border-radius: var(--ui-radius-full);
  box-shadow: var(--ui-well-shadow);
  background: linear-gradient(to right, var(--ui-ink) var(--_fill), var(--ui-well-bg, var(--ui-surface-3)) var(--_fill));
}

.ui-range::-webkit-slider-thumb {
  appearance: none;
  width: calc(1 * var(--ui-u));
  height: calc(1 * var(--ui-u));
  margin-top: calc((4px - calc(1 * var(--ui-u))) / 2);
  border: 1px solid var(--ui-knob-border);
  border-radius: var(--ui-radius-full);
  background: var(--ui-knob-bg);
  box-shadow: var(--ui-knob-shadow);
  transition: scale var(--ui-dur-fast) var(--ui-ease);
}

.ui-range::-moz-range-thumb {
  width: calc(1 * var(--ui-u));
  height: calc(1 * var(--ui-u));
  border: 1px solid var(--ui-knob-border);
  border-radius: var(--ui-radius-full);
  background: var(--ui-knob-bg);
  box-shadow: var(--ui-knob-shadow);
  transition: scale var(--ui-dur-fast) var(--ui-ease);
}

/* As the React Slider: the thumb grows while the slider is hovered or dragged. */
.ui-range:not(:disabled):is(:hover, :active)::-webkit-slider-thumb {
  scale: var(--ui-knob-grow);
}

.ui-range:not(:disabled):is(:hover, :active)::-moz-range-thumb {
  scale: var(--ui-knob-grow);
}

.ui-range:focus-visible {
  outline: none;
}

.ui-range:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--ui-ring);
  outline-offset: 2px;
}

.ui-range:focus-visible::-moz-range-thumb {
  outline: 2px solid var(--ui-ring);
  outline-offset: 2px;
}

/* ── Card ──────────────────────────────────────────────────────────── */

.ui-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--ui-card-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
  background-image: var(--ui-card-fill);
  box-shadow: var(--ui-card-shadow);
  color: var(--ui-fg);
}

:where(.ui-card, .ui-dialog, .ui-popover, .ui-inset) :where(.ui-card, .ui-list, .ui-table-wrap, .ui-accordion, .ui-empty, .ui-filedrop) {
  border-radius: var(--ui-radius-nested);
}

/* Inside a panel that would cut a deep shadow off, cards take the closer one. */
:where(.ui-card, .ui-inset, .ui-sidebar, .ui-scroll, .ui-dialog, .ui-popover, .ui-drawer-body, .ui-resizable-panel) .ui-card {
  box-shadow: var(--ui-card-inner-shadow);
}

.ui-card--raised {
  border-color: transparent;
  box-shadow: var(--ui-card-raised-shadow);
}

/* A whole card that is a link or button. */
.ui-card--action {
  text-decoration: none;
  cursor: pointer;
  transition:
    border-color var(--ui-dur-fast) var(--ui-ease),
    background-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-card--action:hover {
  border-color: var(--ui-border-hover);
  background-color: var(--ui-surface-2);
}

.ui-card-header {
  display: grid;
  gap: var(--ui-space-1);
  padding: var(--ui-pad) var(--ui-pad) 0;
}

.ui-card-title {
  font-size: var(--ui-text-lg);
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.ui-card-description {
  font-size: var(--ui-text-sm);
  color: var(--ui-fg-muted);
}

.ui-card-body {
  padding: var(--ui-pad);
}

/*
 * Nothing touches the edge of a card, whatever is put into it.
 * - A header that is the last thing in a card, or comes straight before the footer, keeps the room under it.
 * - A card with none of its own parts inside (CardHeader, CardBody, a list…) takes the card's room itself.
 * - Something loose beside those parts gets that room around it.
 * - A list, table or accordion straight in a card is the card's own rows: it has no second frame.
 * The two middle rules have no weight (:where), so a class of the tool's own can still say otherwise.
 */
.ui-card-header:last-child,
.ui-card-header:has(+ .ui-card-footer) {
  padding-bottom: var(--ui-pad);
}

:where(.ui-card:not(:has(> .ui-card-header, > .ui-card-body, > .ui-card-footer, > .ui-card-cover, > .ui-inset, > .ui-list, > .ui-table-wrap, > .ui-resizable-frame, > .ui-accordion))) {
  padding: var(--ui-pad);
}

:where(.ui-card:has(> .ui-card-header, > .ui-card-body, > .ui-card-footer, > .ui-card-cover, > .ui-inset, > .ui-list, > .ui-table-wrap, > .ui-resizable-frame, > .ui-accordion)) > :where(:not(.ui-card-header, .ui-card-body, .ui-card-footer, .ui-card-cover, .ui-inset, .ui-list, .ui-table-wrap, .ui-resizable-frame, .ui-accordion, .ui-separator, style, script, template, [hidden])) {
  margin: var(--ui-pad) var(--ui-pad) 0;
}

:where(.ui-card:has(> .ui-card-header, > .ui-card-body, > .ui-card-footer, > .ui-card-cover, > .ui-inset, > .ui-list, > .ui-table-wrap, > .ui-resizable-frame, > .ui-accordion)) > :where(:not(.ui-card-header, .ui-card-body, .ui-card-footer, .ui-card-cover, .ui-inset, .ui-list, .ui-table-wrap, .ui-resizable-frame, .ui-accordion, .ui-separator, style, script, template, [hidden])):last-child {
  margin-bottom: var(--ui-pad);
}

.ui-card > .ui-list,
.ui-card > .ui-table-wrap,
.ui-card > .ui-accordion {
  border: 0;
  border-radius: 0;
  background: none;
}

.ui-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ui-space-2);
  padding: var(--ui-space-4) var(--ui-pad) max(var(--ui-space-4), calc(var(--ui-pad) - var(--ui-space-3)));
  border-top: 1px solid var(--ui-border);
  /* Cards side by side grow to the tallest; the footer stays at the foot, so their buttons line up. */
  margin-top: auto;
}

/* A row put in the footer takes its whole width, so `between` puts a price at the start and its button at the end. */
.ui-card-footer > .ui-row {
  flex: 1;
}

/* ── Stat ──────────────────────────────────────────────────────────── */

.ui-stat {
  display: grid;
  gap: var(--ui-space-1);
}

/* An icon over the label: what the number is about, at a glance. */
.ui-stat > .ui-icon-tile {
  margin-block-end: var(--ui-space-2);
}

.ui-stat-label {
  font-size: var(--ui-text-sm);
  color: var(--ui-fg-muted);
}

.ui-stat-value {
  /* A figure is read at a glance: it never breaks across lines ("11 / days"). */
  white-space: nowrap;
  font-family: var(--ui-font-sans);
  font-size: var(--ui-text-2xl);
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: var(--ui-leading-tight);
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.ui-stat-note {
  font-size: var(--ui-text-sm);
  color: var(--ui-fg-muted);
}

/* ── Badge ─────────────────────────────────────────────────────────── */

.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-1);
  height: calc(1.5 * var(--ui-u));
  padding: 0 calc(0.625 * var(--ui-u));
  border: 1px solid transparent;
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface-3);
  color: var(--ui-fg);
  font-size: var(--ui-text-xs);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1;
  white-space: nowrap;
}

.ui-badge--primary { background: var(--ui-primary-soft); color: var(--ui-primary-text); }
.ui-badge--success { background: var(--ui-success-soft); color: var(--ui-success-text); }
.ui-badge--warning { background: var(--ui-warning-soft); color: var(--ui-warning-text); }
.ui-badge--danger { background: var(--ui-danger-soft); color: var(--ui-danger-text); }
.ui-badge--info { background: var(--ui-info-soft); color: var(--ui-info-text); }

.ui-badge--outline {
  border-color: var(--ui-border);
  background: transparent;
  color: var(--ui-fg-muted);
}

.ui-badge--pill {
  border-radius: var(--ui-radius-round);
}

/* Small status dot inside a badge or next to text. */
.ui-dot {
  flex: none;
  width: calc(0.5 * var(--ui-u));
  height: calc(0.5 * var(--ui-u));
  border-radius: var(--ui-radius-full);
  background: currentColor;
}

/* ── Alert ─────────────────────────────────────────────────────────── */

.ui-alert {
  display: grid;
  gap: var(--ui-space-1);
  padding: var(--ui-pad-sm) calc(var(--ui-pad-sm) + var(--ui-space-1));
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-box);
  background: var(--ui-surface-2);
  color: var(--ui-fg);
  font-size: var(--ui-text-base);
}

.ui-alert-title {
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

.ui-alert--info { border-color: transparent; background: var(--ui-info-soft); }
.ui-alert--info .ui-alert-title { color: var(--ui-info-text); }
.ui-alert--success { border-color: transparent; background: var(--ui-success-soft); }
.ui-alert--success .ui-alert-title { color: var(--ui-success-text); }
.ui-alert--warning { border-color: transparent; background: var(--ui-warning-soft); }
.ui-alert--warning .ui-alert-title { color: var(--ui-warning-text); }
.ui-alert--danger { border-color: transparent; background: var(--ui-danger-soft); }
.ui-alert--danger .ui-alert-title { color: var(--ui-danger-text); }

/* ── Avatar ────────────────────────────────────────────────────────── */

.ui-avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--size, calc(2 * var(--ui-u)));
  height: var(--size, calc(2 * var(--ui-u)));
  overflow: hidden;
  border-radius: var(--ui-radius-round);
  background: var(--ui-primary-soft);
  color: var(--ui-primary-text);
  font-size: calc(var(--size, calc(2 * var(--ui-u))) * 0.4);
  font-weight: var(--ui-weight-bold);
  --ui-icon-weight: var(--ui-icon-bold);
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}

.ui-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ui-avatar--sm { --size: calc(1.5 * var(--ui-u)); }
.ui-avatar--lg { --size: calc(2.75 * var(--ui-u)); }

/* ── Separator ─────────────────────────────────────────────────────── */

.ui-separator {
  flex: none;
  width: 100%;
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--ui-border);
}

.ui-separator--vertical {
  width: 1px;
  height: auto;
  align-self: stretch;
}

/* ── Loading ───────────────────────────────────────────────────────── */

.ui-skeleton {
  display: block;
  min-height: 1em;
  border-radius: min(var(--ui-radius-sm), 0.375rem);
  background: var(--ui-surface-3);
  animation: ui-pulse 1.6s ease-in-out infinite;
}

.ui-spinner {
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  border: 2px solid color-mix(in oklab, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: var(--ui-radius-full);
  animation: ui-spin 0.7s linear infinite;
}

/* The browser's own <progress>, or a div with --value (0–100). */
.ui-progress {
  appearance: none;
  display: block;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border: 0;
  border-radius: var(--ui-radius-round);
  background: var(--ui-well-bg, var(--ui-surface-3));
  box-shadow: var(--ui-well-shadow);
}

.ui-progress::-webkit-progress-bar {
  background: var(--ui-well-bg, var(--ui-surface-3));
}

.ui-progress::-webkit-progress-value {
  border-radius: var(--ui-radius-round);
  background: var(--ui-primary);
  transition: width var(--ui-dur-slow) var(--ui-ease-out);
}

.ui-progress::-moz-progress-bar {
  border-radius: var(--ui-radius-round);
  background: var(--ui-primary);
}

@keyframes ui-pulse {
  50% { opacity: 0.5; }
}

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

/* ── Table ─────────────────────────────────────────────────────────── */

/* Wrap the table so it scrolls sideways on a phone. */
.ui-table-wrap {
  container: ui-table / inline-size;
  overflow-x: auto;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
}

.ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ui-text-base);
  text-align: start;
}

.ui-table th {
  /* Said on th itself: the browser centres headings unless told otherwise, and "start" on the table is not enough. */
  text-align: start;
  padding: var(--ui-space-3) var(--ui-space-5);
  border-bottom: 1px solid var(--ui-border);
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  white-space: nowrap;
}

.ui-table td {
  padding: var(--ui-space-4) var(--ui-space-5);
  border-bottom: 1px solid var(--ui-border);
  vertical-align: middle;
}

.ui-table tbody tr:last-child td {
  border-bottom: 0;
}

/* The edge cells sit in the table's corners, so they get the corner's room. */
.ui-table :is(th, td):first-child {
  padding-inline-start: max(var(--ui-space-5), calc(var(--ui-pad) - var(--ui-space-1)));
}

.ui-table :is(th, td):last-child {
  padding-inline-end: max(var(--ui-space-5), calc(var(--ui-pad) - var(--ui-space-1)));
}

.ui-table td {
  white-space: nowrap;
  transition: background-color var(--ui-dur-fast) var(--ui-ease);
}

/* A cell with a sentence in it: lets it wrap, with a sensible width. */
.ui-table td.ui-wrap {
  min-width: 14rem;
  white-space: normal;
}

.ui-table tbody tr:hover td {
  background: var(--ui-surface-2);
}

/* In a narrow box the cells keep less room at their sides, so more tables fit their columns. */
@container ui-table (max-width: 30rem) {
  .ui-table :is(th, td) {
    padding-inline: var(--ui-space-3);
  }

  .ui-table :is(th, td):first-child {
    padding-inline-start: var(--ui-pad-sm);
  }

  .ui-table :is(th, td):last-child {
    padding-inline-end: var(--ui-pad-sm);
  }
}

/*
 * Stacked (Table sets data-stacked where its columns do not fit): each row is a block. The first cell is its title;
 * every other cell is a line with its column's name at the start and the value at the end.
 */
.ui-table-wrap[data-stacked] :is(.ui-table, tbody) {
  display: block;
}

.ui-table-wrap[data-stacked] thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ui-table-wrap[data-stacked] tbody tr {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-space-2) var(--ui-space-4);
  padding: var(--ui-space-4) var(--ui-pad);
  border-bottom: 1px solid var(--ui-border);
}

.ui-table-wrap[data-stacked] tbody tr:last-child {
  border-bottom: 0;
}

.ui-table-wrap[data-stacked] .ui-table td,
.ui-table-wrap[data-stacked] .ui-table td:is(:first-child, :last-child) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-4);
  min-width: 0;
  padding: 0;
  border: 0;
  white-space: normal;
  text-align: end;
}

.ui-table-wrap[data-stacked] .ui-table td.ui-wrap,
.ui-table-wrap[data-stacked] .ui-table td.ui-wrap:is(:first-child, :last-child) {
  /* A cell that holds a sentence: its column's name above it, so the sentence keeps the whole width and its words,
     code and links flow as one text (in a flex row they would each become a block). */
  display: block;
  text-align: start;
}

.ui-table-wrap[data-stacked] .ui-table td.ui-wrap::before {
  display: block;
  margin-block-end: var(--ui-space-1);
}

.ui-table-wrap[data-stacked] .ui-table td::before {
  content: attr(data-label);
  flex: none;
  font-family: var(--ui-font-sans);
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-sm);
  text-align: start;
}

.ui-table-wrap[data-stacked] .ui-table td:first-child {
  margin-block-end: var(--ui-space-1);
  text-align: start;
}

/* The title and each named line take a whole line; cells without a name share one, the figures at its end. */
.ui-table-wrap[data-stacked] .ui-table td:is(:first-child, [data-label]) {
  flex-basis: 100%;
}

.ui-table-wrap[data-stacked] .ui-table td:not(:first-child, [data-label]) {
  flex: 1 1 auto;
}

.ui-table-wrap[data-stacked] .ui-table td:is(:first-child, :not([data-label])) {
  justify-content: flex-start;
}

.ui-table-wrap[data-stacked] .ui-table td.ui-num:not(:first-child, [data-label]) {
  justify-content: flex-end;
}

.ui-table-wrap[data-stacked] .ui-table td:is(:first-child, :not([data-label]))::before {
  content: none;
}

.ui-table-wrap[data-stacked] .ui-table td:first-child > :only-child {
  flex: 1;
  min-width: 0;
}

.ui-table-wrap[data-stacked] .ui-table td:not(:first-child) > :is(.ui-input, .ui-input-group, .ui-select, .ui-number) {
  flex: 0 1 11rem;
  min-width: 0;
}

.ui-table-wrap[data-stacked] .ui-table tbody tr:hover td {
  background: none;
}

.ui-table .ui-num,
.ui-num {
  font-family: var(--ui-font-mono);
  font-variant-numeric: tabular-nums;
  text-align: end;
}

/* ── Empty state ───────────────────────────────────────────────────── */

.ui-empty {
  display: grid;
  justify-items: center;
  gap: var(--ui-space-2);
  padding: var(--ui-space-12) var(--ui-space-6);
  border: 1px dashed var(--ui-border-strong);
  border-radius: var(--ui-radius-lg);
  text-align: center;
}

/* On a picture or a painted pattern: a solid box, so the words can be read. */
.ui-empty--solid {
  border-style: solid;
  border-color: var(--ui-card-border);
  background: var(--ui-surface);
  background-clip: padding-box;
}

.ui-empty-title {
  font-size: var(--ui-text-lg);
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
}

.ui-empty-text {
  max-width: 42ch;
  color: var(--ui-fg-muted);
}

.ui-empty .ui-btn {
  margin-top: var(--ui-space-2);
}

/* ── Navigation ────────────────────────────────────────────────────── */

.ui-nav {
  display: flex;
  flex-direction: inherit;
  gap: 2px;
  min-width: 0;
}

.ui-nav-item {
  display: flex;
  /* In a row of links (a sidebar that is a strip on a phone) a link keeps its whole width and the row scrolls:
     Firefox and Safari otherwise shrink it a few pixels under its words. */
  flex-shrink: 0;
  align-items: center;
  gap: var(--ui-space-2);
  height: var(--ui-h-md);
  padding: 0 var(--ui-space-3);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: none;
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-base);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    color var(--ui-dur-fast) var(--ui-ease);
}

.ui-nav-item:hover {
  background: var(--ui-surface-2);
  color: var(--ui-fg);
}

.ui-nav-item[aria-current="page"],
.ui-nav-item[data-active] {
  background: var(--ui-surface-3);
  color: var(--ui-fg);
}

.ui-nav-item svg {
  flex: none;
  width: 1.15em;
  height: 1.15em;
}

/* A rail: the sections as icons in a narrow column. Name each item with aria-label and a Tooltip. The chosen one is ink. */
.ui-nav--rail {
  flex-direction: column;
  align-items: center;
  gap: var(--ui-space-1);
}

.ui-nav--rail .ui-nav-item {
  justify-content: center;
  width: var(--ui-h-md);
  padding: 0;
}

.ui-nav--rail .ui-nav-item svg {
  width: 1.25rem;
  height: 1.25rem;
}

.ui-nav--rail .ui-nav-item[aria-current="page"],
.ui-nav--rail .ui-nav-item[data-active] {
  background: var(--ui-ink);
  color: var(--ui-on-ink);
}

.ui-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--ui-text-sm);
  color: var(--ui-fg-muted);
}

.ui-breadcrumb a {
  text-decoration: none;
  transition: color var(--ui-dur-fast) var(--ui-ease);
}

.ui-breadcrumb a:hover {
  color: var(--ui-fg);
}

.ui-breadcrumb li {
  transition: color var(--ui-dur-fast) var(--ui-ease);
}

.ui-breadcrumb li + li::before {
  content: "/";
  margin-inline-end: var(--ui-space-2);
  color: var(--ui-fg-subtle);
}

.ui-breadcrumb li[aria-current="page"] {
  color: var(--ui-fg);
}

.ui-pagination-frame {
  min-width: 0;
}

.ui-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-space-1);
}

/* ── Tabs ──────────────────────────────────────────────────────────── */

.ui-tabs {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
  min-width: 0;
}

.ui-tabs-list {
  --tabs-gap: var(--ui-space-4);
  display: flex;
  gap: var(--tabs-gap);
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--ui-border);
}

/*
 * A row that scrolls sideways inside a card or a dialog runs to its edges, like a carousel with bleed: nothing is cut
 * at the padding line, the first tab still lines up with the text, and the same room is kept after the last one
 * (a row that scrolls itself keeps its end padding).
 */
:is(.ui-card-body, .ui-card-header, .ui-dialog) .ui-tabs-list {
  margin-inline: calc(-1 * var(--box-pad));
  padding-inline: var(--box-pad);
  scroll-padding-inline: var(--box-pad);
}

/* What each box keeps at its sides, for rows that run to its edges. */
.ui-card-body,
.ui-card-header {
  --box-pad: var(--ui-pad);
}

.ui-dialog {
  --box-pad: var(--ui-pad-lg);
}

.ui-tab {
  position: relative;
  height: var(--ui-h-md);
  padding: 0;
  border: 0;
  background: none;
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-base);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--ui-dur-fast) var(--ui-ease);
}

a.ui-tab {
  display: inline-flex;
  align-items: center;
}

.ui-tab:hover {
  color: var(--ui-fg);
}

.ui-tab::after {
  content: "";
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  background: transparent;
  transition: background-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-tab[data-selected],
.ui-tab[aria-selected="true"],
.ui-tab[aria-current="page"] {
  color: var(--ui-fg);
}

.ui-tab[data-selected]::after,
.ui-tab[aria-selected="true"]::after,
.ui-tab[aria-current="page"]::after {
  background: var(--ui-chosen-fill) var(--ui-ink);
}

/* A panel that is picked fades in, from the side of the tab that was picked; nothing just changes. */
.ui-tabs-panel:not([hidden]) {
  animation: ui-panel-in var(--ui-dur) var(--ui-ease-out);
}

.ui-tabs-panel[data-activation-direction="left"] {
  --panel-from: -0.75rem;
}

.ui-tabs-panel[data-activation-direction="right"] {
  --panel-from: 0.75rem;
}

@keyframes ui-panel-in {
  from {
    opacity: 0;
    translate: var(--panel-from, 0) 0;
  }
}

/* A calendar's new month (and its title) fades and slides in from the side it came from (react/calendar.tsx). */
[data-ui-turn] > .ui-calendar-months,
[data-ui-turn] > .ui-calendar-head .ui-calendar-title {
  animation: ui-turn var(--ui-dur) var(--ui-ease-out);
}

[data-ui-turn="next"] {
  --turn-from: 0.75rem;
}

[data-ui-turn="prev"] {
  --turn-from: -0.75rem;
}

@keyframes ui-turn {
  from {
    opacity: 0;
    translate: var(--turn-from, 0) 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui-tabs-panel:not([hidden]),
  [data-ui-turn] > .ui-calendar-months,
  [data-ui-turn] > .ui-calendar-head .ui-calendar-title {
    animation: none;
  }
}

.ui-tabs-panel:focus-visible {
  border-radius: var(--ui-radius-md);
}

/* ── Segmented control ─────────────────────────────────────────────── */

.ui-segmented {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  /* Options of one width where there is room; where there is not (a phone), each keeps the width of its word
     instead of cutting it short. Only a row too long for the box scrolls. */
  display: inline-grid;
  grid-auto-columns: minmax(max-content, 1fr);
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  border-radius: calc(var(--ui-radius-md) + 3px);
  background: var(--ui-well-bg, var(--ui-surface-3));
  box-shadow: var(--ui-well-shadow);
}

.ui-segmented-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-2);
  height: calc(var(--ui-h-md) - 6px);
  padding: 0 var(--ui-space-4);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: none;
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur-fast) var(--ui-ease);
}

/*
 * An option never hides past the edge. A text option's room on each side is a fixed space-2 plus a spacer of space-2
 * that gives way first when room is short (the control is still sized with the full room); only after that does a long
 * word end in "…".
 */
.ui-segmented-item {
  min-width: 0;
}

.ui-segmented-item:has(> .ui-segmented-label) {
  gap: 0;
  padding-inline: var(--ui-space-2);
}

.ui-segmented-item:has(> .ui-segmented-label)::before,
.ui-segmented-item:has(> .ui-segmented-label)::after {
  flex: 0 1 auto;
  width: var(--ui-space-2);
  min-width: 0;
  content: "";
}

/* A small phone: less room round each word, so four options still fit side by side. */
@media (max-width: 400px) {
  .ui-segmented-item,
  .ui-segmented-item:has(> .ui-segmented-label) {
    padding-inline: var(--ui-space-2);
  }

  .ui-segmented-item:has(> .ui-segmented-label)::before,
  .ui-segmented-item:has(> .ui-segmented-label)::after {
    width: 0;
  }
}

.ui-segmented-label {
  flex: 0 0.001 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-segmented-item:hover {
  color: var(--ui-fg);
}

.ui-segmented-item[data-checked],
.ui-segmented-item[aria-pressed="true"],
.ui-segmented-item[aria-checked="true"],
.ui-segmented-item:has(input:checked) {
  background: var(--ui-chosen-fill) var(--ui-ink);
  box-shadow: var(--ui-chosen-shadow);
  color: var(--ui-on-ink);
}

/* Plain HTML: <label class="ui-segmented-item"><input type="radio" …>Text</label> */
.ui-segmented-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ui-segmented-item:has(input:focus-visible) {
  outline: 2px solid var(--ui-ring);
  outline-offset: 2px;
}

/* ── Accordion ─────────────────────────────────────────────────────── */

.ui-accordion {
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
}

.ui-accordion-item + .ui-accordion-item {
  border-top: 1px solid var(--ui-border);
}

.ui-accordion-header {
  margin: 0;
}

.ui-accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-4);
  width: 100%;
  padding: var(--ui-space-4) max(var(--ui-space-5), calc(var(--ui-pad) - var(--ui-space-1)));
  border: 0;
  background: none;
  color: var(--ui-fg);
  font-size: var(--ui-text-base);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  text-align: start;
  cursor: pointer;
  list-style: none;
}

.ui-accordion-trigger::-webkit-details-marker {
  display: none;
}

.ui-accordion-trigger::after {
  content: "";
  flex: none;
  width: calc(0.5 * var(--ui-u));
  height: calc(0.5 * var(--ui-u));
  margin-right: 0.2rem; /* a drawn arrow pointing down: the same way in both directions */
  border-right: 1.5px solid var(--ui-fg-muted);
  border-bottom: 1.5px solid var(--ui-fg-muted);
  transform: translateY(-25%) rotate(45deg);
  transition: transform var(--ui-dur) var(--ui-ease-out);
}

.ui-accordion-trigger[data-open]::after,
.ui-accordion-trigger[aria-expanded="true"]::after,
details[open] > .ui-accordion-trigger::after {
  transform: translateY(25%) rotate(-135deg);
}

.ui-accordion-panel {
  height: var(--accordion-panel-height, auto);
  overflow: hidden;
  color: var(--ui-fg-muted);
  transition: height var(--ui-dur) var(--ui-ease-out);
}

.ui-accordion-panel[data-starting-style],
.ui-accordion-panel[data-ending-style] {
  height: 0;
}

.ui-accordion-content {
  padding: 0 max(var(--ui-space-5), calc(var(--ui-pad) - var(--ui-space-1))) var(--ui-space-5);
}

.ui-accordion-panel > .ui-accordion-content {
  transition:
    opacity var(--ui-dur) var(--ui-ease-out),
    translate var(--ui-dur) var(--ui-ease-out);
}

.ui-accordion-panel[data-ending-style] > .ui-accordion-content {
  opacity: 0;
  translate: 0 calc(-1 * var(--ui-space-2));
}

/* Opening: the content was hidden a moment before, so it fades in from its starting style. */
@starting-style {
  .ui-accordion-panel[data-open] > .ui-accordion-content {
    opacity: 0;
    translate: 0 calc(-1 * var(--ui-space-2));
  }
}

/* ── Popups: shared surface for menus, selects and popovers ────────── */

.ui-popup {
  min-width: 10rem;
  max-width: min(24rem, calc(100vw - 1rem));
  margin: 0;
  padding: var(--ui-space-2);
  border: 1px solid var(--ui-float-border);
  border-radius: var(--ui-radius-box);
  background: var(--ui-surface);
  color: var(--ui-fg);
  font-size: var(--ui-text-base);
  box-shadow: var(--ui-shadow-md);
  outline: none;
  transform-origin: var(--transform-origin, top);
  --_from: translateY(-0.5rem) scale(0.98);
  transition:
    opacity var(--ui-dur) var(--ui-ease-out),
    transform var(--ui-dur) var(--ui-ease-out);
}

/* It slides a little from the side it opens on. */
.ui-popup[data-side="top"] { --_from: translateY(0.5rem) scale(0.98); }
.ui-popup[data-side="left"] { --_from: translateX(0.5rem) scale(0.98); }
.ui-popup[data-side="right"] { --_from: translateX(-0.5rem) scale(0.98); }

.ui-popup[data-starting-style],
.ui-popup[data-ending-style] {
  opacity: 0;
  transform: var(--_from);
}

/* Plain HTML: <div popover class="ui-popup">. Opens and closes with the same motion. */
.ui-popup[popover] {
  inset: auto;
  transition:
    opacity var(--ui-dur) var(--ui-ease-out),
    transform var(--ui-dur) var(--ui-ease-out),
    overlay var(--ui-dur) allow-discrete,
    display var(--ui-dur) allow-discrete;
}

.ui-popup[popover]:not(:popover-open) {
  opacity: 0;
  transform: var(--_from);
}

@starting-style {
  .ui-popup[popover]:popover-open {
    opacity: 0;
    transform: var(--_from);
  }
}

/* A popover spaces what is put in it, like a dialog: a title, a line of text, a switch, a field, buttons. */
.ui-popover {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-3);
  padding: var(--ui-space-4);
}

/* A title and the line under it read as one. */
.ui-popover-title + .ui-popover-description {
  margin-top: calc(var(--ui-space-1) - var(--ui-space-3));
}

.ui-popover-title {
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

.ui-popover-description {
  color: var(--ui-fg-muted);
}

/* Select popup: at least as wide as its trigger, scrolls when long. */
.ui-select-popup {
  min-width: var(--anchor-width, 10rem);
  max-height: min(20rem, var(--available-height, 20rem));
  overflow-y: auto;
}

.ui-select-icon {
  flex: none;
  width: calc(1 * var(--ui-u));
  height: calc(1 * var(--ui-u));
  color: var(--ui-fg-muted);
}

.ui-select-value[data-placeholder] {
  color: var(--ui-fg-subtle);
}

.ui-menu-item {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  width: 100%;
  min-height: calc(var(--ui-h-md) - 4px);
  padding: var(--ui-space-2) var(--ui-space-3);
  border: 0;
  border-radius: max(calc(var(--ui-radius-box) - var(--ui-space-2)), var(--ui-radius-sm));
  background: none;
  color: var(--ui-fg);
  font-size: var(--ui-text-base);
  text-align: start;
  text-decoration: none;
  cursor: default;
  user-select: none;
  outline: none;
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    color var(--ui-dur-fast) var(--ui-ease);
}

.ui-menu-item:hover,
.ui-menu-item:focus-visible,
.ui-menu-item[data-highlighted] {
  background: var(--ui-surface-3);
}

.ui-menu-item[data-disabled],
.ui-menu-item:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.ui-menu-item--danger {
  color: var(--ui-danger-text);
}

.ui-menu-item--danger:hover,
.ui-menu-item--danger[data-highlighted] {
  background: var(--ui-danger-soft);
}

.ui-menu-item > svg {
  flex: none;
  width: calc(1 * var(--ui-u));
  height: calc(1 * var(--ui-u));
  color: var(--ui-fg-muted);
}

/* Tick shown on the chosen option of a select. */
.ui-menu-item-check {
  margin-inline-start: auto;
  color: var(--ui-ink);
}

.ui-menu-shortcut {
  margin-inline-start: auto;
  padding-inline-start: var(--ui-space-4);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
  color: var(--ui-fg-subtle);
}

.ui-menu-label {
  padding: var(--ui-space-2) var(--ui-space-3) var(--ui-space-1);
  font-size: var(--ui-text-xs);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  color: var(--ui-fg-muted);
}

.ui-menu-separator {
  height: 1px;
  margin: var(--ui-space-2) calc(var(--ui-space-2) * -1);
  border: 0;
  background: var(--ui-border);
}

/* ── Tooltip ───────────────────────────────────────────────────────── */

.ui-tooltip {
  max-width: 18rem;
  padding: var(--ui-space-1) var(--ui-space-2);
  border-radius: min(var(--ui-radius-sm), 0.5rem);
  background: var(--ui-fg);
  color: var(--ui-bg);
  font-size: var(--ui-text-xs);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1.4;
  transform-origin: var(--transform-origin, center);
  transition:
    opacity var(--ui-dur-fast) var(--ui-ease),
    transform var(--ui-dur-fast) var(--ui-ease);
}

.ui-tooltip[data-starting-style],
.ui-tooltip[data-ending-style] {
  opacity: 0;
  transform: translateY(0.25rem) scale(0.96);
}

/* ── Dialog ────────────────────────────────────────────────────────── */

.ui-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--ui-z-overlay);
  background: var(--ui-overlay);
  transition: opacity var(--ui-dur) var(--ui-ease-out);
}

.ui-backdrop[data-starting-style],
.ui-backdrop[data-ending-style],
.ui-backdrop[data-closed] {
  /* Closed stays hidden: a drawer or sheet slides out for longer than the overlay fades, and the overlay must not
     come back while it does. */
  opacity: 0;
}

.ui-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: var(--ui-z-overlay);
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
  width: min(var(--width, 28rem), calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: 0;
  padding: var(--ui-pad-lg);
  overflow-y: auto;
  border: 1px solid var(--ui-float-border);
  border-radius: var(--ui-radius-xl);
  background: var(--ui-surface);
  color: var(--ui-fg);
  box-shadow: var(--ui-shadow-lg);
  outline: none;
  transform: translate(-50%, -50%);
  transition:
    opacity var(--ui-dur) var(--ui-ease-out),
    transform var(--ui-dur) var(--ui-ease-out);
}

.ui-dialog[data-starting-style],
.ui-dialog[data-ending-style] {
  opacity: 0;
  transform: translate(-50%, calc(-50% + 0.75rem)) scale(0.98);
}

.ui-dialog--wide {
  --width: 40rem;
}

/* Plain HTML: <dialog class="ui-dialog">, opened with showModal(). It opens and closes with the same motion. */
dialog.ui-dialog {
  transition:
    opacity var(--ui-dur) var(--ui-ease-out),
    transform var(--ui-dur) var(--ui-ease-out),
    overlay var(--ui-dur) allow-discrete,
    display var(--ui-dur) allow-discrete;
}

dialog.ui-dialog:not([open]) {
  display: none;
  opacity: 0;
  transform: translate(-50%, calc(-50% + 0.75rem)) scale(0.98);
}

dialog.ui-dialog::backdrop {
  background: var(--ui-overlay);
  transition:
    opacity var(--ui-dur) var(--ui-ease-out),
    overlay var(--ui-dur) allow-discrete,
    display var(--ui-dur) allow-discrete;
}

dialog.ui-dialog:not([open])::backdrop {
  opacity: 0;
}

@starting-style {
  dialog.ui-dialog[open] {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 0.75rem)) scale(0.98);
  }

  dialog.ui-dialog[open]::backdrop {
    opacity: 0;
  }
}

/* Panel that slides in from the right. */
.ui-dialog--drawer {
  top: 0;
  right: 0;
  left: auto;
  width: min(var(--width, 26rem), 100vw);
  height: 100dvh;
  max-height: none;
  border-width: 0 0 0 1px;
  border-radius: 0;
  transform: none;
}

.ui-dialog--drawer,
.ui-dialog--sheet {
  transition-duration: var(--ui-dur-slow);
}

.ui-dialog--drawer[data-starting-style],
.ui-dialog--drawer[data-ending-style] {
  opacity: 1;
  transform: translateX(100%);
}

dialog.ui-dialog--drawer:not([open]) {
  opacity: 1;
  transform: translateX(100%);
}

@starting-style {
  dialog.ui-dialog--drawer[open] {
    opacity: 1;
    transform: translateX(100%);
  }
}

.ui-dialog-header {
  display: grid;
  gap: var(--ui-space-1);
}

.ui-dialog-title {
  margin: 0;
  font-size: var(--ui-text-xl);
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.ui-dialog-description {
  margin: 0;
  color: var(--ui-fg-muted);
}

.ui-dialog-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--ui-space-2);
  margin-top: var(--ui-space-2);
}

/* ── Toast ─────────────────────────────────────────────────────────── */

.ui-toast-viewport {
  position: fixed;
  inset-inline-end: var(--ui-space-4);
  bottom: var(--ui-space-4);
  z-index: var(--ui-z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-2);
  width: min(22rem, calc(100vw - 2rem));
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The toasts sit in a list inside the region (UI SDK's markup): the list keeps them apart, never touching. */
.ui-toast-viewport > :is(ol, ul) {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

/*
 * A toast: a mark for its kind (success, info, warning, error, loading; none for a plain message), the title and a
 * line under it, and an action at the end. No close button: it leaves by itself, or is swiped away, and the thin line
 * along its foot runs down with the time it has left. The kind is told by the mark; the words stay in the text colour.
 */
.ui-toast {
  --toast-tone: var(--ui-fg-muted);
  --toast-soft: var(--ui-surface-2);
  position: relative;
  display: grid;
  grid-template-areas: "title action";
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: var(--ui-pad-sm) calc(var(--ui-pad-sm) + var(--ui-space-1));
  border: 1px solid var(--ui-float-border);
  border-radius: var(--ui-radius-box);
  background: var(--ui-surface);
  color: var(--ui-fg);
  box-shadow: var(--ui-shadow-md);
  user-select: none;
  transition:
    opacity var(--ui-dur) var(--ui-ease-out),
    transform var(--ui-dur) var(--ui-ease-out);
}

/*
 * One row for a title alone, so it sits on the middle of the mark; a second only when there is a line under it. The
 * two lines keep together in the middle, whatever the mark's height (the title leans down, the line up).
 */
.ui-toast:has(> .ui-toast-description:not(:empty)) {
  grid-template-areas: "title action" "text action";
}

.ui-toast:has(> .ui-toast-mark) {
  grid-template-areas: "mark title action";
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.ui-toast:has(> .ui-toast-mark):has(> .ui-toast-description:not(:empty)) {
  grid-template-areas: "mark title action" "mark text action";
}

.ui-toast:has(> .ui-toast-description:not(:empty)) > .ui-toast-title { align-self: end; }
.ui-toast:has(> .ui-toast-description:not(:empty)) > .ui-toast-description { align-self: start; }

/* The kind's colours, on the toast and on a mark shown anywhere else (a list of what happened). */
:is(.ui-toast, .ui-toast-mark)[data-type="success"] { --toast-tone: var(--ui-success-text); --toast-soft: var(--ui-success-soft); }
:is(.ui-toast, .ui-toast-mark)[data-type="info"] { --toast-tone: var(--ui-info-text); --toast-soft: var(--ui-info-soft); }
:is(.ui-toast, .ui-toast-mark)[data-type="warning"] { --toast-tone: var(--ui-warning-text); --toast-soft: var(--ui-warning-soft); }
:is(.ui-toast, .ui-toast-mark)[data-type="error"] { --toast-tone: var(--ui-danger-text); --toast-soft: var(--ui-danger-soft); }

.ui-toast[data-starting-style],
.ui-toast[data-ending-style] {
  opacity: 0;
  transform: translateY(0.75rem);
}

/* Swiped away: it follows the finger, then leaves the way it was pushed. */
.ui-toast[data-swiping] {
  transform: translate(var(--toast-swipe-x, 0px), var(--toast-swipe-y, 0px));
  transition: none;
}

.ui-toast[data-ending-style][data-swipe-direction="right"] { transform: translateX(110%); }
.ui-toast[data-ending-style][data-swipe-direction="left"] { transform: translateX(-110%); }
.ui-toast[data-ending-style][data-swipe-direction="down"] { transform: translateY(110%); }

.ui-toast-mark {
  grid-area: mark;
  position: relative;
  display: grid;
  place-items: center;
  width: var(--ui-h-sm);
  height: var(--ui-h-sm);
  flex: none;
  border-radius: var(--ui-radius-round);
  background: var(--toast-soft);
  color: var(--toast-tone);
}

.ui-toast > .ui-toast-mark {
  margin-inline-end: var(--ui-space-3);
}

.ui-toast-mark .ui-icon {
  width: 1rem;
  height: 1rem;
}

.ui-toast-mark .ui-spinner {
  width: 0.95rem;
  height: 0.95rem;
}

.ui-toast-title {
  grid-area: title;
  margin: 0;
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: var(--ui-leading-tight);
}

.ui-toast-description {
  grid-area: text;
  margin: 0.2em 0 0;
  font-size: var(--ui-text-sm);
  line-height: var(--ui-leading-tight);
  color: var(--ui-fg-muted);
}

.ui-toast-description:empty {
  display: none;
}

.ui-toast-action {
  grid-area: action;
  margin-inline-start: var(--ui-space-3);
}

/*
 * The time left: a thin ring round the mark that runs down like a clock hand. It waits whenever the timer waits. A
 * plain message (no mark) shows none.
 */

.ui-toast[data-timed] > .ui-toast-mark::before {
  content: "";
  position: absolute;
  inset: -3px;
  padding: 2px;
  border-radius: var(--ui-radius-round);
  /* The coloured part sits at the end of the turn, so it runs down clockwise. */
  background: conic-gradient(transparent calc(100% - var(--toast-left)), color-mix(in oklab, var(--toast-tone) 55%, transparent) 0);
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: ui-toast-time var(--ui-toast-time, 5s) linear forwards;
}

:is(.ui-toast-viewport[data-expanded], .ui-toast-viewport[data-ui-paused], .ui-toast-viewport:hover, .ui-toast-viewport:focus-within) .ui-toast > .ui-toast-mark::before,
.ui-toast[data-swiping] > .ui-toast-mark::before {
  animation-play-state: paused;
}

@keyframes ui-toast-time {
  from { --toast-left: 100%; }
  to { --toast-left: 0%; }
}

@media (prefers-reduced-motion: reduce) {
  .ui-toast[data-timed] > .ui-toast-mark::before {
    display: none;
  }
}

/* ── Lists ─────────────────────────────────────────────────────────── */

/* Rows with a divider between them (settings, people, files). */
.ui-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
}

.ui-list-item {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  min-width: 0;
  padding: var(--ui-space-4) max(var(--ui-space-5), calc(var(--ui-pad) - var(--ui-space-1)));
  transition: opacity var(--ui-dur) var(--ui-ease);
}

/* The text that takes the room never gets narrower than its longest word: where the row cannot hold it (a phone),
   what follows it (a select, a button) goes under it instead of the word running out of its box. */
.ui-list-item {
  flex-wrap: wrap;
}

.ui-list-item > .ui-grow:not(.ui-truncate) {
  min-width: min-content;
}

/* A row that is dealt with: bought, sent, done. It stays, quieter. */
.ui-list-item[data-done] {
  opacity: 0.55;
}

/* The first and last rows sit in the list's corners, so they get the corner's room. */
.ui-list-item:first-child {
  padding-top: max(var(--ui-space-4), calc(var(--ui-pad) * 0.7));
}

.ui-list-item:last-child {
  padding-bottom: max(var(--ui-space-4), calc(var(--ui-pad) * 0.7));
}

.ui-list-item + .ui-list-item {
  border-top: 1px solid var(--ui-border);
}

/* ── Helpers the React components use ──────────────────────────────── */

/* Keeps menus, selects, popovers and tooltips above the page and dialogs. */
.ui-positioner {
  z-index: var(--ui-z-popup);
  outline: none;
}

/* ── Slider (React): the same look as .ui-range, made of parts ─────── */

.ui-slider {
  display: block;
  width: 100%;
}

/* Where presses land: as tall as the thumb's row, with the rail drawn across its whole width. */
.ui-slider-control {
  position: relative;
  display: flex;
  align-items: center;
  height: calc(1.25 * var(--ui-u));
  padding-inline: calc(0.5 * var(--ui-u));
  cursor: pointer;
  touch-action: none;
}

.ui-slider-control::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  height: 4px;
  border-radius: var(--ui-radius-full);
  background: var(--ui-well-bg, var(--ui-surface-3));
  box-shadow: var(--ui-well-shadow);
}

/* The thumb travels along this, half a thumb in from each end, so it never hangs over the rail. */
.ui-slider-track {
  position: relative;
  flex: 1;
  height: 4px;
}

/* The filled part, carried back to the rail's start. */
.ui-slider-fill {
  height: 4px;
  border-radius: var(--ui-radius-full);
  background: var(--ui-chosen-fill) var(--ui-ink);
  box-shadow: calc(-0.5 * var(--ui-u)) 0 0 0 var(--ui-ink);
}

.ui-slider-thumb {
  top: 50%;
  width: calc(1 * var(--ui-u));
  height: calc(1 * var(--ui-u));
  border: 1px solid var(--ui-knob-border);
  border-radius: var(--ui-radius-full);
  background: var(--ui-knob-bg);
  box-shadow: var(--ui-knob-shadow);
  translate: -50% -50%;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color var(--ui-dur-fast) var(--ui-ease), scale var(--ui-dur-fast) var(--ui-ease);
}

/* The thumb grows while the hand is on the slider or moving it, so it is clearly the thing that moves. */
.ui-slider:not([data-disabled]) .ui-slider-control:is(:hover, :active) .ui-slider-thumb,
.ui-slider-thumb[data-dragging] {
  scale: var(--ui-knob-grow);
}

.ui-slider-thumb:has(:focus-visible) {
  outline-color: var(--ui-ring);
}

.ui-slider[data-disabled] {
  opacity: 0.5;
}

/* A slider for a hue: the rail is the rainbow, and there is nothing to fill. */
.ui-slider--hue .ui-slider-control::before {
  background: linear-gradient(to right in oklch longer hue, oklch(0.7 0.16 0), oklch(0.7 0.16 360));
}

.ui-slider--hue .ui-slider-fill {
  background: none;
  box-shadow: none;
}

/* ── Sortable: rows put in order by dragging, or with the keyboard ──── */

.ui-sortable {
  /* Rows measure their place from the list, to slide between orders. */
  position: relative;
  display: grid;
  gap: var(--ui-space-2);
}

.ui-sortable-item {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  min-width: 0;
  padding: var(--ui-space-3) var(--ui-space-4);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-box);
  background: var(--ui-surface);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition:
    border-color var(--ui-dur-fast) var(--ui-ease),
    background-color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur) var(--ui-ease-out),
    scale var(--ui-dur) var(--ui-ease-out),
    /* When it is let go, the row glides from the pointer into its place. */
    transform var(--ui-dur) var(--ui-ease-out);
}

.ui-sortable-item:hover {
  border-color: var(--ui-border-hover);
}

.ui-sortable-grip {
  color: var(--ui-fg-subtle);
}

/* Picked up: lifted off the list, and following the pointer while it is dragged. */
.ui-sortable-item[data-grabbed] {
  position: relative;
  z-index: 1;
  border-color: var(--ui-highlight);
  background: var(--ui-surface-2);
  box-shadow: var(--ui-shadow-md);
}

.ui-sortable-item[data-dragging] {
  z-index: 2;
  transform: translate(var(--drag-x, 0), var(--drag-y, 0));
  scale: 1.02;
  box-shadow: var(--ui-shadow-lg);
  cursor: grabbing;
  /* It follows the pointer exactly; only its look eases. */
  transition:
    box-shadow var(--ui-dur) var(--ui-ease-out),
    scale var(--ui-dur) var(--ui-ease-out);
}

/* ── Tree: things inside things ────────────────────────────────────── */

.ui-tree {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ui-tree-item {
  display: grid;
  gap: 2px;
  min-width: 0;
  outline: none;
}

/* A row steps in once for each level it is deep. */
.ui-tree-row {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  min-width: 0;
  padding: var(--ui-space-2) var(--ui-space-3);
  padding-inline-start: calc(var(--ui-space-2) + (var(--tree-level, 1) - 1) * var(--ui-space-5));
  border-radius: var(--ui-radius-sm);
  outline: 2px solid transparent;
  outline-offset: -2px;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    color var(--ui-dur-fast) var(--ui-ease),
    outline-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-tree-row:hover {
  background: var(--ui-surface-2);
}

.ui-tree-row[data-selected] {
  background: var(--ui-ink-soft);
  color: var(--ui-fg);
}

.ui-tree-item:focus-visible > .ui-tree-row {
  outline-color: var(--ui-ring);
}

/* The arrow of a branch; a leaf keeps the same room, so labels line up. */
.ui-tree-indicator {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.15em;
  color: var(--ui-fg-muted);
}

.ui-tree-indicator > * {
  display: grid;
  transition: rotate var(--ui-dur-fast) var(--ui-ease);
}

.ui-tree-indicator > [data-expanded] {
  rotate: 90deg;
}

.ui-tree-group {
  display: grid;
  gap: 2px;
  height: var(--tree-group-height, auto);
  overflow: hidden;
  transition: height var(--ui-dur) var(--ui-ease);
}

.ui-tree-group[data-starting-style],
.ui-tree-group[data-ending-style] {
  height: 0;
}

/* A branch that opens with open branches inside it: only the outer one grows, so its full height is known from the start. */
.ui-tree-group[data-starting-style] .ui-tree-group {
  height: auto;
  transition: none;
}

/* ── Colour picker ─────────────────────────────────────────────────── */

.ui-color {
  display: grid;
  gap: var(--ui-space-3);
  width: min(100%, 16rem);
}

.ui-color-area {
  position: relative;
  min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
  aspect-ratio: 4 / 3;
  cursor: crosshair;
  touch-action: none;
}

/*
 * The square and the hue line paint on a layer of their own, cut to its corners in one go (clip-path),
 * so the stacked gradients never show coloured slivers at the rounded edges. A faint inner line keeps
 * light colours apart from the card. The dot stays outside the cut and can reach the edges.
 */
.ui-color-area::before,
.ui-color-slider::before {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px oklch(0 0 0 / 0.08);
  pointer-events: none;
}

.ui-color-area::before {
  background: var(--color-area-background);
  clip-path: inset(0 round var(--ui-radius-sm));
}

.ui-color-slider {
  --color-slider-end: calc(0.5 * var(--ui-u));
  position: relative;
  height: calc(0.75 * var(--ui-u));
  margin-inline: var(--color-slider-end);
  cursor: pointer;
  touch-action: none;
}

/* The line runs half a dot past each end, so the dot sits inside it at red on both sides. */
.ui-color-slider::before {
  inset-inline: calc(-1 * var(--color-slider-end));
  /* Always the full rainbow, whatever the colour's brightness: the line shows which hue, the square shows the rest. */
  background: linear-gradient(
    to right,
    hsl(0 100% 50%) var(--color-slider-end),
    hsl(60 100% 50%) calc(var(--color-slider-end) + (100% - 2 * var(--color-slider-end)) / 6),
    hsl(120 100% 50%) calc(var(--color-slider-end) + (100% - 2 * var(--color-slider-end)) * 2 / 6),
    hsl(180 100% 50%) calc(var(--color-slider-end) + (100% - 2 * var(--color-slider-end)) * 3 / 6),
    hsl(240 100% 50%) calc(var(--color-slider-end) + (100% - 2 * var(--color-slider-end)) * 4 / 6),
    hsl(300 100% 50%) calc(var(--color-slider-end) + (100% - 2 * var(--color-slider-end)) * 5 / 6),
    hsl(360 100% 50%) calc(100% - var(--color-slider-end))
  );
  clip-path: inset(0 round var(--ui-radius-full));
}

.ui-color-area > .ui-color-thumb,
.ui-color-slider > .ui-color-thumb {
  z-index: 1;
}

/* The dot that marks the colour, in the square and on the hue line. */
.ui-color-thumb {
  width: calc(1 * var(--ui-u));
  height: calc(1 * var(--ui-u));
  border: 2px solid oklch(1 0 0);
  border-radius: var(--ui-radius-full);
  background: var(--color-picker-color);
  box-shadow: 0 0 0 1px oklch(0 0 0 / 0.25), var(--ui-shadow-sm);
  translate: -50% -50%;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-color-slider > .ui-color-thumb {
  top: 50%;
}

.ui-color-thumb:has(:focus-visible),
.ui-color-thumb:focus-visible {
  outline-color: var(--ui-ring);
}

.ui-color-swatch {
  flex: none;
  width: calc(1.25 * var(--ui-u));
  height: calc(1.25 * var(--ui-u));
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-sm);
  background: var(--color-picker-color);
  box-shadow: inset 0 0 0 1px oklch(0 0 0 / 0.12);
}

.ui-color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-space-2);
}

.ui-color-swatches > .ui-color-swatch {
  cursor: pointer;
  transition: box-shadow var(--ui-dur-fast) var(--ui-ease);
}

.ui-color-swatches > .ui-color-swatch:hover,
.ui-color-swatches > .ui-color-swatch[data-selected] {
  box-shadow:
    0 0 0 2px var(--ui-surface),
    0 0 0 4px var(--ui-border-strong);
}

/* ── Image cropper ─────────────────────────────────────────────────── */

.ui-cropper {
  display: grid;
  gap: var(--ui-space-3);
  min-width: 0;
}

.ui-cropper-viewport {
  width: 100%;
  /* A fixed box: the picture is fitted inside it, so turning the picture never moves the page. */
  min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
  aspect-ratio: 4 / 3;
  border-radius: var(--ui-radius-nested);
  background: var(--ui-surface-3);
}

.ui-cropper-viewport img {
  max-width: none;
  user-select: none;
}

/* The part that is kept; everything outside it is dimmed. */
.ui-cropper-selection {
  outline: 1px solid oklch(1 0 0 / 0.9);
  box-shadow: 0 0 0 100vmax oklch(0 0 0 / 0.5);
  cursor: move;
  touch-action: none;
}

.ui-cropper-selection[data-shape="circle"] {
  border-radius: var(--ui-radius-full);
}

.ui-cropper-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(oklch(1 0 0 / 0.5) 1px, transparent 1px),
    linear-gradient(90deg, oklch(1 0 0 / 0.5) 1px, transparent 1px);
  background-size: 100% 33.34%, 33.34% 100%;
  opacity: 0;
  transition: opacity var(--ui-dur-fast) var(--ui-ease);
}

.ui-cropper-selection[data-dragging] > .ui-cropper-grid,
.ui-cropper-grid[data-dragging] {
  opacity: 1;
}

/* A corner to pull. UI SDK puts each one on its corner of the frame (a point); the kit gives it a size and centres it there. */
.ui-cropper-handle {
  position: absolute;
  width: calc(0.875 * var(--ui-u));
  height: calc(0.875 * var(--ui-u));
  border: 1px solid oklch(0 0 0 / 0.3);
  border-radius: var(--ui-radius-sm);
  background: oklch(1 0 0);
  translate: -50% -50%;
  touch-action: none;
}

.ui-cropper-handle--nw,
.ui-cropper-handle--se { cursor: nwse-resize; }
.ui-cropper-handle--ne,
.ui-cropper-handle--sw { cursor: nesw-resize; }

/* ── Resizable panels ──────────────────────────────────────────────── */

.ui-resizable {
  display: flex;
  width: 100%;
  min-height: 12rem;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
}

.ui-resizable[data-orientation="vertical"] {
  flex-direction: column;
}

.ui-resizable-frame {
  min-width: 0;
}

/* Straight in a card, the card is the frame: no second border inside it. */
.ui-card > .ui-resizable-frame > .ui-resizable {
  border: 0;
  border-radius: inherit;
  background: none;
}

/* Narrower than a phone held upright: the panels stack at their own height (ResizablePanels sets data-stacked). */
.ui-resizable[data-stacked] {
  flex-direction: column !important;
  min-height: 0;
}

.ui-resizable[data-stacked] > .ui-resizable-panel {
  flex: none !important;
  overflow: visible;
}

.ui-resizable[data-stacked] > .ui-resizable-handle {
  width: auto;
  height: 1px;
  cursor: auto;
}

.ui-resizable-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

/* The bar between two panels: a line, with a wider invisible strip to catch the pointer. */
.ui-resizable-handle {
  position: relative;
  flex: none;
  width: 1px;
  background: var(--ui-border);
  cursor: col-resize;
  outline: 2px solid transparent;
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    outline-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-resizable-handle[data-orientation="vertical"] {
  width: auto;
  height: 1px;
  cursor: row-resize;
}

.ui-resizable-handle::after {
  content: "";
  position: absolute;
  inset: 0 calc(var(--ui-space-1) * -1);
}

.ui-resizable-handle[data-orientation="vertical"]::after {
  inset: calc(var(--ui-space-1) * -1) 0;
}

.ui-resizable-handle[data-hovering],
.ui-resizable-handle[data-dragging] {
  background: var(--ui-highlight);
}

.ui-resizable-handle:focus-visible {
  outline-color: var(--ui-ring);
}

/* A radio group adds no box: the radios sit in whatever row or stack is around them. */
.ui-radio-group {
  display: contents;
}

/* Hue slider: the track shows the colours it picks from. */
.ui-range--hue::-webkit-slider-runnable-track {
  background: linear-gradient(to right in oklch longer hue, oklch(0.7 0.16 0), oklch(0.7 0.16 360));
}

.ui-range--hue::-moz-range-track {
  background: linear-gradient(to right in oklch longer hue, oklch(0.7 0.16 0), oklch(0.7 0.16 360));
}

/* ── Icons ─────────────────────────────────────────────────────────── */

/*
 * Lucide line icons. They take the colour of the text around them and their
 * line weight from the text beside them (--ui-icon-stroke × --ui-icon-weight). Works on <Icon>, on any lucide-react
 * icon, and on <svg class="ui-icon"><use href="/icons.svg#search" /></svg>.
 */
.ui-icon,
svg.lucide {
  display: inline-block;
  flex: none;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.2em;
  fill: none;
  stroke: currentColor;
  /* As heavy as the text beside it (tokens.css): the theme's weight for regular text, times the text's weight. */
  stroke-width: calc(var(--ui-icon-stroke) * var(--ui-icon-weight, 1));
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ui-icon--sm { width: 1em; height: 1em; }
.ui-icon--lg { width: calc(1.5 * var(--ui-u)); height: calc(1.5 * var(--ui-u)); }
.ui-icon--xl { width: calc(2 * var(--ui-u)); height: calc(2 * var(--ui-u)); }

/* The "on" state of a line icon (a filled star, a pinned pin). */
.ui-icon--solid {
  fill: currentColor;
}

/* An icon in a soft square, for feature lists, empty states and stat tiles. */
.ui-icon-tile {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--ui-h-md);
  height: var(--ui-h-md);
  border-radius: var(--ui-radius-md);
  background: var(--ui-primary-soft);
  color: var(--ui-primary-text);
}

.ui-menu-item .ui-icon,
.ui-menu-item svg.lucide {
  width: 1rem;
  height: 1rem;
}

/*
 * Right to left: an icon that points along the line (a chevron or arrow to the side, "next", "back") turns round, so
 * "next" still points the way the text runs. The kit's own arrows turn by themselves; give any other such icon
 * ui-icon--flip. Icons that do not point along the line (up, down, a tick, a search glass) stay as they are.
 */
:dir(rtl) :is(.ui-icon--flip, .ui-icon:has(> path[d="m9 18 6-6-6-6"], > path[d="m15 18-6-6 6-6"], > path[d="m12 5 7 7-7 7"], > path[d="m12 19-7-7 7-7"]), .ui-icon:has(use[href$="#chevron-right"], use[href$="#chevron-left"], use[href$="#arrow-right"], use[href$="#arrow-left"], use[href$="#chevrons-right"], use[href$="#chevrons-left"])) {
  scale: -1 1;
}

/* ── Chips ─────────────────────────────────────────────────────────── */

/*
 * A pill for a category, a filter or a tag, with an optional icon.
 * Colour it with a hue: class="ui-chip ui-chip--tone" style="--tone: 150".
 * The chosen one: aria-pressed="true" (a button) or a checked input inside.
 */
.ui-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-2);
  height: var(--ui-h-md);
  padding: 0 var(--ui-space-4);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface);
  color: var(--ui-fg);
  font-family: var(--ui-font-sans);
  font-size: var(--ui-text-base);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    color var(--ui-dur-fast) var(--ui-ease),
    border-color var(--ui-dur-fast) var(--ui-ease);
}

button.ui-chip,
a.ui-chip,
label.ui-chip {
  cursor: pointer;
}

button.ui-chip:hover,
a.ui-chip:hover,
label.ui-chip:hover {
  border-color: var(--ui-border-hover);
}

.ui-chip--sm {
  height: var(--ui-h-sm);
  padding: 0 var(--ui-space-3);
  font-size: var(--ui-text-sm);
}

/* A colour of its own, from a hue (0–360). Readable in light and dark. */
.ui-chip--tone,
.ui-icon-tile--tone {
  border-color: transparent;
  background: light-dark(oklch(0.87 0.1 var(--tone, 250)), oklch(0.42 0.1 var(--tone, 250)));
  color: light-dark(oklch(0.27 0.06 var(--tone, 250)), oklch(0.96 0.03 var(--tone, 250)));
}

.ui-chip[aria-pressed="true"],
.ui-chip[aria-current="true"],
.ui-chip:has(input:checked) {
  border-color: transparent;
  background: var(--ui-chosen-fill) var(--ui-ink);
  color: var(--ui-on-ink);
}

.ui-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ui-chip:has(input:focus-visible) {
  outline: 2px solid var(--ui-ring);
  outline-offset: 2px;
}

/* ── Cells: label over value, side by side ─────────────────────────── */

.ui-cells {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(7.5rem, 100%), 1fr));
  gap: var(--ui-space-1);
}

/* EvenRows sets --cols: the cells share the rows evenly, and a last row with fewer of them fills its width. */
.ui-cells[style*="--cols"] {
  display: flex;
  flex-wrap: wrap;
}

.ui-cells[style*="--cols"] > * {
  flex: 1 1 calc((100% - (var(--cols) - 1) * var(--ui-space-1)) / var(--cols));
}

.ui-cell {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: var(--ui-space-2) var(--ui-space-3);
  border: 1px solid var(--ui-border);
  border-radius: calc(var(--ui-radius) * 0.6);
  background: var(--ui-surface-2);
  font-size: var(--ui-text-sm);
  line-height: 1.35;
}

.ui-cell-label {
  color: var(--ui-fg-muted);
}

/* ── Inset: a quieter panel inside a card ──────────────────────────── */

.ui-inset {
  min-width: 0;
  padding: var(--ui-space-5);
  border-radius: max(calc(var(--ui-radius-lg) - var(--ui-space-2)), var(--ui-radius-sm));
  background: var(--ui-surface-2);
}

.ui-card > .ui-inset {
  margin: var(--ui-space-2);
}

/* ── Figure: one very large, light number ──────────────────────────── */

.ui-figure {
  white-space: nowrap;
  font-size: calc(clamp(3rem, 9vw, 5.5rem) * var(--ui-text-scale));
  font-weight: 400;
  --ui-icon-weight: 1;
  line-height: 0.9;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
}

.ui-figure--sm {
  font-size: calc(clamp(2.25rem, 6vw, 3.5rem) * var(--ui-text-scale));
}

/* ── Avatar group ──────────────────────────────────────────────────── */

.ui-avatar-group {
  display: inline-flex;
}

.ui-avatar-group .ui-avatar {
  box-shadow: 0 0 0 2px var(--ui-surface);
}

.ui-avatar-group .ui-avatar + .ui-avatar {
  margin-inline-start: calc(-0.5 * var(--ui-u));
}

/* ── Hatch and bars ────────────────────────────────────────────────── */

/* Diagonal lines in the text colour: a placeholder, a forecast, "not yet". */
.ui-hatch {
  border: 1px solid color-mix(in oklab, currentColor 40%, transparent);
  background-color: transparent;
  background-image: repeating-linear-gradient(
    135deg,
    color-mix(in oklab, currentColor 40%, transparent) 0 1px,
    transparent 1px 8px
  );
}

/* A small bar chart: each bar's height from --value (0–100). */
.ui-bars {
  display: flex;
  align-items: flex-end;
  gap: var(--ui-space-2);
  height: var(--height, 8rem);
}

/* A short name under each bar (Bars labels). */
.ui-bars-labels {
  display: flex;
  gap: var(--ui-space-2);
  margin-top: var(--ui-space-2);
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-xs);
}

.ui-bars-labels > * {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.ui-bar {
  flex: 1;
  height: calc(var(--value, 0) * 1%);
  min-height: var(--ui-space-2);
  border-radius: min(var(--ui-radius-md), 1rem);
  background: var(--ui-surface-3);
  color: var(--ui-fg-subtle);
  transition: height var(--ui-dur-slow) var(--ui-ease-out);
}

.ui-bar--primary {
  background: var(--ui-primary);
}

.ui-bar.ui-hatch {
  background-color: transparent;
  background-image: repeating-linear-gradient(
    135deg,
    color-mix(in oklab, currentColor 40%, transparent) 0 1px,
    transparent 1px 8px
  );
}

.ui-icon-tile--round {
  border-radius: var(--ui-radius-round);
}

/* ── Patterns: painted pictures where a tool needs an image ────────── */

/*
 * A painted wash, made from a word (the seed) and the theme's colours.
 * The same seed always paints the same picture. React: <Pattern seed="…">.
 * Plain HTML: <div class="ui-pattern" data-pattern="…"> with supply-pattern.js.
 * Until it is painted (or without WebGL) it shows a soft gradient.
 */
.ui-pattern {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: linear-gradient(135deg, var(--ui-primary-soft), var(--ui-surface-3));
}

.ui-pattern > canvas {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  transition: opacity var(--ui-dur-slow) var(--ui-ease);
}

/* The painting comes once scripts run, after the page is on screen: it fades in over the soft gradient (rule 14). */
@starting-style {
  .ui-pattern > canvas {
    opacity: 0;
  }
}

/* A picture at the top of a card. */
.ui-card-cover {
  min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
  aspect-ratio: var(--ratio, 16 / 9);
  margin: var(--ui-space-2) var(--ui-space-2) 0;
  border-radius: max(calc(var(--ui-radius-lg) - var(--ui-space-2)), var(--ui-radius-sm));
}

.ui-card-cover > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* A picture on its own (Picture): the cover's frame without the card, so a picture never needs a card round it. */
.ui-picture {
  min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
  aspect-ratio: var(--ratio, 4 / 3);
  border-radius: var(--ui-radius-lg);
}

.ui-picture > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ══ Second tier ═══════════════════════════════════════════════════ */

/* ── Input group: a field with an icon, a unit or a button inside ──── */

.ui-input-group {
  display: flex;
  box-shadow: var(--ui-field-shadow), 0 0 0 1px transparent;
  align-items: center;
  gap: var(--ui-space-2);
  width: 100%;
  height: var(--ui-h-md);
  padding: 0 var(--ui-space-4);
  border: 1px solid var(--ui-field-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-field-bg);
  color: var(--ui-fg);
  font-size: var(--ui-text-base);
  transition:
    border-color var(--ui-dur-fast) var(--ui-ease),
    background-color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur-fast) var(--ui-ease);
}

.ui-input-group:hover {
  border-color: var(--ui-border-hover);
}

.ui-input-group:focus-within {
  border-color: var(--ui-highlight);
  background: var(--ui-surface);
  box-shadow: var(--ui-field-shadow), 0 0 0 3px var(--ui-focus-halo);
}

/* The field shows the focus, so what is inside it does not show it again. */
.ui-input-group > input:focus,
.ui-input-group > input:focus-visible {
  outline: none;
  box-shadow: none;
}

.ui-input-group:has([aria-invalid="true"]),
.ui-input-group[data-invalid] {
  border-color: var(--ui-danger-text);
}

.ui-input-group:has(input:disabled) {
  opacity: 0.55;
}

/*
 * The text fields share the field's width. `width: 0` keeps a browser's own input width (about 20 letters) out of the
 * field's size, so a field with two inputs (a date range) still fits a phone instead of pushing the page sideways.
 */
.ui-input-group > input {
  flex: 1;
  width: 0;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  outline: none;
  color: inherit;
  font-family: var(--ui-font-sans);
  font-size: inherit;
}

.ui-input-group > input::placeholder {
  color: var(--ui-fg-subtle);
  opacity: 1;
}

.ui-input-group > .ui-icon,
.ui-input-group > svg.lucide,
.ui-input-group-text {
  flex: none;
  color: var(--ui-fg-muted);
}

/* A small button at either end sits as far from the side as from the top and bottom, whatever the field's padding. */
.ui-input-group > .ui-btn:last-child {
  margin-inline-end: calc((var(--ui-h-md) - var(--ui-h-sm)) / 2 - 1px - var(--field-pad, var(--ui-space-4)));
}

.ui-input-group > .ui-btn:first-child {
  margin-inline-start: calc((var(--ui-h-md) - var(--ui-h-sm)) / 2 - 1px - var(--field-pad, var(--ui-space-4)));
}

/* Number field: minus, the number, plus. The number keeps room for all its digits (--chars, set by NumberInput), so it
   is never cut, even in a table cell or a tight row that sizes the field by what is in it. */
.ui-number > input {
  flex: 1 0 auto;
  min-width: calc(var(--chars, 3) * 1ch + var(--ui-space-2));
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/*
 * A text field or a select in a table cell keeps a field's width. A table sizes its columns by what is in them, and a
 * field has no width of its own there, so without this it would shrink to an empty pill on a phone. The table scrolls
 * sideways instead (Table).
 */
.ui-table td > :is(input.ui-input, .ui-input-group:not(.ui-number), button.ui-input) {
  min-width: 10rem;
}

/* Beside a label in a row, a stepper keeps at least a stepper's width, so the label keeps its room. */
.ui-row .ui-number {
  width: auto;
  min-width: 8.5rem;
}

/* A select beside a label in a row or a list row is as wide as what it shows, not the whole row, so the label is never squeezed or covered. */
:is(.ui-row, .ui-list-item, .ui-form-row, .ui-toolbar) > button.ui-input {
  flex: 0 0 auto;
  width: auto;
  min-width: 8rem;
  max-width: 60%;
}

.ui-row > :has(> .ui-number) {
  flex: none;
}

/*
 * A text field in a row with its button (an email and "Sign up", a search and "Go") fills the room the button leaves,
 * instead of taking the whole line and pushing the button under it. Below about 12rem it goes onto a line of its own.
 */
.ui-row > :is(.ui-input-group:not(.ui-number), input.ui-input) {
  flex: 1 1 12rem;
  width: auto;
}

.ui-menu-empty {
  padding: var(--ui-space-3);
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-sm);
  text-align: center;
}

/* The "nothing found" line stays in the page for screen readers; it takes no room while it has nothing to say. */
.ui-menu-empty:empty {
  display: none;
}

/* ── File drop ─────────────────────────────────────────────────────── */

.ui-filedrop {
  display: grid;
  justify-items: center;
  gap: var(--ui-space-2);
  padding: var(--ui-space-8) var(--ui-space-6);
  border: 1px dashed var(--ui-border-strong);
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface-2);
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-base);
  text-align: center;
  cursor: pointer;
  transition:
    border-color var(--ui-dur-fast) var(--ui-ease),
    background-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-filedrop:hover,
.ui-filedrop[data-dragging],
.ui-filedrop:focus-within {
  border-color: var(--ui-primary-text);
  background: var(--ui-primary-soft);
}

.ui-filedrop input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.ui-filedrop-title {
  color: var(--ui-fg);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

/* ── Choice cards: a radio or checkbox as a whole card ─────────────── */

.ui-choice {
  display: flex;
  box-shadow: 0 0 0 1px transparent;
  align-items: flex-start;
  gap: var(--ui-space-3);
  padding: var(--ui-space-4);
  border: 1px solid var(--ui-border);
  border-radius: calc(var(--ui-radius) * 0.9);
  background: var(--ui-surface);
  cursor: pointer;
  transition:
    border-color var(--ui-dur-fast) var(--ui-ease),
    background-color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur-fast) var(--ui-ease);
}

.ui-choice:hover {
  border-color: var(--ui-border-hover);
}

.ui-choice:has(input:checked),
.ui-choice:has([data-checked]) {
  border-color: var(--ui-ink);
  background: var(--ui-surface-2);
  box-shadow: 0 0 0 1px var(--ui-ink);
}

.ui-choice input:focus-visible {
  outline: none;
}

.ui-choice :is(.ui-radio, .ui-checkbox):focus-visible {
  outline: none;
}

.ui-choice:has(input:focus-visible),
.ui-choice:has(:is(.ui-radio, .ui-checkbox):focus-visible) {
  outline: 2px solid var(--ui-ring);
  outline-offset: 2px;
}

.ui-choice-text {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.ui-choice-title {
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

.ui-choice-description {
  font-size: var(--ui-text-sm);
  color: var(--ui-fg-muted);
}

/* ── Form layout ───────────────────────────────────────────────────── */

.ui-fieldset {
  display: grid;
  gap: var(--ui-space-4);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

/* A legend is not a grid item, so the fieldset's gap does not reach it: it keeps its own space. */
.ui-legend {
  padding: 0;
  margin-bottom: var(--ui-space-3);
  font-size: var(--ui-text-md);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

/* A settings row: what it is on the left, the control on the right. */
.ui-form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-2) var(--ui-space-6);
  padding-block: var(--ui-space-4);
}

.ui-form-row + .ui-form-row {
  border-top: 1px solid var(--ui-border);
}

.ui-form-row-text {
  display: grid;
  flex: 1 1 14rem;
  gap: 2px;
  min-width: 0;
}

/* ── Steps ─────────────────────────────────────────────────────────── */

.ui-steps {
  container: ui-steps / inline-size;
  display: flex;
  gap: var(--ui-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: ui-step;
}

.ui-step {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--ui-space-2);
  min-width: 0;
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  white-space: nowrap;
  counter-increment: ui-step;
  transition: color var(--ui-dur-fast) var(--ui-ease);
}

.ui-step::before {
  content: counter(ui-step);
  display: grid;
  place-items: center;
  flex: none;
  width: calc(1.75 * var(--ui-u));
  height: calc(1.75 * var(--ui-u));
  border-radius: var(--ui-radius-round);
  background: var(--ui-surface-3);
  color: var(--ui-fg);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    color var(--ui-dur-fast) var(--ui-ease);
}

.ui-step::after {
  content: "";
  flex: 1;
  min-width: var(--ui-space-3);
  height: 1px;
  background: var(--ui-border);
}

.ui-step:last-child {
  flex: none;
}

.ui-step:last-child::after {
  display: none;
}

.ui-step[data-done]::before {
  content: "✓";
}

.ui-step[aria-current="step"] {
  color: var(--ui-fg);
}

.ui-step[aria-current="step"]::before {
  background: var(--ui-chosen-fill) var(--ui-ink);
  color: var(--ui-on-ink);
}

/* In a narrow box (a phone, a side column) only the current step keeps its name: the others would be cut short. */
@container ui-steps (max-width: 36rem) {
  .ui-step:not([aria-current="step"]) > span {
    display: none;
  }

  .ui-step[aria-current="step"] {
    flex: 0 0 auto;
  }

  .ui-step[aria-current="step"]::after {
    width: var(--ui-space-4);
    flex: none;
  }

  .ui-step:not([aria-current="step"], :last-child) {
    flex: 1 1 0;
  }
}

/* ── Timeline ──────────────────────────────────────────────────────── */

.ui-timeline {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-timeline-item {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 0 0 var(--ui-space-5) var(--ui-space-8);
}

.ui-timeline-item::before {
  content: "";
  position: absolute;
  top: 0.4em;
  inset-inline-start: calc(0.25 * var(--ui-u));
  width: calc(0.625 * var(--ui-u));
  height: calc(0.625 * var(--ui-u));
  border-radius: var(--ui-radius-full);
  background: var(--ui-border);
}

.ui-timeline-item::after {
  content: "";
  position: absolute;
  top: calc(0.4em + 0.625 * var(--ui-u) + 4px);
  bottom: 4px;
  inset-inline-start: calc(0.5625 * var(--ui-u) - 0.5px);
  width: 1px;
  background: var(--ui-border);
}

.ui-timeline-item:last-child {
  padding-bottom: 0;
}

.ui-timeline-item:last-child::after {
  display: none;
}

.ui-timeline-item[data-current]::before {
  background: var(--ui-chosen-fill) var(--ui-ink);
  box-shadow: 0 0 0 3px var(--ui-ink-soft);
}

.ui-timeline-time {
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
  color: var(--ui-fg-muted);
}

/* ── Description list: name on the left, value on the right ────────── */

/* Facts as rows with a hairline between them. Each row (a div round its dt and dd) spans both columns, so the line
   runs under the name and the value as one. */
.ui-dl {
  display: grid;
  grid-template-columns: minmax(6rem, 1fr) 2fr;
  gap: var(--ui-space-3) var(--ui-space-4);
  margin: 0;
}

.ui-dl:has(> div) {
  row-gap: 0;
}

.ui-dl > div {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  padding-block: var(--ui-space-3);
  border-top: 1px solid var(--ui-border);
}

.ui-dl > div:first-child {
  padding-top: 0;
  border-top: 0;
}

.ui-dl > div:last-child {
  padding-bottom: 0;
}

.ui-dl dt {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  color: var(--ui-fg-muted);
}

.ui-dl dd {
  min-width: 0;
  margin: 0;
}

/* Without the lines: short facts in a card. */
.ui-dl--plain:has(> div) {
  row-gap: var(--ui-space-3);
}

.ui-dl--plain > div {
  padding-block: 0;
  border-top: 0;
}

/* An icon before a name: a phone, a pin, a clock. */
.ui-dl-icon {
  display: inline-flex;
  flex: none;
}

/* ── Small things ──────────────────────────────────────────────────── */

/* A count on a tab, a nav item or a bell. */
.ui-count {
  display: inline-grid;
  place-items: center;
  min-width: calc(1.25 * var(--ui-u));
  height: calc(1.25 * var(--ui-u));
  padding: 0 calc(0.35 * var(--ui-u));
  border-radius: var(--ui-radius-round);
  background: var(--ui-primary);
  color: var(--ui-on-primary);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1;
}

.ui-count--muted {
  background: var(--ui-surface-3);
  color: var(--ui-fg);
}

/* A row of filters and actions above a list. */
.ui-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-space-2);
}

.ui-toolbar > .ui-input-group,
.ui-toolbar > .ui-input {
  flex: 1 1 10rem;
  /* Never narrower than a few words: below that the buttons go to the next line instead. */
  min-width: min(10rem, 100%);
  width: auto;
}

/* A block of code or a command. */
/*
 * A bare line that scrolls sideways (no border or background of its own: the fade covers the whole box) fades out where
 * it goes on, instead of stopping mid-word: a command, a row of chips. Where the browser can follow the scroll, the fade moves to the start as the line is scrolled, and clears at the end.
 */


/*
 * The fade is a transparency mask, not a painted colour, so it melts into whatever is behind: the page, a card, a
 * coloured section. It is only where more content continues, so a row that fits has none, and a browser that cannot
 * follow the scroll shows none rather than a wrong one. Carousels have it by themselves, a little wider.
 */
.ui-fade-x,
.ui-carousel-viewport {
  /* An eased fade, not a straight one: it starts barely there and settles softly, so the edge never looks cut. */
  mask-image: linear-gradient(
    to right,
    transparent,
    rgb(0 0 0 / 0.04) calc(var(--fade-start) * 0.15), rgb(0 0 0 / 0.13) calc(var(--fade-start) * 0.3), rgb(0 0 0 / 0.27) calc(var(--fade-start) * 0.45), rgb(0 0 0 / 0.45) calc(var(--fade-start) * 0.6), rgb(0 0 0 / 0.65) calc(var(--fade-start) * 0.75), rgb(0 0 0 / 0.84) calc(var(--fade-start) * 0.88),
    #000 var(--fade-start),
    #000 calc(100% - var(--fade-end)),
    rgb(0 0 0 / 0.84) calc(100% - var(--fade-end) * 0.88), rgb(0 0 0 / 0.65) calc(100% - var(--fade-end) * 0.75), rgb(0 0 0 / 0.45) calc(100% - var(--fade-end) * 0.6), rgb(0 0 0 / 0.27) calc(100% - var(--fade-end) * 0.45), rgb(0 0 0 / 0.13) calc(100% - var(--fade-end) * 0.3), rgb(0 0 0 / 0.04) calc(100% - var(--fade-end) * 0.15),
    transparent
  );
}

.ui-carousel-viewport {
  --fade-size: 1.75rem;
}

@supports (animation-timeline: scroll()) {
  .ui-fade-x,
  .ui-carousel-viewport {
    animation: ui-fade-x linear both;
    animation-timeline: scroll(self inline);
  }
}

@keyframes ui-fade-x {
  0% {
    --fade-start: 0px;
    --fade-end: var(--fade-size, 1.75rem);
  }

  8% {
    --fade-start: var(--fade-size, 1.75rem);
  }

  92% {
    --fade-end: var(--fade-size, 1.75rem);
  }

  100% {
    --fade-start: var(--fade-size, 1.75rem);
    --fade-end: 0px;
  }
}

.ui-pre {
  margin: 0;
  padding: var(--ui-pad-sm) calc(var(--ui-pad-sm) + var(--ui-space-1));
  overflow-x: auto;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-box);
  background: var(--ui-surface-2);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-sm);
  line-height: 1.6;
}

.ui-pagination .ui-btn[aria-current="page"] {
  background: var(--ui-chosen-fill) var(--ui-ink);
  color: var(--ui-on-ink);
}

/* Tabs as pills. */
.ui-tabs-list--pills {
  --tabs-gap: var(--ui-space-1);
  border-bottom: 0;
}

.ui-tabs-list--pills .ui-tab {
  padding: 0 var(--ui-space-4);
  border-radius: var(--ui-radius-md);
}

.ui-tabs-list--pills .ui-tab::after {
  display: none;
}

.ui-tabs-list--pills .ui-tab:hover {
  background: var(--ui-surface-3);
}

.ui-tabs-list--pills .ui-tab[data-selected],
.ui-tabs-list--pills .ui-tab[aria-selected="true"],
.ui-tabs-list--pills .ui-tab[aria-current="page"] {
  background: var(--ui-chosen-fill) var(--ui-ink);
  color: var(--ui-on-ink);
}

/* A sheet that rises from the bottom: the phone's version of a dialog. */
.ui-dialog--sheet {
  top: auto;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: 85dvh;
  border-width: 1px 0 0;
  border-radius: var(--ui-radius-xl) var(--ui-radius-xl) 0 0;
  transform: none;
}

.ui-dialog--sheet[data-starting-style],
.ui-dialog--sheet[data-ending-style] {
  opacity: 1;
  transform: translateY(100%);
}

dialog.ui-dialog--sheet:not([open]) {
  opacity: 1;
  transform: translateY(100%);
}

@starting-style {
  dialog.ui-dialog--sheet[open] {
    opacity: 1;
    transform: translateY(100%);
  }
}

/* ── Charts ────────────────────────────────────────────────────────── */

/* A ring that fills up: style="--value: 72". Put the number inside. */
.ui-ring {
  --size: calc(4 * var(--ui-u));
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: var(--ui-radius-full);
  background: conic-gradient(var(--ui-primary) calc(var(--value, 0) * 1%), var(--ui-surface-3) 0);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

.ui-ring::before {
  content: "";
  position: absolute;
  inset: calc(var(--size) * 0.13);
  border-radius: var(--ui-radius-full);
  background: var(--ring-bg, var(--ui-surface));
}

.ui-ring > * {
  position: relative;
}

.ui-ring--lg {
  --size: calc(6.5 * var(--ui-u));
  font-size: var(--ui-text-lg);
}

/* A small line chart (an <svg>). */
.ui-sparkline {
  display: block;
  width: 100%;
  height: var(--height, 3rem);
  overflow: visible;
  color: var(--ui-primary-text);
}

.ui-sparkline-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.ui-sparkline-area {
  fill: var(--ui-primary-soft);
  stroke: none;
}

/* A bar split into parts: each child's width from --value (they add up to 100). */
.ui-split-bar {
  display: flex;
  gap: 2px;
  height: calc(0.75 * var(--ui-u));
  overflow: hidden;
  border-radius: var(--ui-radius-round);
}

.ui-split-bar > * {
  flex: 0 0 calc(var(--value, 0) * 1%);
  background: var(--ui-surface-3);
  transition: opacity var(--ui-dur) var(--ui-ease);
}

/* A part that steps back while another is looked at. */
.ui-split-bar > [data-dim] {
  opacity: 0.25;
}

.ui-split-bar > :first-child {
  background: var(--ui-primary);
}

.ui-split-bar > [style*="--tone"] {
  background: light-dark(oklch(0.8 0.12 var(--tone)), oklch(0.6 0.12 var(--tone)));
}

/* ── Calendar ──────────────────────────────────────────────────────── */

.ui-calendar {
  display: grid;
  gap: var(--ui-space-3);
  width: 100%;
  max-width: calc(20 * var(--ui-u));
}

.ui-calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-2);
}

.ui-calendar-title {
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

.ui-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.ui-calendar-weekday {
  padding-block: var(--ui-space-1);
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-xs);
  text-align: center;
}

.ui-day {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-md);
  background: none;
  color: var(--ui-fg);
  font-family: var(--ui-font-sans);
  font-size: var(--ui-text-sm);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  /* The ring and the weight too: today is only known in the browser, so its mark comes after the page is on screen. */
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur-fast) var(--ui-ease),
    font-weight var(--ui-dur-fast) var(--ui-ease);
}

.ui-day:hover {
  background: var(--ui-surface-3);
}

.ui-day[data-outside] {
  color: var(--ui-fg-subtle);
}

.ui-day[data-today] {
  box-shadow: inset 0 0 0 1px var(--ui-border-strong);
  font-weight: var(--ui-weight-bold);
  --ui-icon-weight: var(--ui-icon-bold);
}

.ui-day[aria-pressed="true"] {
  background: var(--ui-chosen-fill) var(--ui-ink);
  color: var(--ui-on-ink);
  box-shadow: none;
}

.ui-day:disabled {
  background: none;
  opacity: 0.35;
  cursor: not-allowed;
}

/* A day with something on it. */
.ui-day[data-marked]::after {
  content: "";
  position: absolute;
  /* Low in the cell, clear of the number, and about as heavy as the digits' own strokes. */
  bottom: 8%;
  width: 3px;
  height: 3px;
  border-radius: var(--ui-radius-round);
  background: currentColor;
}

/* ══ Motion that needs newer browsers; older ones keep the plain version ══ */

/* The chosen item of a segmented control and of tabs slides to its new place. */
@supports (anchor-scope: all) {
  .ui-segmented,
  .ui-tabs-list {
    position: relative;
    isolation: isolate;
    anchor-scope: --ui-chosen;
  }

  .ui-segmented-item:is([data-checked], [aria-pressed="true"], [aria-checked="true"], :has(input:checked)),
  .ui-tab:is([data-selected], [aria-selected="true"], [aria-current="page"]) {
    anchor-name: --ui-chosen;
  }

  .ui-segmented-item:is([data-checked], [aria-pressed="true"], [aria-checked="true"], :has(input:checked)) {
    background: none;
    box-shadow: none;
  }

  .ui-segmented::before,
  .ui-tabs-list::before {
    content: "";
    position: absolute;
    z-index: -1;
    position-anchor: --ui-chosen;
    left: anchor(left); /* physical: lines up with the left edge of its anchor box, the same way in both directions */
    width: anchor-size(width);
    transition:
      left var(--ui-dur) var(--ui-ease-out),
      width var(--ui-dur) var(--ui-ease-out);
  }

  .ui-segmented::before {
    top: anchor(top);
    height: anchor-size(height);
    border-radius: var(--ui-radius-md);
    background: var(--ui-chosen-fill) var(--ui-ink);
  }

  /* Tabs: the line under the chosen tab. */
  .ui-tabs-list::before {
    bottom: 0;
    z-index: 1;
    height: 2px;
    background: var(--ui-chosen-fill) var(--ui-ink);
  }

  .ui-tabs-list .ui-tab::after {
    display: none;
  }

  /* Pill tabs: the dark pill behind the chosen tab. */
  .ui-tabs-list--pills::before {
    top: anchor(top);
    bottom: auto;
    z-index: -1;
    height: anchor-size(height);
    border-radius: var(--ui-radius-md);
    background: var(--ui-chosen-fill) var(--ui-ink);
  }

  .ui-tabs-list--pills .ui-tab:is([data-selected], [aria-selected="true"], [aria-current="page"]) {
    background: none;
  }
}

/* <details> opens and closes smoothly. */
@supports (interpolate-size: allow-keywords) {
  .ui-accordion {
    interpolate-size: allow-keywords;
  }

  details.ui-accordion-item::details-content {
    height: 0;
    overflow: hidden;
    transition:
      height var(--ui-dur) var(--ui-ease-out),
      content-visibility var(--ui-dur) allow-discrete;
  }

  details.ui-accordion-item[open]::details-content {
    height: auto;
  }
}

/* The browser's own <select>, with a designed list that slides open. */
@supports (appearance: base-select) {
  select.ui-input,
  select.ui-input::picker(select) {
    appearance: base-select;
  }

  select.ui-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ui-space-2);
    padding-inline-end: var(--ui-space-4);
    background-image: none;
  }

  select.ui-input::picker-icon {
    content: "";
    flex: none;
    width: 0.5rem;
    height: 0.5rem;
    margin-inline: 0.25rem;
    border-right: 1.5px solid var(--ui-fg-muted);
    border-bottom: 1.5px solid var(--ui-fg-muted);
    transform: translateY(-25%) rotate(45deg);
    transition: transform var(--ui-dur) var(--ui-ease-out);
  }

  select.ui-input:open::picker-icon {
    transform: translateY(25%) rotate(-135deg);
  }

  select.ui-input::picker(select) {
    min-width: anchor-size(width);
    margin-block: 6px;
    padding: var(--ui-space-2);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-box);
    background: var(--ui-surface);
    color: var(--ui-fg);
    box-shadow: var(--ui-shadow-md);
    opacity: 0;
    transform: translateY(-0.5rem) scale(0.98);
    transform-origin: top;
    transition:
      opacity var(--ui-dur) var(--ui-ease-out),
      transform var(--ui-dur) var(--ui-ease-out),
      overlay var(--ui-dur) allow-discrete,
      display var(--ui-dur) allow-discrete;
  }

  select.ui-input:open::picker(select) {
    opacity: 1;
    transform: none;
  }

  @starting-style {
    select.ui-input:open::picker(select) {
      opacity: 0;
      transform: translateY(-0.5rem) scale(0.98);
    }
  }

  select.ui-input option {
    display: flex;
    align-items: center;
    gap: var(--ui-space-2);
    min-height: calc(var(--ui-h-md) - 4px);
    padding: var(--ui-space-2) var(--ui-space-3);
    border-radius: max(calc(var(--ui-radius-box) - var(--ui-space-2)), var(--ui-radius-sm));
    background: none;
    font-size: var(--ui-text-base);
    cursor: default;
    transition: background-color var(--ui-dur-fast) var(--ui-ease);
  }

  select.ui-input option:hover,
  select.ui-input option:focus-visible {
    background: var(--ui-surface-3);
    outline: none;
  }

  select.ui-input option::checkmark {
    content: "";
    order: 1;
    width: 0.375rem;
    height: 0.75rem;
    margin-inline-start: auto;
    margin-inline-end: 0.25rem;
    border-right: 1.75px solid var(--ui-ink); /* a tick is drawn the same way in both directions */
    border-bottom: 1.75px solid var(--ui-ink);
    transform: translateY(-10%) rotate(45deg);
  }
}

/* ══ Third tier: the remaining basics ══════════════════════════════ */

/* ── Tooltip without JavaScript: <button data-tip="Delete"> ────────── */

[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  z-index: var(--ui-z-popup);
  width: max-content;
  max-width: 16rem;
  padding: var(--ui-space-1) var(--ui-space-2);
  border-radius: min(var(--ui-radius-sm), 0.5rem);
  background: var(--ui-fg);
  color: var(--ui-bg);
  font-family: var(--ui-font-sans);
  font-size: var(--ui-text-xs);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  translate: -50% 0.25rem;
  transition:
    opacity var(--ui-dur-fast) var(--ui-ease),
    translate var(--ui-dur-fast) var(--ui-ease-out);
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  opacity: 1;
  translate: -50% 0;
  transition-delay: 0.35s;
}

/* Below, for things at the top of the page. */
[data-tip][data-tip-side="bottom"]::after {
  top: calc(100% + 0.5rem);
  bottom: auto;
  translate: -50% -0.25rem;
}

[data-tip][data-tip-side="bottom"]:hover::after,
[data-tip][data-tip-side="bottom"]:focus-visible::after {
  translate: -50% 0;
}

/* ── Button group and toggle ───────────────────────────────────────── */

/* Buttons joined into one control. */
.ui-btn-group {
  display: inline-flex;
  gap: 1px;
  /* Never wider than its box: on a small phone the room round each word shrinks, and a group still too long scrolls
     inside itself instead of widening the page. */
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.ui-btn-group:not(.ui-btn-group--wrap) > .ui-btn {
  flex: none;
}

@media (max-width: 400px) {
  .ui-btn-group:not(.ui-btn-group--wrap) > .ui-btn:not(.ui-btn--icon) {
    padding-inline: var(--ui-space-3);
  }
}

.ui-btn-group > .ui-btn {
  border-radius: 0;
}

.ui-btn-group > .ui-btn:first-child {
  border-start-start-radius: var(--ui-radius-md);
  border-end-start-radius: var(--ui-radius-md);
}

.ui-btn-group > .ui-btn:last-child {
  border-start-end-radius: var(--ui-radius-md);
  border-end-end-radius: var(--ui-radius-md);
}

/* A group of many (a 0 to 10 score, the days of a week): separate buttons, all one size, in as many columns as fit. */
.ui-btn-group--wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(max(var(--ui-h-sm), 2.5rem), 1fr));
  gap: var(--ui-space-1);
}

.ui-btn-group--wrap[style*="--cols"] {
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
}

.ui-btn-group--wrap > .ui-btn {
  border-radius: var(--ui-radius-md);
}

/* A button that stays on: bold, pin, mute. */
.ui-btn[aria-pressed="true"]:not(.ui-btn--primary, .ui-btn--danger),
.ui-btn[data-pressed]:not(.ui-btn--primary, .ui-btn--danger),
/* …and the button of a menu or popover while it is open (not a dialog's: the dialog covers it). */
.ui-btn[data-open]:not(.ui-btn--primary, .ui-btn--danger, [data-ui-dialog]) {
  background: var(--ui-chosen-fill) var(--ui-ink);
  /* The fill stops at the button's own edge like every other button's (line-colour.css): written as `background`
     it would run under the clear border too, and the chosen one of a joined group stood a pixel proud of the rest. */
  background-clip: padding-box;
  color: var(--ui-on-ink);
}

/* ── Chip you can remove ───────────────────────────────────────────── */

.ui-chip-remove {
  display: inline-grid;
  place-items: center;
  width: calc(1.25 * var(--ui-u));
  height: calc(1.25 * var(--ui-u));
  margin-inline: calc(var(--ui-space-1) * -0.5) calc(var(--ui-space-2) * -1);
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-round);
  background: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  transition:
    opacity var(--ui-dur-fast) var(--ui-ease),
    background-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-chip-remove:hover {
  background: color-mix(in oklab, currentColor 14%, transparent);
  opacity: 1;
}

.ui-chip-remove .ui-icon {
  width: 0.875em;
  height: 0.875em;
}

/* ── Menu items that tick ──────────────────────────────────────────── */

.ui-menu-item-indicator {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1rem;
  height: 1rem;
  color: var(--ui-ink);
}

/* The tick sits in its own wrapper; without this it lines up like text and drops below the row's centre. */
.ui-menu-item-indicator > *,
.ui-menu-item-check {
  display: inline-grid;
  place-items: center;
}

.ui-menu-item-indicator .ui-icon,
.ui-menu-item-check .ui-icon {
  display: block;
}

/* Keeps the labels in line when only some rows have a tick. */
.ui-menu-item--inset {
  padding-inline-start: calc(var(--ui-space-3) + 1rem + var(--ui-space-2));
}

/* ── Collapsible: one thing that opens ─────────────────────────────── */

.ui-collapsible > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-2);
  color: var(--ui-fg);
  font-size: var(--ui-text-base);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  cursor: pointer;
  list-style: none;
}

.ui-collapsible > summary::-webkit-details-marker {
  display: none;
}

.ui-collapsible > summary::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  margin-inline: 0.15rem 0.2rem;
  border-right: 1.5px solid var(--ui-fg-muted);
  border-bottom: 1.5px solid var(--ui-fg-muted);
  transform: rotate(-45deg);
  transition: transform var(--ui-dur) var(--ui-ease-out);
}

.ui-collapsible[open] > summary::before {
  transform: rotate(45deg);
}

.ui-collapsible-content {
  padding-top: var(--ui-space-3);
}

@supports (interpolate-size: allow-keywords) {
  .ui-collapsible {
    interpolate-size: allow-keywords;
  }

  .ui-collapsible::details-content {
    height: 0;
    overflow: hidden;
    transition:
      height var(--ui-dur) var(--ui-ease-out),
      content-visibility var(--ui-dur) allow-discrete;
  }

  .ui-collapsible[open]::details-content {
    height: auto;
  }
}

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

/* Five radios drawn as stars: a star is filled when it, or a later one, is chosen. */
.ui-rating {
  display: inline-flex;
  gap: 2px;
  margin: 0;
  padding: 0;
  border: 0;
}

.ui-rating-star {
  display: grid;
  color: var(--ui-control-edge);
  cursor: pointer;
  transition: color var(--ui-dur-fast) var(--ui-ease);
}

.ui-rating-star input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ui-rating-star .ui-icon {
  width: calc(1.5 * var(--ui-u));
  height: calc(1.5 * var(--ui-u));
  fill: currentColor;
}

.ui-rating-star:has(input:checked),
.ui-rating-star:has(~ .ui-rating-star input:checked) {
  color: var(--ui-warning);
}

.ui-rating-star:has(input:focus-visible) {
  outline: 2px solid var(--ui-ring);
  outline-offset: 2px;
  border-radius: var(--ui-radius-sm);
}

.ui-rating--readonly .ui-rating-star {
  cursor: default;
}

/* ── Code input: one box per character ─────────────────────────────── */

.ui-code-input {
  display: flex;
  gap: var(--ui-space-2);
}

/* One box per character. The boxes show the code; a single real input lies over them and takes the typing. */
.ui-code-input > input,
.ui-code-input > [data-slot="otp-input-slot"] {
  display: grid;
  place-items: center;
  flex: 1;
  width: 0;
  min-width: 0;
  max-width: var(--ui-h-lg);
  height: var(--ui-h-lg);
  padding: 0;
  border: 1px solid var(--ui-field-border);
  border-radius: min(var(--ui-radius-md), 1rem);
  background: var(--ui-field-bg);
  box-shadow: var(--ui-field-shadow), 0 0 0 1px transparent;
  color: var(--ui-fg);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-lg);
  text-align: center;
  transition:
    border-color var(--ui-dur-fast) var(--ui-ease),
    background-color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur-fast) var(--ui-ease);
}

.ui-code-input > input:focus,
.ui-code-input > [data-slot="otp-input-slot"][data-active] {
  outline: none;
  border-color: var(--ui-highlight);
  background: var(--ui-surface);
  box-shadow: var(--ui-field-shadow), 0 0 0 3px var(--ui-focus-halo);
}

/* ── Carousel: a row you swipe ─────────────────────────────────────── */

.ui-carousel {
  display: flex;
  gap: var(--ui-space-4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.ui-carousel::-webkit-scrollbar {
  display: none;
}

.ui-carousel > * {
  flex: 0 0 var(--item, 80%);
  min-width: 0;
  scroll-snap-align: start;
}

@media (min-width: 720px) {
  .ui-carousel > * {
    flex-basis: var(--item, 40%);
  }
}

/* ── Banner: a message across the top ──────────────────────────────── */

.ui-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--ui-space-2) var(--ui-space-4);
  padding: var(--ui-space-2) var(--ui-space-4);
  background: var(--ui-fg);
  color: var(--ui-bg);
  font-size: var(--ui-text-sm);
  text-align: center;
}

.ui-banner a {
  color: inherit;
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  text-underline-offset: 0.2em;
}

.ui-banner--primary {
  background: var(--ui-primary);
  color: var(--ui-on-primary);
}

/* ── Scroll area, ratio, divider, trend ────────────────────────────── */

/* A box that scrolls inside the page, with a quiet scrollbar. */
.ui-scroll {
  max-height: var(--max-height, 16rem);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--ui-border-strong) transparent;
}

/* Keeps a shape: style="--ratio: 4 / 3". */
.ui-ratio {
  position: relative;
  overflow: hidden;
  min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
  aspect-ratio: var(--ratio, 16 / 9);
}

.ui-ratio > img,
.ui-ratio > video,
.ui-ratio > iframe,
.ui-ratio > .ui-pattern {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
}

/* A line with a word in the middle: "or". */
.ui-divider {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-sm);
}

.ui-divider::before,
.ui-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ui-border);
}

/* Up or down next to a number. */
.ui-trend {
  display: inline-flex;
  align-items: baseline;
  gap: var(--ui-space-1);
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  color: var(--ui-fg-muted);
}

.ui-trend .ui-icon,
.ui-trend svg.lucide {
  align-self: flex-start;
  margin-top: 0.15em;
  vertical-align: 0;
}

.ui-trend--up { color: var(--ui-success-text); }
.ui-trend--down { color: var(--ui-danger-text); }

/* A dot in a tone, for a chart's legend. */
.ui-dot--tone {
  background: light-dark(oklch(0.8 0.12 var(--tone, 250)), oklch(0.6 0.12 var(--tone, 250)));
}

/* ── Table: sorting and chosen rows ────────────────────────────────── */

.ui-sort {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-1);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: color var(--ui-dur-fast) var(--ui-ease);
}

.ui-sort:hover,
th[aria-sort="ascending"] .ui-sort,
th[aria-sort="descending"] .ui-sort {
  color: var(--ui-fg);
}

.ui-sort::after {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  opacity: 0;
  transform: translateY(-25%) rotate(45deg);
  transition:
    opacity var(--ui-dur-fast) var(--ui-ease),
    transform var(--ui-dur) var(--ui-ease-out);
}

th[aria-sort="descending"] .ui-sort::after {
  opacity: 1;
}

th[aria-sort="ascending"] .ui-sort::after {
  opacity: 1;
  transform: translateY(25%) rotate(-135deg);
}

.ui-table tbody tr[aria-selected="true"] td {
  background: var(--ui-ink-soft);
}

/* ── Tab bar: the main sections at the bottom of a phone ───────────── */

.ui-tabbar {
  position: sticky;
  bottom: 0;
  z-index: var(--ui-z-sticky);
  display: flex;
  justify-content: space-around;
  gap: var(--ui-space-1);
  padding: var(--ui-space-2) var(--ui-space-2) max(var(--ui-space-2), env(safe-area-inset-bottom));
  border-top: 1px solid var(--ui-border);
  background: var(--ui-surface);
}

/* In a card or a dialog the tab bar is the box's own bottom edge: it does not stick to the window and cover what is above it. */
:is(.ui-card, .ui-dialog) > .ui-tabbar {
  position: relative;
  bottom: auto;
}

.ui-tabbar-item {
  display: grid;
  flex: 1;
  justify-items: center;
  gap: 2px;
  min-width: 0;
  padding: var(--ui-space-1);
  border: 0;
  border-radius: var(--ui-radius-md);
  background: none;
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-xs);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--ui-dur-fast) var(--ui-ease);
}

.ui-tabbar-item .ui-icon,
.ui-tabbar-item svg.lucide {
  width: 1.375rem;
  height: 1.375rem;
}

.ui-tabbar-item[aria-current="page"] {
  color: var(--ui-fg);
}

/*
 * A floating tab bar, the dock: a small bar that floats over the screen instead of sitting on its edge. The chosen
 * section is ink and shows its name (in .ui-tabbar-label); the others show only their icon and keep an aria-label.
 */
.ui-tabbar--floating {
  position: relative;
  bottom: auto;
  display: inline-flex;
  justify-content: center;
  gap: var(--ui-space-1);
  padding: var(--ui-space-1);
  border: 1px solid var(--ui-float-border, var(--ui-border));
  border-radius: var(--ui-radius-lg);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-lg);
}

.ui-tabbar--floating .ui-tabbar-item {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0;
  height: var(--ui-h-md);
  padding: 0 var(--ui-space-3);
  font-size: var(--ui-text-sm);
  transition:
    color var(--ui-dur-fast) var(--ui-ease),
    background-color var(--ui-dur) var(--ui-ease);
}

.ui-tabbar--floating .ui-tabbar-item .ui-icon,
.ui-tabbar--floating .ui-tabbar-item svg.lucide {
  width: 1.15rem;
  height: 1.15rem;
}

.ui-tabbar--floating .ui-tabbar-item:hover {
  background: var(--ui-surface-2);
  color: var(--ui-fg);
}

.ui-tabbar--floating .ui-tabbar-item[aria-current="page"] {
  background: var(--ui-ink);
  color: var(--ui-on-ink);
}

.ui-tabbar-label {
  overflow: hidden;
  white-space: nowrap;
}

/*
 * The label opens and closes at its own width (a grid column from 0fr to 1fr), so the one closing shrinks exactly as
 * fast as the one opening grows and the bar never swells in between. (A max-width animation would: the closing label
 * keeps its full width until the limit falls below it.)
 */
.ui-tabbar--floating .ui-tabbar-label {
  display: grid;
  grid-template-columns: 0fr;
  opacity: 0;
  transition:
    grid-template-columns var(--ui-dur) var(--ui-ease-out),
    margin var(--ui-dur) var(--ui-ease-out),
    opacity var(--ui-dur) var(--ui-ease);
}

.ui-tabbar-label > span {
  min-width: 0;
  overflow: hidden;
}

.ui-tabbar--floating .ui-tabbar-item[aria-current="page"] .ui-tabbar-label {
  grid-template-columns: 1fr;
  margin-inline-start: var(--ui-space-2);
  opacity: 1;
}

/* ── Checklist ─────────────────────────────────────────────────────── */

/* Rules or steps that tick themselves: a password's rules, a setup's steps. li[data-done] is met. */
.ui-checklist {
  display: grid;
  gap: var(--ui-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--ui-text-sm);
}

.ui-checklist > li {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  color: var(--ui-fg-muted);
  transition: color var(--ui-dur) var(--ui-ease);
}

.ui-checklist-mark {
  position: relative;
  flex: none;
  width: 1rem;
  height: 1rem;
  border: 1.5px solid currentColor;
  border-radius: var(--ui-radius-round);
  opacity: 0.6;
  transition:
    background-color var(--ui-dur) var(--ui-ease),
    border-color var(--ui-dur) var(--ui-ease),
    opacity var(--ui-dur) var(--ui-ease);
}

/* The tick, drawn as two sides of a turned box. */
.ui-checklist-mark::after {
  position: absolute;
  top: 18%;
  left: 33%; /* a drawn tick: the same way in both directions */
  width: 28%;
  height: 50%;
  border: solid var(--ui-on-success);
  border-width: 0 1.5px 1.5px 0;
  rotate: 45deg;
  opacity: 0;
  content: "";
  transition: opacity var(--ui-dur) var(--ui-ease);
}

.ui-checklist > li[data-done] {
  color: var(--ui-fg);
}

.ui-checklist > li[data-done] .ui-checklist-mark {
  border-color: var(--ui-success);
  background: var(--ui-success);
  opacity: 1;
}

.ui-checklist > li[data-done] .ui-checklist-mark::after {
  opacity: 1;
}

/* ── Pick tiles ────────────────────────────────────────────────────── */

/* A picture to pick: photos to keep, a cover to use. A checkbox sits in its corner; [data-picked] rings it in ink. */
.ui-pick {
  position: relative;
  display: block;
  border-radius: var(--ui-radius-lg);
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color var(--ui-dur) var(--ui-ease);
}

.ui-pick[data-picked] {
  outline-color: var(--ui-ink);
}

.ui-pick > :is(img, .ui-pattern) {
  display: block;
  width: 100%;
  min-width: 0; /* Safari gives a box with an aspect-ratio a minimum width from its height; without this it cannot narrow */
  aspect-ratio: var(--ratio, 4 / 3);
  border-radius: inherit;
  object-fit: cover;
}

.ui-pick > .ui-checkbox,
.ui-pick > .ui-check {
  position: absolute;
  top: var(--ui-space-2);
  inset-inline-start: var(--ui-space-2);
}

/* ── Command palette ───────────────────────────────────────────────── */

.ui-command {
  top: 18%;
  gap: 0;
  padding: 0;
  overflow: hidden;
  transform: translate(-50%, 0);
  --width: 34rem;
}

.ui-command[data-starting-style],
.ui-command[data-ending-style] {
  transform: translate(-50%, -0.75rem) scale(0.98);
}

.ui-command-input {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  padding: var(--ui-space-4) var(--ui-space-5);
  border-bottom: 1px solid var(--ui-border);
  color: var(--ui-fg-muted);
}

.ui-command-input > input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  color: var(--ui-fg);
  font-family: var(--ui-font-sans);
  font-size: var(--ui-text-md);
}

.ui-command-list {
  max-height: min(22rem, 50dvh);
  padding: var(--ui-space-2);
  overflow-y: auto;
}

.ui-command-list .ui-menu-item {
  min-height: var(--ui-h-md);
}

/* ── Prose: long text that came as plain HTML ──────────────────────── */

.ui-prose {
  max-width: 68ch;
  font-size: var(--ui-text-md);
  line-height: 1.65;
  color: var(--ui-fg);
  text-wrap: pretty;
}

.ui-prose > * {
  margin-block: 0;
}

.ui-prose > * + * {
  margin-top: 1em;
}

.ui-prose h1,
.ui-prose h2,
.ui-prose h3,
.ui-prose h4 {
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: var(--ui-leading-tight);
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.ui-prose h1 { font-size: var(--ui-text-3xl); letter-spacing: -0.035em; }
.ui-prose h2 { margin-top: 1.8em; font-size: var(--ui-text-2xl); letter-spacing: -0.03em; }
.ui-prose h3 { margin-top: 1.6em; font-size: var(--ui-text-xl); }
.ui-prose h4 { margin-top: 1.5em; font-size: var(--ui-text-lg); }

/* A heading sits close to the text it introduces; the first thing never pushes down. */
.ui-prose :is(h1, h2, h3, h4) + * { margin-top: 0.6em; }
.ui-prose > :first-child { margin-top: 0; }

/* The opening paragraph, when it is marked: a little larger and quieter. */
.ui-prose .ui-prose-lead {
  font-size: var(--ui-text-lg);
  line-height: 1.55;
  color: var(--ui-fg-muted);
}

.ui-prose a {
  color: var(--ui-fg);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in oklch, currentColor 35%, transparent);
  text-underline-offset: 0.22em;
  transition: text-decoration-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-prose a:hover {
  text-decoration-color: currentColor;
}

.ui-prose strong {
  font-weight: var(--ui-weight-bold);
  --ui-icon-weight: var(--ui-icon-bold);
}

/* Lists: a small brand dot, or a number in a soft round tile. */
.ui-prose ul,
.ui-prose ol {
  padding: 0;
  list-style: none;
}

.ui-prose ol {
  counter-reset: ui-prose-ol;
}

.ui-prose li {
  position: relative;
  padding-inline-start: 1.75em;
}

.ui-prose li + li {
  margin-top: 0.5em;
}

.ui-prose ul > li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0.45em;
  top: calc(0.825em - 0.2em);
  width: 0.4em;
  height: 0.4em;
  border-radius: var(--ui-radius-round);
  background: var(--ui-primary);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--ui-fg) 12%, transparent);
}

.ui-prose ol > li {
  counter-increment: ui-prose-ol;
  padding-inline-start: 2.25em;
}

.ui-prose ol > li::before {
  /* Sized from the reading text, so the tile stays centred on the first line. */
  --_n: calc(var(--ui-text-md) * 1.5);
  content: counter(ui-prose-ol);
  position: absolute;
  inset-inline-start: 0;
  top: calc(var(--ui-text-md) * 0.825 - var(--_n) / 2);
  display: grid;
  place-items: center;
  width: var(--_n);
  height: var(--_n);
  border-radius: var(--ui-radius-round);
  background: var(--ui-surface-3);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1;
  color: var(--ui-fg-muted);
}

/* A quote: a soft grey card with a large quotation mark, like the rest of the system's layers. */
.ui-prose blockquote {
  position: relative;
  margin-inline: 0;
  padding: var(--ui-space-5) var(--ui-space-6) var(--ui-space-5) calc(var(--ui-space-6) + 1.6em);
  border-radius: var(--ui-radius-nested);
  background: var(--ui-surface-2);
  font-size: var(--ui-text-lg);
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--ui-fg);
}

.ui-prose blockquote::before {
  content: '\201C';
  position: absolute;
  inset-inline-start: var(--ui-space-5);
  top: var(--ui-space-3);
  font-size: 2.6em;
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1;
  color: var(--ui-primary-text);
}

.ui-prose blockquote > * + * {
  margin-top: 0.6em;
}

.ui-prose blockquote :is(footer, cite) {
  display: block;
  font-size: var(--ui-text-sm);
  font-style: normal;
  letter-spacing: 0;
  color: var(--ui-fg-muted);
}

.ui-prose code {
  padding: 0.1em 0.4em;
  border-radius: min(var(--ui-radius-sm), 0.375rem);
  background: var(--ui-surface-2);
  font-family: var(--ui-font-mono);
  font-size: 0.875em;
}

.ui-prose pre {
  overflow-x: auto;
  padding: var(--ui-space-4) var(--ui-space-5);
  border-radius: var(--ui-radius-box);
  background: var(--ui-surface-2);
  font-size: var(--ui-text-sm);
  line-height: 1.6;
}

.ui-prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.ui-prose img {
  border-radius: var(--ui-radius-nested);
}

.ui-prose figcaption {
  margin-top: var(--ui-space-2);
  font-size: var(--ui-text-sm);
  color: var(--ui-fg-muted);
}

.ui-prose hr {
  height: 1px;
  margin-block: 2em;
  border: 0;
  background: var(--ui-border);
}

/* A calendar inside a popup (the date picker) keeps a comfortable width. */
.ui-popup .ui-calendar {
  width: calc(17.5 * var(--ui-u));
  max-width: calc(100vw - 3rem);
}

/* ══ Small screens ═════════════════════════════════════════════════ */

@media (max-width: 560px) {
  /* Cards and dialogs give their space to the content. */
  /* Dialog buttons share the width, the main one last (nearest the thumb). */
  .ui-dialog-footer {
    flex-wrap: nowrap;
  }

  .ui-dialog-footer > .ui-btn {
    flex: 1;
    min-width: 0;
  }

  /* A page header's action goes full width under the title. */
  .ui-page-header > .ui-btn {
    width: 100%;
  }

  .ui-empty {
    padding: var(--ui-space-8) var(--ui-space-4);
  }

  .ui-sidebar {
    scrollbar-width: none;
  }

  /* Facts lists stack the name over the value when the value needs the room. */
  .ui-dl {
    grid-template-columns: minmax(5rem, auto) 1fr;
  }
}

/* ══ Notifications ═════════════════════════════════════════════════ */

/* A list of things that happened: in a panel under the bell, or on its own page. */
.ui-notifications {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-notification {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--ui-space-3);
  padding: var(--ui-space-3);
  border-radius: max(calc(var(--ui-radius-box) - var(--ui-space-2)), var(--ui-radius-sm));
  color: var(--ui-fg);
  text-decoration: none;
  transition: background-color var(--ui-dur-fast) var(--ui-ease);
}

a.ui-notification,
button.ui-notification {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.ui-notification:hover {
  background: var(--ui-surface-2);
}

.ui-notification-body {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.ui-notification-title {
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

.ui-notification-text {
  font-size: var(--ui-text-sm);
  color: var(--ui-fg-muted);
}

.ui-notification-time {
  margin-top: 2px;
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
  color: var(--ui-fg-subtle);
}

.ui-notification-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-space-2);
  margin-top: var(--ui-space-2);
}

/* Not read yet: a dot on the right, and the title a little stronger. */
.ui-notification[data-unread] {
  padding-inline-end: var(--ui-space-8);
}

.ui-notification::after {
  content: "";
  position: absolute;
  top: calc(var(--ui-space-3) + 0.35em);
  inset-inline-end: var(--ui-space-3);
  opacity: 0;
  transition: opacity var(--ui-dur) var(--ui-ease);
  width: calc(0.5 * var(--ui-u));
  height: calc(0.5 * var(--ui-u));
  border-radius: var(--ui-radius-round);
  background: var(--ui-primary-text);
}

.ui-notification[data-unread]::after {
  opacity: 1;
}

.ui-notification[data-unread] .ui-notification-title {
  font-weight: var(--ui-weight-bold);
  --ui-icon-weight: var(--ui-icon-bold);
}

/* The panel that opens under the bell. */
.ui-notifications-panel {
  gap: 0;
  width: min(24rem, calc(100vw - 1rem));
  max-height: min(32rem, 80dvh);
  overflow-y: auto;
}

.ui-notifications-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-3);
  padding: var(--ui-space-2) var(--ui-space-3) var(--ui-space-3);
}

.ui-notifications-title {
  font-size: var(--ui-text-md);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

/* A count on the corner of an icon button: the bell. */
.ui-btn--icon {
  position: relative;
}

.ui-btn--icon > .ui-count {
  position: absolute;
  top: calc(-0.25 * var(--ui-u));
  inset-inline-end: calc(-0.25 * var(--ui-u));
  box-shadow: 0 0 0 2px var(--ui-bg);
}

/* A person's picture in a notification is the same size as an icon tile, so the texts line up. */
.ui-notification > .ui-avatar {
  --size: var(--ui-h-md);
}

/* ── Burger: two lines that cross into an X ────────────────────────── */

/* The button that opens the menu on a small screen. aria-expanded="true" when the menu is open. */
.ui-burger {
  position: relative;
  display: inline-grid;
  flex: none;
  width: var(--ui-h-md);
  height: var(--ui-h-md);
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-round);
  background: var(--ui-surface-3);
  color: var(--ui-fg);
  cursor: pointer;
  transition: background-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-burger:hover {
  background: color-mix(in oklab, var(--ui-surface-3) 90%, var(--ui-fg));
}

.ui-burger::before,
.ui-burger::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.125rem;
  height: calc(var(--ui-icon-stroke) * 1px + 0.25px);
  border-radius: var(--ui-radius-full);
  background: currentColor;
  transition:
    translate var(--ui-dur) var(--ui-ease-out),
    rotate var(--ui-dur) var(--ui-ease-out);
}

.ui-burger::before {
  translate: -50% calc(-50% - 0.25rem);
}

.ui-burger::after {
  translate: -50% calc(-50% + 0.25rem);
}

.ui-burger[aria-expanded="true"]::before {
  translate: -50% -50%;
  rotate: 45deg;
}

.ui-burger[aria-expanded="true"]::after {
  translate: -50% -50%;
  rotate: -45deg;
}

/* ── Site header: links in a line, or a menu on a small screen ─────── */

/* It folds by its own width, not the window's, so it works in a card or a narrow column too. */
.ui-site-header {
  container-type: inline-size;
  z-index: var(--ui-z-sticky, 20);
}

/* Sticky: it stays at the top as a floating bar. At the top of the page it sits on the page; once the page scrolls it becomes a solid bar and lifted. */
.ui-site-header--sticky {
  position: sticky;
  top: var(--ui-space-3);
}

/*
 * The bar reaches past the page column by its own room, so at rest its brand and its last button line up with the
 * page's edges, and once it is a bar the same room shows around them. Nothing moves when the bar appears.
 */
.ui-site-header-bar {
  display: flex;
  align-items: center;
  gap: var(--ui-space-4);
  min-width: 0;
  min-height: calc(var(--ui-h-md) + var(--ui-space-2) * 2);
  margin-inline: calc(-1 * var(--ui-space-3));
  padding: var(--ui-space-2) var(--ui-space-3);
  border: 1px solid transparent;
  border-radius: var(--ui-radius-inner, var(--ui-radius-lg));
  background: transparent;
  transition:
    background-color var(--ui-dur) var(--ui-ease),
    border-color var(--ui-dur) var(--ui-ease),
    box-shadow var(--ui-dur) var(--ui-ease);
}

.ui-site-header--sticky[data-scrolled] .ui-site-header-bar {
  border-color: var(--ui-float-border);
  background: var(--ui-bar-bg);
  box-shadow: var(--ui-shadow-md);
}

.ui-site-header-brand {
  flex: 0 1 auto;
  min-width: 0;
}

.ui-site-header-links {
  position: relative;
  display: flex;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.ui-site-header-links .ui-navmenu-list {
  flex-wrap: nowrap;
}

/* The section in view: its link is ink, and a soft pill slides behind it from link to link. */
.ui-site-header-links .ui-navmenu-trigger {
  position: relative;
  z-index: 1;
  transition: color var(--ui-dur) var(--ui-ease), background-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-site-header-links .ui-navmenu-trigger[aria-current] {
  background: none;
  color: var(--ui-fg);
}

.ui-site-header-mark {
  position: absolute;
  top: 50%;
  left: 0;
  width: var(--w, 0);
  height: var(--ui-h-md);
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface-3);
  opacity: 0;
  translate: var(--x, 0) -50%;
  transition:
    translate var(--ui-dur-slow) var(--ui-ease-out),
    width var(--ui-dur-slow) var(--ui-ease-out),
    opacity var(--ui-dur) var(--ui-ease);
  pointer-events: none;
}

.ui-site-header-mark[data-shown] {
  opacity: 1;
}

.ui-site-header-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--ui-space-2);
}

.ui-site-header-burger {
  display: none;
  margin-inline-start: auto;
}

@container (max-width: 48rem) {
  .ui-site-header-links,
  .ui-site-header-actions {
    display: none;
  }

  .ui-site-header-burger {
    display: inline-grid;
  }
}

/* The menu: a floating panel held off the screen's edges, the links set large and numbered. */
.ui-drawer.ui-site-menu[data-side] {
  gap: var(--ui-space-6);
  width: min(var(--width, 26rem), calc(100vw - var(--ui-space-2) * 2));
  height: calc(100dvh - var(--ui-space-2) * 2);
  max-height: none;
  margin: var(--ui-space-2);
  border: 1px solid var(--ui-float-border);
  border-radius: var(--ui-radius-xl);
  overflow: hidden;
}

.ui-drawer.ui-site-menu::after {
  display: none;
}

.ui-site-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-3);
}

.ui-site-menu-title {
  font-size: var(--ui-text-md);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  letter-spacing: -0.01em;
}

.ui-site-menu-body {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.ui-site-menu-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-site-menu-list > li + li {
  border-top: 1px solid var(--ui-border);
}

.ui-site-menu-link {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  min-height: var(--ui-h-lg);
  padding: var(--ui-space-3) 0;
  color: var(--ui-fg);
  text-decoration: none;
  transition: color var(--ui-dur-fast) var(--ui-ease);
}

.ui-site-menu-link--large {
  align-items: baseline;
  gap: var(--ui-space-4);
  padding-block: var(--ui-space-4);
}

.ui-site-menu-index {
  flex: none;
  min-width: 1.75em;
  color: var(--ui-fg-subtle);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
  transition: color var(--ui-dur-fast) var(--ui-ease);
}

.ui-site-menu-text {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.ui-site-menu-label {
  position: relative;
  transition: translate var(--ui-dur) var(--ui-ease-out);
}

.ui-site-menu-link--large .ui-site-menu-label {
  font-size: var(--ui-text-2xl);
  font-weight: var(--ui-weight-heading);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: var(--ui-leading-tight);
  letter-spacing: -0.035em;
}

/* The section the reader is in: a dot of ink after its name. */
.ui-site-menu-link--large .ui-site-menu-label::after {
  content: "";
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  margin-inline-start: 0.5rem;
  border-radius: var(--ui-radius-round);
  background: var(--ui-ink);
  vertical-align: middle;
  opacity: 0;
  scale: 0.4;
  transition:
    opacity var(--ui-dur) var(--ui-ease),
    scale var(--ui-dur) var(--ui-ease-out);
}

.ui-site-menu-link[aria-current] .ui-site-menu-label::after {
  opacity: 1;
  scale: 1;
}

.ui-site-menu-link[aria-current] .ui-site-menu-index {
  color: var(--ui-fg);
}

.ui-site-menu-arrow {
  flex: none;
  align-self: center;
  opacity: 0;
  translate: -0.5rem 0;
  transition:
    opacity var(--ui-dur-fast) var(--ui-ease),
    translate var(--ui-dur) var(--ui-ease-out);
}

.ui-site-menu-link:hover .ui-site-menu-label,
.ui-site-menu-link:focus-visible .ui-site-menu-label {
  translate: 0.25rem 0;
}

.ui-site-menu-link:hover .ui-site-menu-arrow,
.ui-site-menu-link:focus-visible .ui-site-menu-arrow {
  opacity: 1;
  translate: 0 0;
}

/* The foot: a picture painted from the site's name, the actions sharing the width under it. One full-width column,
   whatever a dialog footer does on a phone. */
.ui-drawer > .ui-site-menu-foot {
  display: grid;
  grid-auto-flow: row;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(6.5rem, 1fr) auto;
  flex: 1;
  align-self: stretch;
  justify-content: stretch;
  gap: var(--ui-space-3);
  margin-top: 0;
}

.ui-site-menu-art {
  min-height: 6.5rem;
  border-radius: var(--ui-radius-nested);
}

.ui-site-menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-space-2);
}

.ui-site-menu-actions > * {
  flex: 1 1 8rem;
}

/* Opening: the rows rise in one after another, then the foot. */
@keyframes ui-site-menu-in {
  from {
    opacity: 0;
    translate: 0 0.75rem;
  }
}

.ui-site-menu[data-open] :is(.ui-site-menu-list > li, .ui-site-menu-foot) {
  animation: ui-site-menu-in var(--ui-dur-slow) var(--ui-ease-out) both;
  animation-delay: calc(var(--ui-dur-fast) * 0.5 + var(--i, 0) * 45ms * var(--ui-motion, 1));
}

/* ── Stacks stay packed ────────────────────────────────────────────── */

/*
 * A stack made of grid rows keeps its rows at the top when a neighbour makes it taller (two fields side by side, one
 * with a hint): the extra height goes below, never between a label and its field.
 */
:is(.ui-field, .ui-fieldset, .ui-card-header, .ui-dialog-header, .ui-item-text, .ui-stat, .ui-cell, .ui-checklist, .ui-choice-text, .ui-form-row-text, .ui-notification-body, .ui-notifications, .ui-timeline, .ui-timeline-item, .ui-sortable, .ui-tree, .ui-dl, .ui-alert, .ui-toast) {
  align-content: start;
}

/* ── Corners inside corners ────────────────────────────────────────── */

/*
 * A box inside a padded box follows its curve: the inner corner is the outer corner less the room between them, never
 * less than the small corner. Each padded box tells what it holds (--ui-radius-inner); every box put inside takes it.
 * A list, table or accordion put straight into a card (no room between) is part of the card and has no corner of its own.
 */
.ui-card,
.ui-card-body,
.ui-card-header,
.ui-card-footer {
  --ui-radius-inner: max(var(--ui-radius-sm), calc(var(--ui-radius-lg) - var(--ui-pad)));
}

.ui-dialog {
  --ui-radius-inner: max(var(--ui-radius-sm), calc(var(--ui-radius-xl) - var(--ui-pad-lg)));
}

.ui-popover {
  --ui-radius-inner: max(var(--ui-radius-sm), calc(var(--ui-radius-box) - var(--ui-space-4)));
}

.ui-inset {
  --ui-radius-inner: max(var(--ui-radius-sm), calc(max(calc(var(--ui-radius-lg) - var(--ui-space-2)), var(--ui-radius-sm)) - var(--ui-space-5)));
}

.ui-alert,
.ui-toast {
  --ui-radius-inner: max(var(--ui-radius-sm), calc(var(--ui-radius-box) - var(--ui-pad-sm)));
}

:is(.ui-card, .ui-dialog, .ui-popover, .ui-inset, .ui-alert, .ui-toast) :is(.ui-list, .ui-table-wrap, .ui-accordion, .ui-picture, .ui-filedrop, .ui-pre, .ui-alert, .ui-inset, .ui-scroll, .ui-card, .ui-cells, .ui-calendar-months, .ui-waterfall, .ui-board, .ui-board-column, .ui-tree, .ui-listbox, .ui-choice, .ui-sortable-item, .ui-resizable, .ui-cropper-viewport, .ui-empty, .ui-color-area) {
  border-radius: var(--ui-radius-inner);
}

/*
 * --ui-radius-inner is for what sits at the box's padding. An inset put straight into a card sits closer, at its own
 * small margin, so its corner is the card's less that margin: the two curves stay the same distance apart all round.
 */
.ui-card > .ui-inset {
  border-radius: max(calc(var(--ui-radius-lg) - var(--ui-space-2)), var(--ui-radius-sm));
}

/* Chips in a chips field follow the field's curve the same way. */
.ui-chips-field .ui-chip {
  border-radius: max(var(--ui-radius-sm), calc(var(--ui-radius-md) - var(--chips-pad)));
}

/* ── Field text is clipped where its room starts ───────────────────── */

/*
 * A browser clips a field's text at its padding edge, so long text would run under the rounded side and be sliced by the
 * curve. Here the side room is a clear part of the border and the visible line is drawn inside it (an outline set back
 * by its own width), so the text stops where its room starts. A value too long to show ends in "…" until it is edited.
 */
input.ui-input {
  /* No line at rest (a filled box); the line on hover and focus is drawn over the field's own fill. */
  --field-line: transparent;
  padding-inline: 0;
  border-color: transparent;
  border-inline-width: calc(1px + var(--ui-space-4));
  outline: 1px solid var(--field-line);
  outline-offset: -1px;
  text-overflow: ellipsis;
  transition:
    outline-color var(--ui-dur-fast) var(--ui-ease),
    background-color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur-fast) var(--ui-ease);
}

input.ui-input:hover {
  --field-line: var(--ui-border-hover);
  border-color: transparent;
}

input.ui-input:is(:focus, :focus-visible, [data-open]) {
  --field-line: var(--ui-highlight);
  border-color: transparent;
  outline: 1px solid var(--field-line);
  outline-offset: -1px;
}

input.ui-input:is([aria-invalid="true"], [data-invalid]) {
  --field-line: var(--ui-danger-text);
  border-color: transparent;
}

/*
 * A box that scrolls holds everything in it, also what is placed absolutely inside (a label for screen readers in a
 * table heading): it is the containing block, so nothing escapes the scroll and widens the page.
 */
:is(.ui-table-wrap, .ui-scroll, .ui-tabs-list, .ui-pre, .ui-fade-x) {
  position: relative;
}

/* ── One line colour ───────────────────────────────────────────────── */

/*
 * Every line that only shows where a box ends (a card, a cell, a list, a table, a badge, a chip, a field, a popup) is
 * --ui-border, and it is painted over what is behind the box, not over the box's own fill. So inside one card all its
 * lines are the same colour, whatever each box is filled with. The stronger line (--ui-border-strong) is only for
 * controls that are operated: a checkbox or radio edge, a switch track, a field or card on hover.
 */
:is(.ui-card, .ui-list, .ui-table-wrap, .ui-accordion, .ui-badge, .ui-chip, .ui-popup, .ui-toast, .ui-alert, .ui-choice, .ui-board-column, .ui-board-card, .ui-sortable-item, .ui-pre, .ui-filedrop, .ui-segmented, .ui-btn) {
  background-clip: padding-box;
}

/*
 * A box shows its edge with a fill or with a line, never both. Filled boxes (fields of every kind, cells) have no line
 * at rest: their fill runs to the edge, so no lighter rim shows around a darker fill. Their line appears on hover and
 * focus, where it says something.
 */
:is(.ui-input, .ui-input-group, .ui-cell, .ui-code-input > [data-slot="otp-input-slot"]) {
  border-color: transparent;
  background-clip: border-box;
}

input.ui-input {
  --field-line: transparent;
}

/* ── Logo: the site's name with a mark, drawn when no logo is given ── */

.ui-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-2);
  min-width: 0;
  color: var(--ui-fg);
  font-size: var(--ui-text-md);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  letter-spacing: -0.01em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity var(--ui-dur-fast) var(--ui-ease);
}

a.ui-logo:hover {
  opacity: 0.75;
}

.ui-logo-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--ui-h-sm);
  height: var(--ui-h-sm);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-primary);
  color: var(--ui-on-primary);
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-bold);
  --ui-icon-weight: var(--ui-icon-bold);
  letter-spacing: 0;
}

.ui-logo-mark :is(.ui-icon, svg) {
  width: 1.15em;
  height: 1.15em;
}

.ui-logo-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.ui-logo img {
  display: block;
  width: auto;
  height: var(--ui-h-sm);
}

/* ── Carousel arrows: a lifted circle, seen on the page and in a card alike ── */

.ui-btn.ui-carousel-arrow {
  border-color: var(--ui-card-border);
  background: var(--ui-surface);
  box-shadow: var(--ui-control-shadow);
}

.ui-btn.ui-carousel-arrow:hover {
  background: var(--ui-surface-2);
}

/* ── Cover: a picture filling a band, with what is said on a solid panel over it ── */

.ui-cover {
  position: relative;
  display: grid;
  min-height: var(--cover-height, min(72svh, 40rem));
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--ui-radius-xl);
}

.ui-cover--md {
  --cover-height: min(56svh, 30rem);
}

.ui-cover--full {
  --cover-height: 100svh;
}

.ui-cover.ui-bleed {
  border-radius: 0;
}

.ui-cover-media {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.ui-cover-media > :is(img, video, picture, .ui-pattern) {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The panel sits low in the band, at the start of the page column (or in its middle with align="center"). */
.ui-cover-inner {
  display: grid;
  align-content: end;
  justify-items: start;
  padding-block: var(--ui-gap-lg);
}

.ui-cover:not(.ui-bleed) .ui-cover-inner {
  padding-inline: var(--ui-gap-lg);
}

.ui-cover--center .ui-cover-inner {
  align-content: center;
  justify-items: center;
  text-align: center;
}

.ui-cover-panel {
  --ui-radius-inner: max(var(--ui-radius-sm), calc(var(--ui-radius-xl) - var(--ui-pad-lg)));
  display: grid;
  gap: var(--ui-space-4);
  width: min(36rem, 100%);
  padding: var(--ui-pad-lg);
  border: 1px solid var(--ui-float-border);
  border-radius: var(--ui-radius-xl);
  background: var(--ui-bar-bg);
  box-shadow: var(--ui-shadow-md);
}

.ui-cover--center .ui-cover-panel > .ui-row {
  justify-content: center;
}

/* ── Page to page (rule 14, "Nothing jumps") ──────────────────────────
 * Going to another page never just swaps the screen: the page fades out and the new one fades and rises in, while
 * what both pages share (the app's sidebar, a site's header, the tab bar) stays still. A site of plain pages gets it
 * from @view-transition; an app with client routing (Next.js) wraps each page's content in <PageTransition>, which
 * uses the same animation (class ui-page). In a browser without view transitions the new page fades in (below).
 */

/* What every page of the app or site shares keeps its place: one name each, so there is one per page. */
.ui-app > aside.ui-sidebar {
  view-transition-name: ui-sidebar;
}

.ui-site-page > .ui-site-header {
  view-transition-name: ui-site-header;
}

.ui-tabbar:not(.ui-tabbar--floating, :is(.ui-card, .ui-dialog) > .ui-tabbar) {
  view-transition-name: ui-tabbar;
}

::view-transition-group(*) {
  animation-duration: var(--ui-dur);
  animation-timing-function: var(--ui-ease);
}

/* The page that goes fades quickly; the new one fades and rises a little, the way ui-appear brings in a part. */
::view-transition-old(root),
::view-transition-old(.ui-page) {
  animation: ui-page-out var(--ui-dur-fast) var(--ui-ease) both;
}

::view-transition-new(root),
::view-transition-new(.ui-page) {
  animation: ui-page-in var(--ui-dur) var(--ui-ease-out) both;
}

@keyframes ui-page-out {
  to {
    opacity: 0;
  }
}

@keyframes ui-page-in {
  from {
    opacity: 0;
    translate: 0 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none;
  }
}

/* ── A page arrives (rule 14) ─────────────────────────────────────────
 * A page that comes on its own (a first visit, a reload, a typed address, a link from somewhere else, a browser
 * without view transitions) has no page before it to move from, so it fades in: the page's colour is there at once
 * and everything on it comes up together. No class and no script: every page that loads the kit gets it. Only the
 * fade, never a move: a body that moves would carry fixed things (a sticky bar, a dock) with it for a moment.
 * When the browser shows the move from the page before (above), that is the entrance and this one stands aside.
 * check-style.mjs stops the build if these rules go missing.
 */
body {
  transition: opacity var(--ui-dur-slow) var(--ui-ease);
}

@starting-style {
  body {
    opacity: 0;
  }
}

:root:active-view-transition body {
  transition: none;
}


/*
 * Supply UI: parts that come from UI SDK components (ui-sdk.dev).
 * The React components put these classes on the SDK's parts; the SDK adds the state (data-open, data-selected…)
 * and the measurements (--progress-value, --collapsible-panel-height…) the rules below read.
 */

/* The parts, in the order they apply. The build puts them together (and into their cascade layer); each file is one component or family. */
/* ── Avatar: the picture lies over the initials ────────────────────── */

.ui-avatar > * {
  grid-area: 1 / 1;
}

.ui-avatar-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

/* ── Progress and meter ────────────────────────────────────────────── */

.ui-gauge {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--ui-space-2);
  width: 100%;
}

.ui-gauge-label {
  color: var(--ui-fg);
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

.ui-gauge-value {
  color: var(--ui-fg-muted);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
  font-variant-numeric: tabular-nums;
}

.ui-gauge-track {
  position: relative;
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
  border-radius: var(--ui-radius-round);
  background: var(--ui-well-bg, var(--ui-surface-3));
  box-shadow: var(--ui-well-shadow);
}

.ui-gauge-fill {
  position: absolute;
  inset-block: 0;
  border-radius: var(--ui-radius-round);
  background: var(--ui-primary);
  transition:
    width var(--ui-dur-slow) var(--ui-ease-out),
    background-color var(--ui-dur) var(--ui-ease);
}

/* Not known yet how far: a short bar travels along the track. */
.ui-gauge-fill[data-indeterminate] {
  width: 40%;
  animation: ui-gauge-travel calc(1400ms * var(--ui-motion)) var(--ui-ease) infinite;
}

@keyframes ui-gauge-travel {
  from { inset-inline-start: -40%; }
  to { inset-inline-start: 100%; }
}

.ui-gauge[data-level="warning"] .ui-gauge-fill {
  background: var(--ui-warning);
}

.ui-gauge[data-level="danger"] .ui-gauge-fill {
  background: var(--ui-danger);
}

/* ── Collapsible ───────────────────────────────────────────────────── */

.ui-collapsible-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-2);
  padding: 0;
  border: 0;
  /* Rounded, so the keyboard focus ring follows the system's corners instead of a square box. */
  border-radius: var(--ui-radius-sm);
  background: none;
  color: var(--ui-fg);
  font-family: var(--ui-font-sans);
  font-size: var(--ui-text-base);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  text-align: start;
  cursor: pointer;
  transition: opacity var(--ui-dur-fast) var(--ui-ease);
}

.ui-collapsible-trigger::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  margin-inline: 0.15rem 0.2rem;
  border-right: 1.5px solid var(--ui-fg-muted);
  border-bottom: 1.5px solid var(--ui-fg-muted);
  transform: rotate(-45deg);
  transition: transform var(--ui-dur) var(--ui-ease-out);
}

.ui-collapsible-trigger[data-open]::before {
  transform: rotate(45deg);
}

.ui-collapsible-trigger[data-disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.ui-collapsible-panel {
  height: var(--collapsible-panel-height, auto);
  overflow: hidden;
  transition: height var(--ui-dur) var(--ui-ease-out);
}

.ui-collapsible-panel[data-starting-style],
.ui-collapsible-panel[data-ending-style] {
  height: 0;
}

/* What is inside fades and slides in as the panel grows, and back out as it shrinks. */
.ui-collapsible-panel > .ui-collapsible-content {
  transition:
    opacity var(--ui-dur) var(--ui-ease-out),
    translate var(--ui-dur) var(--ui-ease-out);
}

.ui-collapsible-panel[data-ending-style] > .ui-collapsible-content {
  opacity: 0;
  translate: 0 calc(-1 * var(--ui-space-2));
}

/* Opening: the content was hidden a moment before, so it fades in from its starting style. */
@starting-style {
  .ui-collapsible-panel[data-open] > .ui-collapsible-content {
    opacity: 0;
    translate: 0 calc(-1 * var(--ui-space-2));
  }
}

/* ── Rating: each star fills from its start edge, so half stars work ── */

.ui-rating-star[data-slot="rating-item"] {
  flex: none;
  width: calc(1.5 * var(--ui-u));
  height: calc(1.5 * var(--ui-u));
}

.ui-rating-star[data-slot="rating-item"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, var(--ui-warning) calc(var(--rating-fill, 0) * 100%), var(--ui-control-edge) 0);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z' stroke='%23000' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
  transition: opacity var(--ui-dur-fast) var(--ui-ease);
}

.ui-rating-star[data-slot="rating-item"]:dir(rtl)::before {
  background: linear-gradient(to left, var(--ui-warning) calc(var(--rating-fill, 0) * 100%), var(--ui-control-edge) 0);
}

/* The score a pointer is trying out. */
.ui-rating-star[data-highlighted]::before {
  opacity: 0.6;
}

.ui-rating-star > [data-slot="rating-radio"] {
  border-radius: var(--ui-radius-sm);
  cursor: pointer;
}

.ui-rating:is([data-readonly], [data-disabled]) [data-slot="rating-radio"] {
  cursor: default;
}

.ui-rating[data-disabled] {
  opacity: 0.55;
}

/* ── Carousel ──────────────────────────────────────────────────────── */

.ui-carousel-root {
  display: grid;
  gap: var(--ui-space-3);
  min-width: 0;
}

.ui-carousel-viewport {
  scrollbar-width: none;
  border-radius: var(--ui-radius-sm);
}

.ui-carousel-viewport::-webkit-scrollbar {
  display: none;
}

/* The slides can be dragged with a mouse or a pen, and say so: an open hand over them, a closed one while dragging. */
.ui-carousel-viewport {
  cursor: grab;
}

.ui-carousel-viewport[data-dragging] {
  cursor: grabbing;
}

.ui-carousel-viewport :is(a, button, input, label, [role="button"]) {
  cursor: pointer;
}

/* Pictures in a slide are moved with the slide, never dragged out of it on their own. */
.ui-carousel-viewport :is(img, svg, canvas) {
  -webkit-user-drag: none;
  user-select: none;
}

/* Bleed: the row runs to the edges of the card or dialog it sits in (always there; `bleed` for any other box, with its
   padding as a length); the first item still lines up with the text. The space goes on the viewport, whose scroll
   padding the carousel measures to place its snap points. */
:is(.ui-card-body, .ui-card-header, .ui-dialog) .ui-carousel-root,
.ui-carousel-root--bleed {
  --carousel-bleed: var(--bleed, var(--box-pad, var(--ui-pad)));
}

:is(.ui-card-body, .ui-card-header, .ui-dialog) .ui-carousel-root > .ui-carousel-viewport,
.ui-carousel-root--bleed > .ui-carousel-viewport {
  margin-inline: calc(-1 * var(--carousel-bleed));
  padding-inline: var(--carousel-bleed);
  border-radius: 0;
  scroll-padding-inline: var(--carousel-bleed);
  /* The box's own edge cuts the row cleanly; a fade on top would only darken the slide there. Only a carousel loose on
     the page fades out where more continues. */
  mask-image: none;
}

/*
 * A scroller does not count its padding after the last item, so at the end the last item would touch the box's edge.
 * A spacer as wide as the padding (less the gap the row adds before it) keeps the same room at the end as at the start.
 */
:is(.ui-card-body, .ui-card-header, .ui-dialog) .ui-carousel-root .ui-carousel::after,
.ui-carousel-root--bleed .ui-carousel::after {
  flex: 0 0 max(0px, calc(var(--carousel-bleed) - var(--ui-space-4)));
  content: "";
}

/* Inside the component the viewport scrolls, not the row. */
.ui-carousel[data-slot="carousel-content"] {
  overflow: visible;
  scroll-snap-type: none;
}

.ui-carousel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-3);
}

.ui-carousel-dots {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
}

.ui-carousel-dot {
  width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-round);
  background: var(--ui-control-edge);
  cursor: pointer;
  transition:
    width var(--ui-dur) var(--ui-ease-out),
    background-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-carousel-dot:hover {
  background: var(--ui-fg-muted);
}

.ui-carousel-dot[data-selected] {
  width: 1.25rem;
  background: var(--ui-chosen-fill) var(--ui-ink);
}

/* ── Scroll area ───────────────────────────────────────────────────── */

.ui-scroll[data-slot="scroll-area"] {
  max-height: none;
  overflow: hidden;
}

/* The content fades out towards an edge only while there is more beyond it. */
.ui-scroll-viewport {
  --scroll-area-overflow-y-start: inherit;
  --scroll-area-overflow-y-end: inherit;
  max-height: var(--max-height, 16rem);
  overscroll-behavior: contain;
  mask-image: linear-gradient(
    to bottom,
    transparent,
    #000 min(var(--ui-space-6), var(--scroll-area-overflow-y-start, 0px)),
    #000 calc(100% - min(var(--ui-space-6), var(--scroll-area-overflow-y-end, 0px))),
    transparent
  );
}

.ui-scroll-viewport::-webkit-scrollbar {
  display: none;
}

.ui-scrollbar {
  display: flex;
  padding: 2px;
  opacity: 0;
  transition: opacity var(--ui-dur-fast) var(--ui-ease);
}

.ui-scrollbar[data-orientation="vertical"] {
  flex-direction: column;
  width: 0.625rem;
}

.ui-scrollbar[data-orientation="horizontal"] {
  height: 0.625rem;
}

.ui-scrollbar:is([data-visible], [data-hovering], [data-scrolling]) {
  opacity: 1;
}

.ui-scrollbar-thumb {
  position: relative;
  border-radius: var(--ui-radius-round);
  background: var(--ui-border-strong);
  transition: background-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-scrollbar-thumb:hover,
.ui-scrollbar-thumb[data-dragging] {
  background: var(--ui-fg-muted);
}

/* ── Pagination: the list adds no box of its own ───────────────────── */

.ui-pagination-list,
.ui-pagination-list > li {
  display: contents;
}

/* ── Toolbar ───────────────────────────────────────────────────────── */

.ui-toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--ui-space-1);
}

.ui-toolbar > .ui-separator--vertical {
  align-self: center;
  height: calc(1.25 * var(--ui-u));
}

.ui-toolbar[data-orientation="vertical"] {
  flex-direction: column;
  align-items: stretch;
}

/* ── Password ──────────────────────────────────────────────────────── */

.ui-password {
  display: grid;
  gap: var(--ui-space-1);
  min-width: 0;
}

/* ── Files ─────────────────────────────────────────────────────────── */

.ui-file {
  display: grid;
  gap: var(--ui-space-2);
  min-width: 0;
}

/* The box takes drops and pastes; the button inside it opens the chooser. */
div.ui-filedrop {
  cursor: default;
}

.ui-filedrop[data-drag-reject] {
  border-color: var(--ui-danger-text);
  background: var(--ui-danger-soft);
}

.ui-file-list {
  display: grid;
  gap: var(--ui-space-1);
}

.ui-file-list:empty,
.ui-file-refused:empty {
  display: none;
}

.ui-file-item {
  display: flex;
  align-items: center;
  gap: var(--ui-space-2);
  min-height: var(--ui-h-md);
  padding: 0 var(--ui-space-1) 0 var(--ui-space-3);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  background: var(--ui-surface);
  font-size: var(--ui-text-sm);
}

.ui-file-item > .ui-icon {
  flex: none;
}

.ui-file-refused {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ── Calendar: the month is a real grid of cells ───────────────────── */

.ui-calendar-title[data-slot] {
  margin: 0;
  font-family: var(--ui-font-sans);
  font-size: var(--ui-text-base);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: var(--ui-leading);
  letter-spacing: normal;
}

.ui-calendar-months {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-space-5);
}

.ui-calendar--wide {
  width: auto;
  max-width: none;
}

.ui-calendar-table {
  display: grid;
  flex: 1 1 calc(15 * var(--ui-u));
  gap: 2px;
  min-width: 0;
  margin: 0;
  border: 0;
}

.ui-calendar-table :is(thead, tbody) {
  display: contents;
}

.ui-calendar-table tr {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.ui-calendar-table th {
  padding-inline: 0;
  font-weight: var(--ui-weight);
  --ui-icon-weight: 1;
}

/* The number sits in the middle of its cell (Safari needs to be told for a cell that takes its height from its width). */
.ui-day[data-slot] {
  align-content: center;
}

.ui-day[data-selected] {
  background: var(--ui-chosen-fill) var(--ui-ink);
  color: var(--ui-on-ink);
  box-shadow: none;
}

/* A range: its ends are filled, the days between them are tinted and join up. */
.ui-day[data-range-middle] {
  border-radius: 0;
  background: var(--ui-ink-soft);
  color: var(--ui-fg);
}

.ui-day[data-range-start]:not([data-range-end]) {
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}

.ui-day[data-range-end]:not([data-range-start]) {
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}

.ui-day[data-disabled],
.ui-day[data-unavailable] {
  background: none;
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Date and time typed part by part ──────────────────────────────── */

.ui-segments {
  gap: 0;
  font-variant-numeric: tabular-nums;
}

.ui-segments > [data-type="literal"] {
  padding-inline: 1px;
  color: var(--ui-fg-muted);
  white-space: pre;
}

.ui-segments > input {
  flex: none;
  width: calc(2ch + 6px);
  height: calc(1.6 * var(--ui-u));
  padding: 0 3px;
  border-radius: var(--ui-radius-sm);
  text-align: center;
  caret-color: transparent;
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    color var(--ui-dur-fast) var(--ui-ease);
}

.ui-segments > input[data-type="year"] {
  width: calc(4ch + 6px);
}

.ui-segments > input[data-type="dayPeriod"] {
  width: calc(2.6ch + 6px);
}

/* A part selects its own text when it is entered: the part's fill shows that, so the text keeps the colour that reads on it. */
.ui-segments > input::selection {
  background: transparent;
  color: var(--ui-on-ink);
}

.ui-segments > input:focus {
  background: var(--ui-chosen-fill) var(--ui-ink);
  color: var(--ui-on-ink);
}

.ui-segments > input:focus::placeholder {
  color: var(--ui-on-ink);
}

.ui-segments[data-disabled] {
  opacity: 0.55;
}

/* ── Timeline: status of a step, and events side by side ───────────── */

.ui-timeline-item:focus-visible {
  outline-offset: 4px;
  border-radius: var(--ui-radius-sm);
}

.ui-timeline-item[data-complete]::before {
  background: var(--ui-chosen-fill) var(--ui-ink);
}

.ui-timeline-item[data-upcoming] {
  color: var(--ui-fg-muted);
}

.ui-timeline[data-orientation="horizontal"] {
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
}

.ui-timeline[data-orientation="horizontal"] > .ui-timeline-item {
  padding: var(--ui-space-6) var(--ui-space-4) 0 0;
}

.ui-timeline[data-orientation="horizontal"] > .ui-timeline-item::before {
  top: 0;
  inset-inline-start: 0;
}

.ui-timeline[data-orientation="horizontal"] > .ui-timeline-item::after {
  top: calc(0.3125 * var(--ui-u) - 0.5px);
  inset-inline-end: 4px;
  bottom: auto;
  inset-inline-start: calc(0.625 * var(--ui-u) + 4px);
  width: auto;
  height: 1px;
}

/* ── Listbox: options that stay in view ────────────────────────────── */

.ui-listbox {
  display: grid;
  gap: 2px;
  max-height: var(--max-height, 16rem);
  padding: var(--ui-space-2);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-box);
  background: var(--ui-surface);
  outline: none;
  transition:
    border-color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur-fast) var(--ui-ease),
    opacity var(--ui-dur-fast) var(--ui-ease);
}

.ui-listbox:focus-within {
  border-color: var(--ui-highlight);
  box-shadow: 0 0 0 3px var(--ui-focus-halo);
}

.ui-listbox[data-orientation="horizontal"] {
  display: flex;
  overflow: auto hidden;
}

.ui-listbox[data-disabled] {
  opacity: 0.55;
}

.ui-listbox .ui-menu-item[data-selected] {
  background: var(--ui-ink-soft);
  color: var(--ui-fg);
}

/* The part of a suggestion that matches what was typed. */
.ui-match mark {
  background: none;
  color: inherit;
  font-weight: var(--ui-weight-bold);
  --ui-icon-weight: var(--ui-icon-bold);
}

/* A shortcut at the end of a menu row: the component writes it the way the person's computer shows it. */
.ui-menu-item > [data-slot$="-shortcut"] {
  margin-inline-start: auto;
  padding-inline-start: var(--ui-space-4);
  color: var(--ui-fg-subtle);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
}

/* The arrow of a submenu's row keeps to the far end, whatever the row holds before it. */
.ui-menu-item > .ui-menu-sub-arrow {
  margin-inline-start: auto;
  margin-inline-end: calc(var(--ui-space-1) * -1);
}

/* ── Menubar ───────────────────────────────────────────────────────── */

/* A bar: one quiet fill under its menus. Clear buttons alone on a page start their words a button's padding to the
   right of everything else, and look as if they had drifted. */
.ui-menubar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  width: fit-content;
  max-width: 100%;
  padding: 3px;
  border-radius: calc(var(--ui-radius-md) + 3px);
  background: var(--ui-well-bg, var(--ui-surface-2));
}

.ui-menubar[data-orientation="vertical"] {
  flex-direction: column;
  align-items: stretch;
  width: auto;
}

/* ── Tokens: pieces that stay whole inside text ────────────────────── */

.ui-token-editor {
  display: block;
  height: auto;
  min-height: var(--ui-h-md);
  padding-block: calc((var(--ui-h-md) - 1.5em) / 2 - 1px);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
}

.ui-token-editor[data-empty]::before {
  content: attr(aria-placeholder);
  color: var(--ui-fg-subtle);
  pointer-events: none;
}

.ui-token-editor [data-slot="token-input-host"] {
  display: inline-block;
  vertical-align: baseline;
}

.ui-token {
  display: inline-flex;
  align-items: center;
  gap: var(--ui-space-1);
  padding: 0 var(--ui-space-2);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-primary-soft);
  color: var(--ui-primary-text);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1.45;
  transition:
    background-color var(--ui-dur-fast) var(--ui-ease),
    color var(--ui-dur-fast) var(--ui-ease),
    opacity var(--ui-dur-fast) var(--ui-ease);
}

.ui-token[data-selected] {
  background: var(--ui-chosen-fill) var(--ui-ink);
  color: var(--ui-on-ink);
}

.ui-token[data-pending] {
  opacity: 0.6;
}

.ui-token[data-unresolved] {
  background: var(--ui-warning-soft);
  color: var(--ui-warning-text);
}

.ui-token-remove {
  display: inline-grid;
  place-items: center;
  border-radius: var(--ui-radius-sm);
  opacity: 0.6;
  cursor: pointer;
  transition: opacity var(--ui-dur-fast) var(--ui-ease);
}

.ui-token-remove:hover {
  opacity: 1;
}

.ui-token-remove > .ui-icon {
  width: 0.85em;
  height: 0.85em;
}

/* ── Navigation menu: a row of links, some with a panel of links ───── */

.ui-navmenu {
  position: relative;
}

.ui-navmenu-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-navmenu-list[data-orientation="vertical"] {
  flex-direction: column;
  align-items: stretch;
}

.ui-navmenu-trigger {
  font-family: var(--ui-font-sans);
}

/* On their own the links have the resting fill of a quiet button: clear, their words would start a button's padding
   to the right of everything else. In a site's header the header is the bar, and they stay clear. */
.ui-navmenu-trigger:not(.ui-site-header-links *) {
  background: var(--ui-surface-2);
}

.ui-navmenu-trigger:not(.ui-site-header-links *):hover {
  background: var(--ui-surface-3);
}

.ui-navmenu-trigger[data-open],
.ui-navmenu-trigger[data-current] {
  background: var(--ui-surface-3);
  color: var(--ui-fg);
}

.ui-navmenu-arrow {
  transition: transform var(--ui-dur) var(--ui-ease-out);
}

.ui-navmenu-trigger[data-open] > .ui-navmenu-arrow {
  transform: rotate(180deg);
}

/* One popup that holds whichever panel is open, and takes its size. */
.ui-navmenu-viewport {
  --panel-height: var(--available-height);
  width: var(--viewport-width);
  max-width: none;
  height: var(--viewport-height);
  padding: 0;
  overflow: hidden;
  transition:
    opacity var(--ui-dur) var(--ui-ease-out),
    transform var(--ui-dur) var(--ui-ease-out),
    width var(--ui-dur) var(--ui-ease-out),
    height var(--ui-dur) var(--ui-ease-out),
    left var(--ui-dur) var(--ui-ease-out),
    top var(--ui-dur) var(--ui-ease-out);
}

.ui-navmenu-content {
  width: max-content;
  max-width: calc(100vw - 2rem);
  max-height: var(--panel-height, none);
  padding: var(--ui-space-2);
  overflow-y: auto;
  outline: none;
  transition: opacity var(--ui-dur) var(--ui-ease-out);
}

.ui-navmenu-viewport > .ui-navmenu-content {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
}

.ui-navmenu-content[data-starting-style],
.ui-navmenu-content[data-ending-style] {
  opacity: 0;
}

.ui-navmenu-links {
  display: grid;
  gap: 2px;
  width: min(18rem, calc(100vw - 3rem));
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-navmenu-link {
  display: flex;
  align-items: flex-start;
  gap: var(--ui-space-3);
  padding: var(--ui-space-2) var(--ui-space-3);
  border-radius: max(calc(var(--ui-radius-box) - var(--ui-space-2)), var(--ui-radius-sm));
  color: var(--ui-fg);
  font-size: var(--ui-text-base);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  text-decoration: none;
  outline-offset: -2px;
  transition: background-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-navmenu-link:hover,
.ui-navmenu-link[data-highlighted] {
  background: var(--ui-surface-3);
}

.ui-navmenu-link > .ui-icon {
  flex: none;
  margin-top: 0.15em;
  color: var(--ui-fg-muted);
}

.ui-navmenu-link-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ui-navmenu-link-text > .ui-small {
  font-weight: var(--ui-weight);
  --ui-icon-weight: 1;
}

/* ── Drawer: a panel from an edge that can be dragged ──────────────── */

/* The drawer sets how dark this is as it moves. */
.ui-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--ui-z-overlay);
  background: var(--ui-overlay);
}

.ui-drawer-backdrop[data-hidden] {
  display: none;
}

[data-slot="drawer-viewport"] {
  position: fixed;
  inset: 0;
  z-index: var(--ui-z-overlay);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}

[data-slot="drawer-viewport"][data-side="top"] {
  justify-content: flex-start;
}

[data-slot="drawer-viewport"]:is([data-side="left"], [data-side="right"]) {
  flex-direction: row;
}

[data-slot="drawer-viewport"][data-side="left"] > * {
  margin-right: auto; /* physical: a drawer from the left or right side of the screen */
}

[data-slot="drawer-viewport"][data-side="right"] > * {
  margin-left: auto; /* physical: a drawer from the left or right side of the screen */
}

[data-slot="drawer-viewport"] > * {
  pointer-events: auto;
}

.ui-drawer {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-4);
  width: 100%;
  max-height: 85dvh;
  padding: var(--ui-pad-lg);
  border: 1px solid var(--ui-float-border);
  background: var(--ui-surface);
  color: var(--ui-fg);
  box-shadow: var(--ui-shadow-lg);
  outline: none;
}

/* Covers the gap a drag past the edge would open. */
.ui-drawer::after {
  content: "";
  position: absolute;
  background: inherit;
}

.ui-drawer:is([data-side="bottom"], [data-side="top"]) {
  max-width: var(--width, 34rem);
  height: fit-content;
  margin-inline: auto;
}

.ui-drawer:is([data-side="bottom"], [data-side="top"])::after {
  inset-inline: -1px;
  height: 6rem;
}

.ui-drawer[data-side="bottom"] {
  border-bottom: 0;
  border-radius: var(--ui-radius-xl) var(--ui-radius-xl) 0 0;
}

.ui-drawer[data-side="bottom"]::after {
  top: 100%;
}

.ui-drawer[data-side="top"] {
  border-top: 0;
  border-radius: 0 0 var(--ui-radius-xl) var(--ui-radius-xl);
}

.ui-drawer[data-side="top"]::after {
  bottom: 100%;
}

.ui-drawer:is([data-side="left"], [data-side="right"]) {
  width: min(var(--width, 24rem), 88vw);
  height: 100%;
  max-height: none;
  border-block: 0;
}

.ui-drawer:is([data-side="left"], [data-side="right"])::after {
  inset-block: 0;
  width: 6rem;
}

.ui-drawer[data-side="left"] {
  border-left: 0;
}

.ui-drawer[data-side="left"]::after {
  right: 100%; /* physical: a drawer from the left or right side of the screen */
}

.ui-drawer[data-side="right"] {
  border-right: 0;
}

.ui-drawer[data-side="right"]::after {
  left: 100%; /* physical: a drawer from the left or right side of the screen */
}

/* A drawer that rests at several heights is as tall as its highest one; the drawer shows as much of it as each asks. */
.ui-drawer:is([data-side="bottom"], [data-side="top"]):has(> button.ui-drawer-handle) {
  height: var(--height, 92dvh);
  max-height: none;
}

/* The short bar that says "drag me". As a button it moves the drawer between its resting places. */
.ui-drawer-handle {
  flex: none;
  align-self: center;
  width: 2.5rem;
  height: 0.3rem;
  margin-block: calc(var(--ui-space-3) * -1) 0;
  padding: 0;
  border: 0;
  border-radius: var(--ui-radius-round);
  background: var(--ui-border-strong);
  transition: background-color var(--ui-dur-fast) var(--ui-ease);
}

button.ui-drawer-handle {
  cursor: grab;
}

button.ui-drawer-handle:hover {
  background: var(--ui-fg-muted);
}

.ui-drawer:is([data-side="left"], [data-side="right"]) > .ui-drawer-handle {
  display: none;
}

.ui-drawer-body {
  flex: 1;
  min-height: 0;
  margin-inline: calc(var(--ui-pad-lg) * -1);
  padding-inline: var(--ui-pad-lg);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ── Waterfall: spans as bars on one time axis ─────────────────────── */

.ui-waterfall {
  --name: minmax(7rem, 14rem);
  --cell: minmax(3.5rem, 5.5rem);
  display: grid;
  min-width: 0;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  border-radius: var(--ui-radius-nested);
  font-size: var(--ui-text-sm);
  overflow: hidden;
}

.ui-waterfall-row {
  display: grid;
  grid-template-columns: var(--name) repeat(var(--columns, 0), var(--cell)) minmax(6rem, 1fr);
  align-items: center;
  min-height: calc(var(--ui-h-md) - 4px);
  border-top: 1px solid var(--ui-border);
  outline-offset: -2px;
  cursor: default;
  transition: background-color var(--ui-dur-fast) var(--ui-ease);
}

.ui-waterfall-row[hidden] {
  display: none;
}

.ui-waterfall-head {
  min-height: var(--ui-h-sm);
  border-top: 0;
  background: var(--ui-surface-2);
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-xs);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

.ui-waterfall-row:not(.ui-waterfall-head):hover {
  background: var(--ui-surface-2);
}

.ui-waterfall-row[data-selected] {
  background: var(--ui-ink-soft);
}

.ui-waterfall-name {
  display: flex;
  align-items: center;
  gap: var(--ui-space-1);
  min-width: 0;
  padding-inline: calc(var(--ui-space-3) + (var(--waterfall-level, 1) - 1) * var(--ui-space-4)) var(--ui-space-2);
}

/* A span without children keeps the arrow's room, so the names line up. */
.ui-waterfall-row:not([data-branch], .ui-waterfall-head) > .ui-waterfall-name {
  padding-inline-start: calc(var(--ui-space-3) + (var(--waterfall-level, 1) - 1) * var(--ui-space-4) + 1em + var(--ui-space-1));
}

.ui-waterfall-indicator {
  display: inline-grid;
  flex: none;
  color: var(--ui-fg-muted);
  cursor: pointer;
  transition: transform var(--ui-dur) var(--ui-ease-out);
}

.ui-waterfall-indicator[data-expanded] {
  transform: rotate(90deg);
}

.ui-waterfall-cell {
  padding-inline: var(--ui-space-2);
  color: var(--ui-fg-muted);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
  white-space: nowrap;
}

.ui-waterfall-track {
  position: relative;
  align-self: stretch;
  min-width: 0;
  margin-inline: var(--ui-space-2) var(--ui-space-4);
}

/* The bar itself: placed and sized by the span's start and length. */
.ui-waterfall-row:not(.ui-waterfall-head) > .ui-waterfall-track::before {
  content: "";
  position: absolute;
  inset-block: 28%;
  inset-inline-start: var(--waterfall-start, 0%);
  width: max(var(--waterfall-size, 0%), 3px);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-primary);
  transition:
    inset-inline-start var(--ui-dur) var(--ui-ease-out),
    width var(--ui-dur) var(--ui-ease-out);
}

.ui-waterfall-row[data-level="1"] > .ui-waterfall-track::before {
  background: var(--ui-fg);
}

.ui-waterfall-axis {
  position: absolute;
  inset: 0;
}

/* A tick label that would run into another label hides; its line stays (Waterfall measures this). */
.ui-waterfall-axis > [data-slot="waterfall-tick"][data-crowded] {
  color: transparent;
}

.ui-waterfall-axis > [data-slot="waterfall-tick"] {
  position: absolute;
  inset-block: 0;
  inset-inline-start: var(--waterfall-tick);
  display: flex;
  align-items: center;
  padding-inline-start: var(--ui-space-1);
  border-inline-start: 1px solid var(--ui-border);
  font-family: var(--ui-font-mono);
  white-space: nowrap;
}

/* A marked moment sits in the head like a tick: a line the full height of the head and its label centred beside it,
   in the brand's text colour, over the ticks it passes. */
.ui-waterfall-mark {
  position: absolute;
  inset-block: 0;
  inset-inline-start: var(--waterfall-mark);
  z-index: 1;
  display: flex;
  align-items: center;
  padding-inline: var(--ui-space-1);
  border-inline-start: 1px solid var(--ui-primary-text);
  background: var(--ui-surface-2);
  color: var(--ui-primary-text);
  font-family: var(--ui-font-mono);
  white-space: nowrap;
}

/* Where it would run past the edge, the label sits before the line. */
.ui-waterfall-mark[data-end] {
  border-inline-start: 0;
  border-inline-end: 1px solid var(--ui-primary-text);
  translate: -100% 0;
}

/* It fits on neither side (a narrow screen): only the line shows; the label is its title. */
.ui-waterfall-mark[data-crowded] {
  padding: 0;
  background: none;
  font-size: 0;
}

/* A name too long for its column takes a second line instead of losing its end. */
.ui-waterfall-label {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  line-height: var(--ui-leading-tight);
}

.ui-waterfall-row:not(.ui-waterfall-head) > .ui-waterfall-name {
  padding-block: var(--ui-space-1);
}

/* A narrow box (a phone): the names and the cells give up width before the bars run out of the box. */
.ui-waterfall {
  container: ui-waterfall / inline-size;
}

@container ui-waterfall (max-width: 22rem) {
  .ui-waterfall-row {
    grid-template-columns: minmax(0, 1.2fr) repeat(var(--columns, 0), minmax(0, auto)) minmax(4.5rem, 1fr);
  }
}

/* ── Date picker: the field's inputs share its width ───────────────── */

.ui-date-picker > input {
  /* A date is always the same length: each input keeps room for all of it, so a range in a narrow box never cuts one. */
  min-width: 10.5ch;
  font-variant-numeric: tabular-nums;
}

/* ── What changed, and by whom ─────────────────────────────────────── */

.ui-activity {
  display: grid;
  justify-items: start;
  gap: var(--ui-space-3);
  min-width: 0;
}

.ui-activity-list {
  display: grid;
  gap: var(--ui-space-2);
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ui-activity-item {
  display: flex;
  align-items: baseline;
  gap: var(--ui-space-2);
  font-size: var(--ui-text-sm);
  transition: opacity var(--ui-dur-fast) var(--ui-ease);
}

.ui-activity-item[data-reverted] {
  opacity: 0.5;
  text-decoration: line-through;
}

.ui-activity-who {
  flex: none;
  padding: 0 var(--ui-space-2);
  border-radius: var(--ui-radius-sm);
  background: var(--ui-surface-3);
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-xs);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
  line-height: 1.6;
}

.ui-activity-item[data-source="agent"] > .ui-activity-who {
  background: var(--ui-primary-soft);
  color: var(--ui-primary-text);
}

.ui-activity-what {
  min-width: 0;
  color: var(--ui-fg);
}

/* A control that holds a suggested value, until the person keeps it or puts it back. */
[data-suggested] {
  outline: 2px dashed var(--ui-primary-text);
  outline-offset: 3px;
  border-radius: var(--ui-radius-md);
}

/* ── Board: cards moved between columns ────────────────────────────── */

/* Columns side by side where they fit. Where they do not (a phone), the ones that do not fit go under the others
   at full width: a column cut off at the edge of its box reads as broken, and nothing says it scrolls. */
.ui-board {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--ui-space-3);
  min-width: 0;
}

.ui-board-column {
  display: flex;
  flex: 1 1 11rem;
  flex-direction: column;
  gap: var(--ui-space-2);
  min-width: 0;
  padding: var(--ui-space-3);
  border-radius: var(--ui-radius-box);
  background: var(--ui-surface-2);
  transition: opacity var(--ui-dur-fast) var(--ui-ease);
}

/* On the bare page (not in a card or a dialog) the quiet fill would be the page's own colour: one step deeper instead. */
.ui-board-column:not(:is(.ui-card, .ui-dialog, .ui-popover, .ui-drawer, .ui-sheet, .ui-inset) .ui-board-column) {
  background: var(--ui-surface-3);
}

/* …and what was one step deeper in it (a muted count) is the card colour instead. */
.ui-board-column:not(:is(.ui-card, .ui-dialog, .ui-popover, .ui-drawer, .ui-sheet, .ui-inset) .ui-board-column) .ui-count--muted {
  background: var(--ui-surface);
}

.ui-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-2);
  padding-inline: var(--ui-space-1);
  color: var(--ui-fg-muted);
  font-size: var(--ui-text-sm);
  font-weight: var(--ui-weight-medium);
  --ui-icon-weight: var(--ui-icon-medium);
}

/* The whole column takes a drop, also below its last card. */
.ui-board-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--ui-space-2);
  min-height: var(--ui-h-md);
}

.ui-board-card {
  min-width: 0;
  padding: var(--ui-space-3);
  border: 1px solid var(--ui-border);
  border-radius: max(calc(var(--ui-radius-box) - var(--ui-space-3)), var(--ui-radius-sm));
  background: var(--ui-surface);
  font-size: var(--ui-text-sm);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition:
    border-color var(--ui-dur-fast) var(--ui-ease),
    box-shadow var(--ui-dur-fast) var(--ui-ease),
    opacity var(--ui-dur-fast) var(--ui-ease);
}

.ui-board-card:hover {
  border-color: var(--ui-border-hover);
}

/* Picked up with the keyboard: lifted. Dragged: a copy follows the pointer, and the card shows where it would land. */
.ui-board-card[data-grabbed] {
  border-color: var(--ui-highlight);
  box-shadow: var(--ui-shadow-md);
}

.ui-board-card[data-dragging] {
  opacity: 0.4;
  box-shadow: none;
}

.ui-board-card[data-drag-preview] {
  box-shadow: var(--ui-shadow-lg);
  cursor: grabbing;
}

/* ── Several chosen, as chips inside the field ─────────────────────── */

/*
 * A field that holds chips keeps the same room on every side: what is left of a field's height around one row of chips.
 * The text being typed starts where a chip's text does, so it lines up with the chips above it.
 */
.ui-chips-field {
  --chips-pad: calc((var(--ui-h-md) - var(--ui-h-sm)) / 2 - 1px);
  --field-pad: var(--chips-pad);
  height: auto;
  min-height: var(--ui-h-md);
  padding: var(--chips-pad);
}

.ui-chips {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-space-1);
  min-width: 0;
}

.ui-chips > input {
  flex: 1 1 5rem;
  min-width: 3rem;
  height: calc(var(--ui-h-sm) - 2px);
  padding: 0 var(--ui-space-3);
  border: 0;
  background: none;
  outline: none;
  color: inherit;
  font-family: var(--ui-font-sans);
  font-size: inherit;
}

.ui-chips > input::placeholder {
  color: var(--ui-fg-subtle);
  opacity: 1;
}

/* ── Range slider: the two values above the track ──────────────────── */

.ui-slider-value {
  display: block;
  margin-bottom: var(--ui-space-1);
  color: var(--ui-fg-muted);
  font-family: var(--ui-font-mono);
  font-size: var(--ui-text-xs);
  font-variant-numeric: tabular-nums;
}

/* A checkbox in a tree row sits between the arrow and the name. */
.ui-tree-row > .ui-checkbox {
  flex: none;
}

/* Last, so it wins over every component and part at the same specificity. */
/* ── High contrast: Windows' forced colours, and "more contrast" ────── */

/*
 * Forced colours (Windows high contrast, some browser modes) repaint every fill and text in the person's own colours
 * and drop every shadow. What the kit shows with a fill or a shadow alone (a field, a card, a chosen option, a focus
 * halo, a bar of progress) would vanish, so here it gets an edge, the system's Highlight, or keeps its own colour.
 */
@media (forced-colors: active) {
  /* Every box that was only a fill gets an edge. An outline, not a border: it takes no room, so nothing moves. */
  :is(.ui-input, .ui-input-group, .ui-select, .ui-cell, .ui-segmented, .ui-card, .ui-popup, .ui-dialog, .ui-drawer, .ui-toast, .ui-alert, .ui-inset, .ui-chip, .ui-badge, .ui-code-input > [data-slot="otp-input-slot"], .ui-board-column, .ui-board-card, .ui-sortable-item, .ui-choice, .ui-list, .ui-table-wrap) {
    outline: 1px solid CanvasText;
    outline-offset: -1px;
  }

  .ui-btn:not(.ui-btn--ghost, .ui-btn--link) {
    outline: 1px solid ButtonText;
    outline-offset: -1px;
  }

  /* Controls that are only an edge keep a strong one. */
  :is(.ui-checkbox, .ui-radio, .ui-switch) {
    border-color: ButtonText;
    outline: 1px solid ButtonText;
    outline-offset: -1px;
  }

  .ui-switch::before {
    forced-color-adjust: none;
    background: ButtonText;
  }

  /* What is chosen or on: the system's highlight, in its own text colour. */
  :is(.ui-segmented-item, .ui-tab, .ui-btn, .ui-nav-item, .ui-day, .ui-menu-item, .ui-tabbar-item, [role="option"], [role="tab"]):is([data-checked], [aria-checked="true"], [aria-pressed="true"], [aria-selected="true"], [aria-current="page"], [data-selected]),
  :is(.ui-checkbox, .ui-radio, .ui-switch):is(:checked, [data-checked]) {
    forced-color-adjust: none;
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
  }

  /* The pill that slides behind the chosen option, and the line under the chosen tab, are drawn behind the row. */
  :is(.ui-segmented, .ui-tabs-list)::before {
    forced-color-adjust: none;
    background: Highlight;
  }

  /* Focus is always an outline: the kit's soft halos are shadows, which forced colours remove. */
  :focus-visible,
  .ui-input-group:focus-within,
  .ui-code-input > [data-slot="otp-input-slot"][data-active] {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }

  /* Progress, meters, bars and rings keep their fill, drawn in the highlight colour. */
  :is(.ui-gauge-fill, .ui-bar, .ui-ring::before, .ui-slider-range, [data-slot="slider-range"]) {
    forced-color-adjust: none;
    background: Highlight;
  }

  /* Pictures the kit paints stay as they are: they are pictures, not text on a fill. */
  .ui-pattern {
    forced-color-adjust: none;
  }
}


/*
 * Supply UI — theme: Simple.
 *
 * Flat layers, soft lines, depth only on what floats. Simple is the Material tokens as tokens.css sets them, so this
 * file has nothing to change: it is here so every theme has its file, and as the pattern for the next one.
 *
 * ── Adding a theme (3D, Neumorphism, Glass…) ──────────────────────────
 * 1. Add it to `themeStyles` in src/react/theme.ts: a value (lowercase letters and digits, it is also the file name
 *    and the theme code's `t` part), a label and one line saying what it looks like.
 * 2. Make src/css/themes/<value>.css. Every rule starts with [data-ui-style="<value>"], so the theme applies to the
 *    element that carries it (normally <html>) and everything inside it.
 * 3. Set the Material tokens (tokens.css, "Material") the theme needs, in light-dark() where light and dark differ.
 *    Write every one you change, also the -hover and -active ones: tokens worked out from others are worked out on
 *    <html>, so a theme on a smaller part of the page would not reach them otherwise.
 * 4. A theme never sets the owner's choices (brand colour, greys, page, corners, size, icons, fonts): the build stops
 *    if it does. If the theme needs something no Material token gives, add a token to tokens.css with Simple's value,
 *    make the components read it, and then set it here: every theme gains the knob, and Simple stays as it is.
 *    Rules for single components are the last resort, and still read tokens.
 * 5. Run node build.mjs (it checks all of the above), look at /ui/ in the theme, light and dark, and bump VERSION.
 *
 * The build adds the files in the order of `themeStyles`.
 */

[data-ui-style="simple"] {
  /* The Material defaults in tokens.css. */
}
}
