/* =========================================================================
   FIR3x's Toolbox — design system
   -------------------------------------------------------------------------
   One stylesheet, no framework. Everything is built from the tokens in :root,
   so re-theming the site means changing values here rather than hunting down
   utility classes. Layer order:
     1. Tokens        2. Reset        3. Primitives
     4. Layout        5. Components   6. Utilities   7. Motion
   ========================================================================= */

/* ---------- 1. Tokens ---------------------------------------------------- */

:root {
    color-scheme: dark;

    /* Accent — overridden per-site by [data-accent] below. */
    --accent-h: 187;
    --accent-s: 92%;
    --accent-l: 56%;

    --accent:        hsl(var(--accent-h) var(--accent-s) var(--accent-l));
    --accent-strong: hsl(var(--accent-h) var(--accent-s) calc(var(--accent-l) - 12%));

    /* A saturated accent is bright enough for a button or a chart line but far
       too luminous to read as small text on a light ground — cyan on its own
       tint measures about 2:1. These -text variants are what labels, chips and
       alert copy use; in the dark theme they are the display colour, and the
       light theme darkens each one until it clears 4.5:1. */
    --accent-text:   hsl(var(--accent-h) var(--accent-s) var(--accent-l));
    --accent-soft:   hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.14);
    --accent-line:   hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.35);
    --accent-glow:   hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.22);
    --accent-ink:    hsl(var(--accent-h) 60% 8%);
    /* The accent as a *fill* under near-black ink. In this theme it is the
       same colour; in the light theme the two part company, because there the
       accent is darkened so it can be read as text on white — which makes a
       filled button darker at exactly the moment it needs to be lighter. */
    --accent-fill:        var(--accent);
    --accent-fill-strong: var(--accent-strong);

    /* Surfaces */
    --bg:            hsl(222 24% 7%);
    --bg-elevated:   hsl(222 22% 10%);
    --surface:       hsl(222 20% 12%);
    --surface-hover: hsl(222 20% 15%);
    --surface-sunken:hsl(222 26% 8%);
    --overlay:       hsl(222 30% 5% / 0.72);

    /* Text */
    --text:      hsl(210 30% 96%);
    --text-muted:hsl(214 14% 68%);
    /* Body-sized help text and captions use --text-dim, so it has to clear
       WCAG AA's 4.5:1 against the lightest surface it sits on, not the 3:1
       that would do for large text. 52% measured 4.39:1 and failed. */
    --text-dim:  hsl(214 12% 56%);

    /* Lines */
    --border:        hsl(215 18% 22%);
    --border-strong: hsl(215 18% 32%);

    /* Status. Each has a -text variant for the same reason as the accent. */
    --ok:      hsl(152 62% 46%);
    --ok-text:      hsl(152 62% 46%);
    --warn-text:    hsl(38 92% 58%);
    /* 62% measured 3.47:1 against the chip background and 4.02:1 against its
       own soft tint — both under AA for the 12-13px text these are used at.
       71% is the first value that clears 4.5 on all three grounds it lands on
       (surface, chip, and danger-soft). */
    --danger-text:  hsl(0 78% 71%);
    --info-text:    hsl(211 92% 62%);
    /* Same reason: 60% measured 4.2:1 on a chip. */
    --neutral-text: hsl(214 12% 62%);
    --ok-soft: hsl(152 62% 46% / 0.15);
    --warn:      hsl(38 92% 58%);
    --warn-soft: hsl(38 92% 58% / 0.15);
    --danger:      hsl(0 78% 62%);
    --danger-soft: hsl(0 78% 62% / 0.15);
    --info:      hsl(211 92% 62%);
    --info-soft: hsl(211 92% 62% / 0.15);
    --neutral:      hsl(214 12% 60%);
    --neutral-soft: hsl(214 12% 60% / 0.15);

    /* Type — fluid, so nothing needs a breakpoint to stay readable. */
    --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;

    --text-xs:  0.75rem;
    --text-sm:  0.8125rem;
    --text-base:0.9375rem;
    --text-md:  1rem;
    --text-lg:  clamp(1.0625rem, 0.98rem + 0.4vw, 1.1875rem);
    --text-xl:  clamp(1.25rem, 1.12rem + 0.6vw, 1.5rem);
    --text-2xl: clamp(1.5rem, 1.28rem + 1.1vw, 2rem);
    --text-3xl: clamp(1.875rem, 1.5rem + 1.9vw, 2.75rem);
    --text-4xl: clamp(2.25rem, 1.6rem + 3.2vw, 3.75rem);

    /* Space */
    --space-1: 0.25rem;  --space-2: 0.5rem;   --space-3: 0.75rem;
    --space-4: 1rem;     --space-5: 1.5rem;   --space-6: 2rem;
    --space-7: 3rem;     --space-8: 4rem;     --space-9: 6rem;

    /* Shape */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 999px;

    /* Depth */
    --shadow-sm: 0 1px 2px hsl(222 40% 3% / 0.4);
    --shadow:    0 4px 16px -4px hsl(222 40% 3% / 0.5);
    --shadow-md: 0 12px 32px -8px hsl(222 40% 3% / 0.55);
    --shadow-lg: 0 28px 60px -18px hsl(222 40% 2% / 0.7);

    /* Motion */
    --ease: cubic-bezier(0.32, 0.72, 0, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --fast: 140ms;
    --normal: 240ms;
    --slow: 420ms;

    /* Layout */
    --page-max: 1200px;
    --page-narrow: 760px;
    --header-height: 64px;
}

