/* ==========================================================================
   Lifeform - design system
   Dark-first "laboratory instrument" palette: near-black surfaces, hairline
   rules, one phosphor accent, and a faint cell lattice running under it all.
   ========================================================================== */

/* --------------------------------------------------------------- tokens */
/* Every ink step below is chosen to clear WCAG 4.5:1 against the darkest and
   lightest surface it can sit on. Verified by tools/contrast.js — re-run it if
   you change any of these. */
:root {
    color-scheme: dark;

    --void: #06080d;
    --surface: #0b111a;
    --panel: #121b29;
    --raised: #1a2532;
    --overlay: #222e3d;

    --line: rgba(155, 190, 230, 0.16);
    --line-soft: rgba(155, 190, 230, 0.085);
    --line-strong: rgba(155, 190, 230, 0.32);

    --ink: #f0f5fc;
    --ink-2: #bccada;
    --ink-3: #95a6bb;
    --ink-4: #7d8fa5;

    --aqua: #2ee6c5;
    --cyan: #56c2f7;
    --violet: #a294ff;
    --amber: #ffbe5c;
    --rose: #ff7d99;
    --lime: #b0ec48;

    --accent: var(--aqua);
    --accent-ink: #03120f;
    --accent-glow: rgba(46, 230, 197, 0.3);

    /* cell age ramp - shared by every canvas on the site */
    --cell-0: #f2fffb;
    --cell-1: #7dfae1;
    --cell-2: #2ee6c5;
    --cell-3: #21c8d6;
    --cell-4: #3f97e6;
    --cell-5: #6272ee;
    --cell-6: #8355e4;
    --cell-7: #52389b;
    --grid-line: rgba(155, 190, 230, 0.11);
    --canvas-bg: #080b11;

    /* Fertility ramp for Antiot's Field: exhausted ground to rich ground.
       Deliberately recessive - the ground is texture, the cells are the subject. */
    --soil-1: #0b0c09;
    --soil-2: #11110b;
    --soil-3: #18170c;
    --soil-4: #221f0f;
    --soil-5: #2e2812;

    --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

    --radius: 14px;
    --radius-sm: 9px;
    --radius-lg: 22px;
    --shell: 1240px;
    --shell-narrow: 780px;
    --nav-h: 66px;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-2: 0 10px 30px -12px rgba(0, 0, 0, .75);
    --shadow-3: 0 28px 70px -28px rgba(0, 0, 0, .9);

    --ease: cubic-bezier(.22, .61, .36, 1);
}

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

    --void: #eceff5;
    --surface: #f6f8fb;
    --panel: #ffffff;
    --raised: #e9edf4;
    --overlay: #ffffff;

    --line: rgba(16, 32, 54, 0.16);
    --line-soft: rgba(16, 32, 54, 0.085);
    --line-strong: rgba(16, 32, 54, 0.32);

    --ink: #0b1420;
    --ink-2: #374456;
    --ink-3: #4c5a6c;
    --ink-4: #5c6b80;

    --aqua: #0f766e;
    --cyan: #1668a5;
    --violet: #5438c9;
    --amber: #8f5a00;
    --rose: #b81f42;
    --lime: #456f08;

    --accent: var(--aqua);
    --accent-ink: #ffffff;
    --accent-glow: rgba(15, 118, 110, 0.2);

    --cell-0: #052b24;
    --cell-1: #0a5f51;
    --cell-2: #0f8f79;
    --cell-3: #10849f;
    --cell-4: #2566bd;
    --cell-5: #4344c9;
    --cell-6: #6e3bbd;
    --cell-7: #a08fd6;
    --grid-line: rgba(16, 32, 54, 0.12);
    --canvas-bg: #ffffff;

    --soil-1: #fbf9f0;
    --soil-2: #f7f1de;
    --soil-3: #f1e8cb;
    --soil-4: #ebdfb8;
    --soil-5: #e4d5a4;

    /* Light surfaces separate by only ~1.15:1, so cards need a real shadow as
       well as a hairline or they float unanchored on the page. */
    --shadow-1: 0 1px 2px rgba(16, 32, 54, .07);
    --shadow-2: 0 2px 4px rgba(16, 32, 54, .05), 0 12px 28px -12px rgba(16, 32, 54, .22);
    --shadow-3: 0 4px 8px rgba(16, 32, 54, .06), 0 28px 60px -24px rgba(16, 32, 54, .3);
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--nav-h) + 20px);
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--void);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.65;
    letter-spacing: -0.003em;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(to right, var(--line-soft) 1px, transparent 1px),
        linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
    background-size: 34px 34px;
    -webkit-mask-image: radial-gradient(130% 85% at 50% 0%, #000 0%, transparent 78%);
    mask-image: radial-gradient(130% 85% at 50% 0%, #000 0%, transparent 78%);
}

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

/* touch-action is set per context, NOT globally. A blanket `touch-action: none`
   on every canvas meant a swipe that happened to start on one of the little
   catalogue tiles refused to scroll the page - which on the gallery and the
   encyclopaedia is most of the screen. See lab.css for the interactive ones. */

/* author-level svg/canvas display rules would otherwise beat the UA hidden rule */
[hidden] { display: none !important; }

h1, h2, h3, h4, h5 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.13;
    letter-spacing: -0.028em;
    margin: 0 0 .55em;
    color: var(--ink);
    text-wrap: balance;
}

