/**
 * Design tokens — the single source of every visual value in the app.
 *
 * Two tiers (docs/architecture/ui-design-system.md §13):
 *   1. Primitives (--palette-*): raw colour values. Components must NEVER
 *      reference these directly — only this file and the theme files do.
 *   2. Semantic tokens (--color-*, --font-size-*, --space-*, ...): roles that
 *      components consume. Light values live on :root, dark overrides on
 *      :root.dark. The .dark class is set on <html> before first paint
 *      (index.html), so the first frame already has the right mode.
 *
 * This file is the default theme, "Oceanic" (id "standard"): a light page
 * tinted with its header colour and white cards in light mode (shared by
 * every theme since r-152), slate dark, the sky-to-cyan header, and its
 * materials.
 * Other themes live in ui_design/css/themes/<name>.css and override semantic
 * tokens only, switched by the data-theme attribute on <html>; their raw
 * colours are primitives here, in the "Theme palettes" section (§13 "Themes").
 *
 * The palette is the app's existing one (Tailwind-derived shades already in
 * the former oceanic-plus.css), not a new design. Contrast is checked by
 * `npm run check-contrast` (scripts/check-contrast.js), which parses this file,
 * so keep values in the forms it understands: hex, rgb()/rgba(), var(),
 * or color-mix(in srgb, <color> N%, transparent).
 *
 * @see docs/architecture/ui-design-system.md §13
 * @see docs/architecture/module-map/tokens.css.md
 */

