/* ==========================================================================
   Core — the one stylesheet every surface loads first
   The marketing site, CAA Console, the Passport and the dealership pages each link
   this, then their own sheet (site.css, console.css, passport.css, select.css).
   The link page links neither; it is one response and link.css.

   Three parts, in the order they cascade:

     1. Tokens  — the roles of docs/DESIGN-SYSTEM.md § 2 (surfaces, ink,
                  accent, status, focus, type, spacing, radii, elevation,
                  motion) with the one dark palette, then the old palette's
                  names (--black, --carbon, --gunmetal, --champagne…) as
                  aliases of them. CAA Console points its --console-* theme
                  tokens at the roles and re-points the roles for its light
                  theme; the other surfaces, dark only, point the same
                  --console-* names at the roles (the link page and the
                  estimator, which do not load this file, carry a copy of the
                  roles they use). tools/a11y.test.mjs checks the contrast of
                  every role and that every copy agrees.
     2. Base    — the reset, document defaults and the rules that keep
                  [hidden], focus rings and reduced motion correct everywhere.
     3. UI      — the shared primitives: wrap, band, button, panel, card,
                  choice, chip, field, badge, specs, toast. Written against
                  the names in part 1, so a surface restyles one by
                  re-pointing a name or overriding the rule in its own sheet.

   This used to be three files (tokens.css, base.css, ui.css), linked one
   after another by every shell. They are one file now in the same order, so
   nothing cascades differently and every page makes two fewer requests.
   ========================================================================== */

/* ==========================================================================
   1. Tokens
   ========================================================================== */

/* --- The roles -------------------------------------------------------------
   docs/DESIGN-SYSTEM.md § 2 is the contract: these names are fixed, and they
   are roles, not colours. The values are the one dark language every surface
   shares. A surface that has a light theme of its own (CAA Console) re-points
   the roles inside that theme; the dark-only surfaces (site.css, passport.css,
   select.css) point CAA Console's --console-* names at them and leave them
   alone.

   Contrast is WCAG 2.x, measured against --bg-0 / --bg-1 / --bg-2 / --bg-3
   (the last because menus, dialogs and toasts sit on it). tools/a11y.test.mjs
   recomputes every ratio from this block, resolving var(), so the comments
   cannot drift from the values without the build saying so.

   Each surface declares its own faces — Inter for text, Newsreader for
   headings, served from this origin so no font request reaches a third party
   before a visitor has chosen anything — and the families below are only the
   fallback for a page that forgets to.
   -------------------------------------------------------------------------- */