/* Light theme. Roles keep their meaning; only the values swap. */
[data-theme="light"] {
    color-scheme: light;

    --accent-l: 42%;

    /* 42% under the near-black ink measures 3.79:1 and fails AA on a button.
       Filled surfaces keep the brighter value, which measures about 9:1. */
    --accent-fill:        hsl(var(--accent-h) var(--accent-s) 62%);
    --accent-fill-strong: hsl(var(--accent-h) var(--accent-s) 54%);

    --bg:            hsl(210 36% 97%);
    --bg-elevated:   hsl(0 0% 100%);
    --surface:       hsl(0 0% 100%);
    --surface-hover: hsl(210 32% 96%);
    --surface-sunken:hsl(210 30% 94%);
    --overlay:       hsl(215 30% 22% / 0.4);

    --text:      hsl(217 32% 13%);
    --text-muted:hsl(216 14% 38%);
    --text-dim:  hsl(216 10% 42%);

    --border:        hsl(214 20% 87%);
    --border-strong: hsl(214 18% 74%);

    --ok:     hsl(152 58% 34%);
    --warn:   hsl(32 88% 42%);
    --danger: hsl(0 68% 48%);
    --info:   hsl(211 88% 46%);
    --neutral:hsl(215 14% 44%);

    /* Solved against each colour's own soft background so small text clears
       WCAG AA rather than merely looking tinted. */
    /* 26% measured 4.44:1 against --accent-soft, which is the pairing the
       active sidebar link uses on every admin page. 25% clears it at 4.70. */
    --accent-text:  hsl(var(--accent-h) var(--accent-s) 25%);
    --ok-text:      hsl(152 58% 27%);
    --warn-text:    hsl(32 88% 31%);
    --danger-text:  hsl(0 68% 42%);
    --info-text:    hsl(211 88% 38%);
    --neutral-text: hsl(215 14% 38%);

    --shadow-sm: 0 1px 2px hsl(215 30% 40% / 0.09);
    --shadow:    0 4px 16px -4px hsl(215 30% 40% / 0.12);
    --shadow-md: 0 12px 30px -8px hsl(215 30% 40% / 0.16);
    --shadow-lg: 0 28px 56px -18px hsl(215 30% 40% / 0.2);
}

/* Accent palettes, chosen in the admin settings. */
[data-accent="violet"] { --accent-h: 265; --accent-s: 85%; --accent-l: 66%; }
[data-accent="amber"]  { --accent-h: 38;  --accent-s: 94%; --accent-l: 56%; }
[data-accent="lime"]   { --accent-h: 88;  --accent-s: 68%; --accent-l: 50%; }
[data-accent="rose"]   { --accent-h: 344; --accent-s: 84%; --accent-l: 60%; }

/* ---------- 2. Reset ----------------------------------------------------- */

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

* { margin: 0; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + var(--space-4));
}

body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* A quiet ambient wash so large dark areas do not read as flat. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(900px 500px at 12% -10%, var(--accent-glow), transparent 65%),
        radial-gradient(700px 420px at 92% 4%, hsl(265 80% 60% / 0.10), transparent 60%);
}

[data-theme="light"] body::before { opacity: 0.55; }

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

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

button { cursor: pointer; background: none; border: none; }

h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    font-weight: 650;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

p, li { text-wrap: pretty; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent-strong); }

hr { border: none; border-top: 1px solid var(--border); margin: var(--space-6) 0; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

::selection { background: var(--accent-soft); color: var(--text); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-full);
    border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ---------- 3. Primitives ------------------------------------------------ */

.skip-link {
    position: absolute;
    left: var(--space-4);
    top: var(--space-4);
    z-index: 200;
    padding: var(--space-2) var(--space-4);
    background: var(--accent-fill);
    color: var(--accent-ink);
    border-radius: var(--radius);
    font-weight: 600;
    transform: translateY(-200%);
    transition: transform var(--fast) var(--ease);
}
.skip-link:focus { transform: translateY(0); }

.container {
    width: 100%;
    max-width: var(--page-max);
    margin-inline: auto;
    padding-inline: clamp(var(--space-4), 4vw, var(--space-6));
}

.container--narrow { max-width: var(--page-narrow); }

.section { padding-block: clamp(var(--space-6), 6vw, var(--space-8)); }
.section--tight { padding-block: var(--space-6); }

.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-6); }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-text);
}

.lede {
    font-size: var(--text-lg);
    color: var(--text-muted);
    max-width: 62ch;
}

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}
.section-head h2 { font-size: var(--text-2xl); }
.section-head p { color: var(--text-muted); margin-top: var(--space-1); }

/* ---------- 4. Layout ---------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: hsl(from var(--bg) h s l / 0.78);
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    border-bottom: 1px solid transparent;
    transition: border-color var(--normal) var(--ease), background var(--normal) var(--ease);
}

/* Toggled from app.js once the page scrolls, so the header only gains a
   dividing line when there is content behind it. */
.site-header.is-stuck { border-bottom-color: var(--border); }

@supports not (background: hsl(from red h s l)) {
    .site-header { background: var(--bg-elevated); }
}

.site-header__inner {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    font-weight: 650;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
    white-space: nowrap;
}
.brand:hover { color: var(--text); }

/* The logo is a 512x80 wordmark: size it by height and let the width follow,
   or it gets squashed into whatever box it is given. It is a transparent PNG
   in the brand red, so it reads on both the light and dark grounds. */
.brand__logo {
    height: 22px;
    width: auto;
    max-width: min(200px, 42vw);
    object-fit: contain;
    object-position: left center;
}

.brand__name { font-size: var(--text-md); }

.badge-version {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    background: var(--accent-soft);
    color: var(--accent-text);
    border: 1px solid var(--accent-line);
}

.site-nav { margin-left: auto; }

.site-nav__list {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    list-style: none;
    padding: 0;
    margin: 0;
}

.site-nav__link {
    display: block;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--text-base);
    font-weight: 500;
    transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.site-nav__link:hover { color: var(--text); background: var(--surface-hover); }