h1 { font-size: clamp(2.1rem, 5.2vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); }
h3 { font-size: clamp(1.16rem, 2.1vw, 1.42rem); }
h4 { font-size: 1.04rem; letter-spacing: -0.015em; }

p { margin: 0 0 1.15em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; transition: color .16s var(--ease); }
a:hover { color: var(--ink); }

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

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

hr { border: 0; height: 1px; background: var(--line); margin: 2.5rem 0; }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: .88em; }

code {
    background: var(--raised);
    border: 1px solid var(--line-soft);
    padding: .12em .42em;
    border-radius: 5px;
    color: var(--ink);
    word-break: break-word;
}

pre {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 1rem 1.15rem;
    overflow-x: auto;
    line-height: 1.55;
    margin: 0 0 1.4em;
}
pre code { background: none; border: 0; padding: 0; }

kbd {
    display: inline-block;
    min-width: 1.75em;
    text-align: center;
    padding: .16em .46em;
    border-radius: 6px;
    background: var(--raised);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    color: var(--ink-2);
    font-size: .76em;
    line-height: 1.35;
}

/* --------------------------------------------------------------- layout */
.shell {
    width: 100%;
    max-width: var(--shell);
    margin-inline: auto;
    padding-inline: clamp(1.15rem, 4vw, 2.5rem);
    position: relative;
    z-index: 1;
}
.shell--narrow { max-width: var(--shell-narrow); }
.shell--wide { max-width: 1460px; }

.site-main { position: relative; z-index: 1; min-height: 55vh; }
.site-main--padded { padding-block: clamp(2.4rem, 6vw, 4.5rem); }

.section { padding-block: clamp(3rem, 7vw, 6rem); }
/* a page head already supplies the breathing room above the first section */
.page-head + .section, .page-head + .article { padding-top: clamp(1.8rem, 3.5vw, 2.8rem); }
.section--tight { padding-block: clamp(2rem, 4vw, 3rem); }
.section--edge { border-top: 1px solid var(--line-soft); }

.stack > * + * { margin-top: 1.1rem; }

/* --------------------------------------------------------------- page head */
.page-head {
    padding-block: clamp(2.6rem, 6vw, 4.6rem) clamp(1.6rem, 3vw, 2.4rem);
    border-bottom: 1px solid var(--line-soft);
    position: relative;
    overflow: hidden;
}
.page-head::after {
    content: "";
    position: absolute;
    inset: -90% 40% 10% -40%;
    background: radial-gradient(closest-side, var(--accent-glow), transparent 72%);
    opacity: .45;
    pointer-events: none;
}
:root[data-theme="light"] .page-head::after { opacity: .22; }
.page-head > * { position: relative; z-index: 1; }
.page-head h1 { margin-bottom: .35em; }
.page-head .lede { max-width: 62ch; }