:root {
  /* --- Surfaces: four elevation steps -----------------------------------
     Warm-neutral near-black. Each step is about 5.5 L* above the last, which
     is what it takes to tell them apart on a phone at low brightness. */
  --bg-0: #0d0d0c;            /* the page */
  --bg-1: #1a1a19;            /* raised: cards, panels, the sidebar */
  --bg-2: #262523;            /* raised again: inputs on a card, table head, hover */
  --bg-3: #32312f;            /* floating: menus, popovers, dialogs, toasts */
  --bg-selected: #3a3936;     /* a selected row or item */
  --border: #302f2c;          /* hairline between surfaces */
  --border-strong: #4d4b47;   /* dividers that must be seen (2.00:1 on --bg-1); not for controls */
  --border-input: #6b6964;    /* control boundaries, WCAG 1.4.11 3:1: 3.55 on --bg-0, 3.18 on --bg-1 */
  /* The same boundary on the floating surfaces. --border-input is 2.79 on
     --bg-2 and 2.37 on --bg-3, so .dialog and .menu re-point it to this:
     3.67 on --bg-2, 3.12 on --bg-3. */
  --border-input-raised: #7e7c77;
  --hairline: rgba(255, 255, 255, 0.1); /* the light top edge on a raised panel */
  --scrim: rgba(0, 0, 0, 0.6);          /* behind a dialog */

  /* --- Ink: three emphasis levels -----------------------------------------
     Ratios on bg-0 / bg-1 / bg-2 / bg-3. Off-white, never #fff: pure white
     on near-black halates, and the warm grey matches the surfaces. */
  --ink: #f2f0ec;             /* 17.08 / 15.30 / 13.45 / 11.42 */
  --ink-2: #b6b3ac;           /*  9.29 /  8.32 /  7.32 /  6.21 */
  --ink-3: #9d9a92;           /*  6.92 /  6.20 /  5.45 /  4.62 */
  /* Text on a light fill (an ink-coloured button, a white chip). 17.08:1 on
     --ink. Text on the accent is --on-accent, below. */
  --ink-inverse: #0d0d0c;

  /* --- Accent: CAA red, used sparingly ------------------------------------
     A fill only: #b11217 is 2.75:1 on --bg-0, so it is never the ink. */
  --accent: #b11217;
  --accent-hover: #8f0e12;    /* the hover/pressed step (the old --crimson-dark) */
  --accent-text: #f37377;     /*  6.97 /  6.24 /  5.49 /  4.66 — the same hue as text */
  --accent-tint: color-mix(in srgb, var(--accent) 12%, transparent); /* --accent-text on it over --bg-1: 5.98 */
  --on-accent: #fbfaf8;       /* 6.78:1 on --accent, 8.99:1 on --accent-hover */

  /* --- Status, tuned for dark ---------------------------------------------
     Ratios on bg-0 / bg-1 / bg-2 / bg-3, then on its own 12% tint over --bg-1
     (a status badge or message). */
  --ok: #5cc98a;              /*  9.42 /  8.44 /  7.42 /  6.30, tint 6.77 */
  --warn: #e3b25a;            /*  9.98 /  8.94 /  7.86 /  6.67, tint 7.10 */
  --danger: #f0787c;          /*  7.11 /  6.37 /  5.60 /  4.75, tint 5.35 */
  --info: #86a8ff;            /*  8.39 /  7.51 /  6.61 /  5.61, tint 6.11 */
  --ok-tint: color-mix(in srgb, var(--ok) 12%, transparent);
  --warn-tint: color-mix(in srgb, var(--warn) 12%, transparent);
  --danger-tint: color-mix(in srgb, var(--danger) 12%, transparent);
  --info-tint: color-mix(in srgb, var(--info) 12%, transparent);

  /* --- Focus ------------------------------------------------------------------
     Blue, so focus is never mistaken for selection (which is the accent).
     7.72:1 on --bg-0, 5.16:1 on --bg-3; 3:1 is the floor for a UI indicator. */
  --focus: #7aa2f7;
  --ring: 0 0 0 2px var(--bg-0), 0 0 0 4px var(--focus);

  /* --- Type ------------------------------------------------------------- */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-num: var(--font);

  /* Fluid display sizes, taken from the design's clamp() pairs. */
  --fs-display: clamp(40px, 11vw, 96px);
  /* The statement band: one big line of type across the page. */
  --fs-statement: clamp(2.75rem, 11vw, 9rem);
  --fs-h1: clamp(36px, 9vw, 72px);
  --fs-h2: clamp(28px, 6.5vw, 56px);
  --fs-h3: clamp(24px, 5.5vw, 40px);
  --fs-lead: clamp(16px, 4.2vw, 20px);
  --fs-body: 16px;
  --fs-sm: 14px;
  --fs-xs: 12px;
  --fs-caption: 11px;

  --lh-tight: 1.1;
  --lh-base: 1.5;
  --lh-loose: 1.7;
  --tracking-tight: -0.02em;
  --tracking-wide: 0.12em;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  /* --- Spacing ---------------------------------------------------------- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;
  --sp-9: 96px;

  /* --- Radii ------------------------------------------------------------ */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --r-pill: 999px;

  /* --- Elevation -------------------------------------------------------- */
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.32);
  --shadow-float: 0 16px 48px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.55);
  --glow-accent: 0 0 0 1px rgba(177, 18, 23, 0.5), 0 8px 28px rgba(177, 18, 23, 0.35);
  --blur-glass: blur(24px) saturate(180%);

  /* --- Motion ------------------------------------------------------------
     Durations become 1ms under prefers-reduced-motion (part 2). */
  --t-fast: 120ms;            /* hover, pressed, toggles */
  --t-base: 200ms;            /* open, close, reveal */
  --t-slow: 360ms;            /* sheets, page-level moves */
  --t-scene: 900ms;           /* a scene's own movement: a line rising out of its mask, a photograph settling */
  --t-film: 6600ms;           /* the home page's opening, end to end: the one scene allowed to take its time */
  --t-intro: 1600ms;          /* the home page's intro, end to end; no scene animation is longer */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);      /* arrivals: reveals, the intro, an image settling */
  --ease-quart: cubic-bezier(0.76, 0, 0.24, 1);    /* panels and curtains: the menu, page transitions, the masthead */

  /* --- Layout --------------------------------------------------------- */
  --pad: 20px;
  --maxw: 1280px;
  --maxw-prose: 820px;
  --maxw-narrow: 760px;

  /* The iOS home indicator, plus a margin: what a bar fixed to the foot of
     the screen (the configurator's estimate, the consent banner) clears. */
  --bar-inset: calc(14px + env(safe-area-inset-bottom));
}

/* --- The old names ---------------------------------------------------------
   Every rule written before the roles reads these, and every surface sheet
   re-points some of them, so they stay: aliases of the roles where there is
   one, real values where they are product colour rather than interface. New
   code uses the role names. */
:root {
  --black: var(--bg-0);
  --midnight: var(--bg-0);
  --carbon: var(--bg-1);
  --surface: var(--bg-1);
  --surface-2: var(--bg-2);
  --gunmetal: var(--border);
  /* --hairline is a role and keeps its own name, above. */
  --white: var(--ink);
  --light: var(--ink);
  --grey: var(--ink-2);
  --dim: var(--ink-3);

  --crimson: var(--accent);
  --crimson-dark: var(--accent-hover);
  /* #b11217 as text is 2.75:1 on the page; this is the same hue lifted over
     4.5:1. For `color:` only — fill and border stay on --crimson. */
  --crimson-text: var(--accent-text);

  /* Real values, not roles. Champagne and blue are no longer interface
     accents — the accent is --accent and only --accent — but they remain the
     colours of the wrap and coating pillars and of anything already drawn in
     them. --blue-text is blue lifted for text: 5.25 / 4.70 / 4.13 on
     bg-0 / bg-1 / bg-2, so it is for --bg-0 and --bg-1 only. */
  --champagne: #b98955;
  --blue: #1f5eff;
  --blue-text: #4a7dff;
  /* The one channel the customer actually replies on. */
  --whatsapp: #25d366;

  /* Pillar colours, referenced by id so data and CSS agree. Product data,
     never interface accents. */
  --pillar-ppf: var(--crimson);
  --pillar-coating: var(--blue);
  --pillar-correction: var(--white);
  --pillar-wrap: var(--champagne);
  --pillar-detailing: #8d8d8d; /* the detailing pillar's grey, kept as it was (not an ink role) */

  /* Type sizes under their old names. */
  --fs-hero: var(--fs-display);
  --fs-deck: var(--fs-lead);
  --fs-eyebrow: var(--fs-caption);
}

/* The default scheme, for the form controls and scrollbars the browser draws.
   A surface with a light theme resets it inside that theme. */
:root {
  color-scheme: dark;
}