.site-nav__link[aria-current="page"] { color: var(--text); background: var(--accent-soft); }

.header-actions { display: flex; align-items: center; gap: var(--space-2); }

.nav-toggle { display: none; }

@media (max-width: 820px) {
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px; height: 38px;
        border-radius: var(--radius);
        border: 1px solid var(--border);
        color: var(--text-muted);
        background: var(--surface);
    }
    .nav-toggle:hover { color: var(--text); }

    .site-nav {
        position: fixed;
        inset: var(--header-height) 0 auto 0;
        margin: 0;
        padding: var(--space-4) clamp(var(--space-4), 4vw, var(--space-6)) var(--space-5);
        background: var(--bg-elevated);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        display: none;
    }
    .site-nav.is-open { display: block; animation: slide-down var(--normal) var(--ease-out); }
    .site-nav__list { flex-direction: column; align-items: stretch; gap: var(--space-1); }
    .site-nav__link { padding: var(--space-3); font-size: var(--text-md); }
}

.site-main { flex: 1; }

.site-footer {
    margin-top: var(--space-8);
    padding-block: var(--space-6);
    border-top: 1px solid var(--border);
    background: var(--surface-sunken);
}

.site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-5);
    justify-content: space-between;
    align-items: start;
}

.site-footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    list-style: none;
    padding: 0;
    margin: 0;
}
.site-footer__links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--text-base);
}
.site-footer__links a:hover { color: var(--accent); }

.site-footer__meta { font-size: var(--text-sm); color: var(--text-dim); }

/* ---------- 5. Components ------------------------------------------------ */

/* Buttons ---------------------------------------------------------------- */

.btn {
    --btn-bg: var(--surface);
    --btn-fg: var(--text);
    --btn-border: var(--border);

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.625rem 1.125rem;
    border-radius: var(--radius);
    border: 1px solid var(--btn-border);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-size: var(--text-base);
    font-weight: 570;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: transform var(--fast) var(--ease),
                background var(--fast) var(--ease),
                border-color var(--fast) var(--ease),
                box-shadow var(--fast) var(--ease),
                opacity var(--fast) var(--ease);
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }

.btn--primary {
    --btn-bg: var(--accent-fill);
    --btn-fg: var(--accent-ink);
    --btn-border: transparent;
    box-shadow: 0 1px 0 hsl(0 0% 100% / 0.16) inset, 0 6px 20px -8px var(--accent-glow);
}
.btn--primary:hover {
    background: var(--accent-fill-strong);
    border-color: transparent;
    color: var(--accent-ink);
    box-shadow: 0 1px 0 hsl(0 0% 100% / 0.16) inset, 0 10px 26px -8px var(--accent-glow);
}

.btn--ghost { --btn-bg: transparent; --btn-border: transparent; color: var(--text-muted); }
.btn--ghost:hover { color: var(--text); background: var(--surface-hover); border-color: transparent; }

.btn--outline { --btn-bg: transparent; --btn-border: var(--border-strong); }

/* --danger-text, not --danger: the label is 13px text on the soft tint, which
   is exactly the case the -text variants exist for. The raw colour measured
   4.02:1 there. */
.btn--danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger-text); --btn-border: transparent; }
.btn--danger:hover { background: var(--danger); color: hsl(0 0% 100%); }

.btn--sm { padding: 0.375rem 0.75rem; font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn--lg { padding: 0.8125rem 1.5rem; font-size: var(--text-md); border-radius: var(--radius-md); }
.btn--block { width: 100%; }

.btn--icon { width: 38px; height: 38px; padding: 0; }

.btn-group { display: inline-flex; flex-wrap: wrap; gap: var(--space-2); }

/* Cards ------------------------------------------------------------------ */

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--normal) var(--ease),
                transform var(--normal) var(--ease),
                box-shadow var(--normal) var(--ease);
}

.card__body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); flex: 1; }
.card__footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); }
.card__header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
}
.card__title { font-size: var(--text-lg); }

.card--interactive:hover {
    border-color: var(--accent-line);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.card--flush .card__body { padding: 0; }

/* Tool cards ------------------------------------------------------------- */

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
    gap: var(--space-4);
}

.tool-card { position: relative; }

.tool-card::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity var(--normal) var(--ease);
}
.tool-card:hover::after { opacity: 1; }

.tool-card__icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-line);
    flex-shrink: 0;
    overflow: hidden;
}
.tool-card__icon img { width: 100%; height: 100%; object-fit: cover; }
.tool-card__icon svg { width: 26px; height: 26px; }

.tool-card__top { display: flex; align-items: start; gap: var(--space-4); }
.tool-card__top > .chip { flex-shrink: 0; }
.tool-card__heading { flex: 1; min-width: 0; }
.tool-card__name { font-size: var(--text-lg); }
.tool-card__tagline { color: var(--text-muted); font-size: var(--text-sm); margin-top: 2px; }
.tool-card__text { color: var(--text-muted); flex: 1; }

/* Stretched link: the whole card is the hit target, and the heading reads as
   a heading rather than an underlined link. */
.tool-card__link,
.vehicle-card__link {
    color: inherit;
    text-decoration: none;
}
/* --accent is the display colour and measures 2.4:1 on the light theme's
   white card; --accent-text is the variant solved for text contrast. */
.tool-card:hover .tool-card__link,
.vehicle-card:hover .vehicle-card__link { color: var(--accent-text); }

.tool-card__link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

/* Accent variants let each card own a hue without extra markup. */
/* Each card can carry its own hue; --accent-text is derived from the same
   custom properties, so it follows automatically. */