.crumbs {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-family: var(--font-mono);
    font-size: .74rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-4);
    margin-bottom: 1.1rem;
}
.crumbs a { color: var(--ink-3); }
.crumbs a:hover { color: var(--accent); }

/* --------------------------------------------------------------- skip link */
.skip-link {
    position: absolute;
    left: 1rem;
    top: -100px;
    z-index: 999;
    background: var(--accent);
    color: var(--accent-ink);
    padding: .6rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    transition: top .2s var(--ease);
}
.skip-link:focus { top: 1rem; }

/* --------------------------------------------------------------- nav */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    background: color-mix(in srgb, var(--void) 80%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line-soft);
    transition: border-color .2s var(--ease), background .2s var(--ease);
}
.site-nav[data-scrolled="true"] {
    border-bottom-color: var(--line);
    background: color-mix(in srgb, var(--void) 94%, transparent);
}

.nav-inner {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    width: 100%;
    max-width: var(--shell);
    margin-inline: auto;
    padding-inline: clamp(1.15rem, 4vw, 2.5rem);
}
.nav-inner--wide { max-width: 1460px; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: .62rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.03em;
    color: var(--ink);
    flex: none;
}
.brand:hover { color: var(--ink); }
.brand:hover .brand-mark { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }

.brand-mark {
    width: 30px; height: 30px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--panel);
    color: var(--accent);
    transition: border-color .2s var(--ease), box-shadow .25s var(--ease);
}
.brand-mark svg { width: 17px; height: 17px; }

.nav-links {
    display: flex;
    align-items: center;
    gap: .1rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
}

.nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .7rem;
    border-radius: 8px;
    color: var(--ink-2);
    font-size: .91rem;
    font-weight: 500;
    white-space: nowrap;
    background: none;
    border: 0;
    font-family: inherit;
    cursor: pointer;
    transition: color .16s var(--ease), background .16s var(--ease);
}
.nav-link:hover { color: var(--ink); background: var(--line-soft); }
.nav-link.is-active { color: var(--ink); }
.nav-link.is-active::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 2px;
    width: 5px; height: 5px;
    translate: -50% 0;
    background: var(--accent);
    border-radius: 1px;
    box-shadow: 0 0 8px var(--accent-glow);
}
.nav-link svg { width: 13px; height: 13px; opacity: .6; }

.nav-actions { display: flex; align-items: center; gap: .5rem; flex: none; }

.nav-toggle {
    display: none;
    width: 40px; height: 40px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
    place-items: center;
}
.nav-toggle svg { width: 18px; height: 18px; }

.nav-group { position: relative; }
.nav-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: -8px;
    min-width: 290px;
    padding: .45rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-3);
    list-style: none;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    translate: 0 -6px;
    transition: opacity .18s var(--ease), translate .18s var(--ease), visibility .18s;
}
.nav-group:hover .nav-menu,
.nav-group:focus-within .nav-menu { opacity: 1; visibility: visible; translate: 0 0; }

.nav-menu a {
    display: block;
    padding: .5rem .68rem;
    border-radius: 8px;
    color: var(--ink-2);
    font-size: .89rem;
    line-height: 1.4;
}
.nav-menu a:hover { background: var(--raised); color: var(--ink); }
.nav-menu a span { display: block; font-size: .77rem; color: var(--ink-4); }
.nav-menu a:hover span { color: var(--ink-3); }