/* ==========================================================================
   2. Base — reset, document defaults and script-correctness rules
   ========================================================================== */

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

html {
  background: var(--black);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100svh;
}

h1,
h2,
h3,
h4,
p,
figure,
dl,
dd,
ol,
ul {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

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

/* The user-agent rule for [hidden] is `display: none` at the lowest possible
   specificity, so any component that sets its own `display` silently defeats
   it and renders an empty box. Restate it as a hard rule once, here, rather
   than remembering to guard every component that uses grid or flex. */
[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

a {
  color: var(--champagne);
  text-decoration: none;
}

a:hover {
  color: var(--light);
}

::selection {
  background: var(--crimson);
  color: #fff;
}

input[type="search"]::-webkit-search-cancel-button {
  filter: invert(1);
  opacity: 0.5;
}

/* Every interactive element gets the same visible focus ring. Removing the
   default without replacing it is how a keyboard user loses their place. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------------------
   Motion
   ---------------------------------------------------------------------------
   The one reduced-motion rule for every surface. The durations go to 1ms
   rather than 0 so a script waiting on transitionend or animationend still
   hears it. `html:root` outranks the plain `:root` a surface sheet sets its
   own timings on, though this file loads first. Every animation and
   transition is stilled whatever duration a rule wrote, which is what drops
   the movement; `transform` itself is left alone, because it also positions
   things (a centred popover, a rotated chevron) and removing it would move
   them rather than still them. A surface's own reduced-motion rules (a
   reveal made visible, a lift switched off) stay in its sheet.
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html:root {
    --t-fast: 1ms;
    --t-base: 1ms;
    --t-slow: 1ms;
    --t-scene: 1ms;
    --t-intro: 1ms;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Visually hidden but still announced. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Skip link — first tab stop on every surface. */
.skip-link {
  position: absolute;
  left: 14px;
  top: -60px;
  z-index: 200;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  background: var(--crimson);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: top var(--t-fast) var(--ease);
}

.skip-link:focus {
  top: 14px;
  color: #fff;
}

/* ==========================================================================
   3. UI — the shared primitives
   ========================================================================== */

/* The Claude Design source expresses everything as inline style attributes,
   which is right for a design file and wrong for a codebase. Every repeated
   inline treatment there becomes exactly one class here, so a change to (say)
   the panel edge happens once instead of in forty places. */

/* --- Layout ------------------------------------------------------------- */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-inline: var(--pad);
}

.wrap--prose {
  max-width: var(--maxw-prose);
}

.wrap--narrow {
  max-width: var(--maxw-narrow);
}

.band {
  padding-block: 72px;
}

.band--tight {
  padding-block: 48px;
}

.band--carbon {
  background: var(--carbon);
  border-top: 1px solid var(--gunmetal);
}

/* --- Eyebrow ------------------------------------------------------------ */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: var(--fs-eyebrow);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--champagne);
  line-height: 1.4;
}

.eyebrow::before {
  content: "";
  flex: 0 0 auto;
  width: 22px;
  height: 2px;
  background: var(--crimson);
}

/* A bare label with no rule — used inside cards where the rule would fight
   the card's own left border. */
.label {
  font-size: var(--fs-eyebrow);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--champagne);
}

.label--crimson {
  color: var(--crimson-text);
}

.label--grey {
  color: var(--grey);
}

/* --- Display type ------------------------------------------------------- */
.display {
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  text-wrap: balance;
}

.display--hero {
  font-size: var(--fs-hero);
  line-height: 0.95;
  max-width: 14em;
}

.display--1 {
  font-size: var(--fs-h1);
}

.display--2 {
  font-size: var(--fs-h2);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.015em;
}

.display--3 {
  font-size: var(--fs-h3);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.015em;
}

.display .accent {
  color: var(--champagne);
}

.deck {
  font-size: var(--fs-deck);
  line-height: 1.55;
  color: var(--light);
  text-wrap: pretty;
  max-width: 42ch;
}

.lede {
  font-size: var(--fs-body);
  line-height: 1.7;
  color: var(--grey);
  text-wrap: pretty;
  max-width: 44ch;
}

.quote {
  font-size: 18px;
  line-height: 1.5;
  color: var(--champagne);
  font-style: italic;
}

/* --- Buttons ------------------------------------------------------------- */
/* Variants, in order of weight: --primary (the one main action on a screen),
   --secondary, --ghost (outlined, quiet), --quiet (text only), --danger.
   --ghost and --whatsapp are the site's own and keep their names.

   The three new variants and the new sizes are written `.btn.btn--x` on
   purpose. Surface sheets restyle the bare `.btn` after this file loads, and a
   one-class variant would lose to it; two classes win without !important. */
.btn {
  --btn-spin: var(--ink);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 48px;
  padding-inline: var(--sp-5);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wide);
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease),
    opacity var(--t-fast) var(--ease);
}

.btn > svg {
  flex: 0 0 auto;
}

.btn--sm {
  height: 36px;
  padding-inline: var(--sp-4);
  font-size: var(--fs-xs);
}

.btn--md {
  height: 48px;
  padding-inline: var(--sp-5);
}

.btn.btn--lg {
  height: 56px;
  padding-inline: var(--sp-6);
  font-size: var(--fs-body);
}

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

/* Pressed: one pixel down, the way a key travels. */
.btn:active:where(:not(:disabled, [aria-disabled="true"])),
.btn.is-pressed {
  transform: translateY(1px);
}

/* Focus: the shared ring. The global :focus-visible outline is replaced, not
   removed, so a keyboard user always sees where they are. */
.btn:focus-visible,
.btn.is-focus {
  outline: 2px solid transparent; /* forced-colors still draws it */
  box-shadow: var(--ring);
}