.tool-card[data-accent="cyan"]   { --accent-h: 187; --accent-s: 92%; }
.tool-card[data-accent="violet"] { --accent-h: 265; --accent-s: 85%; }
.tool-card[data-accent="amber"]  { --accent-h: 38;  --accent-s: 94%; }
.tool-card[data-accent="lime"]   { --accent-h: 88;  --accent-s: 68%; }
.tool-card[data-accent="rose"]   { --accent-h: 344; --accent-s: 84%; }

/* Chips, pills and badges ------------------------------------------------- */

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.1875rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.01em;
    background: var(--neutral-soft);
    color: var(--neutral-text);
    border: 1px solid transparent;
    white-space: nowrap;
}

.chip--ok     { background: var(--ok-soft);     color: var(--ok-text); }
.chip--warn   { background: var(--warn-soft);   color: var(--warn-text); }
.chip--danger { background: var(--danger-soft); color: var(--danger-text); }
.chip--info   { background: var(--info-soft);   color: var(--info-text); }
.chip--accent { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }

/* Colour-named aliases. Vehicle statuses are editable records that store a
   colour by name, so the stylesheet has to answer to the name rather than to
   a fixed set of meanings. */
.chip--green  { background: var(--ok-soft);       color: var(--ok-text); }
.chip--amber  { background: var(--warn-soft);     color: var(--warn-text); }
.chip--red    { background: var(--danger-soft);   color: var(--danger-text); }
.chip--blue   { background: var(--info-soft);     color: var(--info-text); }
.chip--violet { background: hsl(265 85% 66% / 0.16); color: hsl(265 85% 72%); }
.chip--grey   { background: var(--neutral-soft);  color: var(--neutral-text); }

[data-theme="light"] .chip--violet { color: hsl(265 70% 48%); }

.chip--lg { padding: 0.3125rem 0.75rem; font-size: var(--text-sm); }

/* Filter bar ------------------------------------------------------------- */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
}

.filter-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.filter-chip {
    padding: 0.375rem 0.8125rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 550;
    transition: all var(--fast) var(--ease);
}
.filter-chip:hover { color: var(--text); border-color: var(--border-strong); }
.filter-chip[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent-text);
    border-color: var(--accent-line);
}
/* Opacity here stacked on top of an already-dim colour and pushed the count
   below AA. A discrete token keeps it visually secondary but readable. */
.filter-chip__count { color: var(--text-dim); margin-left: 0.25em; font-variant-numeric: tabular-nums; }
.filter-chip[aria-pressed="true"] .filter-chip__count { color: inherit; }

.search-field {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.search-field svg {
    position: absolute;
    left: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--text-dim);
    pointer-events: none;
}
.search-field input { padding-left: 2.25rem; }

/* Forms ------------------------------------------------------------------ */

.field { display: flex; flex-direction: column; gap: var(--space-2); }

.label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.label__optional { font-weight: 400; color: var(--text-dim); font-size: var(--text-xs); }

.input, .select, .textarea {
    width: 100%;
    padding: 0.5625rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: var(--text-base);
    transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
    appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }

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

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.textarea { min-height: 7rem; resize: vertical; line-height: 1.55; }
.textarea--tall { min-height: 18rem; font-family: var(--font-mono); font-size: var(--text-sm); }

.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 2.25rem;
}

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

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

/* Range sliders — same look in both engines. */
.range { width: 100%; appearance: none; background: transparent; height: 22px; }
.range::-webkit-slider-runnable-track {
    height: 5px; border-radius: var(--radius-full); background: var(--surface-sunken);
    border: 1px solid var(--border);
}
.range::-moz-range-track {
    height: 5px; border-radius: var(--radius-full); background: var(--surface-sunken);
    border: 1px solid var(--border);
}
.range::-webkit-slider-thumb {
    appearance: none;
    width: 17px; height: 17px; margin-top: -7px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
    box-shadow: 0 1px 6px hsl(222 40% 3% / 0.5);
    transition: transform var(--fast) var(--ease);
}
.range::-moz-range-thumb {
    width: 17px; height: 17px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
}
.range:hover::-webkit-slider-thumb { transform: scale(1.14); }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft); }

.range-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.range-value {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--accent-text);
    font-variant-numeric: tabular-nums;
}

/* Switch ----------------------------------------------------------------- */

.switch { display: flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch__track {
    position: relative;
    width: 40px; height: 23px;
    flex-shrink: 0;
    background: var(--surface-sunken);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-full);
    transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.switch__track::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 17px; height: 17px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: transform var(--fast) var(--ease), background var(--fast) var(--ease);
}
.switch input:checked + .switch__track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(17px); background: var(--accent-ink); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px var(--accent-soft); }

.switch__text { font-size: var(--text-base); }
.switch__text small { display: block; color: var(--text-dim); font-size: var(--text-sm); }

/* Checkbox --------------------------------------------------------------- */

.check { display: flex; align-items: start; gap: var(--space-3); cursor: pointer; }
.check input {
    appearance: none;
    width: 18px; height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    transition: all var(--fast) var(--ease);
}
.check input:checked {
    background: var(--accent);
    border-color: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
    background-size: 13px;
    background-position: center;
    background-repeat: no-repeat;
}
.check input:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Alerts and banners ------------------------------------------------------ */