/* --------------------------------------------------------------- buttons */
.btn {
    --btn-bg: var(--raised);
    --btn-ink: var(--ink);
    --btn-line: var(--line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .66rem 1.12rem;
    border: 1px solid var(--btn-line);
    border-radius: 10px;
    background: var(--btn-bg);
    color: var(--btn-ink);
    font-family: var(--font-body);
    font-size: .92rem;
    font-weight: 550;
    letter-spacing: -0.01em;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: transform .14s var(--ease), background .16s var(--ease), border-color .16s var(--ease), box-shadow .2s var(--ease), color .16s var(--ease);
}
.btn:hover { color: var(--btn-ink); border-color: var(--line-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn--primary {
    --btn-bg: var(--accent);
    --btn-ink: var(--accent-ink);
    --btn-line: transparent;
    font-weight: 650;
}
.btn--primary:hover { box-shadow: 0 8px 26px -8px var(--accent-glow), 0 0 0 4px var(--accent-glow); }

.btn--ghost { --btn-bg: transparent; --btn-ink: var(--ink-2); }
.btn--ghost:hover { --btn-ink: var(--ink); background: var(--raised); }

.btn--danger { --btn-ink: var(--rose); }
.btn--danger:hover { border-color: var(--rose); }

.btn--sm { padding: .4rem .78rem; font-size: .84rem; border-radius: 8px; }
.btn--sm svg { width: 14px; height: 14px; }
.btn--lg { padding: .88rem 1.5rem; font-size: 1rem; border-radius: 12px; }
.btn--block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

.btn-icon {
    display: inline-grid;
    place-items: center;
    width: 38px; height: 38px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel);
    color: var(--ink-2);
    cursor: pointer;
    transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease);
}
.btn-icon:hover { color: var(--ink); border-color: var(--line-strong); background: var(--raised); }
.btn-icon svg { width: 17px; height: 17px; }

.btn-row { display: flex; flex-wrap: wrap; gap: .7rem; }

/* --------------------------------------------------------------- eyebrow */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    font-family: var(--font-mono);
    font-size: .715rem;
    font-weight: 500;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: 1rem;
}
.eyebrow::before {
    content: "";
    width: 6px; height: 6px;
    background: var(--accent);
    border-radius: 1px;
    box-shadow: 0 0 10px var(--accent-glow);
    flex: none;
}

.section-head { max-width: 64ch; margin-bottom: clamp(1.8rem, 4vw, 2.8rem); }
.section-head p { color: var(--ink-2); font-size: 1.04rem; }

.lede {
    font-size: clamp(1.05rem, 1.7vw, 1.26rem);
    line-height: 1.6;
    color: var(--ink-2);
    letter-spacing: -0.012em;
}

/* --------------------------------------------------------------- cards */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--panel), var(--surface));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.45rem;
    overflow: hidden;
    color: inherit;
    box-shadow: var(--shadow-1);
    transition: border-color .22s var(--ease), transform .22s var(--ease), box-shadow .22s var(--ease);
}
.card > * { position: relative; z-index: 1; }
a.card:hover, .card--hover:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
    transform: translateY(-3px);
    box-shadow: var(--shadow-2);
    color: inherit;
}
.card h3 { margin-bottom: .4rem; }
.card p { color: var(--ink-2); font-size: .935rem; margin-bottom: 0; }
.card-foot { margin-top: auto; padding-top: 1rem; }

.card-glow::after {
    content: "";
    position: absolute;
    inset: -50% 40% 55% -25%;
    background: radial-gradient(closest-side, var(--accent-glow), transparent);
    opacity: 0;
    transition: opacity .35s var(--ease);
    z-index: 0;
}
a.card.card-glow:hover::after, .card--hover.card-glow:hover::after { opacity: .6; }

.card-index {
    font-family: var(--font-mono);
    font-size: .7rem;
    letter-spacing: .12em;
    color: var(--ink-4);
    margin-bottom: .85rem;
}

.card-arrow {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    /* auto, so the call to action sits on a common baseline across a row of
       cards whose descriptions run to different lengths */
    margin-top: auto;
    padding-top: 1rem;
    font-size: .85rem;
    font-weight: 550;
    color: var(--accent);
    align-self: flex-start;
}
.card-arrow svg { width: 14px; height: 14px; transition: translate .2s var(--ease); }
a.card:hover .card-arrow svg { translate: 3px 0; }

.grid { display: grid; gap: 1.15rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(272px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(214px, 1fr)); }