.btn--primary {
  --btn-spin: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn--primary:hover:where(:not(:disabled, [aria-disabled="true"])),
.btn--primary.is-hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent);
  box-shadow: var(--glow-accent);
}

.btn--primary:focus-visible,
.btn--primary.is-focus {
  box-shadow: var(--ring);
}

.btn--primary:hover:focus-visible:where(:not(:disabled, [aria-disabled="true"])),
.btn--primary.is-hover.is-focus {
  box-shadow: var(--ring), var(--glow-accent);
}

.btn.btn--secondary {
  background: var(--bg-2);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn.btn--secondary:hover:where(:not(:disabled, [aria-disabled="true"])),
.btn.btn--secondary.is-hover {
  background: var(--bg-3);
  border-color: var(--ink-3);
  color: var(--ink);
}

/* Ghost is the site's outlined button: quiet, with an edge. */
.btn--ghost {
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn--ghost:hover:where(:not(:disabled, [aria-disabled="true"])),
.btn--ghost.is-hover {
  background: var(--bg-2);
  border-color: var(--ink-3);
  color: var(--ink);
}

.btn.btn--quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

.btn.btn--quiet:hover:where(:not(:disabled, [aria-disabled="true"])),
.btn.btn--quiet.is-hover {
  background: var(--bg-2);
  color: var(--ink);
}

.btn.btn--danger {
  --btn-spin: var(--ink-inverse);
  background: var(--danger);
  border-color: var(--danger);
  color: var(--ink-inverse);
}

.btn.btn--danger:hover:where(:not(:disabled, [aria-disabled="true"])),
.btn.btn--danger.is-hover {
  filter: brightness(1.1);
  color: var(--ink-inverse);
}

.btn--whatsapp {
  background: var(--whatsapp);
  border-color: var(--whatsapp);
  color: var(--black);
}

.btn--whatsapp:hover {
  color: var(--black);
  filter: brightness(1.08);
}

.btn--outline-whatsapp {
  border-color: var(--whatsapp);
  color: var(--ink);
}

/* Icon only: a square, and it must carry an aria-label. */
.btn.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--r-md);
}

.btn.btn--icon.btn--sm {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
}

.btn.btn--icon.btn--lg {
  width: 48px;
  height: 48px;
}

/* Loading: the label goes transparent (so the button keeps its width) and a
   ring turns in its place. aria-busy tells a screen reader the same; the
   script that sets it should also ignore a second press. */
.btn[aria-busy="true"] {
  color: transparent;
  pointer-events: none;
}

.btn[aria-busy="true"] > * {
  opacity: 0;
}

.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2px solid var(--btn-spin);
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 700ms linear infinite;
}

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

.btn:disabled,
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* Quiet uppercase text link with a trailing chevron, used for "All work ›". */
.textlink {
  display: inline-block;
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.underlink {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--light);
  border-bottom: 1px solid var(--gunmetal);
  padding-bottom: 4px;
}

.underlink:hover {
  border-bottom-color: var(--champagne);
}

/* --- Panels and cards ---------------------------------------------------- */
/* The signature surface: a raised fill, a hairline edge, and a brighter top
   edge so a panel reads as lit from above rather than as a flat rectangle. */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-top-color: var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--sp-6) var(--sp-5);
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-top-color: var(--hairline);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  color: var(--ink);
}

/* Card whose left edge carries a pillar accent. Set the colour with
   `--marker` (never `--accent`, which is the brand red everywhere now). */
.card--accent {
  border-left: 3px solid var(--marker, var(--border-strong));
}

/* Media card: the picture first, clipped to the card's corners; the words in
   .card__body. */
.card--media {
  padding: 0;
  overflow: hidden;
  border-radius: var(--r-lg);
}

.card--media > img,
.card--media > picture,
.card--media > .card__media {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.card__body {
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
}

/* Interactive: the whole card is the target. Lift on hover, ring on focus. */
.card--interactive,
a.card,
button.card {
  display: block;
  width: 100%;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), transform var(--t-base) var(--ease),
    box-shadow var(--t-base) var(--ease);
}

.card--interactive:hover,
a.card:hover,
button.card:hover {
  background: var(--bg-2);
  border-color: var(--border-strong);
  border-left-color: var(--marker, var(--border-strong));
  color: var(--ink);
}

.card--interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.card--interactive:focus-visible,
.card--interactive.is-focus,
a.card:focus-visible,
button.card:focus-visible {
  outline: 2px solid transparent; /* forced-colors still draws it */
  box-shadow: var(--ring);
}

/* --- Rule grid -----------------------------------------------------------
   A grid whose 1px gaps show the container's gunmetal background, giving
   hairline dividers between cells without per-cell border bookkeeping. */
.rule-grid {
  display: grid;
  gap: 1px;
  background: var(--gunmetal);
  border: 1px solid var(--gunmetal);
  border-radius: var(--r-md);
  overflow: hidden;
  grid-template-columns: repeat(auto-fit, minmax(var(--min, 220px), 1fr));
}

.rule-grid > * {
  background: var(--black);
  padding: 24px 20px;
}

/* --- Spec list ------------------------------------------------------------
   Key on the left, value hard right, hairline between rows. Used for case
   specs, equipment, opening hours, passport attributes and Console detail panes. */
.specs {
  border-top: 1px solid var(--gunmetal);
}

.specs__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gunmetal);
}

.specs__k {
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey);
}

.specs__v {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* --- Client-owed notice ---------------------------------------------------
   A deliberate, visible blank. The design marks every fact the studio has not
   yet supplied — warranty terms, real reviews, the pickup fee — rather than
   inventing one, because an invented warranty term on a live site is a
   liability. Each block is driven by content.js and disappears on its own the
   moment the real value is filled in. */
.owed {
  border: 1px dashed var(--crimson);
  border-radius: var(--r-md);
  padding: 18px;
}

.owed__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--crimson-text);
  margin-bottom: 8px;
}