.alert {
    display: flex;
    align-items: start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: var(--text-base);
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.alert strong { display: block; margin-bottom: 2px; }

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

/* Inheriting the alert's colour is enough of a hierarchy; the extra opacity
   that used to be here dropped the copy below the contrast floor. */
.alert--info p, .alert--warning p, .alert--danger p, .alert--success p { color: inherit; }

.announcement {
    padding: var(--space-3) 0;
    font-size: var(--text-sm);
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.announcement--info    { background: var(--info-soft);   color: var(--info); }
.announcement--warning { background: var(--warn-soft);   color: var(--warn); }
.announcement--danger  { background: var(--danger-soft); color: var(--danger); }

/* Toasts ----------------------------------------------------------------- */

.toast-stack {
    position: fixed;
    right: var(--space-4);
    bottom: var(--space-4);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: min(380px, calc(100vw - 2rem));
}

.toast {
    display: flex;
    align-items: start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-base);
    animation: toast-in var(--slow) var(--ease-out);
}
.toast--success { border-left-color: var(--ok); }
.toast--error   { border-left-color: var(--danger); }
.toast__close { margin-left: auto; color: var(--text-dim); line-height: 1; }
.toast__close:hover { color: var(--text); }
.toast.is-leaving { animation: toast-out var(--normal) var(--ease) forwards; }

/* Tables ----------------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

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

.table th, .table td {
    padding: 0.6875rem var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table thead th {
    font-size: var(--text-xs);
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
    background: var(--surface-sunken);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-hover); }

.table td.is-numeric, .table th.is-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.table .cell-actions { text-align: right; white-space: nowrap; }

.spec-table th[scope="row"] { font-weight: 600; color: var(--text); width: 30%; }
.spec-table td:nth-child(2) { font-family: var(--font-mono); font-size: var(--text-sm); }
.spec-table td:last-child { color: var(--text-muted); }

/* Empty state ------------------------------------------------------------ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-8) var(--space-5);
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text-muted);
}
.empty-state svg { width: 36px; height: 36px; color: var(--text-dim); }
.empty-state h3 { color: var(--text); font-size: var(--text-lg); }

/* Hero ------------------------------------------------------------------- */

.hero { padding-block: clamp(var(--space-7), 9vw, var(--space-9)) var(--space-7); }
.hero__title { font-size: var(--text-4xl); letter-spacing: -0.035em; max-width: 18ch; }
.hero__title em {
    font-style: normal;
    background: linear-gradient(120deg, var(--accent), hsl(265 85% 70%));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero__lede { margin-top: var(--space-4); font-size: var(--text-lg); color: var(--text-muted); max-width: 58ch; }
.hero__actions { margin-top: var(--space-6); display: flex; flex-wrap: wrap; gap: var(--space-3); }

.stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-6);
    margin-top: var(--space-7);
    padding-top: var(--space-5);
    border-top: 1px solid var(--border);
}
.stat__value { font-size: var(--text-2xl); font-weight: 680; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat__label { font-size: var(--text-sm); color: var(--text-dim); }

/* Vehicle cards ---------------------------------------------------------- */

.vehicle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
    gap: var(--space-4);
}

.vehicle-card { position: relative; }

.vehicle-card__media {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--surface-sunken);
}
.vehicle-card__media img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform var(--slow) var(--ease-out);
}
.vehicle-card:hover .vehicle-card__media img { transform: scale(1.045); }

/* The chip overlays a photograph, so its translucent token background is not
   enough on its own — sit it on a blurred dark plate so it stays legible
   whatever the image behind it. */
.vehicle-card__status {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    z-index: 1;
    background-color: hsl(222 30% 8% / 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid hsl(0 0% 100% / 0.12);
    box-shadow: var(--shadow-sm);
}
/* On the dark plate above a photograph the chips need their brighter tints,
   whatever the page theme is. */
.vehicle-card__status.chip--ok,
.vehicle-card__status.chip--green  { color: hsl(152 70% 62%); }
.vehicle-card__status.chip--warn,
.vehicle-card__status.chip--amber  { color: hsl(38 96% 66%); }
.vehicle-card__status.chip--danger,
.vehicle-card__status.chip--red    { color: hsl(0 84% 70%); }
.vehicle-card__status.chip--info,
.vehicle-card__status.chip--blue   { color: hsl(211 96% 70%); }
.vehicle-card__status.chip--violet { color: hsl(265 90% 76%); }
.vehicle-card__status.chip--grey,
.vehicle-card__status:not([class*="chip--"]) { color: hsl(214 16% 80%); }

.vehicle-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.vehicle-card__name { font-size: var(--text-lg); }
.vehicle-card__sub { font-size: var(--text-sm); color: var(--text-muted); }
.vehicle-card__text { color: var(--text-muted); font-size: var(--text-base); }

.vehicle-card__link::after { content: ""; position: absolute; inset: 0; }

/* Filtered out — the same class for every card the filter bar drives. */
.is-hidden { display: none !important; }

/* Vehicle detail --------------------------------------------------------- */

.vehicle-hero {
    display: grid;
    gap: var(--space-6);
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    align-items: start;
}
@media (max-width: 900px) { .vehicle-hero { grid-template-columns: 1fr; } }

.vehicle-hero__media {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-sunken);
    aspect-ratio: 16 / 10;
}
.vehicle-hero__media img { width: 100%; height: 100%; object-fit: cover; }

.detail-nav {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-7);
    padding-top: var(--space-5);
    border-top: 1px solid var(--border);
}
.detail-nav a { display: flex; flex-direction: column; gap: 2px; text-decoration: none; }
.detail-nav small { color: var(--text-dim); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; }
.detail-nav span { color: var(--text); font-weight: 600; }
.detail-nav a:hover span { color: var(--accent); }
.detail-nav__next { text-align: right; }

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-dim);
    margin-bottom: var(--space-4);
    list-style: none;
    padding: 0;
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb li:not(:last-child)::after { content: "/"; margin-left: var(--space-2); opacity: 0.5; }

/* Tool workspace (calculator) -------------------------------------------- */

.workspace {
    display: grid;
    gap: var(--space-5);
    grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
    align-items: start;
}
@media (max-width: 960px) { .workspace { grid-template-columns: 1fr; } }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}
.panel__title { font-size: var(--text-md); font-weight: 620; }
.panel__body { padding: var(--space-5); }
.panel__body--flush { padding: 0; }

