/* @svelte-lean/styles — design tokens: the theme.
 * Every token is a `--slean-*` custom property inside the `slean.tokens` layer, so an unlayered
 * override in application CSS always wins: a theme is a block of token overrides (see the
 * package README, "Create a theme"), and there is no JavaScript. Every selector is
 * zero-specificity, like the rest of the package; within this layer the source order decides.
 *
 * Blocks, in order:
 * 1. Theme-independent tokens on :root: spacing unit and scale, shape (radius), control heights,
 *    icons, typography (families, sizes, the h1-h6 / subtitle / body / caption / overline / button
 *    scale), motion (durations and easings), z-index, breakpoints.
 * 2. The palette: light on :root, dark under prefers-color-scheme: dark and on data-theme="dark"
 *    or class="dark". Per color (primary, secondary, error, warning, info, success) a main, light
 *    and dark tone, the contrast text on main, and the soft tint and its text; elevation 0-5. A
 *    theme scope forces a palette on its subtree: data-theme="light|dark" or class="light|dark".
 * 3. Semantic aliases (surfaces, text, border, neutral palette, the current color, control shell,
 *    focus ring, component defaults) derived from the palette and declared again on every theme
 *    scope (data-theme, data-slean-theme, .dark, .light), so a subtree that redefines
 *    --slean-primary-main also recolors its focus rings, hovered borders and selected options.
 * 4. The current color (data-color on any element, ADR 0011 §3.3), the components whose default
 *    color is neutral, and density (data-density="compact|comfortable" on any element).
 * 5. Forced colors, reduced motion and coarse-pointer adjustments. */
@layer slean.reset, slean.tokens, slean.base, slean.components, slean.compositions, slean.utilities;