.owed__body {
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--light);
}

/* --- Chips and filters ----------------------------------------------------- */
.chip-row {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  padding-bottom: var(--sp-1);
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  height: 40px;
  padding-inline: var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-xs);
  transition: border-color var(--t-fast) var(--ease),
    background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.chip:hover {
  border-color: var(--ink-3);
  background: var(--bg-2);
}

.chip:focus-visible,
.chip.is-focus {
  outline: 2px solid transparent; /* forced-colors still draws it */
  box-shadow: var(--ring);
}

.chip--filter {
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

/* Selected is the accent's job, but as a wash and an edge: a row of filters
   with one filled red pill each would shout. */
.chip[aria-pressed="true"] {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--ink);
}

/* --- Form controls --------------------------------------------------------- */
/* Two generations live here.

   `.field` on an <input>, <select> or <textarea> is the site's own control: a
   56px pill (`.field--boxy` squares it off). It keeps working as it did.

   `.field` on a <div>, <label>, <fieldset> or <p> is the new wrapper: label
   above, the control, a hint and an error below. Inside it the control is an
   `.input`, `.textarea` or `.select`. The rules at the end of this block turn
   the wrapper's box off, so the same class can mean both without either
   inheriting the other's height or border. */
.field {
  width: 100%;
  height: 56px;
  padding-inline: 20px;
  background: var(--bg-1);
  border: 1px solid var(--border-input);
  border-radius: var(--r-pill);
  color: var(--ink);
  font-size: var(--fs-body);
  outline: 2px solid transparent; /* forced-colors still draws it */
  transition: border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}

.field::placeholder {
  color: var(--ink-3);
}

.field:hover {
  border-color: var(--ink-3);
}

.field:focus {
  border-color: var(--focus);
  box-shadow: var(--ring);
}

.field--boxy {
  height: 48px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
}

textarea.field {
  height: auto;
  min-height: 110px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  line-height: var(--lh-base);
  resize: vertical;
}

select.field {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
    linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) center, calc(100% - 14px) center;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 42px;
}

.field:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* The new inputs. 16px text so a phone does not zoom in on focus. */
.input,
.textarea,
.select {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0 var(--sp-3);
  background: var(--bg-2);
  border: 1px solid var(--border-input);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: inherit;
  font-size: var(--fs-body);
  line-height: var(--lh-base);
  outline: 2px solid transparent; /* forced-colors still draws it */
  transition: border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-3);
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--ink-3);
}

.input:focus,
.textarea:focus,
.select:focus,
.input.is-focus,
.textarea.is-focus,
.select.is-focus {
  border-color: var(--focus);
  box-shadow: var(--ring);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input[readonly] {
  background: transparent;
}

.textarea {
  min-height: 110px;
  padding: var(--sp-3);
  resize: vertical;
}

/* The chevron is two gradients rather than an image so it can read --ink-2:
   a data: URI cannot see a custom property. */
.select {
  appearance: none;
  padding-right: 42px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
    linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) center, calc(100% - 14px) center;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

/* Error: the edge turns to --danger, whichever way it was marked. */
.field[aria-invalid="true"],
.input[aria-invalid="true"],
.textarea[aria-invalid="true"],
.select[aria-invalid="true"],
.field[data-state="error"] .input,
.field[data-state="error"] .textarea,
.field[data-state="error"] .select {
  border-color: var(--danger);
}

/* The wrapper. */
.field:is(div, label, fieldset, p) {
  display: grid;
  gap: var(--sp-1);
  height: auto;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--ink);
  font-size: var(--fs-sm);
  min-width: 0;
}

.field:is(div, label, fieldset, p):hover,
.field:is(div, label, fieldset, p):focus-within {
  background: none;
  border-color: transparent;
  box-shadow: none;
}

.field > label:not(.check):not(.radio):not(.switch),
.field__label {
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

.field__hint {
  color: var(--ink-2);
  font-size: var(--fs-xs);
  line-height: var(--lh-base);
}

/* Shown only in the error state, so a form can carry them all the time and
   validate.js (or the server's reply) only has to flip data-state. */
.field__error {
  display: none;
  align-items: flex-start;
  gap: var(--sp-1);
  color: var(--danger);
  font-size: var(--fs-xs);
  line-height: var(--lh-base);
}

.field__error::before {
  content: "!";
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  margin-top: 1px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font-size: 9px;
  font-weight: var(--fw-semibold);
  line-height: 1;
}

.field[data-state="error"] .field__error,
.field:has([aria-invalid="true"]) .field__error {
  display: flex;
}

.field__error:empty {
  display: none !important;
}

/* Check, radio and switch are the real inputs, redrawn, so keyboard and screen
   reader behaviour stay the platform's. The usual markup is a label around the
   input and a <span> for the words, which makes the whole row one 44px target:

     <label class="check"><input type="checkbox" name="x"><span>Remind me</span></label>
     <label class="switch"><input type="checkbox" role="switch"><span>Alerts</span></label>

   The class on the bare input (`input.check`) and on a button
   (`button.switch[role="switch"][aria-checked]`) draw the same control. */
label.check,
label.radio,
label.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  color: var(--ink);
  font-size: var(--fs-sm);
  cursor: pointer;
}

label.check > span,
label.radio > span,
label.switch > span {
  min-width: 0;
}