.panel--sticky { position: sticky; top: calc(var(--header-height) + var(--space-4)); }
@media (max-width: 960px) { .panel--sticky { position: static; } }

.field-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.chart-shell {
    position: relative;
    height: clamp(240px, 34vh, 340px);
    padding: var(--space-4);
}
.chart-shell canvas { width: 100% !important; height: 100% !important; }

.output-area {
    margin: 0;
    padding: var(--space-4);
    max-height: 26rem;
    overflow: auto;
    background: var(--surface-sunken);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.55;
    white-space: pre;
    tab-size: 4;
}
.output-area:empty::before {
    content: "Run the calculator to see the torque table here.";
    color: var(--text-dim);
    font-family: var(--font-sans);
    white-space: normal;
}

.readout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1px;
    background: var(--border);
    border-block: 1px solid var(--border);
}
.readout {
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
}
.readout__label { font-size: var(--text-xs); color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.readout__value { font-size: var(--text-lg); font-weight: 640; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* Tabs ------------------------------------------------------------------- */

.tabs {
    display: flex;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.tab {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 570;
    color: var(--text-muted);
    text-align: center;
    transition: all var(--fast) var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.tab-panel[hidden] { display: none; }

/* Prose ------------------------------------------------------------------ */

.prose { max-width: 68ch; color: var(--text-muted); font-size: var(--text-md); line-height: 1.72; }
.prose > * + * { margin-top: var(--space-4); }
.prose h2 { color: var(--text); font-size: var(--text-xl); margin-top: var(--space-6); }
.prose h3 { color: var(--text); font-size: var(--text-lg); margin-top: var(--space-5); }
.prose ul, .prose ol { padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); }
.prose strong { color: var(--text); }
.prose code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    padding: 0.1em 0.35em;
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
}
.prose blockquote {
    padding-left: var(--space-4);
    border-left: 3px solid var(--accent-line);
    color: var(--text-muted);
}

/* Theme toggle ----------------------------------------------------------- */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent-line); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Pagination ------------------------------------------------------------- */

.pagination { display: flex; gap: var(--space-2); align-items: center; justify-content: center; margin-top: var(--space-6); }
.pagination__info { color: var(--text-dim); font-size: var(--text-sm); }

/* ---------- 6. Utilities ------------------------------------------------- */

/* Components that set their own display (flex, grid) otherwise win against
   the hidden attribute and render as an empty box. */
[hidden] { display: none !important; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }

.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.ml-auto { margin-left: auto; }

.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-medium { font-weight: 550; }
.font-semibold { font-weight: 620; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

.hide-sm { }
@media (max-width: 640px) { .hide-sm { display: none !important; } }
@media (max-width: 820px) { .hide-md { display: none !important; } }

/* ---------- 7. Motion ---------------------------------------------------- */

@keyframes slide-down {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateX(20px); }
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Progressive reveal — app.js adds .is-visible as elements enter the
   viewport. Hiding is scoped to `.js`, set by an inline script in the head, so
   a browser with JavaScript off shows the content rather than a page of
   invisible cards. */
.reveal-ready .reveal { opacity: 0; }
.reveal-ready .reveal.is-visible { animation: fade-up var(--slow) var(--ease-out) forwards; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .reveal-ready .reveal { opacity: 1; }
    .vehicle-card:hover .vehicle-card__media img { transform: none; }
}

@media print {
    .site-header, .site-footer, .filter-bar, .btn, .toast-stack { display: none !important; }
    body { background: #fff; color: #000; }
    .card, .table-wrap { border-color: #ccc; box-shadow: none; }
}

/* ---------- Gear ratio calculator ---------------------------------------- */

.gear-list { display: flex; flex-direction: column; gap: var(--space-2); }

.gear-row {
    display: grid;
    grid-template-columns: 1.6rem minmax(0, 1fr) auto;
    gap: var(--space-2);
    align-items: center;
}

.gear-row__number {
    font-size: var(--text-sm);
    font-weight: 650;
    color: var(--text-dim);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ---------- Unit converter ----------------------------------------------- */

.converter-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: var(--space-4);
    align-items: start;
}

.converter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-3);
    align-items: stretch;
}

/* Unit names are different lengths and some wrap to two lines. Pushing the
   input to the bottom of its cell keeps every field in a row on one baseline
   instead of stepping down wherever a label happened to wrap. */
.converter-grid .field { justify-content: space-between; }
.converter-grid .input { margin-top: auto; }

/* ---------- The way in --------------------------------------------------- */

/* The one iridescent thing outside the gate: the link into the VIP area, in
   the header and on the account page. It has to live here rather than in
   vip.css, which neither of those pages loads — and it needs its own copy of
   the sheen keyframes for exactly the same reason. */
.btn--vip {
    position: relative;
    border: 1px solid transparent;
    background:
        linear-gradient(var(--surface), var(--surface)) padding-box,
        linear-gradient(100deg, #ff3df0, #9a5cff, #2f7bff, #22e0ff, #34f5c5, #ffd23f, #ff3df0) border-box;
    background-size: auto, 300% 100%;
    color: var(--text);
    font-weight: 600;
    animation: vip-sheen 9s linear infinite;
}

.btn--vip:hover,
.btn--vip:focus-visible {
    box-shadow: 0 0 0 1px rgb(154 92 255 / 0.4), 0 6px 22px rgb(154 92 255 / 0.28);
}

@keyframes vip-sheen {
    from { background-position: 0 0,   0% 50%; }
    to   { background-position: 0 0, 300% 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .btn--vip { animation: none; background-position: 0 0, 50% 50%; }
}

/* Workbench: quick routes into the tools, with a searchable directory. */
.hero--workbench { padding-block: clamp(2.5rem, 5vw, 4rem) 2rem; }
.workbench-hero { display: grid; grid-template-columns: 1.2fr 1fr; align-items: center; gap: clamp(2rem, 4vw, 4rem); }
.workbench-hero__copy { min-width: 0; }
.hero--workbench .hero__title { font-size: clamp(2.25rem, 4.1vw, 3.45rem); line-height: 1.13; }
.hero--workbench .hero__title em { background: none; -webkit-text-fill-color: currentColor; color: var(--accent-text); }
.hero--workbench .hero__lede { font-size: var(--text-md); max-width: 51ch; }
.hero--workbench .hero__actions { gap: .75rem; align-items: center; }
.hero-indicator { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); margin-right: .5rem; flex-shrink: 0; }
.launch-panel { position: relative; padding: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: linear-gradient(145deg, var(--accent-soft), transparent 48%), var(--bg-elevated); box-shadow: var(--shadow-md); }
.launch-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.launch-panel__head .chip { font-size: .65rem; }
.launch-panel > h2 { font-size: var(--text-xl); }
.launch-panel > p { font-size: var(--text-sm); margin-top: .3rem; }
.launch-panel__links { margin-top: 1.25rem; }
.launch-link { display: flex; align-items: center; gap: .85rem; border-top: 1px solid var(--border); padding: 1rem 0; color: var(--text); text-decoration: none; }
.launch-link:hover { color: var(--accent-text); }
.launch-link__number { font-family: var(--font-mono); color: var(--accent-text); font-size: .75rem; }
.launch-link strong { display: block; font-weight: 600; font-size: var(--text-base); }
.launch-link small { display: block; color: var(--text-muted); font-size: var(--text-xs); margin-top: .2rem; line-height: 1.5; }
.launch-link__arrow { margin-left: auto; font-size: 1.25rem; }
.launch-panel__foot { border-top: 1px solid var(--border); padding-top: .9rem; display: flex; gap: .5rem; font-size: var(--text-xs); color: var(--text-muted); }
.workbench-stats { display: flex; flex-wrap: wrap; gap: .75rem 2rem; padding-block: 1.25rem; margin-top: 2rem; border-block: 1px solid var(--border); color: var(--text-muted); font-size: var(--text-sm); }
.workbench-stats strong { color: var(--text); font-weight: 600; }
.directory-intro { padding-bottom: 2rem; }
.directory-intro h1 { max-width: 23ch; font-size: var(--text-3xl); }
.directory-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.directory-controls { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 2rem; }
.directory-search { flex: 1 1 260px; }
.directory-category { flex: 0 1 210px; }
.directory-controls .input { min-height: 44px; }
.directory-controls .btn { min-height: 44px; }
.directory-saved[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.directory-saved span { min-width: 1.35rem; border-radius: 4px; background: var(--surface-hover); font-family: var(--font-mono); }
.directory-hint { flex-basis: 100%; }
kbd { font: .75rem var(--font-mono); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 .3rem; }
.directory-group + .directory-group { margin-top: 2rem; }
.directory-group .section-head h3 { font-size: var(--text-md); font-weight: 550; }
.tool-card .card__body { gap: .7rem; padding: 1.35rem; }
.tool-card__top { align-items: center; margin-bottom: .5rem; gap: .6rem; }
.tool-card__top > .chip { margin-left: auto; }
.tool-card__icon { width: 44px; height: 44px; }
.tool-card__name { font-size: 1.1rem; line-height: 1.4; }
.tool-card__tagline { font-size: var(--text-sm); color: var(--accent-text); margin-top: 0; }
.tool-card__text { font-size: var(--text-sm); line-height: 1.7; }
.tool-card__bottom { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); margin-top: .75rem; padding-top: .9rem; font-size: var(--text-sm); font-weight: 600; }
.tool-save { position: relative; z-index: 2; flex-shrink: 0; display: grid; place-items: center; width: 44px; height: 44px; margin-left: auto; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--text-muted); cursor: pointer; }
.tool-card__top > .chip + .tool-save { margin-left: 0; }
.tool-save:hover { border-color: var(--border); background: var(--surface-hover); }
.tool-save[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); }
.tool-save[aria-pressed="true"] svg { fill: var(--accent-soft); }
.tool-card:focus-within { border-color: var(--accent-text); }
.directory-empty { border: 1px dashed var(--border-strong); border-radius: var(--radius-md); }
.site-nav__account { display: none; }
@media (max-width: 980px) { .workbench-hero { grid-template-columns: 1fr 1fr; gap: 1.5rem; } }
@media (max-width: 820px) {
    .workbench-hero { grid-template-columns: 1fr; }
    .hero--workbench .hero__title { max-width: 22ch; }
    .launch-panel { padding: 1.25rem; }
    .workbench-stats { margin-top: 1.5rem; gap: .5rem 1.5rem; }
    .header-actions { margin-left: auto; }
    .site-nav__account { display: block; }
    .site-nav { max-height: calc(100dvh - var(--header-height)); overflow-y: auto; }
    html:not(.nav-ready) .site-header__inner { flex-wrap: wrap; height: auto; padding-block: .75rem; }
    html:not(.nav-ready) .site-nav { position: static; display: block; order: 3; width: 100%; box-shadow: none; padding: .5rem 0; }
    html:not(.nav-ready) .nav-toggle { display: none; }
}
@media (max-width: 520px) {
    .directory-heading { align-items: start; flex-direction: column; gap: .5rem; }
    .directory-controls { padding: 1rem; }
    .directory-category { flex: 1 1 100%; }
    .directory-search { min-width: 0; }
    .directory-controls > .btn { flex: 1; }
    .hero--workbench .hero__actions > a { width: 100%; justify-content: center; }
    .launch-panel__head { gap: .5rem; }
    .tool-card .card__body { padding: 1.25rem; }
}
/* Recompute card accents locally so the inherited site accent does not win. */
.tool-card {
    --accent: hsl(var(--accent-h) var(--accent-s) 65%);
    --accent-text: hsl(var(--accent-h) var(--accent-s) 72%);
    --accent-soft: hsl(var(--accent-h) var(--accent-s) 56% / .1);
    --accent-line: hsl(var(--accent-h) var(--accent-s) 56% / .3);
}
[data-theme="light"] .tool-card { --accent-text: hsl(var(--accent-h) var(--accent-s) 28%); }
.tool-card__icon { color: var(--accent-text); }
.theme-toggle, .nav-toggle { min-width: 44px; min-height: 44px; }
@media (max-width: 520px) { .directory-intro { padding-top: 2rem; padding-bottom: 1rem; } }

/* ---------- Page builder blocks ------------------------------------------ */

/* Edge-to-edge blocks reach the window's sides; this stops them making it
   scroll sideways, without becoming a scroll container that would break the
   sticky header. */
.page-view { overflow-x: clip; }

.page-blocks > * + * { margin-top: var(--space-5); }
.page-blocks > .block--heading { margin-top: var(--space-7); }
.page-blocks > .block--heading + * { margin-top: var(--space-3); }
.page-blocks > :first-child { margin-top: 0; }

h2.block--heading { font-size: var(--text-2xl); }
h3.block--heading { font-size: var(--text-xl); }

.block--center { text-align: center; }

/* Wide blocks break out of the reading column on a narrow page. */
.container--narrow .block--wide {
    --wide: min(1120px, calc(100vw - 2rem));
    width: var(--wide);
    margin-left: calc((100% - var(--wide)) / 2);
}
.block--full { width: 100vw; margin-left: calc(50% - 50vw); }
.block--full img { border-radius: 0; }

.block--hero {
    display: grid;
    align-items: center;
    gap: var(--space-6);
    padding: clamp(var(--space-5), 4vw, var(--space-7));
    background:
        radial-gradient(800px 320px at 0% 0%, var(--accent-soft), transparent 70%),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.block-hero--media { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
@media (max-width: 820px) { .block-hero--media { grid-template-columns: 1fr; } }
.block-hero__title { margin-top: var(--space-3); font-size: var(--text-4xl); line-height: 1.05; letter-spacing: -0.03em; }
.block-hero__lede { margin-top: var(--space-4); color: var(--text-muted); font-size: var(--text-lg); max-width: 56ch; }
.block-hero__lede > * + * { margin-top: var(--space-3); }
.block--center .block-hero__lede { margin-inline: auto; }
.block-hero__actions { margin-top: var(--space-5); }
.block-hero__media { overflow: hidden; aspect-ratio: 4 / 3; border-radius: var(--radius-md); background: var(--surface-sunken); }
.block-hero__media img { width: 100%; height: 100%; object-fit: cover; }

.block-image { margin-inline: 0; margin-bottom: 0; }
.block-image img { width: 100%; border-radius: var(--radius-md); }
.block-image figcaption { margin-top: var(--space-2); color: var(--text-dim); font-size: var(--text-sm); text-align: center; }

.block--columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); }
.block-columns--left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.block-columns--right { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.block--columns .prose > * + * { margin-top: var(--space-3); }
@media (max-width: 720px) { .block--columns { grid-template-columns: 1fr !important; gap: var(--space-4); } }

.block--buttons { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.block--buttons.block--center { justify-content: center; }

.block--quote { margin-inline: 0; margin-bottom: 0; padding: var(--space-2) 0 var(--space-2) var(--space-5); border-left: 3px solid var(--accent); }
.block--quote blockquote { color: var(--text); font-size: var(--text-xl); line-height: 1.45; }
.block--quote blockquote > * + * { margin-top: var(--space-3); }
.block--quote figcaption { margin-top: var(--space-3); color: var(--text-dim); font-size: var(--text-sm); }

.block--callout > div > * + * { margin-top: var(--space-2); }

.block-list--checks { list-style: none; padding-left: 0; }
.block-list--checks li { position: relative; padding-left: 1.6em; }
.block-list--checks li::before { content: "✓"; position: absolute; left: 0; color: var(--accent-text); font-weight: 700; }

.block--stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
    gap: var(--space-3);
    margin-inline: 0;
}
.block-stat {
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-1);
    padding: var(--space-4) var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.block-stat__value { margin: 0; font-size: var(--text-3xl); font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.block-stat__label { color: var(--text-dim); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; }

.block-table__caption { caption-side: top; padding: var(--space-3) var(--space-4); color: var(--text-muted); font-size: var(--text-sm); font-weight: 600; text-align: left; }

.block--code { margin-inline: 0; margin-bottom: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); }
.block-code__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-1) var(--space-2) var(--space-1) var(--space-4);
    color: var(--text-dim);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: var(--text-xs);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.block-code__body {
    margin: 0;
    max-height: 32rem;
    overflow: auto;
    padding: var(--space-4);
    background: var(--surface-sunken);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.6;
    tab-size: 4;
}

.block--divider { margin-block: var(--space-6); }
.block-divider--ornament { border: 0; text-align: center; }
.block-divider--ornament::after { content: "✦  ✦  ✦"; color: var(--text-dim); letter-spacing: 0.5em; white-space: pre; }
.block--space { height: var(--space-7); }

.block-tools__heading { margin-bottom: var(--space-4); font-size: var(--text-2xl); }

.preview-banner {
    position: sticky;
    top: var(--header-height);
    z-index: 50;
    padding: var(--space-2) var(--space-4);
    background: var(--warn-soft);
    color: var(--warn-text);
    font-size: var(--text-sm);
    font-weight: 600;
    text-align: center;
    backdrop-filter: blur(8px);
}