/* --------------------------------------------------------------- badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .18rem .55rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--raised);
    font-family: var(--font-mono);
    font-size: .69rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-3);
    white-space: nowrap;
}
.badge--accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.badge--amber { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.badge--violet { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 40%, transparent); }
.badge--rose { color: var(--rose); border-color: color-mix(in srgb, var(--rose) 40%, transparent); }
.badge--cyan { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 40%, transparent); }

/* Category colours. Informative rather than decorative: the hue is the fastest
   way to scan a grid of specimens for the kind of object you want. Each is a
   palette accent, all of which clear 4.5:1 on both panel surfaces. */
.badge--still-life { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 42%, transparent); }
.badge--oscillator { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 42%, transparent); }
.badge--spaceship { color: var(--aqua); border-color: color-mix(in srgb, var(--aqua) 42%, transparent); }
.badge--gun { color: var(--rose); border-color: color-mix(in srgb, var(--rose) 42%, transparent); }
.badge--methuselah { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 42%, transparent); }
.badge--misc { color: var(--lime); border-color: color-mix(in srgb, var(--lime) 42%, transparent); }

.tag-row { display: flex; flex-wrap: wrap; gap: .4rem; }

/* --------------------------------------------------------------- prose */
.prose { max-width: 73ch; }
.prose > h2 {
    margin-top: 2.6em;
    padding-top: 1.6rem;
    border-top: 1px solid var(--line-soft);
    scroll-margin-top: calc(var(--nav-h) + 24px);
}
.prose > h2:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.prose > h3 { margin-top: 2em; scroll-margin-top: calc(var(--nav-h) + 24px); }
.prose p, .prose li { color: var(--ink-2); font-size: 1.026rem; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.25rem; margin: 0 0 1.3em; }
.prose li { margin-bottom: .5em; }
.prose li::marker { color: var(--ink-4); }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: currentColor; }
.prose dt { color: var(--ink); font-weight: 600; margin-top: 1.1em; }
.prose dd { margin: .2em 0 0; color: var(--ink-2); }

.prose blockquote {
    margin: 2rem 0;
    padding: .3rem 0 .3rem 1.4rem;
    border-left: 2px solid var(--accent);
    color: var(--ink);
    font-size: 1.1rem;
    font-style: italic;
    letter-spacing: -0.012em;
}
.prose blockquote p { color: var(--ink); }
.prose blockquote cite {
    display: block;
    margin-top: .7rem;
    font-size: .84rem;
    font-style: normal;
    color: var(--ink-3);
}

.callout {
    display: flex;
    gap: 1rem;
    margin: 2rem 0;
    padding: 1.1rem 1.3rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 2px solid var(--accent);
    border-radius: var(--radius-sm);
}
.callout h4 { margin-bottom: .3rem; font-size: .95rem; }
.callout p { margin-bottom: 0; font-size: .93rem; color: var(--ink-2); }
.callout-mark { flex: none; color: var(--accent); padding-top: .15rem; }
.callout-mark svg { width: 19px; height: 19px; }
.callout--violet { border-left-color: var(--violet); }
.callout--violet .callout-mark { color: var(--violet); }
.callout--amber { border-left-color: var(--amber); }
.callout--amber .callout-mark { color: var(--amber); }

.figure {
    margin: 2.2rem 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--panel);
}
.figure-body { padding: 1rem; background: var(--surface); }
.figure figcaption {
    padding: .8rem 1.1rem;
    border-top: 1px solid var(--line);
    font-size: .85rem;
    color: var(--ink-3);
    line-height: 1.55;
}
.figure figcaption b { color: var(--ink-2); font-weight: 600; }

/* two-column article layout with a sticky contents rail */
.article {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 232px;
    gap: clamp(2rem, 5vw, 4.5rem);
    align-items: start;
    padding-block: clamp(2.4rem, 5vw, 4rem);
}
/* Same trap as .sim-shell: a track declared `1fr` is `minmax(auto, 1fr)` and
   refuses to shrink below its content's min-content width. A nowrap table
   header inside the prose was dragging the whole page wider than a phone. */