input.check,
input.radio,
.check > input,
.radio > input {
  appearance: none;
  flex: 0 0 auto;
  display: inline-grid;
  place-content: center;
  width: 20px;
  height: 20px;
  margin: 0;
  background: var(--bg-2);
  border: 1px solid var(--border-input);
  color: var(--on-accent);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

input.check,
.check > input {
  border-radius: var(--r-xs);
}

input.radio,
.radio > input {
  border-radius: 50%;
}

input.check:hover,
input.radio:hover,
.check > input:hover,
.radio > input:hover {
  border-color: var(--ink-3);
}

input.check::before,
.check > input::before {
  content: "";
  width: 10px;
  height: 10px;
  background: currentColor;
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 38% 72%);
  transform: scale(0);
  transition: transform var(--t-fast) var(--ease);
}

input.radio::before,
.radio > input::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  transform: scale(0);
  transition: transform var(--t-fast) var(--ease);
}

input.check:checked,
input.radio:checked,
input.check:indeterminate,
.check > input:checked,
.radio > input:checked,
.check > input:indeterminate {
  background: var(--accent);
  border-color: var(--accent);
}

input.check:checked::before,
input.radio:checked::before,
.check > input:checked::before,
.radio > input:checked::before {
  transform: scale(1);
}

/* Indeterminate: a bar in place of the tick. */
input.check:indeterminate::before,
.check > input:indeterminate::before {
  clip-path: none;
  height: 2px;
  transform: scale(1);
}

input.check:focus-visible,
input.radio:focus-visible,
.check > input:focus-visible,
.radio > input:focus-visible,
.switch:focus-visible,
.switch > input:focus-visible,
:is(.check, .radio, .switch) > input.is-focus,
input.check.is-focus,
input.radio.is-focus,
.switch.is-focus {
  outline: 2px solid transparent; /* forced-colors still draws it */
  box-shadow: var(--ring);
}

input.check:disabled,
input.radio:disabled,
.check > input:disabled,
.radio > input:disabled,
.switch:disabled,
.switch > input:disabled,
.switch[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

input.check[aria-invalid="true"],
input.radio[aria-invalid="true"],
.check > input[aria-invalid="true"],
.radio > input[aria-invalid="true"] {
  border-color: var(--danger);
}

/* Switch: the input inside <label class="switch"> (role="switch"), or a
   <button role="switch" aria-checked class="switch">. The knob is a ::after
   that slides on a transform. */
button.switch,
input.switch,
.switch > input {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  margin: 0;
  padding: 0;
  background: var(--bg-3);
  border: 1px solid var(--border-input);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

button.switch::after,
input.switch::after,
.switch > input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink-2);
  transition: transform var(--t-fast) var(--ease),
    background-color var(--t-fast) var(--ease);
}

button.switch[aria-checked="true"],
input.switch:checked,
.switch > input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

button.switch[aria-checked="true"]::after,
input.switch:checked::after,
.switch > input:checked::after {
  transform: translateX(18px);
  background: var(--on-accent);
}

/* Choice card — a radio or checkbox styled as a selectable panel. The real
   input stays in the DOM (hidden but focusable) so keyboard and screen-reader
   behaviour is the platform's, not a reimplementation. */
.choice {
  position: relative;
  display: block;
  min-height: 64px;
  padding: var(--sp-4) 18px;
  background: var(--bg-0);
  border: 1px solid var(--border-strong);
  border-top-color: var(--hairline);
  border-left: 3px solid var(--marker, var(--border-strong));
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
}

.choice:hover {
  background: var(--bg-1);
}

.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.choice input:focus-visible ~ .choice__top {
  outline: 2px solid var(--focus);
  outline-offset: 6px;
  border-radius: var(--r-xs);
}

.choice__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.choice__label {
  font-weight: var(--fw-semibold);
  font-size: var(--fs-body);
  color: var(--ink);
}

.choice__price {
  font-size: var(--fs-xs);
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.choice__spec {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-2);
}

.choice:has(input:checked) {
  background: var(--bg-1);
  border-color: var(--ink-3);
  border-left-color: var(--marker, var(--accent));
}

.choice:has(input:checked) .choice__label {
  color: var(--ink);
}

/* --- Glass bar ------------------------------------------------------------
   Shared by the tab bar, the estimate bar and the sheet. */
.glass {
  background: rgba(24, 24, 24, 0.8);
  -webkit-backdrop-filter: var(--blur-glass);
  backdrop-filter: var(--blur-glass);
  border: 1px solid var(--gunmetal);
  border-top-color: rgba(255, 255, 255, 0.13);
  box-shadow: var(--shadow-float);
}

/* --- Badges ---------------------------------------------------------------- */
/* A status is a wash and a word, never colour alone: the label says it too. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-2);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wide);
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}

.badge--ok {
  background: var(--ok-tint);
  border-color: transparent;
  color: var(--ok);
}

.badge--warn {
  background: var(--warn-tint);
  border-color: transparent;
  color: var(--warn);
}

.badge--danger {
  background: var(--danger-tint);
  border-color: transparent;
  color: var(--danger);
}

.badge--info {
  background: var(--info-tint);
  border-color: transparent;
  color: var(--info);
}

.badge--accent {
  background: var(--accent-tint);
  border-color: transparent;
  color: var(--accent-text);
}

/* --- Grids ----------------------------------------------------------------- */
.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(var(--min, 240px), 1fr));
}

.grid--16 {
  gap: 16px;
}

.stack {
  display: grid;
  gap: var(--gap, 16px);
}