@layer slean.tokens {
	:where(:root) {
		/* Spacing: one unit and its multiples. Override --slean-spacing on :root to scale every gap
		 * and padding of the package at once. */
		--slean-spacing: 0.25rem;
		--slean-space-1: calc(var(--slean-spacing) * 1);
		--slean-space-2: calc(var(--slean-spacing) * 2);
		--slean-space-3: calc(var(--slean-spacing) * 3);
		--slean-space-4: calc(var(--slean-spacing) * 4);
		--slean-space-5: calc(var(--slean-spacing) * 5);
		--slean-space-6: calc(var(--slean-spacing) * 6);
		--slean-space-7: calc(var(--slean-spacing) * 8);
		--slean-space-8: calc(var(--slean-spacing) * 10);

		/* Shape: one radius and its steps. --slean-radius is the medium step (fields, buttons,
		 * cards); 0 gives a square theme. */
		--slean-radius: 0.625rem;
		--slean-radius-sm: calc(var(--slean-radius) * 0.6);
		--slean-radius-md: var(--slean-radius);
		--slean-radius-lg: calc(var(--slean-radius) * 1.4);
		--slean-radius-full: 9999px;

		/* The space between a dialog's children (none by default: the header and the footer bring
		 * their own). Set it here rather than with gap on the dialog, so the close button, which
		 * takes no room, cancels it. */
		--slean-dialog-gap: 0px;

		/* Control heights of data-size="small" (32px), "medium" (36px, the default of every form
		 * control, button and bar) and "large" (44px); xs (28px) is for dense rows. A coarse pointer
		 * raises them to 40, 44 and 48px; data-density changes them for a subtree (block 4). */
		--slean-control-height-xs: 1.75rem;
		--slean-control-height-sm: 2rem;
		--slean-control-height-md: 2.25rem;
		--slean-control-height-lg: 2.75rem;
		/* The border of a field under the pointer (outlined variant). Unset by default, so it is the
		 * field's current color (data-color, primary by default); a theme sets it to soften the
		 * hover, for example to var(--slean-fg-muted). */
		--slean-control-border-hover: initial;
		/* The check mark at the end of a chosen option row. */
		--slean-option-check-size: 1rem;
		/* The side of a file drop tile (data-variant="picture-card" and "picture-circle"): each
		 * chosen file and the add tile. */
		--slean-file-drop-tile-size: 6.5rem;

		/* Icons (ADR 0007): 16×16 SVG masks. A primitive paints one with
		 * `background: currentColor; mask: var(--slean-icon-…) center / contain no-repeat`, so it
		 * takes the text color and follows the theme. Replace a token to swap an icon set. */
		--slean-icon-select: var(--slean-icon-chevron-down);
		/* How far the select icon turns while the list is open: a chevron points up; an
		 * up-and-down pair stays as it is (0deg). */
		--slean-icon-select-turn: 180deg;
		--slean-icon-chevron-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
		--slean-icon-chevron-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 10l4-4 4 4' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
		--slean-icon-chevron-left: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M10 4L6 8l4 4' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
		--slean-icon-chevron-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 4l4 4-4 4' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
		--slean-icon-chevrons-left: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 4L4 8l4 4M12 4L8 8l4 4' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
		--slean-icon-chevrons-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l4 4-4 4M8 4l4 4-4 4' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
		--slean-icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
		--slean-icon-minus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8h9' stroke='black' stroke-width='1.5' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
		--slean-icon-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 3.5v9M3.5 8h9' stroke='black' stroke-width='1.5' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
		--slean-icon-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 4.5l7 7m0-7l-7 7' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
		--slean-icon-clear: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cdefs%3E%3Cmask id='m'%3E%3Crect width='16' height='16' fill='white'/%3E%3Cpath d='M6 6l4 4m0-4l-4 4' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/mask%3E%3C/defs%3E%3Ccircle cx='8' cy='8' r='6.5' mask='url(%23m)'/%3E%3C/svg%3E");
		--slean-icon-more: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='3.5' cy='8' r='1.25'/%3E%3Ccircle cx='8' cy='8' r='1.25'/%3E%3Ccircle cx='12.5' cy='8' r='1.25'/%3E%3C/svg%3E");
		--slean-icon-grip: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 4h.01M10 4h.01M6 8h.01M10 8h.01M6 12h.01M10 12h.01' stroke='black' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
		--slean-icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5L14 14'/%3E%3C/g%3E%3C/svg%3E");
		--slean-icon-eye: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M1.5 8s2.5-4.5 6.5-4.5S14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2'/%3E%3C/g%3E%3C/svg%3E");
		--slean-icon-eye-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M1.5 8s2.5-4.5 6.5-4.5S14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z'/%3E%3Ccircle cx='8' cy='8' r='2'/%3E%3Cpath d='M2.5 2.5l11 11'/%3E%3C/g%3E%3C/svg%3E");
		--slean-icon-calendar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Crect x='2.5' y='3.5' width='11' height='10' rx='1.5'/%3E%3Cpath d='M2.5 6.75h11M5.5 2v3M10.5 2v3'/%3E%3C/g%3E%3C/svg%3E");
		--slean-icon-arrow-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 8h11M10 4.5L13.5 8 10 11.5' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
		--slean-icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='8' cy='8' r='6.25'/%3E%3Cpath d='M8 7.5v3.5M8 5v.01'/%3E%3C/g%3E%3C/svg%3E");
		--slean-icon-success: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='8' cy='8' r='6.25'/%3E%3Cpath d='M5.5 8.25l1.75 1.75 3.25-3.5'/%3E%3C/g%3E%3C/svg%3E");
		--slean-icon-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M6.7 2.75a1.5 1.5 0 012.6 0l5.1 8.9a1.5 1.5 0 01-1.3 2.25H2.9a1.5 1.5 0 01-1.3-2.25z'/%3E%3Cpath d='M8 6.25v3M8 11.5v.01'/%3E%3C/g%3E%3C/svg%3E");
		--slean-icon-error: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Ccircle cx='8' cy='8' r='6.25'/%3E%3Cpath d='M10 6l-4 4M6 6l4 4'/%3E%3C/g%3E%3C/svg%3E");
		--slean-icon-file: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'%3E%3Cpath d='M9 1.75H4.5a1.5 1.5 0 00-1.5 1.5v9.5a1.5 1.5 0 001.5 1.5h7a1.5 1.5 0 001.5-1.5V5.75z'/%3E%3Cpath d='M9 1.75v4h4'/%3E%3C/g%3E%3C/svg%3E");
		--slean-icon-upload: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 10.5V2.5m0 0L5 5.5m3-3l3 3M2.5 10.5v1.5a1.5 1.5 0 001.5 1.5h8a1.5 1.5 0 001.5-1.5v-1.5' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");

		/* Typography. --slean-font-sans is the theme's family: a family list, or `initial` (on any
		 * element; `inherit` on :root does the same) for the page's own font: the token is then
		 * invalid, and `font-family: var(--slean-font-sans)` falls back to the inherited family.
		 * The scale is MUI's set of variants at an application-sized ramp: per variant a weight, a
		 * size and a line height (longhands, which the package reads, so the family can be
		 * invalid), and a `font` shorthand of the three and the family for your own rules (with
		 * the family invalid, the whole shorthand is: use the longhands).
		 * data-typography="h1" … on any element applies a variant (base.css). Controls (buttons,
		 * fields) take the page's family. */
		--slean-font-sans:
			Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
		--slean-font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
		--slean-text-xs: 0.75rem;
		--slean-text-sm: 0.875rem;
		--slean-text-md: 1rem;
		--slean-text-lg: 1.125rem;
		--slean-leading: 1.5;
		--slean-font-weight-regular: 400;
		--slean-font-weight-medium: 500;
		--slean-font-weight-semibold: 600;
		--slean-font-weight-bold: 700;
		--slean-typography-h1-weight: 700;
		--slean-typography-h1-size: 2.25rem;
		--slean-typography-h1-line-height: 1.2;
		--slean-typography-h2-weight: 700;
		--slean-typography-h2-size: 1.875rem;
		--slean-typography-h2-line-height: 1.25;
		--slean-typography-h3-weight: 600;
		--slean-typography-h3-size: 1.5rem;
		--slean-typography-h3-line-height: 1.3;
		--slean-typography-h4-weight: 600;
		--slean-typography-h4-size: 1.25rem;
		--slean-typography-h4-line-height: 1.35;
		--slean-typography-h5-weight: 600;
		--slean-typography-h5-size: 1.125rem;
		--slean-typography-h5-line-height: 1.4;
		--slean-typography-h6-weight: 600;
		--slean-typography-h6-size: 1rem;
		--slean-typography-h6-line-height: 1.5;
		--slean-typography-subtitle1-weight: 500;
		--slean-typography-subtitle1-size: 1rem;
		--slean-typography-subtitle1-line-height: 1.5;
		--slean-typography-subtitle2-weight: 500;
		--slean-typography-subtitle2-size: 0.875rem;
		--slean-typography-subtitle2-line-height: 1.45;
		--slean-typography-body1-weight: 400;
		--slean-typography-body1-size: 1rem;
		--slean-typography-body1-line-height: 1.5;
		--slean-typography-body2-weight: 400;
		--slean-typography-body2-size: 0.875rem;
		--slean-typography-body2-line-height: 1.45;
		--slean-typography-caption-weight: 400;
		--slean-typography-caption-size: 0.75rem;
		--slean-typography-caption-line-height: 1.65;
		--slean-typography-overline-weight: 500;
		--slean-typography-overline-size: 0.75rem;
		--slean-typography-overline-line-height: 2;
		--slean-typography-button-weight: 500;
		--slean-typography-button-size: 0.875rem;
		--slean-typography-button-line-height: 1.25;
		--slean-typography-h1: var(--slean-typography-h1-weight) var(--slean-typography-h1-size) /
			var(--slean-typography-h1-line-height) var(--slean-font-sans);
		--slean-typography-h2: var(--slean-typography-h2-weight) var(--slean-typography-h2-size) /
			var(--slean-typography-h2-line-height) var(--slean-font-sans);
		--slean-typography-h3: var(--slean-typography-h3-weight) var(--slean-typography-h3-size) /
			var(--slean-typography-h3-line-height) var(--slean-font-sans);
		--slean-typography-h4: var(--slean-typography-h4-weight) var(--slean-typography-h4-size) /
			var(--slean-typography-h4-line-height) var(--slean-font-sans);
		--slean-typography-h5: var(--slean-typography-h5-weight) var(--slean-typography-h5-size) /
			var(--slean-typography-h5-line-height) var(--slean-font-sans);
		--slean-typography-h6: var(--slean-typography-h6-weight) var(--slean-typography-h6-size) /
			var(--slean-typography-h6-line-height) var(--slean-font-sans);
		--slean-typography-subtitle1: var(--slean-typography-subtitle1-weight)
			var(--slean-typography-subtitle1-size) / var(--slean-typography-subtitle1-line-height)
			var(--slean-font-sans);
		--slean-typography-subtitle2: var(--slean-typography-subtitle2-weight)
			var(--slean-typography-subtitle2-size) / var(--slean-typography-subtitle2-line-height)
			var(--slean-font-sans);
		--slean-typography-body1: var(--slean-typography-body1-weight)
			var(--slean-typography-body1-size) / var(--slean-typography-body1-line-height)
			var(--slean-font-sans);
		--slean-typography-body2: var(--slean-typography-body2-weight)
			var(--slean-typography-body2-size) / var(--slean-typography-body2-line-height)
			var(--slean-font-sans);
		--slean-typography-caption: var(--slean-typography-caption-weight)
			var(--slean-typography-caption-size) / var(--slean-typography-caption-line-height)
			var(--slean-font-sans);
		--slean-typography-overline: var(--slean-typography-overline-weight)
			var(--slean-typography-overline-size) / var(--slean-typography-overline-line-height)
			var(--slean-font-sans);
		--slean-typography-button: var(--slean-typography-button-weight)
			var(--slean-typography-button-size) / var(--slean-typography-button-line-height)
			var(--slean-font-sans);
		--slean-typography-button-transform: none;
		--slean-typography-overline-transform: uppercase;

		/* Motion. The indicator duration is one turn of a loading indicator (the busy button and
		 * the circular progress); reduced motion slows it instead of stopping it, so a still ring never reads
		 * as a stuck page. */
		--slean-duration-fast: 100ms;
		--slean-duration-normal: 160ms;
		--slean-duration-slow: 240ms;
		--slean-duration-indicator: 750ms;
		--slean-ease: cubic-bezier(0.2, 0, 0, 1);
		--slean-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
		--slean-ease-out: cubic-bezier(0, 0, 0.2, 1);
		--slean-ease-in: cubic-bezier(0.4, 0, 1, 1);
		--slean-ease-sharp: cubic-bezier(0.4, 0, 0.6, 1);

		/* Scroll edge fades (scroll-area.css, data-slean-fade): how deep the fade at an edge that
		 * can still scroll is (set on :root, as the ramp reads it there), and the mask's ramp over
		 * that depth (only the alpha counts) — eased, so the row at the edge stays a ghost of
		 * itself rather than a gap. */
		--slean-fade-size: 1.5rem;
		--slean-fade-ramp:
			oklch(0% 0 0 / 0.08), oklch(0% 0 0 / 0.55) calc(var(--slean-fade-size) / 2),
			oklch(0% 0 0) var(--slean-fade-size);

		/* Stacking, for application chrome outside the top layer (a sticky app bar, an in-page
		 * drawer). Dialogs, popovers, menus, tooltips and toasts live in the browser's top layer,
		 * above every z-index; these values only order what is not in it. */
		--slean-z-app-bar: 1100;
		--slean-z-drawer: 1200;
		--slean-z-modal: 1300;
		--slean-z-snackbar: 1400;
		--slean-z-tooltip: 1500;

		/* Breakpoints, for reference and container queries (a custom property cannot appear in a
		 * media query): xs 0, sm 600px, md 900px, lg 1200px, xl 1536px. */
		--slean-breakpoint-xs: 0px;
		--slean-breakpoint-sm: 600px;
		--slean-breakpoint-md: 900px;
		--slean-breakpoint-lg: 1200px;
		--slean-breakpoint-xl: 1536px;

		/* Focus ring geometry, used by every :focus-visible outline. */
		--slean-focus-ring-width: 2px;
		--slean-focus-ring-offset: 2px;

		/* Inputs written as inline styles on a root, not theme tokens: the range slider's two
		 * values and the splitter's first pane (written by their behaviors), and the value of a
		 * circular progress (written by the author next to value), as percentages without the unit;
		 * the color of one swatch of a swatch radio group (written by the author on its label). */
		--slean-range-start: 0;
		--slean-range-end: 100;
		--slean-split: 50;
		--slean-value: 0;
		--slean-swatch: transparent;
	}

	/* Light palette: the default, and the palette of any subtree marked data-theme="light" or
	 * class="light" inside a dark page. */
	:where(:root),
	:where([data-theme='light']),
	:where(.light) {
		--slean-color-scheme: light;

		/* Neutral scale: 1 = page background, 12 = strongest text. 8 is the control border, at least
		 * 3:1 against the surface and the page background in both themes. */
		--slean-neutral-1: oklch(99.5% 0.002 260);
		--slean-neutral-2: oklch(98.2% 0.003 260);
		--slean-neutral-3: oklch(95.8% 0.004 260);
		--slean-neutral-4: oklch(93.2% 0.005 260);
		--slean-neutral-5: oklch(90.5% 0.006 260);
		--slean-neutral-6: oklch(87.2% 0.007 260);
		--slean-neutral-7: oklch(80.8% 0.009 260);
		--slean-neutral-8: oklch(63.5% 0.012 260);
		--slean-neutral-9: oklch(55.2% 0.015 260);
		--slean-neutral-10: oklch(50.8% 0.015 260);
		--slean-neutral-11: oklch(44.6% 0.014 260);
		--slean-neutral-12: oklch(20.5% 0.012 260);

		/* Palette (MUI-style): per color a main tone, a lighter and a darker one, the text that sits
		 * on main (contrast-text), and the tint and text of the standard (soft) variants. Neutral is
		 * derived from the neutral scale in the alias block. Every pair a variant draws meets WCAG AA
		 * (tests/contrast.test.ts): contrast-text on main and dark at least 4.5:1, main as text on
		 * the surface, the page and its own hover tint at least 4.5:1, soft-text on soft at least
		 * 4.5:1. In light the mains are dark enough for white text; in dark they are light, with dark
		 * text, as in MUI's dark palette. */
		--slean-primary-main: oklch(51% 0.18 258);
		--slean-primary-light: oklch(64% 0.144 258);
		--slean-primary-dark: oklch(45% 0.165 258);
		--slean-primary-contrast-text: oklch(100% 0 0);
		--slean-primary-soft: oklch(95% 0.02 258);
		--slean-primary-soft-text: oklch(42% 0.155 258);
		--slean-secondary-main: oklch(52% 0.2 305);
		--slean-secondary-light: oklch(64% 0.16 305);
		--slean-secondary-dark: oklch(45% 0.2 305);
		--slean-secondary-contrast-text: oklch(100% 0 0);
		--slean-secondary-soft: oklch(95.5% 0.025 305);
		--slean-secondary-soft-text: oklch(43% 0.17 305);
		--slean-error-main: oklch(52% 0.19 25);
		--slean-error-light: oklch(64% 0.152 25);
		--slean-error-dark: oklch(45% 0.18 25);
		--slean-error-contrast-text: oklch(100% 0 0);
		--slean-error-soft: oklch(95.5% 0.02 25);
		--slean-error-soft-text: oklch(45% 0.18 25);
		--slean-warning-main: oklch(52% 0.125 55);
		--slean-warning-light: oklch(64% 0.104 55);
		--slean-warning-dark: oklch(45% 0.11 55);
		--slean-warning-contrast-text: oklch(100% 0 0);
		--slean-warning-soft: oklch(96% 0.04 85);
		--slean-warning-soft-text: oklch(45% 0.09 75);
		--slean-info-main: oklch(50% 0.105 235);
		--slean-info-light: oklch(62% 0.088 235);
		--slean-info-dark: oklch(43% 0.09 235);
		--slean-info-contrast-text: oklch(100% 0 0);
		--slean-info-soft: oklch(95.5% 0.025 235);
		--slean-info-soft-text: oklch(43% 0.09 235);
		--slean-success-main: oklch(49% 0.13 150);
		--slean-success-light: oklch(61% 0.104 150);
		--slean-success-dark: oklch(42% 0.115 150);
		--slean-success-contrast-text: oklch(100% 0 0);
		--slean-success-soft: oklch(95.5% 0.04 150);
		--slean-success-soft-text: oklch(40% 0.11 150);

		/* Surfaces that differ between the themes. */
		--slean-surface: oklch(100% 0 0);
		--slean-muted: var(--slean-neutral-3);
		--slean-muted-hover: var(--slean-neutral-4);
		--slean-overlay: oklch(0% 0 0 / 0.4);
		/* Elevation 0-5 (MUI's 0-24 compressed): resting surfaces 1, raised cards 2, menus and
		 * popovers 3, dialogs 4, drawers and toasts 5. */
		--slean-elevation-0: none;
		--slean-elevation-1: 0 1px 2px oklch(0% 0 0 / 0.08);
		--slean-elevation-2: 0 2px 6px oklch(0% 0 0 / 0.08), 0 1px 2px oklch(0% 0 0 / 0.06);
		--slean-elevation-3: 0 4px 12px oklch(0% 0 0 / 0.1), 0 1px 3px oklch(0% 0 0 / 0.08);
		--slean-elevation-4: 0 16px 40px oklch(0% 0 0 / 0.18), 0 2px 6px oklch(0% 0 0 / 0.08);
		--slean-elevation-5: 0 24px 56px oklch(0% 0 0 / 0.22), 0 4px 10px oklch(0% 0 0 / 0.1);
	}

	/* Dark palette, following the system unless the root forces light. The two dark blocks are
	 * identical by contract (checked by scripts/check.mjs). */
	@media (prefers-color-scheme: dark) {
		:where(:root:not([data-theme='light'], .light)) {
			--slean-color-scheme: dark;
			--slean-neutral-1: oklch(16.5% 0.008 260);
			--slean-neutral-2: oklch(19.5% 0.009 260);
			--slean-neutral-3: oklch(23% 0.01 260);
			--slean-neutral-4: oklch(26% 0.011 260);
			--slean-neutral-5: oklch(29.5% 0.012 260);
			--slean-neutral-6: oklch(33.5% 0.013 260);
			--slean-neutral-7: oklch(39.5% 0.014 260);
			--slean-neutral-8: oklch(53% 0.015 260);
			--slean-neutral-9: oklch(58% 0.015 260);
			--slean-neutral-10: oklch(63% 0.015 260);
			--slean-neutral-11: oklch(74% 0.012 260);
			--slean-neutral-12: oklch(95% 0.005 260);
			--slean-primary-main: oklch(71% 0.13 258);
			--slean-primary-light: oklch(80% 0.099 258);
			--slean-primary-dark: oklch(64% 0.13 258);
			--slean-primary-contrast-text: oklch(18% 0.02 258);
			--slean-primary-soft: oklch(28% 0.07 258);
			--slean-primary-soft-text: oklch(85% 0.07 258);
			--slean-secondary-main: oklch(72% 0.13 305);
			--slean-secondary-light: oklch(81% 0.104 305);
			--slean-secondary-dark: oklch(65% 0.13 305);
			--slean-secondary-contrast-text: oklch(18% 0.02 305);
			--slean-secondary-soft: oklch(28% 0.08 305);
			--slean-secondary-soft-text: oklch(86% 0.08 305);
			--slean-error-main: oklch(72% 0.13 25);
			--slean-error-light: oklch(81% 0.104 25);
			--slean-error-dark: oklch(65% 0.13 25);
			--slean-error-contrast-text: oklch(18% 0.02 25);
			--slean-error-soft: oklch(27% 0.08 25);
			--slean-error-soft-text: oklch(85% 0.08 25);
			--slean-warning-main: oklch(76% 0.14 55);
			--slean-warning-light: oklch(85% 0.092 55);
			--slean-warning-dark: oklch(69% 0.14 55);
			--slean-warning-contrast-text: oklch(18% 0.02 55);
			--slean-warning-soft: oklch(28% 0.055 80);
			--slean-warning-soft-text: oklch(87% 0.12 85);
			--slean-info-main: oklch(72% 0.11 235);
			--slean-info-light: oklch(81% 0.088 235);
			--slean-info-dark: oklch(65% 0.11 235);
			--slean-info-contrast-text: oklch(18% 0.02 235);
			--slean-info-soft: oklch(28% 0.055 235);
			--slean-info-soft-text: oklch(86% 0.08 235);
			--slean-success-main: oklch(72% 0.14 150);
			--slean-success-light: oklch(81% 0.112 150);
			--slean-success-dark: oklch(65% 0.14 150);
			--slean-success-contrast-text: oklch(18% 0.02 150);
			--slean-success-soft: oklch(27% 0.07 150);
			--slean-success-soft-text: oklch(85% 0.12 150);
			--slean-surface: var(--slean-neutral-2);
			--slean-muted: var(--slean-neutral-4);
			--slean-muted-hover: var(--slean-neutral-5);
			--slean-overlay: oklch(0% 0 0 / 0.6);
			--slean-elevation-0: none;
			--slean-elevation-1: 0 1px 2px oklch(0% 0 0 / 0.4);
			--slean-elevation-2: 0 2px 6px oklch(0% 0 0 / 0.45), 0 1px 2px oklch(0% 0 0 / 0.35);
			--slean-elevation-3: 0 4px 12px oklch(0% 0 0 / 0.5), 0 1px 3px oklch(0% 0 0 / 0.4);
			--slean-elevation-4: 0 16px 40px oklch(0% 0 0 / 0.6), 0 2px 6px oklch(0% 0 0 / 0.4);
			--slean-elevation-5: 0 24px 56px oklch(0% 0 0 / 0.65), 0 4px 10px oklch(0% 0 0 / 0.45);
		}
	}

	/* Dark palette, forced: data-theme="dark" or class="dark" (the mode-watcher and Tailwind
	 * convention) on the root or on any subtree. */
	:where([data-theme='dark']),
	:where(.dark) {
		--slean-color-scheme: dark;
		--slean-neutral-1: oklch(16.5% 0.008 260);
		--slean-neutral-2: oklch(19.5% 0.009 260);
		--slean-neutral-3: oklch(23% 0.01 260);
		--slean-neutral-4: oklch(26% 0.011 260);
		--slean-neutral-5: oklch(29.5% 0.012 260);
		--slean-neutral-6: oklch(33.5% 0.013 260);
		--slean-neutral-7: oklch(39.5% 0.014 260);
		--slean-neutral-8: oklch(53% 0.015 260);
		--slean-neutral-9: oklch(58% 0.015 260);
		--slean-neutral-10: oklch(63% 0.015 260);
		--slean-neutral-11: oklch(74% 0.012 260);
		--slean-neutral-12: oklch(95% 0.005 260);
		--slean-primary-main: oklch(71% 0.13 258);
		--slean-primary-light: oklch(80% 0.099 258);
		--slean-primary-dark: oklch(64% 0.13 258);
		--slean-primary-contrast-text: oklch(18% 0.02 258);
		--slean-primary-soft: oklch(28% 0.07 258);
		--slean-primary-soft-text: oklch(85% 0.07 258);
		--slean-secondary-main: oklch(72% 0.13 305);
		--slean-secondary-light: oklch(81% 0.104 305);
		--slean-secondary-dark: oklch(65% 0.13 305);
		--slean-secondary-contrast-text: oklch(18% 0.02 305);
		--slean-secondary-soft: oklch(28% 0.08 305);
		--slean-secondary-soft-text: oklch(86% 0.08 305);
		--slean-error-main: oklch(72% 0.13 25);
		--slean-error-light: oklch(81% 0.104 25);
		--slean-error-dark: oklch(65% 0.13 25);
		--slean-error-contrast-text: oklch(18% 0.02 25);
		--slean-error-soft: oklch(27% 0.08 25);
		--slean-error-soft-text: oklch(85% 0.08 25);
		--slean-warning-main: oklch(76% 0.14 55);
		--slean-warning-light: oklch(85% 0.092 55);
		--slean-warning-dark: oklch(69% 0.14 55);
		--slean-warning-contrast-text: oklch(18% 0.02 55);
		--slean-warning-soft: oklch(28% 0.055 80);
		--slean-warning-soft-text: oklch(87% 0.12 85);
		--slean-info-main: oklch(72% 0.11 235);
		--slean-info-light: oklch(81% 0.088 235);
		--slean-info-dark: oklch(65% 0.11 235);
		--slean-info-contrast-text: oklch(18% 0.02 235);
		--slean-info-soft: oklch(28% 0.055 235);
		--slean-info-soft-text: oklch(86% 0.08 235);
		--slean-success-main: oklch(72% 0.14 150);
		--slean-success-light: oklch(81% 0.112 150);
		--slean-success-dark: oklch(65% 0.14 150);
		--slean-success-contrast-text: oklch(18% 0.02 150);
		--slean-success-soft: oklch(27% 0.07 150);
		--slean-success-soft-text: oklch(85% 0.12 150);
		--slean-surface: var(--slean-neutral-2);
		--slean-muted: var(--slean-neutral-4);
		--slean-muted-hover: var(--slean-neutral-5);
		--slean-overlay: oklch(0% 0 0 / 0.6);
		--slean-elevation-0: none;
		--slean-elevation-1: 0 1px 2px oklch(0% 0 0 / 0.4);
		--slean-elevation-2: 0 2px 6px oklch(0% 0 0 / 0.45), 0 1px 2px oklch(0% 0 0 / 0.35);
		--slean-elevation-3: 0 4px 12px oklch(0% 0 0 / 0.5), 0 1px 3px oklch(0% 0 0 / 0.4);
		--slean-elevation-4: 0 16px 40px oklch(0% 0 0 / 0.6), 0 2px 6px oklch(0% 0 0 / 0.4);
		--slean-elevation-5: 0 24px 56px oklch(0% 0 0 / 0.65), 0 4px 10px oklch(0% 0 0 / 0.45);
	}

	/* Semantic aliases, derived from the palette on the root and again on every theme scope.
	 * data-slean-theme marks a subtree that redefines palette tokens (a brand primary) without
	 * switching between light and dark. */
	:where(:root),
	:where([data-theme]),
	:where([data-slean-theme]),
	:where(.dark),
	:where(.light) {
		/* Semantic surfaces and text. */
		--slean-bg: var(--slean-neutral-1);
		--slean-fg: var(--slean-neutral-12);
		--slean-fg-muted: var(--slean-neutral-11);
		--slean-border: var(--slean-neutral-6);
		--slean-border-strong: var(--slean-neutral-8);

		/* Neutral, the seventh color: the grey scale as a palette. */
		--slean-neutral-main: var(--slean-neutral-11);
		--slean-neutral-light: var(--slean-neutral-8);
		--slean-neutral-dark: var(--slean-neutral-12);
		--slean-neutral-contrast-text: var(--slean-neutral-1);
		--slean-neutral-soft: var(--slean-neutral-3);
		--slean-neutral-soft-text: var(--slean-neutral-12);

		/* The current color: what data-color selects (block 4), primary by default. A component
		 * draws its variants from these eight tokens only, so every color works with every
		 * variant. */
		--slean-color-main: var(--slean-primary-main);
		--slean-color-light: var(--slean-primary-light);
		--slean-color-dark: var(--slean-primary-dark);
		--slean-color-contrast-text: var(--slean-primary-contrast-text);
		--slean-color-soft: var(--slean-primary-soft);
		--slean-color-soft-text: var(--slean-primary-soft-text);
		/* The ink and the line of the outlined and text variants: the main tone and a half-tone
		 * line of it for every color; for neutral, MUI's "inherit": the text color and the border
		 * hairline (block 4). */
		--slean-color-text: var(--slean-primary-main);
		--slean-color-border: color-mix(in oklch, var(--slean-primary-main) 50%, transparent);

		/* Control shell (ADR 0007): the field every form control shares (input, select, autocomplete,
		 * date picker and the other fields). The border is at least 3:1 against the surface; hover
		 * and focus take the primary color and the focus ring is a soft halo of it; a disabled control
		 * sits on the muted surface. */
		--slean-control-bg: var(--slean-surface);
		--slean-control-bg-disabled: var(--slean-muted);
		--slean-control-border-disabled: var(--slean-border);
		--slean-control-border: var(--slean-border-strong);
		--slean-control-ring-error: 0 0 0 3px
			color-mix(in oklch, var(--slean-error-main) 22%, transparent);
		--slean-control-ring-warning: 0 0 0 3px
			color-mix(in oklch, var(--slean-warning-main) 28%, transparent);
		/* The surface of data-variant="filled" fields and the line of "standard" ones. */
		--slean-control-filled-bg: var(--slean-muted);
		--slean-control-filled-bg-hover: var(--slean-muted-hover);
		--slean-control-icon: var(--slean-fg-muted);
		/* Option rows of every listbox (select, autocomplete, the native picker): the
		 * active row (hover or keyboard position) and the chosen one, and the row's own metrics. A
		 * theme that marks the chosen row with its check alone sets the ring to none and the weight
		 * to the normal one. */
		--slean-option-active: var(--slean-muted);
		--slean-option-active-fg: var(--slean-fg);
		--slean-option-selected: var(--slean-primary-soft);
		--slean-option-selected-fg: var(--slean-primary-soft-text);
		--slean-option-selected-weight: var(--slean-font-weight-semibold);
		--slean-option-selected-ring: inset 0 0 0 1px var(--slean-option-selected-fg);
		--slean-option-min-height: var(--slean-control-height-sm);
		--slean-option-padding-block: var(--slean-space-1);
		--slean-option-padding-inline: var(--slean-space-2);
		--slean-popup-radius: var(--slean-radius-md);
		--slean-popup-shadow: var(--slean-elevation-3);

		/* Component defaults a theme sets in one place (MUI's theme.components). */
		--slean-button-radius: var(--slean-radius-md);
		/* A font shorthand; button.css takes the family from the page, so the family here is only a
		 * placeholder and --slean-font-sans may be anything, `initial` included. */
		--slean-button-font: var(--slean-typography-button-weight) var(--slean-typography-button-size) /
			var(--slean-typography-button-line-height) sans-serif;
		--slean-button-transform: var(--slean-typography-button-transform);
		--slean-field-radius: var(--slean-radius-md);
		--slean-card-radius: var(--slean-radius-lg);
		--slean-card-elevation: var(--slean-elevation-1);
		--slean-dialog-radius: var(--slean-radius-lg);
		--slean-dialog-elevation: var(--slean-elevation-4);
		/* The dialog's padding: its content inset, the bleed of its sticky header and footer and
		 * their sticky offsets all follow it, so a denser theme changes one token. */
		--slean-dialog-padding: var(--slean-space-6);
		--slean-chip-radius: var(--slean-radius-full);

		/* Focus ring, used by every :focus-visible outline. */
		--slean-focus-ring-color: var(--slean-primary-main);
		--slean-focus-ring: var(--slean-focus-ring-width) solid var(--slean-focus-ring-color);
	}

	/* The current color (ADR 0011 §3.3): data-color on an element selects the palette its
	 * variants are drawn from, for the element and its subtree. */
	/* The ink and the line of the outlined and text variants follow the main tone of the element's
	 * own color, a color of the application's included ([data-color='brand'] setting the six
	 * tones); neutral replaces them below. */
	:where([data-color]) {
		--slean-color-text: var(--slean-color-main);
		--slean-color-border: color-mix(in oklch, var(--slean-color-main) 50%, transparent);
	}

	:where([data-color='primary']) {
		--slean-color-main: var(--slean-primary-main);
		--slean-color-light: var(--slean-primary-light);
		--slean-color-dark: var(--slean-primary-dark);
		--slean-color-contrast-text: var(--slean-primary-contrast-text);
		--slean-color-soft: var(--slean-primary-soft);
		--slean-color-soft-text: var(--slean-primary-soft-text);
	}

	:where([data-color='secondary']) {
		--slean-color-main: var(--slean-secondary-main);
		--slean-color-light: var(--slean-secondary-light);
		--slean-color-dark: var(--slean-secondary-dark);
		--slean-color-contrast-text: var(--slean-secondary-contrast-text);
		--slean-color-soft: var(--slean-secondary-soft);
		--slean-color-soft-text: var(--slean-secondary-soft-text);
	}

	:where([data-color='error']) {
		--slean-color-main: var(--slean-error-main);
		--slean-color-light: var(--slean-error-light);
		--slean-color-dark: var(--slean-error-dark);
		--slean-color-contrast-text: var(--slean-error-contrast-text);
		--slean-color-soft: var(--slean-error-soft);
		--slean-color-soft-text: var(--slean-error-soft-text);
	}

	:where([data-color='warning']) {
		--slean-color-main: var(--slean-warning-main);
		--slean-color-light: var(--slean-warning-light);
		--slean-color-dark: var(--slean-warning-dark);
		--slean-color-contrast-text: var(--slean-warning-contrast-text);
		--slean-color-soft: var(--slean-warning-soft);
		--slean-color-soft-text: var(--slean-warning-soft-text);
	}

	:where([data-color='info']) {
		--slean-color-main: var(--slean-info-main);
		--slean-color-light: var(--slean-info-light);
		--slean-color-dark: var(--slean-info-dark);
		--slean-color-contrast-text: var(--slean-info-contrast-text);
		--slean-color-soft: var(--slean-info-soft);
		--slean-color-soft-text: var(--slean-info-soft-text);
	}

	:where([data-color='success']) {
		--slean-color-main: var(--slean-success-main);
		--slean-color-light: var(--slean-success-light);
		--slean-color-dark: var(--slean-success-dark);
		--slean-color-contrast-text: var(--slean-success-contrast-text);
		--slean-color-soft: var(--slean-success-soft);
		--slean-color-soft-text: var(--slean-success-soft-text);
	}

	:where([data-color='neutral']) {
		--slean-color-main: var(--slean-neutral-main);
		--slean-color-light: var(--slean-neutral-light);
		--slean-color-dark: var(--slean-neutral-dark);
		--slean-color-contrast-text: var(--slean-neutral-contrast-text);
		--slean-color-soft: var(--slean-neutral-soft);
		--slean-color-soft-text: var(--slean-neutral-soft-text);
		--slean-color-text: var(--slean-fg);
		--slean-color-border: var(--slean-border);
	}

	/* Components whose default color is neutral (MUI's "default" chip and alert-less tint): they
	 * take a color only from their own data-color. */
	:where([data-slean='badge']:not([data-color])),
	:where([data-slean='alert']:not([data-color])),
	:where([data-slean='toast'] [data-slean-part='item']:not([data-color])),
	:where([data-slean='timeline'] > li:not([data-color])) {
		--slean-color-main: var(--slean-neutral-main);
		--slean-color-light: var(--slean-neutral-light);
		--slean-color-dark: var(--slean-neutral-dark);
		--slean-color-contrast-text: var(--slean-neutral-contrast-text);
		--slean-color-soft: var(--slean-neutral-soft);
		--slean-color-soft-text: var(--slean-neutral-soft-text);
		--slean-color-text: var(--slean-fg);
		--slean-color-border: var(--slean-border);
	}

	/* Density (any element, inherited by its subtree): compact for data-heavy screens,
	 * comfortable for touch-first ones. Control heights and option rows follow. */
	:where([data-density='compact']) {
		--slean-control-height-xs: 1.5rem;
		--slean-control-height-sm: 1.75rem;
		--slean-control-height-md: 2rem;
		--slean-control-height-lg: 2.5rem;
		--slean-option-padding-block: 0.125rem;
	}

	:where([data-density='comfortable']) {
		--slean-control-height-xs: 2rem;
		--slean-control-height-sm: 2.25rem;
		--slean-control-height-md: 2.5rem;
		--slean-control-height-lg: 3rem;
		--slean-option-padding-block: var(--slean-space-2);
	}

	/* Forced colors (Windows High Contrast): the platform replaces most colors itself. Only the
	 * tokens that stay author-controlled are mapped to system colors here. */
	@media (forced-colors: active) {
		:where(:root),
		:where([data-theme]),
		:where([data-slean-theme]),
		:where(.dark),
		:where(.light) {
			--slean-focus-ring-color: Highlight;
			--slean-border: CanvasText;
			--slean-border-strong: CanvasText;
			--slean-elevation-1: none;
			--slean-elevation-2: none;
			--slean-elevation-3: none;
			--slean-elevation-4: none;
			--slean-elevation-5: none;
		}
	}

	/* Transitions stop; a loading indicator keeps turning, slower. */
	@media (prefers-reduced-motion: reduce) {
		:where(:root) {
			--slean-duration-fast: 0ms;
			--slean-duration-normal: 0ms;
			--slean-duration-slow: 0ms;
			--slean-duration-indicator: 1600ms;
		}
	}

	/* Touch: every control height grows by 8px; the small one reaches the 40px pointer target,
	 * also under data-density="compact". */
	@media (pointer: coarse) {
		:where(:root),
		:where([data-density]) {
			--slean-control-height-xs: 2.25rem;
			--slean-control-height-sm: 2.5rem;
			--slean-control-height-md: 2.75rem;
			--slean-control-height-lg: 3rem;
		}
	}
}