/* ── Primitives + light theme ─────────────────────────────── */
:root {
  /* RULE: primitives — raw palette, only referenced inside this file */
  --palette-white: #FFFFFF;
  --palette-black: #000000;

  --palette-slate-50: #F8FAFC;
  --palette-slate-100: #F1F5F9;
  --palette-slate-200: #E2E8F0;
  --palette-slate-300: #CBD5E1;
  --palette-slate-400: #94A3B8;
  --palette-slate-500: #64748B;
  --palette-slate-600: #475569;
  --palette-slate-700: #334155;
  --palette-slate-800: #1E293B;
  --palette-slate-900: #0F172A;

  /* Graphite neutrals for the light theme (Peter's pick, 2026-10-13): a
     dim, plain grey with no colour cast, replacing r-51's warm paper/ink.
     Low steps are backgrounds, high steps text and borders. */
  --palette-graphite-50: #F2F2F3;
  --palette-graphite-100: #DDDDE0;
  --palette-graphite-150: #D7D7DB;
  --palette-graphite-200: #CFCFD3;
  --palette-graphite-500: #71717A;
  --palette-graphite-600: #5A5A62;
  --palette-graphite-650: #52525B;
  --palette-graphite-700: #3F3F46;
  --palette-graphite-750: #3A3A41;
  --palette-graphite-900: #18181C;

  /* Paper neutrals for the light mode of every theme (r-152, Peter
     2026-11-03): a near-white page (tinted per theme, see --color-bg-page),
     white cards, inset fields and a near-black ink. */
  --palette-paper-page: #F3F5F7;
  --palette-paper-field: #EEF1F4;
  --palette-paper-ink: #1E2228;
  --palette-paper-ink-soft: #48505B;

  --palette-cyan-glow: #7EF8FF;
  --palette-cyan-25: #F0FDFF;
  --palette-cyan-100: #CFFAFE;
  --palette-cyan-300: #67E8F9;
  --palette-cyan-400: #22D3EE;
  --palette-cyan-500: #06B6D4;
  --palette-cyan-600: #0891B2;
  --palette-cyan-700: #0E7490;
  --palette-cyan-800: #155E75;
  --palette-cyan-900: #164E63;

  --palette-sky-700: #0369A1;

  --palette-blue-100: #DBEAFE;
  --palette-blue-200: #BFDBFE;
  --palette-blue-300: #93C5FD;
  --palette-blue-400: #60A5FA;
  --palette-blue-500: #3B82F6;
  --palette-blue-600: #2563EB;
  --palette-blue-700: #1D4ED8;
  --palette-blue-800: #1E40AF;

  --palette-indigo-100: #E0E7FF;
  --palette-indigo-300: #A5B4FC;
  --palette-indigo-400: #818CF8;
  --palette-indigo-500: #6366F1;
  --palette-indigo-700: #4338CA;

  --palette-violet-100: #EDE9FE;
  --palette-violet-300: #C4B5FD;
  --palette-violet-400: #A78BFA;
  --palette-violet-500: #8B5CF6;
  --palette-violet-600: #7C3AED;
  --palette-violet-700: #6D28D9;
  --palette-violet-800: #5B21B6;

  --palette-green-100: #DCFCE7;
  --palette-green-400: #4ADE80;
  --palette-green-600: #16A34A;
  --palette-green-700: #15803D;
  --palette-green-800: #166534;

  --palette-emerald-100: #D1FAE5;
  --palette-emerald-400: #34D399;
  --palette-emerald-600: #059669;
  --palette-emerald-700: #047857;

  --palette-lime-600: #65A30D;

  --palette-amber-100: #FEF3C7;
  --palette-amber-400: #FBBF24;
  --palette-amber-500: #F59E0B;
  --palette-amber-600: #D97706;
  --palette-amber-700: #B45309;
  --palette-amber-800: #92400E;

  --palette-orange-100: #FFEDD5;
  --palette-orange-300: #FDBA74;
  --palette-orange-400: #FB923C;
  --palette-orange-500: #F97316;
  --palette-orange-700: #C2410C;
  --palette-orange-800: #9A3412;

  --palette-red-100: #FEE2E2;
  --palette-red-300: #FCA5A5;
  --palette-red-400: #F87171;
  --palette-red-500: #EF4444;
  --palette-red-600: #DC2626;
  --palette-red-700: #B91C1C;
  --palette-red-800: #991B1B;

  /* RULE: theme palettes — raw colours of the themes in ui_design/css/themes/
     (§13 "Themes"). Only those files and the swatches below use them.
     The six-theme set (v0.109.0, Peter 2026-10-14: "none of them are cool"):
     Oceanic (this file), CoolKonyha Red, Forest, Espresso, Porcelain, Ion,
     each with a light and a dark mode and its own "materials" (effects.css). */

  /* Espresso (v0.109.0): an oat-paper light mode with coffee ink and a
     plum-heather accent, and the warm umber dark mode (v0.105.1) with its
     heather accent; a caramel-to-roast header with copper edges.
     RULE: the accent is not an amber in either mode: amber is the warning
     and price colour (check-contrast "distinct" pairs, v0.106.0). */
  --palette-oat-50: #F1E9DE;
  --palette-oat-75: #E8DDCF;
  --palette-oat-100: #E6DDD0;
  --palette-oat-150: #E0D5C6;
  --palette-oat-200: #DBCEBD;
  --palette-oat-600: #7A6553;
  --palette-coffee-700: #574536;
  --palette-coffee-900: #2A1F17;
  --palette-plum-300: #B48AA6;
  --palette-plum-700: #613C55;
  --palette-espresso-100: #EFE7DD;
  --palette-espresso-300: #C0B2A2;
  --palette-espresso-500: #8A7B6C;
  --palette-espresso-600: #5E4A38;
  --palette-espresso-700: #4A3A2C;
  --palette-espresso-800: #312A24;
  --palette-espresso-850: #29231E;
  --palette-espresso-900: #1F1A16;
  --palette-heather-300: #C2AAB8;
  --palette-cream-200: #F2E2CE;
  --palette-crema-50: #FFF8EE;
  --palette-crema-100: #FFECD6;
  --palette-caramel-200: #E8C9A6;
  --palette-caramel-400: #D69A62;
  --palette-caramel-600: #8A5A33;
  --palette-caramel-700: #7A5232;
  --palette-copper-500: #B07A4A;
  --palette-copper-600: #9A6A40;
  --palette-roast-700: #5E3F27;
  --palette-roast-750: #4E3624;
  --palette-roast-900: #3B2A1E;
  --palette-roast-950: #2A1E16;

  /* CoolKonyha Red (from Peter's palette 2026-10-13): navy base, crimson
     and wine for the brand bar and primary buttons, peach highlights; its
     danger is violet. #E10812 is the logo red (i-58). Wine-700 and plum-950
     carry the header's crimson → wine → plum run. */
  --palette-navy-50: #EEF0F4;
  --palette-navy-100: #E2E5EB;
  --palette-navy-150: #DCDFE6;
  --palette-navy-200: #D3D7E0;
  --palette-navy-300: #A9B2C4;
  --palette-navy-400: #6B7690;
  --palette-navy-500: #5A6478;
  --palette-navy-700: #384358;
  --palette-navy-800: #242F49;
  --palette-navy-900: #1D263B;
  --palette-navy-950: #161E2F;
  --palette-peach-100: #FFD9CC;
  --palette-peach-300: #FFA586;
  --palette-crimson-700: #B51A2B;
  --palette-wine-700: #7A1730;
  --palette-wine-900: #541A2E;
  --palette-plum-950: #36122A;

  /* Forest (from Peter's palette 2026-10-13): deep forest greens for dark
     mode, a dimmed mint paper for light mode. Its header is a lighter
     green (fern, Peter 2026-10-14: "could be lighter … darker leaves"). */
  --palette-forest-50: #EEF6F0;
  --palette-forest-100: #D9E9DE;
  --palette-forest-150: #D1E2D6;
  --palette-forest-200: #C8DACE;
  --palette-forest-300: #9FD3B0;
  --palette-forest-400: #8EB69B;
  --palette-forest-500: #4F7D69;
  --palette-forest-600: #4A6B5C;
  --palette-forest-700: #235347;
  --palette-forest-800: #163832;
  --palette-forest-900: #0B2B26;
  --palette-forest-950: #051F20;
  --palette-fern-500: #397461;
  --palette-fern-600: #2F6B59;
  --palette-fern-700: #285C4D;
  --palette-mint-50: #DAF1DE;
  /* Forest's secondary text: a green-grey, so it never equals the accent.
     600 a step darker in r-130 (#4F5752 → #4A524D): a neutral badge on My
     activity's sunken box was 4.30:1 (PR #76 review, finding 3). */
  --palette-lichen-300: #AEBBB2;
  --palette-lichen-600: #4A524D;
  /* Forest's light-mode link green (b-110): brighter than the dark body
     ink, so a "Change…" link stands out from the text around it. */
  --palette-leaf-700: #0F6463;
  --palette-leaf-300: #5FD0C8;

  /* Porcelain (v0.109.0): a dimmed ivory paper with ink text and a cobalt
     signal under an ink-blue header; graphite-ink with electric blue in
     dark mode. From the 2026-10-14 research (ChatGPT's "Porcelain"),
     dimmed to keep the light-mode glare rule. */
  --palette-porcelain-50: #F2EEE6;
  --palette-porcelain-75: #E8E2D6;
  --palette-porcelain-100: #E8E3D9;
  --palette-porcelain-150: #E3DDD1;
  --palette-porcelain-200: #DCD5C8;
  --palette-porcelain-600: #6B6A66;
  --palette-ink-500: #4A5566;
  --palette-ink-700: #434F5D;
  --palette-ink-900: #1D2633;
  --palette-cobalt-100: #DCEBFF;
  --palette-cobalt-200: #9FC4F0;
  --palette-cobalt-300: #78B5FF;
  --palette-cobalt-400: #5B8FD6;
  --palette-cobalt-600: #2A5597;
  --palette-cobalt-700: #284F8A;
  --palette-inkblue-600: #2A4A72;
  --palette-inkblue-700: #1E3858;
  --palette-inkblue-750: #1A2D47;
  --palette-inkblue-800: #182C47;
  --palette-inkblue-850: #15243A;
  --palette-inkblue-900: #111D2D;
  --palette-inkblue-shadow: #1A3D6A;
  --palette-graphink-100: #E6ECF3;
  --palette-graphink-300: #AEBBC9;
  --palette-graphink-500: #6A7C92;
  --palette-graphink-700: #3A4A5D;
  --palette-graphink-800: #222C39;
  --palette-graphink-850: #1C2430;
  --palette-graphink-900: #151A22;
  --palette-graphink-950: #0D1622;
  --palette-umber-shadow: #332F27;

  /* Ion (v0.109.0; the v0.105.0 "Futuristic" deck colours): blue-black deck
     steps for dark mode, a dim cool steel for light mode, a cyan signal for
     active, selected and focused things. */
  --palette-deck-50: #E2EEF7;
  --palette-deck-100: #D5DEE6;
  --palette-deck-150: #CDD7E0;
  --palette-deck-200: #C8D2DC;
  --palette-deck-300: #9DB4C6;
  --palette-deck-500: #5F7A90;
  --palette-deck-600: #4B6378;
  --palette-deck-700: #2F4356;
  --palette-deck-750: #0F2A40;
  --palette-deck-800: #133047;
  --palette-deck-850: #0F2436;
  --palette-deck-900: #0C1B2A;
  --palette-deck-950: #07111D;
  --palette-deck-ink: #0E1C29;
  --palette-signal-100: #B9EBFF;
  --palette-signal-300: #5DE1ED;
  --palette-signal-400: #22C7DA;
  --palette-signal-700: #0A5C70;
  --palette-signal-800: #08495A;

  /* Theme picker swatches of the default theme (Settings → Theme); every
     theme file declares its own four: page, card, accent, header. */
  --theme-swatch-standard-1: color-mix(in srgb, var(--theme-swatch-standard-4) 5%, var(--palette-paper-page));
  --theme-swatch-standard-2: var(--palette-white);
  --theme-swatch-standard-3: var(--palette-cyan-800);
  --theme-swatch-standard-4: var(--palette-sky-700);

  /* RULE: semantic colours — light theme */
  /* RULE: light surfaces (r-152, Peter 2026-11-03, after three dimmer
     fixes failed): a really light page with white cards, in every theme.
     The page is the paper neutral with 5% of the theme's own header colour
     (resolved on <html>, so each theme's --color-header-start tints it
     without a per-theme value); cards and the surface are white; fields
     sit inset (--color-bg-field). Brightness order page < card, fields and
     pills never brighter than their card: check-contrast checkSurfaceOrder.
     Theme files do not set these five tokens in light mode. §13. */
  --color-bg-page: color-mix(in srgb, var(--color-header-start) 5%, var(--palette-paper-page));
  --color-bg-surface: var(--palette-white);
  --color-bg-card: var(--palette-white);
  --color-bg-field: var(--palette-paper-field);
  --color-bg-overlay: rgba(0, 0, 0, 0.55);
  /* RULE: the account drop-up stands out from the sidebar (Peter, 2026-10-20):
     a wash of the theme's own text colour over the surface, so the menu is
     darker than the sidebar in light mode and lighter in dark mode, in every
     theme without a per-theme value. profile.css .account-menu; §24. */
  --color-menu-shade: color-mix(in srgb, var(--color-text-primary) 12%, transparent);

  --color-text-primary: var(--palette-paper-ink);
  --color-text-secondary: var(--palette-paper-ink-soft);
  --color-text-inverse: var(--palette-white);

  /* Interactive controls use --color-border; non-interactive separators use
     the fainter --color-divider, so controls stay recognizable (§13). */
  --color-border: var(--palette-graphite-600);
  --color-divider: color-mix(in srgb, var(--palette-graphite-900) 14%, transparent);

  --color-accent: var(--palette-cyan-800);
  /* Accent tints are the bright cyan in BOTH themes: that's what every
     highlight/hover/selection wash in the app already used. Five steps
     replace the ~16 hand-written alpha values (r-39 b1). */
  --color-accent-tint-1: color-mix(in srgb, var(--palette-cyan-400) 5%, transparent);
  --color-accent-tint-2: color-mix(in srgb, var(--palette-cyan-400) 8%, transparent);
  --color-accent-tint-3: color-mix(in srgb, var(--palette-cyan-400) 12%, transparent);
  --color-accent-tint-4: color-mix(in srgb, var(--palette-cyan-400) 20%, transparent);
  --color-accent-tint-5: color-mix(in srgb, var(--palette-cyan-400) 35%, transparent);
  --color-accent-glow: color-mix(in srgb, var(--palette-cyan-400) 50%, transparent);

  --color-action-primary: var(--color-accent);
  --color-action-primary-text: var(--palette-white);

  --color-success: var(--palette-green-800);
  --color-success-bg: var(--palette-green-100);
  --color-success-tint: color-mix(in srgb, var(--color-success) 10%, transparent);
  --color-warning: var(--palette-amber-800);
  --color-warning-text: var(--palette-amber-800);
  --color-warning-bg: var(--palette-amber-100);
  --color-danger: var(--palette-red-800);
  --color-danger-text: var(--palette-red-800);
  --color-danger-hover: var(--palette-red-800);
  --color-danger-bg: var(--palette-red-100);
  --color-danger-tint: color-mix(in srgb, var(--color-danger) 8%, transparent);
  --color-danger-border: color-mix(in srgb, var(--color-danger) 40%, transparent);
  --color-info: var(--palette-blue-700);
  --color-info-bg: var(--palette-blue-100);

  /* Money amounts (prices, totals) */
  --color-price: var(--palette-amber-800);

  /* Neutral washes (logo tiles, mono tags, resizer grip) */
  --color-neutral-tint: color-mix(in srgb, var(--palette-graphite-500) 14%, transparent);
  --color-neutral-tint-strong: color-mix(in srgb, var(--palette-graphite-500) 32%, transparent);
  /* The detail drawer's wash is the theme's own neutral tint (v0.106.0):
     it stands out from the card in every theme (check-contrast ΔE00 ≥ 3)
     without Standard's slate cast, and text stays ≥ 4.5:1 on it. The old
     slate-800 50% was a dark band in light mode (secondary text 2.9:1) and
     all but invisible in Standard dark. */
  --color-bg-inset: var(--color-neutral-tint);
  /* A sunken panel, darker than the card in every theme, light and dark:
     My activity reads like a terminal log (r-130, Peter 2026-10-19). */
  --color-bg-sunken: color-mix(in srgb, var(--palette-graphite-900) 7%, transparent);
  /* A setting tile's light tint (r-147, Peter 2026-11-02: "only slightly"):
     laid over --color-bg-sunken on a switch tile that is on, and always on
     the Theme tile. It is the theme's own accent, so the Theme tile follows
     the chosen theme; lighter than the lit icon (--color-accent-tint-4).
     Text on it is checked by check-contrast.js checkTileTint(). */
  --color-tile-tint: color-mix(in srgb, var(--color-accent) 5%, transparent);

  /* Solid danger button: a destructive confirmation (.btn-primary.btn-danger, §7) */
  --color-action-danger: var(--palette-red-700);
  --color-action-danger-hover: var(--palette-red-800);
  --color-action-danger-text: var(--palette-white);

  /* The "+ New" CTA: white pill on the teal header in light mode (b-62),
     solid accent in dark mode (ui-design-system.md §8). */
  --color-cta-bg: var(--palette-white);
  --color-cta-bg-hover: var(--palette-cyan-25);
  --color-cta-text: var(--color-accent);

  /* Orders pipeline track (r-47, Peter's pick 2026-09-29): its own tokens so
     the bar's brightness can change without touching the app-wide accent.
     Light: a lighter fill (cyan-500) alone is only ~2:1 against the row, so
     a darker cyan-700 outline carries the 3:1 non-text contrast; the glow is
     replaced by that 1px ring. Dark keeps the accent with its glow (option A). */
  --color-pipeline-order: var(--palette-cyan-500);
  --color-pipeline-order-outline: var(--palette-cyan-700);
  --color-pipeline-order-glow: color-mix(in srgb, var(--palette-cyan-500) 50%, transparent);
  --pipeline-order-node-shadow: none;
  --pipeline-order-line-shadow: 0 0 0 1px var(--color-pipeline-order-outline);

  /* Maintenance domain colour (icons, badges, pipeline) */
  --color-maintenance: var(--palette-orange-700);
  --color-maintenance-bg: var(--palette-orange-100);
  --color-maintenance-border: color-mix(in srgb, var(--palette-orange-700) 30%, transparent);
  --color-maintenance-glow: color-mix(in srgb, var(--palette-orange-400) 50%, transparent);

  /* Section header bar (teal gradient) and everything drawn on top of it */
  --color-header-start: var(--palette-sky-700);
  --color-header-end: var(--palette-cyan-700);
  --color-on-header: var(--palette-white);
  --color-on-header-strong: color-mix(in srgb, var(--palette-white) 90%, transparent);
  --color-on-header-muted: color-mix(in srgb, var(--palette-white) 90%, transparent);
  --color-on-header-faint: color-mix(in srgb, var(--palette-white) 20%, transparent);
  --color-on-header-fill: color-mix(in srgb, var(--palette-white) 15%, transparent);
  --color-on-header-sunken: color-mix(in srgb, var(--palette-black) 15%, transparent);
  --color-on-header-chart: var(--palette-cyan-glow);
  /* A page title's icon on the header (.section-header .text-accent): the
     accent was the header's own hue in most themes, so it vanished (Peter,
     2026-10-14: the package icon next to "Order cases"). ≥ 3:1 on both
     header ends (check-contrast). */
  --color-on-header-icon: var(--color-on-header-chart);

  /* Header-count dots (header-counts.css): always the bright variants, both
     themes, as they sit on the dark header bar */
  --color-stat-open: var(--palette-orange-400);
  --color-stat-closed: var(--palette-green-400);
  --color-online: var(--palette-green-400);

  /* Toggle switches, themed in every theme (v0.109.0, Peter 2026-10-14: "the
     sliders are still white"). Light: off is a pale tinted track with a dark
     knob, on is the accent with a pale knob. A theme's dark mode sets its
     own off track; there the knob is pale when off and the page colour when
     on. check-contrast keeps each knob ≥ 3:1 on its track.
     RULE: the off track is never the accent (Forest's was, so on and off
     looked the same). */
  --color-control-track: var(--color-neutral-tint-strong);
  --color-control-track-on: var(--color-accent);
  --color-control-track-border: var(--color-border);
  --color-control-knob: var(--color-text-secondary);
  --color-control-knob-on: var(--palette-white);

  /* A field that is invalid right now (.field-invalid, fields.css; b-111):
     the danger border, a solid 1px ring outside it and a soft danger wash,
     so it shows at a glance and stays visible while the field has focus. */
  --color-invalid-border: var(--color-danger);
  --color-invalid-ring: color-mix(in srgb, var(--color-danger) 30%, transparent);
  --color-invalid-bg: color-mix(in srgb, var(--color-danger) 8%, transparent);

  /* Glass (effects.css): the pop-up and pick-one panels' see-through surface,
     and the header buttons' tint, light at the top and dark at the bottom so
     the header's white text keeps its contrast on every header colour. */
  --color-glass-surface: color-mix(in srgb, var(--color-bg-surface) 88%, transparent);
  --color-hero-glass-top: color-mix(in srgb, var(--palette-white) 6%, transparent);
  --color-hero-glass-bottom: color-mix(in srgb, var(--palette-black) 14%, transparent);

  /* PISTA chat: CK's own messages */
  --color-chat-user-bg: color-mix(in srgb, var(--palette-violet-500) 12%, transparent);
  --color-chat-user-border: color-mix(in srgb, var(--palette-violet-500) 20%, transparent);

  /* Brief full-screen flash on theme switch */
  --color-flash: color-mix(in srgb, var(--palette-white) 80%, transparent);

  --focus-ring-color: var(--color-accent);
  --focus-ring-width: 2px;

  /* A disabled button. 0.5 sat too close to the enabled look next to an
     active button (Peter, 2026-09-28); disabled controls are exempt from
     the contrast minimum but must stay recognisable. */
  --opacity-disabled: 0.35;

  /* RULE: status pill colours — one bg/fg pair per workflow status.
     Order statuses, then activity markers (DONE, NOTE), then Maintenance. */
  --color-status-new-bg: var(--palette-graphite-50);
  --color-status-new-fg: var(--palette-graphite-700);
  --color-status-offer-sent-bg: var(--palette-violet-100);
  --color-status-offer-sent-fg: var(--palette-violet-700);
  --color-status-order-confirmed-bg: var(--palette-cyan-100);
  --color-status-order-confirmed-fg: var(--palette-cyan-700);
  --color-status-purchase-bg: var(--palette-amber-100);
  --color-status-purchase-fg: var(--palette-amber-700);
  --color-status-ready-for-delivery-bg: var(--palette-indigo-100);
  --color-status-ready-for-delivery-fg: var(--palette-indigo-700);
  --color-status-delivery-bg: var(--palette-blue-100);
  --color-status-delivery-fg: var(--palette-blue-700);
  /* r-60: Delivered is a deeper shade of Delivery's blue, so green means
     Closed only; a delivered case isn't finished until it's invoiced. */
  --color-status-delivered-bg: var(--palette-blue-200);
  --color-status-delivered-fg: var(--palette-blue-800);
  --color-status-invoiced-bg: var(--palette-amber-100);
  --color-status-invoiced-fg: var(--palette-amber-700);
  --color-status-closed-bg: var(--palette-green-100);
  --color-status-closed-fg: var(--palette-green-700);
  --color-status-cancelled-bg: var(--palette-red-100);
  --color-status-cancelled-fg: var(--palette-red-700);
  --color-status-quote-sent-bg: var(--palette-amber-100);
  --color-status-quote-sent-fg: var(--palette-amber-700);
  --color-status-scheduled-bg: var(--palette-orange-100);
  --color-status-scheduled-fg: var(--palette-orange-700);
  --color-status-waiting-bg: var(--palette-orange-100);
  --color-status-waiting-fg: var(--palette-orange-800);
  --color-status-in-repair-bg: var(--palette-red-100);
  --color-status-in-repair-fg: var(--palette-red-700);
  --color-status-on-hold-bg: var(--palette-graphite-50);
  --color-status-on-hold-fg: var(--palette-graphite-700);
  /* r-60: Ready (repaired, not yet closed) takes Delivered's blue: the
     same "work done, not closed yet" stage on the Maintenance board. */
  --color-status-ready-bg: var(--palette-blue-200);
  --color-status-ready-fg: var(--palette-blue-800);

  /* RULE: type scale — 6 steps only, 13/14/16/18/22/28px (§13). No text
     people read is smaller than 13px (r-152, Peter 2026-11-03: 12px was
     too small on CK's Full HD screen); typeScale.unit.test.js holds it. */
  --font-size-xs: 0.8125rem;
  --font-size-sm: 0.875rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.375rem;
  --font-size-2xl: 1.75rem;
  /* The value in a pop-up field (view and edit mode): 14px in medium
     weight and full-contrast colour over the 12px muted uppercase label.
     The data stands out by weight and contrast, not by a big size jump;
     Peter picked this (variant B) on 2026-09-29 after finding 16px too big
     (ui-design-system.md §13 "Forms"). */
  --font-size-field-value: var(--font-size-sm);
  --font-weight-field-value: var(--font-weight-medium);

  /* Font families, weights and letter-spacing — consumed by the text roles
     in typography.css (§13 "Text roles") */
  --font-family-body: 'Inter', sans-serif;
  --font-family-head: 'Montserrat', sans-serif;
  /* Keys, dates and numbers: one of four fonts, a per-person preference
     (r-152, My profile → Appearance; typography.css maps data-key-font on
     <html> to one of these). JetBrains Mono is the default. */
  --font-family-mono-jetbrains: 'JetBrains Mono', monospace;
  --font-family-mono-plex: 'IBM Plex Mono', monospace;
  --font-family-mono-roboto: 'Roboto Mono', monospace;
  --font-family-mono: var(--font-family-mono-jetbrains);
  /* Code and log text (stack traces, log values, <pre>/<code>) keeps a fixed
     monospace whatever key font a person picks, so its columns stay aligned
     (r-152 review F4). */
  --font-family-code: var(--font-family-mono-jetbrains);
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-heavy: 800;
  --letter-spacing-sm: 0.04em;
  --letter-spacing-md: 0.1em;
  --letter-spacing-lg: 0.15em;

  /* Spacing — 4px grid (§13). --space-0-5 (2px) is the one half-step, for
     tight pill/tag padding where 4px looks chunky (Peter, 2026-09-26). */
  --space-0-5: 0.125rem;
  --space-1: 0.25rem;
  /* Room for descenders and double accents above/below a line-height-1 text that clips (profile hero name, PR #70 review). Font-relative on purpose. */
  --space-glyph-guard: 0.15em;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Control height — §9 "Header-row control sizing": every control in a
     header row or toolbar is one height (Peter, 2026-11-02: the clear-filters
     icon was "smaller than the other buttons"). .btn and the field
     primitives reach it with --space-2 vertical padding, --font-size-sm at
     this line height and a 1px border; an icon-only button there takes it
     as its width and height. */
  --control-line-height: 1.5;
  --control-border-width: 1px;
  --control-height: calc(2 * var(--space-2) + var(--font-size-sm) * var(--control-line-height) + 2 * var(--control-border-width));

  /* Radius — 0 / 4 / 6 / 8 / pill only (§13) */
  --radius-none: 0;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 999px;

  /* Elevation — at most 4 levels; never the only sign of a boundary (§13) */
  --shadow-1: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-3: 0 8px 32px rgba(0, 0, 0, 0.18);
  --shadow-4: 0 30px 80px rgba(0, 0, 0, 0.45);

  /* RULE: materials (v0.109.0, §13 "Themes"; "Visual effects" in Settings):
     the light and texture a theme adds on top of its colours, drawn by
     effects.css only while effects are on (data-effects="off" on <html>
     turns them all off, so do forced colours). These are Oceanic's own
     values; every other theme sets its own. None of them may change
     layout: no sizes, no border widths, no movement. */
  /* Static ambient light behind the app (body background-image), and the
     size of each of its layers (a dot grid needs a tile size). */
  --bg-atmosphere: radial-gradient(ellipse 70% 40% at 8% 0%, color-mix(in srgb, var(--palette-cyan-500) 10%, transparent), transparent 70%);
  --bg-atmosphere-size: auto;
  /* A thin light edge along the top of cards and dialogs (inset shadow). */
  --surface-highlight: color-mix(in srgb, var(--palette-white) 50%, transparent);
  /* A halo around a focused control, on top of (never instead of) the outline. */
  --shadow-glow: none;
  /* The page header ("hero"): its layered background, a broad diagonal
     sheen, a 1px light line along its bottom, a static grain (0 = none) and
     a theme motif (beans, leaves) drawn in --color-hero-motif through a
     same-origin SVG mask, faded out behind the title. */
  /* Oceanic too has a grain, and in dark mode a bloom (b-140): with neither,
     effects on and off looked the same on its header. Light mode has no
     bloom: over its brighter header it cost the white title its 4.5:1. */
  --hero-layers:
    radial-gradient(ellipse 45% 140% at 100% 0%, var(--color-hero-bloom), transparent 70%),
    linear-gradient(in oklch 100deg, var(--color-header-start) 0%, var(--color-header-end) 100%);
  --hero-sheen: color-mix(in srgb, var(--palette-white) 16%, transparent);
  --hero-edge: color-mix(in srgb, var(--palette-cyan-glow) 45%, transparent);
  --hero-grain: 0.06;
  --hero-motif: none;
  --hero-motif-size: auto;
  /* The header's bloom (a soft light patch inside --hero-layers) and motif
     colours; check-contrast measures the header's text over both. */
  --color-hero-bloom: color-mix(in srgb, var(--palette-white) 0%, transparent);
  --color-hero-motif: color-mix(in srgb, var(--palette-white) 0%, transparent);
  /* Primary buttons: a satin fill lightened by --button-light at the top, a
     specular top edge, a tinted shadow and the theme's button radius. */
  --button-light: 8%;
  --button-highlight: color-mix(in srgb, var(--palette-white) 35%, transparent);
  /* Glass secondary buttons (b-140): the share of --color-sheen-light in the
     lit top band. Per mode: white over a light fill only raises contrast,
     over a dark fill it lowers it, so dark mode takes less (:root.dark);
     check-contrast measures it (checkSecondarySheen). */
  --button-secondary-sheen: 14%;
  --button-shadow: color-mix(in srgb, var(--palette-cyan-900) 22%, transparent);
  --button-radius: var(--radius-lg);
  /* Cards: border and top-edge colours, a shadow tinted with the theme's
     hue, an optional glow and an optional 1px gradient border. */
  --card-border: var(--color-divider);
  --card-top: var(--card-border);
  --shadow-tint: color-mix(in srgb, var(--palette-slate-900) 14%, transparent);
  --card-glow: 0 0 0 0 transparent;
  --border-gradient: none;
  /* How quickly a control answers hover and press. */
  --motion-fast: 160ms;
  /* RULE: pop-up motion ("Subtle", Peter 2026-10-18, picked from a
     three-variant demo). A pop-up opens in --motion-enter from a slightly
     smaller (--motion-scale), slightly lower (--motion-drift) and transparent
     start, and closes faster, in --motion-exit. A dialog covered by another
     steps back to --motion-behind. Only transform and opacity animate.
     Reduced motion and Visual effects off keep the fade only (scale 1,
     drift 0, behind 1: effects.css). ui-design-system.md §13. */
  --motion-enter: 180ms;
  --motion-exit: 120ms;
  --motion-scale: 0.985;
  --motion-drift: 2px;
  --motion-behind: 0.99;
  --ease-enter: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);
  /* Plain white and black for the materials' light and shade (mixed into a
     button's own colour), and an opaque colour for masks, which only read
     alpha. Not text or surface colours. */
  --color-sheen-light: var(--palette-white);
  --color-sheen-dark: var(--palette-black);
  --color-mask: var(--palette-black);
  /* Heading weight, and a letter-spacing adjustment added to each heading
     role's own spacing (typography.css, shell.css). */
  --heading-weight: var(--font-weight-heavy);
  --heading-tracking: 0em;
  /* The uppercase headings' spacing with that adjustment. */
  --letter-spacing-heading-md: calc(var(--letter-spacing-md) + var(--heading-tracking));
  --letter-spacing-heading-lg: calc(var(--letter-spacing-lg) + var(--heading-tracking));

  /* Icon sizes (§13) */
  --icon-sm: 0.875rem;
  --icon-md: 1rem;
  --icon-lg: 1.25rem;
  --icon-xl: 1.5rem;
  --icon-2xl: 2.25rem;

  /* Dialog sizes (r-39 c4) — feed the shell in dialogs.css. A large dialog
     has a fixed height; small and medium ones grow up to --dialog-max-h. */
  --dialog-w-sm: 27.5rem;
  --dialog-w-md: 37.5rem;
  --dialog-w-wide: 56.25rem;
  --dialog-w-lg: 90rem;
  --dialog-h-lg: min(88vh, 52rem);
  --dialog-max-h: 88vh;
  /* The edit pop-up (r-73 note 1): taller and wider than the detail pop-up
     it opens over, so several line cards fit before it scrolls. */
  --dialog-w-edit: 100rem;
  --dialog-h-edit: min(94vh, 64rem);
  --dialog-aside-w: 22.5rem;
  --dialog-pane-w: 20rem;
  /* A toast's widest line (Peter, 2026-10-12): longer text wraps, so its
     action (Undo) is never pushed out of view. */
  --toast-max-w: 30rem;
  --dialog-footer-h: 4.5rem;

  /* RULE: Sign-in page "Frost" (r-126, chosen by CK 2026-10-19). A brand
     exception: only login.css reads these, mapping them onto the semantic
     tokens inside .login-frost, so the shared field and button primitives
     draw in Frost. Fixed light, never switched by .dark or a theme. */
  --login-bg: #E6EFF8;
  --login-flake: #C6D8EC;
  --login-surface: #FFFFFF;
  --login-card-border: #C9D8EA;
  --login-field-bg: #F3F7FC;
  /* The design's field border (#BCCEE2) is 1.6:1 on white; darkened to
     3.3:1 so a field's edge meets WCAG 1.4.11 like every app field. */
  --login-field-border: #7A91A8;
  --login-text: #0B2233;
  --login-text-2: #2F4C66;
  --login-text-label: #34536A;
  --login-text-muted: #4D687C;
  --login-accent: #1F5FD6;
  --login-accent-hover: #1546A3;
  --login-on-accent: #FFFFFF;
  --login-hot: #E8703A;
  --login-warm: #F2A541;
  --login-cool: #8DB6FF;
  --login-accent-tint: rgba(31, 95, 214, 0.12);
  --login-accent-ring: rgba(31, 95, 214, 0.22);
  --login-card-shadow: 0 30px 60px -30px rgba(11, 34, 51, 0.35);
  --login-font: 'Sora', sans-serif;
  --login-font-accent: 'Instrument Serif', serif;
  --login-font-size-headline: clamp(2.75rem, 5.8vw, 5.25rem);
  --login-font-size-headline-2: clamp(2.125rem, 4.45vw, 4rem);
  --login-font-size-lede: 1.125rem;
  --login-font-size-card-title: 1.875rem;
  --login-font-size-field: 1rem;
  --login-font-size-cta: 1.0625rem;
  --login-font-size-label: 0.8125rem;
  --login-font-size-small: 0.8125rem;
  --login-font-size-option: 0.875rem;
  --login-font-weight-light: 400;
  /* The page's outer margin: 16px on a phone up to the design's 120px. */
  --login-gutter: clamp(1rem, 7vw, 7.5rem);
  --login-gutter-top: clamp(1rem, 4vw, 3.5rem);
  --login-card-pad-y: clamp(1.75rem, 4vw, 3rem);
  --login-card-pad-x: clamp(1.25rem, 3.5vw, 2.75rem);
  --login-story-gap: 1.625rem;
  --login-card-gap: 1.375rem;
  --login-letter-spacing-headline: -0.04em;
  --login-letter-spacing-headline-2: -0.01em;
  --login-letter-spacing-title: -0.02em;
  --login-radius-card: 28px;
  --login-radius-control: 14px;
  --login-field-h: 3.25rem;
  --login-cta-h: 3.5rem;
  --login-card-w: 28.75rem;
  /* The story column and the gap to the card (the 1440 design: 640px, ~124px).
     Story + gap + card make one content area, centred on wider screens (r-128). */
  --login-story-w: 40rem;
  --login-content-gap: clamp(2rem, 8vw, 8rem);
}