/* --- Empty, loading and error ------------------------------------------------ */
.empty {
  display: grid;
  justify-items: center;
  gap: var(--sp-2);
  padding: var(--sp-7) var(--sp-5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  text-align: center;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  line-height: var(--lh-loose);
}

.empty > svg,
.empty__icon {
  color: var(--ink-3);
}

.empty__title {
  color: var(--ink);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
}

/* Skeleton: a placeholder with the shape of what is coming. The container
   should carry aria-busy="true" and one visually hidden "Loading"; the pieces
   themselves are decoration. */
.skeleton {
  display: block;
  background-color: var(--bg-2);
  border-radius: var(--r-sm);
  animation: skeleton-pulse 1.4s var(--ease-in-out) infinite;
}

.skeleton--text {
  height: 1em;
  margin-block: 0.4em;
  border-radius: var(--r-xs);
}

.skeleton--text:last-child:not(:only-child) {
  width: 60%;
}

.skeleton--block {
  min-height: 96px;
  border-radius: var(--r-md);
}

@keyframes skeleton-pulse {
  0%,
  100% {
    background-color: var(--bg-2);
  }
  50% {
    background-color: var(--bg-3);
  }
}

/* Error state: what failed, and a way to try again. The retry is a .btn
   (usually .btn--secondary) that also carries .error-state__retry. */
.error-state {
  display: grid;
  justify-items: start;
  gap: var(--sp-2);
  padding: var(--sp-5);
  background: var(--danger-tint);
  border: 1px solid var(--danger);
  border-radius: var(--r-md);
  color: var(--ink);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
}

.error-state__title {
  color: var(--danger);
  font-weight: var(--fw-semibold);
}

.error-state__retry {
  margin-top: var(--sp-2);
}

/* --- Notifications ----------------------------------------------------------
   Bottom centre, stacked, and shaped like notifications rather than a banner:
   out of the way of the heading of whatever has just been saved, and clear of
   the home indicator. The newest sits at the bottom.

   The host does not take pointer events; each notification does, so the page
   underneath stays clickable between them and the dismiss button still works. */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
  z-index: 120;
  display: grid;
  gap: var(--sp-2);
  justify-items: stretch;
  width: min(420px, calc(100vw - 2 * var(--sp-3)));
  translate: -50% 0;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--r-md);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--ink-3);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
  color: var(--ink);
  animation: toast-in var(--t-base) var(--ease);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Added by the timer a beat before the node is removed, so a notification
   fades out deliberately instead of vanishing between frames. */
.toast[data-leaving="true"] {
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}

.toast__icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--r-xs);
  background: var(--info-tint);
  color: var(--info);
  flex: none;
}

.toast__body {
  min-width: 0;
  line-height: var(--lh-base);
  overflow-wrap: anywhere;
}

/* The kind, above the message, so a glance answers "is this bad news?"
   without reading the sentence. */
.toast__label {
  display: block;
  margin-bottom: 3px;
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-2);
}

/* The one optional action: Undo, View. Quiet text in the accent's text tone. */
.toast__action {
  align-self: center;
  min-height: 32px;
  padding: 0 var(--sp-2);
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--accent-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease);
}

.toast__action:hover {
  background: var(--bg-2);
}

.toast__action:focus-visible,
.toast__close:focus-visible {
  outline: 2px solid transparent; /* forced-colors still draws it */
  box-shadow: var(--ring);
}

.toast__close {
  flex: none;
  border: 0;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
  padding: 2px;
  line-height: 0;
  border-radius: var(--r-xs);
  transition: color var(--t-fast) var(--ease);
}

.toast__close:hover {
  color: var(--ink);
}

.toast--ok {
  border-left-color: var(--ok);
}

.toast--ok .toast__icon {
  background: var(--ok-tint);
  color: var(--ok);
}

.toast--danger {
  border-left-color: var(--danger);
}

.toast--danger .toast__icon {
  background: var(--danger-tint);
  color: var(--danger);
}

.toast--warn {
  border-left-color: var(--warn);
}

.toast--warn .toast__icon {
  background: var(--warn-tint);
  color: var(--warn);
}

/* --- Tables ------------------------------------------------------------------
   Hairline rows, no zebra. Put a wide table in .table-scroll so it scrolls
   inside itself on a phone instead of the page. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

.table th {
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-strong);
  color: var(--ink-2);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-wide);
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

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

.table tbody tr {
  transition: background-color var(--t-fast) var(--ease);
}

.table tbody tr:hover {
  background: var(--bg-2);
}

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

.table--sticky thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-1);
}

.table--dense th,
.table--dense td {
  padding: var(--sp-2) var(--sp-3);
}

.table .table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Row actions wait until the row is hovered or has focus inside it. They are
   transparent, not hidden, so a keyboard user can still land on them (and
   focus-within then shows them). Without a pointer they are always there. */
.table__actions {
  text-align: right;
  white-space: nowrap;
}

.table__actions > * {
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}

.table tr:hover .table__actions > *,
.table tr:focus-within .table__actions > * {
  opacity: 1;
}

@media (hover: none) {
  .table__actions > * {
    opacity: 1;
  }
}

/* Controls inside a floating surface sit on --bg-3 (or a card on it), where
   --border-input is 2.37:1. One scoped re-point, so every .input, .select and
   .check inside picks up the lighter boundary without a new selector. */
.dialog,
.menu {
  --border-input: var(--border-input-raised);
}

/* --- Dialog -----------------------------------------------------------------
   A native <dialog>, opened with showModal() by components/dialog.js. The
   script sets data-state: "enter" for the frame before it opens and "closing"
   while it leaves; with neither, a plain `dialog.showModal()` still looks
   right. The backdrop is the dialog's own ::backdrop. */
.dialog {
  width: min(520px, calc(100vw - 2 * var(--sp-4)));
  max-width: none;
  max-height: min(86dvh, 760px);
  padding: 0;
  overflow: hidden;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-top-color: var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
  color: var(--ink);
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}

.dialog[open] {
  display: flex;
  flex-direction: column;
}