.article > * { min-width: 0; }
.toc {
    position: sticky;
    top: calc(var(--nav-h) + 26px);
    font-size: .87rem;
    border-left: 1px solid var(--line);
    padding-left: 1.1rem;
}
.toc h4 {
    font-family: var(--font-mono);
    font-size: .7rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-4);
    margin-bottom: .9rem;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin-bottom: .1rem; }
.toc a {
    display: block;
    padding: .28rem 0;
    color: var(--ink-3);
    line-height: 1.4;
}
.toc a:hover { color: var(--ink); }
.toc a.is-current { color: var(--accent); }

/* --------------------------------------------------------------- tables */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}
table.data { width: 100%; border-collapse: collapse; font-size: .89rem; }
table.data th {
    text-align: left;
    padding: .7rem 1rem;
    background: var(--raised);
    border-bottom: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: .7rem;
    font-weight: 500;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-3);
    white-space: nowrap;
}
table.data td {
    padding: .66rem 1rem;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink-2);
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--raised) 55%, transparent); }
table.data td strong, table.data td b { color: var(--ink); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--font-mono); font-size: .85em; }

/* --------------------------------------------------------------- forms */
.field { display: block; margin-bottom: 1rem; }
.field > label, .form-label {
    display: block;
    margin-bottom: .36rem;
    font-size: .82rem;
    font-weight: 550;
    color: var(--ink-2);
}
.field-hint { font-size: .78rem; color: var(--ink-4); margin-top: .3rem; }

.input, input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="number"], input[type="url"], input[type="tel"],
textarea, select {
    width: 100%;
    padding: .6rem .78rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--ink);
    font-family: inherit;
    font-size: .92rem;
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
.input:focus, input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--panel);
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%236d7f96' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .6rem center;
    background-size: 12px;
    padding-right: 2rem;
    cursor: pointer;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    cursor: pointer;
    font-size: .89rem;
    color: var(--ink-2);
}
.check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.text-danger, .validation-summary-errors, .field-validation-error {
    color: var(--rose) !important;
    font-size: .85rem;
}
.validation-summary-errors ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.validation-summary-valid { display: none; }

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 20px;
    background: transparent;
    cursor: pointer;
    padding: 0;
    border: 0;
}
input[type="range"]:focus { box-shadow: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--line-strong); }
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    margin-top: -5.5px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--void);
    box-shadow: 0 0 0 1px var(--accent);
    transition: box-shadow .16s var(--ease);
}
input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 0 0 5px var(--accent-glow); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line-strong); }
input[type="range"]::-moz-range-thumb {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--accent); border: 2px solid var(--void);
}

/* --------------------------------------------------------------- footer */
.site-footer {
    position: relative;
    z-index: 1;
    margin-top: clamp(4rem, 9vw, 7rem);
    border-top: 1px solid var(--line);
    background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--panel) 70%, transparent));
}
.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr repeat(3, 1fr);
    gap: 2.5rem;
    padding-block: clamp(2.5rem, 5vw, 3.6rem);
}
.footer-col h4 {
    font-family: var(--font-mono);
    font-size: .705rem;
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-4);
    margin-bottom: 1rem;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: .48rem; }
.footer-col a { color: var(--ink-2); font-size: .89rem; }
.footer-col a:hover { color: var(--accent); }
.footer-blurb { color: var(--ink-3); font-size: .89rem; max-width: 36ch; margin-top: 1rem; }

.footer-base {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-block: 1.3rem;
    border-top: 1px solid var(--line-soft);
    font-size: .83rem;
    color: var(--ink-4);
}
.footer-base a { color: var(--ink-3); }
.footer-base a:hover { color: var(--accent); }