/* ── Dark theme — semantic overrides only, never primitives ── */
:root.dark {
  /* 7% is the most that keeps secondary text ≥ 4.5:1 under the sheen in
     every theme (Oceanic, on the page, is the tightest: 4.61); 14% gave 3.66. */
  --button-secondary-sheen: 7%;
  --color-bg-page: var(--palette-slate-900);
  --color-bg-surface: var(--palette-slate-800);
  --color-bg-card: color-mix(in srgb, var(--palette-slate-800) 72%, transparent);
  /* Dark fields keep the page colour they always had (r-152 changed only light mode). */
  --color-bg-field: var(--color-bg-page);
  --color-menu-shade: color-mix(in srgb, var(--color-text-primary) 10%, transparent);

  --color-text-primary: var(--palette-slate-100);
  --color-text-secondary: var(--palette-slate-400);
  --color-text-inverse: var(--palette-slate-900);

  --color-border: var(--palette-slate-500);
  --color-divider: color-mix(in srgb, var(--palette-white) 6%, transparent);

  /* Light moved to graphite neutrals (2026-10-13); dark keeps its cool slate values. */
  --color-neutral-tint: color-mix(in srgb, var(--palette-slate-400) 12%, transparent);
  --color-neutral-tint-strong: color-mix(in srgb, var(--palette-slate-400) 35%, transparent);
  --color-bg-sunken: color-mix(in srgb, var(--palette-black) 28%, transparent);
  /* Dark mode takes a little more of the accent to show at all on the dark
     sunken tile (light mode: 5%, the most Forest's secondary text allows). */
  --color-tile-tint: color-mix(in srgb, var(--color-accent) 8%, transparent);
  --color-control-track: var(--palette-slate-600);

  --color-accent: var(--palette-cyan-400);

  /* Orders pipeline track (r-47): option A — the accent with its glow, no ring */
  --color-pipeline-order: var(--color-accent);
  --color-pipeline-order-outline: var(--color-accent);
  --color-pipeline-order-glow: var(--color-accent-glow);
  --pipeline-order-node-shadow: 0 0 6px var(--color-pipeline-order);
  --pipeline-order-line-shadow: 0 0 4px var(--color-pipeline-order);
  --color-action-primary-text: var(--palette-slate-900);

  --color-success: var(--palette-green-400);
  --color-success-bg: color-mix(in srgb, var(--palette-green-400) 20%, transparent);
  --color-warning: var(--palette-amber-400);
  --color-warning-bg: color-mix(in srgb, var(--palette-amber-400) 20%, transparent);
  --color-warning-text: var(--palette-amber-400);
  --color-danger: var(--palette-red-400);
  --color-danger-text: var(--palette-red-400);
  --color-danger-hover: var(--palette-red-500);
  --color-danger-bg: color-mix(in srgb, var(--palette-red-500) 20%, transparent);
  --color-info: var(--palette-blue-400);
  --color-info-bg: color-mix(in srgb, var(--palette-blue-400) 12%, transparent);

  --color-price: var(--palette-amber-500);

  --color-action-danger: var(--palette-red-600);
  --color-action-danger-hover: var(--palette-red-700);

  --color-cta-bg: var(--color-accent);
  /* Mimics the 0.85-opacity hover of an ordinary primary, on the fill only. */
  --color-cta-bg-hover: color-mix(in srgb, var(--color-accent) 85%, transparent);
  --color-cta-text: var(--palette-slate-900);

  --color-maintenance: var(--palette-orange-400);
  --color-maintenance-bg: color-mix(in srgb, var(--palette-orange-400) 12%, transparent);
  --color-maintenance-border: color-mix(in srgb, var(--palette-orange-400) 30%, transparent);

  --color-header-start: var(--palette-cyan-900);
  --color-header-end: var(--palette-cyan-800);

  --color-flash: color-mix(in srgb, var(--palette-cyan-400) 28%, transparent);

  --color-status-new-bg: color-mix(in srgb, var(--palette-slate-400) 15%, transparent);
  --color-status-new-fg: var(--palette-slate-400);
  --color-status-offer-sent-bg: color-mix(in srgb, var(--palette-violet-500) 20%, transparent);
  --color-status-offer-sent-fg: var(--palette-violet-400);
  --color-status-order-confirmed-bg: color-mix(in srgb, var(--palette-cyan-400) 20%, transparent);
  --color-status-order-confirmed-fg: var(--palette-cyan-400);
  --color-status-purchase-bg: color-mix(in srgb, var(--palette-amber-400) 20%, transparent);
  --color-status-purchase-fg: var(--palette-amber-400);
  --color-status-ready-for-delivery-bg: color-mix(in srgb, var(--palette-indigo-500) 20%, transparent);
  --color-status-ready-for-delivery-fg: var(--palette-indigo-300);
  --color-status-delivery-bg: color-mix(in srgb, var(--palette-blue-500) 20%, transparent);
  --color-status-delivery-fg: var(--palette-blue-400);
  --color-status-delivered-bg: color-mix(in srgb, var(--palette-blue-400) 30%, transparent);
  --color-status-delivered-fg: var(--palette-blue-300);
  --color-status-invoiced-bg: color-mix(in srgb, var(--palette-amber-400) 20%, transparent);
  --color-status-invoiced-fg: var(--palette-amber-400);
  --color-status-closed-bg: color-mix(in srgb, var(--palette-green-400) 15%, transparent);
  --color-status-closed-fg: var(--palette-green-400);
  --color-status-cancelled-bg: color-mix(in srgb, var(--palette-red-500) 20%, transparent);
  --color-status-cancelled-fg: var(--palette-red-400);
  --color-status-quote-sent-bg: color-mix(in srgb, var(--palette-amber-400) 20%, transparent);
  --color-status-quote-sent-fg: var(--palette-amber-400);
  --color-status-scheduled-bg: color-mix(in srgb, var(--palette-orange-500) 20%, transparent);
  --color-status-scheduled-fg: var(--palette-orange-400);
  --color-status-waiting-bg: color-mix(in srgb, var(--palette-orange-400) 20%, transparent);
  --color-status-waiting-fg: var(--palette-orange-300);
  --color-status-in-repair-bg: color-mix(in srgb, var(--palette-red-500) 20%, transparent);
  --color-status-in-repair-fg: var(--palette-red-400);
  --color-status-on-hold-bg: color-mix(in srgb, var(--palette-slate-400) 20%, transparent);
  --color-status-on-hold-fg: var(--palette-slate-300);
  --color-status-ready-bg: color-mix(in srgb, var(--palette-blue-400) 30%, transparent);
  --color-status-ready-fg: var(--palette-blue-300);

  --shadow-1: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 8px 40px rgba(0, 0, 0, 0.42);

  /* Toggle switches (see :root): dark knob colours. */
  --color-control-knob: var(--color-text-primary);
  --color-control-knob-on: var(--color-bg-page);

  /* Oceanic's dark materials (see :root "RULE: materials"). */
  --bg-atmosphere: radial-gradient(ellipse 70% 40% at 8% 0%, color-mix(in srgb, var(--palette-cyan-400) 10%, transparent), transparent 70%);
  --surface-highlight: color-mix(in srgb, var(--palette-white) 12%, transparent);
  --color-hero-bloom: color-mix(in srgb, var(--palette-white) 18%, transparent);
  --shadow-tint: color-mix(in srgb, var(--palette-black) 35%, transparent);
}

/* ── Lighter dark pages — one shared opt-in layer (v0.106.0) ──
   RULE: a dark mode whose page is lighter than Standard's near-black needs a
   step lighter text on the tinted pills and banners (Standard's -400 shades
   fall below 4.5:1 there). Themes opt in by being listed here; check-contrast
   applies this block to exactly these themes' dark modes. */
:root:is([data-theme="espresso"], [data-theme="porcelain"]).dark {
  --color-danger: var(--palette-red-300);
  --color-danger-text: var(--palette-red-300);
  --color-info: var(--palette-blue-300);
  --color-status-offer-sent-fg: var(--palette-violet-300);
  --color-status-delivery-fg: var(--palette-blue-300);
  --color-status-delivered-fg: var(--palette-blue-200);
  --color-status-cancelled-fg: var(--palette-red-300);
  --color-status-scheduled-fg: var(--palette-orange-300);
  --color-status-in-repair-fg: var(--palette-red-300);
  --color-status-ready-fg: var(--palette-blue-200);
}