.dialog::backdrop {
  background: var(--scrim);
  transition: opacity var(--t-base) var(--ease);
}

.dialog[data-state="enter"],
.dialog[data-state="closing"] {
  opacity: 0;
  transform: translateY(8px) scale(0.98);
}

.dialog[data-state="enter"]::backdrop,
.dialog[data-state="closing"]::backdrop {
  opacity: 0;
}

.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.dialog__title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--fs-lead);
  font-weight: var(--fw-medium);
  line-height: var(--lh-tight);
  text-wrap: balance;
}

/* The title and, under it, one quiet line (who it is for). */
.dialog__heading {
  min-width: 0;
}

.dialog__sub {
  margin: var(--sp-1) 0 0;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
}

.dialog__close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-right: calc(-1 * var(--sp-2));
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.dialog__close:hover {
  background: var(--bg-2);
  color: var(--ink);
}

.dialog__close:focus-visible {
  outline: 2px solid transparent; /* forced-colors still draws it */
  box-shadow: var(--ring);
}

/* The only part that scrolls: the head and the footer stay in view. */
.dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--sp-5);
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--ink-2);
  font-size: var(--fs-body);
  line-height: var(--lh-base);
}

/* The typed confirm's field sits under the sentence it answers. */
.dialog__body > * + .field {
  margin-top: var(--sp-3);
}

.dialog__foot:empty {
  display: none;
}

.dialog__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
}

/* On a phone a sheet rises from the bottom edge and takes the width. */
@media (max-width: 640px) {
  .dialog--sheet {
    width: 100%;
    max-height: 90dvh;
    margin: auto 0 0;
    border-bottom: 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    transition-duration: var(--t-slow);
  }

  .dialog--sheet[data-state="enter"],
  .dialog--sheet[data-state="closing"] {
    transform: translateY(100%);
    opacity: 1;
  }

  .dialog--sheet .dialog__foot {
    flex-direction: column-reverse;
  }

  .dialog--sheet .dialog__foot .btn {
    width: 100%;
  }
}

/* --- Menu -------------------------------------------------------------------
   Positioned by components/menu.js, which sets --menu-x, --menu-y,
   --menu-min and --menu-max in pixels. */
.menu {
  position: fixed;
  left: var(--menu-x, 0);
  top: var(--menu-y, 0);
  z-index: 130;
  min-width: var(--menu-min, 180px);
  max-width: min(320px, calc(100vw - 2 * var(--sp-3)));
  max-height: var(--menu-max, 60dvh);
  overflow-y: auto;
  padding: var(--sp-1);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  color: var(--ink);
  transform-origin: var(--menu-origin, top left);
  animation: menu-in var(--t-fast) var(--ease);
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: 36px;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}

.menu__item > svg {
  flex: 0 0 auto;
  color: var(--ink-2);
}

.menu__item:hover,
.menu__item:focus-visible {
  background: var(--bg-2);
  outline: 2px solid transparent; /* forced-colors still draws it */
}

.menu__item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus);
}

.menu__item[aria-disabled="true"] {
  color: var(--ink-3);
  cursor: not-allowed;
}

.menu__item[aria-disabled="true"]:hover {
  background: transparent;
}

.menu__item--danger,
.menu__item--danger > svg {
  color: var(--danger);
}

.menu__sep {
  height: 1px;
  margin: var(--sp-1) calc(-1 * var(--sp-1));
  background: var(--border);
}

.menu__label {
  padding: var(--sp-2) var(--sp-3) var(--sp-1);
  color: var(--ink-2);
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

/* --- Segmented control and tabs ----------------------------------------------
   Both are wired by components/tabs.js. A segmented control is a pill of
   options, one lit; tabs are an underlined row that switches panels. */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.segmented__item {
  min-height: 32px;
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.segmented__item:hover {
  color: var(--ink);
}

.segmented__item[aria-pressed="true"],
.segmented__item[aria-selected="true"] {
  background: var(--bg-3);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

.segmented__item:focus-visible,
.segmented__item.is-focus {
  outline: 2px solid transparent; /* forced-colors still draws it */
  box-shadow: var(--ring);
}

/* After the base rule above, because a media query adds no specificity: placed
   earlier in the file it loses to that rule. The Console raises this to 44px
   in its own sheet; the public pages stay here. */
@media (pointer: coarse) {
  .segmented__item {
    min-height: 40px;
  }
}

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

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs__tab {
  position: relative;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease);
}

.tabs__tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: transparent;
  transition: background-color var(--t-fast) var(--ease);
}

.tabs__tab:hover {
  color: var(--ink);
}

.tabs__tab[aria-selected="true"] {
  color: var(--ink);
}

.tabs__tab[aria-selected="true"]::after {
  background: var(--accent);
}

.tabs__tab:focus-visible,
.tabs__tab.is-focus {
  outline: 2px solid transparent; /* forced-colors still draws it */
  box-shadow: var(--ring);
  border-radius: var(--r-xs);
}

.tabs__panel {
  padding-top: var(--sp-5);
}

/* --- Reduced motion ------------------------------------------------------------
   core.css part 2 shortens every duration. What it cannot do is decide that a
   thing which *moves* should simply appear: these drop the transforms, and
   leave the skeleton standing still. */
@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled),
  .btn.is-pressed,
  .card--interactive:hover {
    transform: none;
  }

  .dialog[data-state="enter"],
  .dialog[data-state="closing"],
  .dialog--sheet[data-state="enter"],
  .dialog--sheet[data-state="closing"] {
    transform: none;
  }

  .toast,
  .menu {
    animation: none;
  }

  .skeleton {
    animation: none;
  }

  .toast[data-leaving="true"] {
    transition: none;
  }
}