/* --------------------------------------------------------------- utility */
.u-mono { font-family: var(--font-mono); }
.u-muted { color: var(--ink-3); }
.u-dim { color: var(--ink-4); }
.u-center { text-align: center; }
.u-nowrap { white-space: nowrap; }
.u-accent { color: var(--accent); }
.u-mt-0 { margin-top: 0 !important; }
.u-mb-0 { margin-bottom: 0 !important; }
.u-mt-2 { margin-top: 1rem; }
.u-mt-3 { margin-top: 1.6rem; }
.u-mt-4 { margin-top: 2.4rem; }
.u-flex { display: flex; align-items: center; gap: .7rem; }
.u-flex-wrap { flex-wrap: wrap; }
.u-between { justify-content: space-between; }
.u-grow { flex: 1; }
.u-small { font-size: .86rem; }
.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;
}

/* --------------------------------------------------------------- pills */
.pillbar { display: flex; flex-wrap: wrap; gap: .45rem; }
.pill {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .38rem .85rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    color: var(--ink-2);
    font-size: .845rem;
    font-family: inherit;
    cursor: pointer;
    transition: all .16s var(--ease);
}
.pill:hover { border-color: var(--line-strong); color: var(--ink); }
.pill.is-active {
    background: var(--accent);
    border-color: transparent;
    color: var(--accent-ink);
    font-weight: 600;
}
.pill.is-active:hover { color: var(--accent-ink); }
.pill small { opacity: .62; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- specimen tiles */
.mini {
    position: relative;
    background: var(--canvas-bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border: 1px solid var(--line);
}
.mini canvas { width: 100%; height: 100%; }

.specimen {
    display: flex;
    flex-direction: column;
    gap: .8rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-1);
    transition: border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.specimen:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
    transform: translateY(-3px);
    box-shadow: var(--shadow-2);
}
.specimen-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.specimen-head h3 { font-size: 1rem; margin: 0; }
.specimen p { font-size: .865rem; color: var(--ink-3); margin: 0; line-height: 1.55; }
.specimen-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    font-family: var(--font-mono);
    font-size: .705rem;
    color: var(--ink-4);
    letter-spacing: .04em;
}
.specimen-actions { display: flex; gap: .5rem; margin-top: auto; padding-top: .2rem; }

/* --------------------------------------------------------------- stats */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.stat {
    background: var(--panel);
    box-shadow: 0 0 0 1px var(--line);
    padding: 1.1rem 1.2rem;
}
.stat-label {
    font-family: var(--font-mono);
    font-size: .68rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-4);
    margin-bottom: .4rem;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--ink);
    line-height: 1.1;
}
.stat-sub { font-size: .78rem; color: var(--ink-3); margin-top: .25rem; }

/* --------------------------------------------------------------- theme toggle */
:root[data-theme="light"] .icon-moon { display: none; }
:root:not([data-theme="light"]) .icon-sun { display: none; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 1040px) {
    .article { grid-template-columns: minmax(0, 1fr); }
    .toc { display: none; }
}

@media (max-width: 1000px) {
    .nav-links {
        position: fixed;
        inset: var(--nav-h) 0 auto;
        flex-direction: column;
        align-items: stretch;
        gap: .1rem;
        padding: 1rem clamp(1.15rem, 4vw, 2.5rem) 1.5rem;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow-3);
        max-height: calc(100vh - var(--nav-h));
        overflow-y: auto;
        display: none;
    }
    .nav-links[data-open="true"] { display: flex; }
    .nav-link { padding: .7rem .6rem; font-size: 1rem; justify-content: flex-start; }
    .nav-link.is-active::after { left: 4px; bottom: 50%; translate: 0 50%; }
    .nav-toggle { display: grid; }
    .nav-menu {
        position: static;
        opacity: 1; visibility: visible; translate: 0;
        box-shadow: none;
        border: 0;
        background: transparent;
        padding: 0 0 .5rem .7rem;
        min-width: 0;
    }
    .nav-menu a span { display: none; }
    .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
}

@media (max-width: 560px) {
    .footer-grid { grid-template-columns: 1fr; }
    .grid--4, .grid--3 { grid-template-columns: 1fr; }
}

@media print {
    .site-nav, .site-footer, .btn, .pillbar, .toc { display: none !important; }
    body { background: #fff; color: #000; }
    body::before { display: none; }
}
