/* =========================================================================
   Jev & System One Models — Field Guide
   Design system: shadcn-inspired tokens. Neutral surfaces, blue/teal accents.
   No violet. Light + dark. Mobile-first: 1100 / 900 / 640 / 380 breakpoints.
   ========================================================================= */

/* ---------- Tokens: light ---------- */
:root {
  --background: #f4f6f8;
  --foreground: #0a0a0a;
  --card: #ffffff;
  --card-foreground: #0a0a0a;
  --muted: #eef1f5;
  --muted-foreground: #56627a;
  --border: #e2e6ec;
  --border-strong: #cdd4de;
  --input: #e2e6ec;

  --primary: #126ed3;
  --primary-hover: #0e5cb4;
  --primary-foreground: #ffffff;
  --primary-soft: #e8f1fc;
  --accent: #1dc19c;
  --accent-soft: #e4f7f2;
  --ring: #3186ff;

  --good: #12855f;
  --good-soft: #e6f6f0;
  --warn: #9a6206;
  --warn-soft: #fdf3e2;
  --bad: #c0322b;
  --bad-soft: #fdecea;
  --info: #126ed3;
  --info-soft: #e8f1fc;
  --neutral-soft: #f2f4f7;

  --radius: 0.65rem;
  --radius-sm: 0.45rem;
  --radius-lg: 1rem;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(10, 10, 10, 0.05);
  --shadow: 0 1px 3px rgba(10, 10, 10, 0.07), 0 1px 2px rgba(10, 10, 10, 0.04);
  --shadow-lg: 0 10px 30px -12px rgba(10, 10, 10, 0.18);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --maxw: 1180px;
  --header-h: 60px;
}

/* ---------- Tokens: dark (navy, not black) ---------- */
html.dark {
  --background: #031426;
  --foreground: #e9ebf0;
  --card: #072033;
  --card-foreground: #e9ebf0;
  --muted: #0b2a41;
  --muted-foreground: #93a4bd;
  --border: #12395a;
  --border-strong: #1c4d75;
  --input: #12395a;

  --primary: #4a9bff;
  --primary-hover: #6cb0ff;
  --primary-foreground: #04121f;
  --primary-soft: #0a2b47;
  --accent: #2fd7b0;
  --accent-soft: #06302a;
  --ring: #3186ff;

  --good: #46d5a6;
  --good-soft: #06302a;
  --warn: #f0b45e;
  --warn-soft: #33240a;
  --bad: #ff8578;
  --bad-soft: #3a1512;
  --info: #6cb0ff;
  --info-soft: #0a2b47;
  --neutral-soft: #0b2a41;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 34px -12px rgba(0, 0, 0, 0.65);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
  overflow-wrap: break-word;
}
img, svg { max-width: 100%; }
a { color: var(--primary); text-decoration: none; border-radius: 2px; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
h1, h2, h3, h4 { line-height: 1.22; letter-spacing: -0.018em; margin: 0 0 .5em; font-weight: 650; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.85rem); letter-spacing: -0.028em; }
h2 { font-size: clamp(1.35rem, 1.05rem + 1.1vw, 1.85rem); margin-top: 0; }
h3 { font-size: clamp(1.08rem, .98rem + .45vw, 1.28rem); }
h4 { font-size: 1rem; }
p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-left: 1.25rem; }
li { margin-bottom: .4rem; }
li > ul, li > ol { margin-top: .4rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
strong { font-weight: 650; }
code, kbd, samp { font-family: var(--mono); font-size: .87em; }
:not(pre) > code {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .12em .38em;
  font-size: .84em;
  white-space: nowrap;
}
::selection { background: var(--primary-soft); color: var(--foreground); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--background); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-foreground); }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem; }
main { display: block; padding-bottom: 3rem; }
.page-main { padding-top: 2rem; }
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--primary); color: var(--primary-foreground);
  padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem;
  height: var(--header-h); display: flex; align-items: center; gap: .85rem;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 680; color: var(--foreground); font-size: 1rem; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px;
  background: linear-gradient(140deg, var(--primary), var(--accent));
  display: grid; place-items: center; color: #fff;
  font-family: var(--mono); font-size: .76rem; font-weight: 700; letter-spacing: -.03em;
}
.brand-sub { font-weight: 480; color: var(--muted-foreground); font-size: .82rem; }
.nav { margin-left: auto; display: flex; align-items: center; gap: .15rem; }
.nav a {
  color: var(--muted-foreground); font-size: .875rem; font-weight: 520;
  padding: .45rem .6rem; border-radius: var(--radius-sm); white-space: nowrap;
}
.nav a:hover { color: var(--foreground); background: var(--muted); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.header-tools { display: flex; align-items: center; gap: .4rem; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: transparent; color: var(--muted-foreground);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--muted); color: var(--foreground); }
/* Theme toggle: moon in light mode, sun in dark mode.
   Specificity must beat `.icon-btn svg` below, so these use the #id. */
#theme-toggle .icon-sun { display: none; }
html.dark #theme-toggle .icon-moon { display: none; }
html.dark #theme-toggle .icon-sun { display: block; }
.icon-btn svg { display: block; }
.nav-toggle { display: none; }
.nav-toggle .bars { display: block; width: 16px; height: 2px; background: currentColor; border-radius: 2px; position: relative; }
.nav-toggle .bars::before, .nav-toggle .bars::after {
  content: ""; position: absolute; left: 0; width: 16px; height: 2px; background: currentColor; border-radius: 2px;
}
.nav-toggle .bars::before { top: -5px; } .nav-toggle .bars::after { top: 5px; }

/* ---------- Hero ---------- */
.hero {
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(900px 320px at 12% -10%, var(--primary-soft), transparent 62%),
    radial-gradient(700px 300px at 92% 0%, var(--accent-soft), transparent 60%);
}
.hero-inner { max-width: var(--maxw); margin: 0 auto; padding: 3.25rem 1.25rem 2.75rem; }
.hero.page-hero .hero-inner { padding: 2.25rem 1.25rem 2rem; }
.eyebrow {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--mono); font-size: .72rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--primary);
  background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  padding: .3rem .7rem; border-radius: var(--radius-pill); margin-bottom: 1rem;
}
.hero h1 { margin-bottom: .85rem; }
.lede { font-size: clamp(1.02rem, .98rem + .3vw, 1.16rem); color: var(--muted-foreground); max-width: 68ch; margin-bottom: 1.35rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .9rem; font-weight: 570; padding: .6rem 1.05rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card); color: var(--foreground); cursor: pointer;
  min-height: 44px; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--muted); text-decoration: none; border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); font-weight: 620; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; }

/* ---------- Sections & prose ---------- */
section { padding: 2.5rem 0; border-bottom: 1px solid var(--border); }
section:last-of-type { border-bottom: 0; }
section > .wrap > h3, section > .wrap > h4 { margin-top: 1.9rem; }
.section-eyebrow {
  font-family: var(--mono); font-size: .72rem; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted-foreground); margin-bottom: .45rem; display: block;
}
.section-title { margin-bottom: .6rem; }
.section-lede { color: var(--muted-foreground); max-width: 74ch; margin-bottom: 1.5rem; font-size: 1.02rem; }
.prose { max-width: 78ch; }
.prose > h3 { margin-top: 2rem; }
.prose > h4 { margin-top: 1.6rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); gap: 1.1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 1rem; }
.stack > * + * { margin-top: 1rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.3rem; box-shadow: var(--shadow-sm);
}
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; margin-bottom: .6rem; }
.card h3, .card h4 { margin-bottom: .4rem; }
.card p:last-child { margin-bottom: 0; }
.card-muted { background: var(--card); border-color: var(--border); }
a.card { color: inherit; display: block; }
a.card:hover {
  text-decoration: none; border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: var(--shadow); transform: translateY(-2px); transition: all .16s ease;
}
a.card .card-cta { color: var(--primary); font-size: .85rem; font-weight: 600; display: inline-flex; gap: .35rem; align-items: center; margin-top: .7rem; }

/* Nav hub grid */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(288px, 1fr)); gap: 1.1rem; }
.hub-num {
  font-family: var(--mono); font-size: .74rem; font-weight: 700; color: var(--muted-foreground);
  letter-spacing: .06em; margin-bottom: .5rem; display: block;
}

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-family: var(--mono); font-size: .7rem; font-weight: 600;
  letter-spacing: .02em; padding: .2rem .5rem; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--neutral-soft); color: var(--muted-foreground);
  white-space: nowrap; line-height: 1.5;
}
.badge-blue { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 28%, transparent); color: var(--primary); }
.badge-teal { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--good); }
.badge-good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 28%, transparent); color: var(--good); }
.badge-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.badge-bad  { background: var(--bad-soft);  border-color: color-mix(in srgb, var(--bad) 28%, transparent);  color: var(--bad); }
.badge-set { display: flex; flex-wrap: wrap; gap: .35rem; }

/* ---------- Stat strip ---------- */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.stat { background: var(--card); padding: 1.1rem 1.15rem; }
.stat-num { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.75rem); font-weight: 700; letter-spacing: -.03em; display: block; line-height: 1.15; }
.stat-num.accent { color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--muted-foreground); display: block; margin-top: .25rem; }

/* ---------- Definition list / KV ---------- */
.kv { display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--card); }
.kv > div { display: grid; grid-template-columns: 200px 1fr; gap: 1rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { font-weight: 600; font-size: .88rem; color: var(--muted-foreground); margin: 0; }
.kv dd { margin: 0; font-size: .92rem; }

/* ---------- Tables ---------- */
/* Outer card is ALWAYS the scroll container — fixes mobile AND tablet clipping */
.table-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin: 1.35rem 0; position: relative;
}
.table-wrap::after {
  content: ""; position: absolute; top: 0; right: 0; width: 30px; height: 100%;
  background: linear-gradient(to right, transparent, var(--card) 80%);
  pointer-events: none; border-top-right-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg);
}
.table-wrap.scroll-hint-off::after { display: none; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
caption { caption-side: bottom; text-align: left; padding: .7rem 1rem; font-size: .78rem; color: var(--muted-foreground); }
th, td { padding: .68rem .85rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
thead th {
  background: var(--muted); font-weight: 620; font-size: .78rem; letter-spacing: .03em;
  text-transform: uppercase; color: var(--muted-foreground); white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--neutral-soft); }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono { font-family: var(--mono); font-size: .82rem; }
.tbl-tight th, .tbl-tight td { padding: .5rem .65rem; }
.row-good td:first-child { box-shadow: inset 3px 0 0 var(--good); }
.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.row-note td { background: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); }

/* ---------- Callouts ---------- */
.callout {
  border: 1px solid var(--border); border-left: 3px solid var(--muted-foreground);
  background: var(--card); border-radius: var(--radius); padding: .95rem 1.1rem; margin: 1.25rem 0;
  font-size: .92rem;
}
.callout > :last-child { margin-bottom: 0; }
.callout-title { font-weight: 650; display: flex; align-items: center; gap: .45rem; margin-bottom: .3rem; font-size: .9rem; }
.callout-info { border-left-color: var(--info); background: var(--info-soft); }
.callout-info .callout-title { color: var(--info); }
.callout-good { border-left-color: var(--good); background: var(--good-soft); }
.callout-good .callout-title { color: var(--good); }
.callout-warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout-warn .callout-title { color: var(--warn); }
.callout-bad { border-left-color: var(--bad); background: var(--bad-soft); }
.callout-bad .callout-title { color: var(--bad); }

/* ---------- Code ---------- */
pre {
  background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; overflow-x: auto; font-size: .82rem; line-height: 1.6;
  margin: 0 0 1rem; -webkit-overflow-scrolling: touch;
}
pre code { font-size: inherit; background: none; border: 0; padding: 0; white-space: pre; }
.code-wrap { position: relative; margin-bottom: 1.25rem; }
.code-wrap pre { margin-bottom: 0; padding-right: 3.4rem; }
.code-label {
  font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted-foreground); margin-bottom: .35rem; display: block;
}
.copy-btn {
  position: absolute; top: .6rem; right: .6rem;
  font-family: var(--mono); font-size: .68rem; font-weight: 600;
  padding: .3rem .5rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); color: var(--muted-foreground);
  cursor: pointer; min-height: 30px;
}
.copy-btn:hover { color: var(--foreground); border-color: var(--border-strong); }
.copy-btn.done { color: var(--good); border-color: var(--good); }

/* ---------- Pipeline diagram (pure CSS) ---------- */
.pipeline { display: grid; gap: .75rem; margin: 1.5rem 0; }
.pipe-row {
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card);
  padding: 1rem 1.15rem; box-shadow: var(--shadow-sm);
}
.pipe-row.dim { opacity: .62; }
.pipe-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .7rem; }
.pipe-title { font-weight: 640; font-size: .95rem; }
.pipe-track { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.step {
  font-family: var(--mono); font-size: .74rem; font-weight: 600;
  border-radius: var(--radius-sm); padding: .38rem .6rem; border: 1px solid var(--border);
  background: var(--neutral-soft); color: var(--muted-foreground); white-space: nowrap;
}
.step.seq { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); color: var(--warn); }
.step.par { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); color: var(--good); }
.step.out { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 28%, transparent); color: var(--primary); }
.arrow { color: var(--muted-foreground); font-family: var(--mono); font-size: .8rem; padding: 0 .1rem; }
.pipe-note { font-size: .82rem; color: var(--muted-foreground); margin-top: .6rem; }

/* ---------- Model cards ---------- */
.model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 1.1rem; }
.model-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.model-card h3 { margin-bottom: .35rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.model-org { font-size: .82rem; color: var(--muted-foreground); margin-bottom: .7rem; }
.model-facts { display: grid; grid-template-columns: auto 1fr; gap: .3rem .7rem; font-size: .84rem; margin: .8rem 0 0; }
.model-facts dt { color: var(--muted-foreground); font-weight: 540; }
.model-facts dd { margin: 0; }
.model-card .badge-set { margin-bottom: .3rem; }
.model-link { margin-top: auto; padding-top: .9rem; font-size: .85rem; font-weight: 600; }
.model-link a { display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: .45rem; margin: 1.25rem 0; align-items: center; }
.chip {
  font-size: .82rem; font-weight: 560; padding: .42rem .8rem; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--card); color: var(--muted-foreground);
  cursor: pointer; min-height: 44px; transition: all .14s;
}
.chip:hover { color: var(--foreground); border-color: var(--border-strong); }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.filter-count { font-size: .82rem; color: var(--muted-foreground); margin-left: auto; font-family: var(--mono); }

/* ---------- TOC ---------- */
.toc { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.15rem; margin-bottom: 1.75rem; }
.toc-title { font-size: .76rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted-foreground); font-weight: 620; margin-bottom: .5rem; font-family: var(--mono); }
.toc ol { margin: 0; padding-left: 1.1rem; columns: 2; column-gap: 1.5rem; font-size: .88rem; }
.toc li { margin-bottom: .25rem; break-inside: avoid; }

/* ---------- Accordion ---------- */
details.acc {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
  padding: .85rem 1.05rem; margin-bottom: .6rem;
}
details.acc > summary { cursor: pointer; font-weight: 600; font-size: .93rem; list-style: none; display: flex; align-items: center; gap: .5rem; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::before { content: "+"; font-family: var(--mono); color: var(--primary); font-weight: 700; width: 1em; }
details.acc[open] > summary::before { content: "−"; }
details.acc > *:not(summary) { margin-top: .7rem; }
details.acc > *:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--card); padding: 2.25rem 0; margin-top: 0; }
.footer-inner { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 2rem; }
.footer-inner p { font-size: .86rem; color: var(--muted-foreground); margin-bottom: .5rem; }
.footer-h { font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted-foreground); font-weight: 650; margin-bottom: .6rem; font-family: var(--mono); }
.footer-links { display: flex; flex-direction: column; gap: .3rem; font-size: .86rem; }
.footer-legal { border-top: 1px solid var(--border); margin-top: 1.75rem; padding-top: 1.1rem; font-size: .78rem; color: var(--muted-foreground); display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }

/* ---------- Breadcrumb / pager ---------- */
.crumbs { font-size: .82rem; color: var(--muted-foreground); margin-bottom: .9rem; font-family: var(--mono); }
.crumbs a { color: var(--muted-foreground); }
.crumbs a:hover { color: var(--primary); }
.pager { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding-top: 1.5rem; }
.pager a { font-size: .88rem; font-weight: 570; display: inline-flex; gap: .4rem; align-items: center; }
.pager .next { margin-left: auto; }

/* ---------- Sources list ---------- */
.src-list { list-style: none; padding: 0; margin: 0; }
.src-list li { padding: .7rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; margin: 0; }
.src-list li:last-child { border-bottom: 0; }
.src-tag { font-family: var(--mono); font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: .12rem .42rem; border-radius: var(--radius-sm); background: var(--muted); color: var(--muted-foreground); margin-right: .45rem; }
.src-tag.primary { background: var(--primary-soft); color: var(--primary); }
.src-tag.indep { background: var(--accent-soft); color: var(--good); }

/* ---------- Utility ---------- */
.muted { color: var(--muted-foreground); }
.small { font-size: .84rem; }
.tiny { font-size: .78rem; }
.mono { font-family: var(--mono); }
.nb { white-space: nowrap; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; } .mt1 { margin-top: 1rem; } .mt2 { margin-top: 2rem; } .mb1 { margin-bottom: 1rem; } .mb2 { margin-bottom: 2rem; }
.center { text-align: center; }
.hide { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.checklist { list-style: none; padding-left: 0; }
.checklist li { padding-left: 1.6rem; position: relative; }
.checklist li::before { content: "→"; position: absolute; left: 0; color: var(--primary); font-weight: 700; }

/* ---------- Overflow hardening ----------
   Grid and flex children default to min-width:auto, which means a wide code
   block, a long unbreakable token or a nowrap badge can force its column wider
   than the viewport. Everything below removes that failure mode. */
.grid-2 > *, .grid-3 > *, .grid-4 > *, .hub-grid > *,
.model-grid > *, .pipeline > *, .stat-strip > *, .kv > * { min-width: 0; }

.code-wrap, pre, .pipe-row, .pipe-head, .pipe-track, .pipe-title,
.pipe-note, .model-card, .card, .callout, .toc, .table-wrap { min-width: 0; max-width: 100%; }

/* `anywhere` (unlike `break-word`) lowers min-content, so a single long token
   can no longer hold a container open. It only breaks when it has to. */
pre, .step, .pipe-title, .pipe-note, .badge,
.model-facts dt, .model-facts dd, .model-org, .kv dt, .kv dd { overflow-wrap: anywhere; }

.step { white-space: normal; }
.pipe-head, .card-head, .card-head h3 { flex-wrap: wrap; }
.badge { white-space: normal; }
.model-facts { grid-template-columns: auto minmax(0, 1fr); }

/* Inline code: allow a long token to wrap rather than widen the paragraph. */
:not(pre) > code { white-space: normal; overflow-wrap: anywhere; }

/* Tables must still be able to exceed their scroll container. */
table { max-width: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .toc ol { columns: 2; }
}
@media (max-width: 900px) {
  :root { --header-h: 56px; }
  .footer-inner { grid-template-columns: 1fr; gap: 1.5rem; }
  .hero-inner { padding: 2.5rem 1.25rem 2.25rem; }
  .kv > div { grid-template-columns: 1fr; gap: .2rem; }
}
@media (max-width: 1000px) {
  .nav-toggle { display: grid; }
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--card); border-bottom: 1px solid var(--border);
    padding: .5rem .75rem 1rem; gap: .1rem;
    box-shadow: var(--shadow-lg);
    max-height: calc(100dvh - var(--header-h)); overflow-y: auto;
    display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: .8rem .7rem; font-size: .95rem; border-radius: var(--radius-sm); min-height: 46px; display: flex; align-items: center; }
  .brand-sub { display: none; }
  .toc ol { columns: 1; }
}
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  section { padding: 2rem 0; }
  .hero-inner { padding: 2rem 1rem 1.75rem; }
  .wrap { padding: 0 1rem; }
  .header-inner { padding: 0 1rem; }
  .card { padding: 1.1rem; }
  table { font-size: .82rem; }
  th, td { padding: .55rem .65rem; }
  .grid-2, .grid-3, .grid-4, .hub-grid, .model-grid { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .hero-actions .btn { flex: 1 1 auto; justify-content: center; }
}
@media (max-width: 380px) {
  .stat-strip { grid-template-columns: 1fr; }
  .brand { font-size: .92rem; }
  .btn { padding: .55rem .8rem; font-size: .86rem; }
}

/* Coarse pointer: bigger tap targets for every interactive element,
   including the inline text links that stay compact on desktop. */
@media (hover: none) and (pointer: coarse) {
  .nav a, .btn, .chip, .icon-btn, .model-link a,
  .footer-links a, .pager a, .crumbs a, .brand, details.acc > summary {
    min-height: 44px;
  }
  .footer-links a, .pager a, .crumbs a, .brand { display: inline-flex; align-items: center; }
  .icon-btn { width: 44px; height: 44px; }
}

/* ---------- Print ---------- */
@media print {
  :root { --background: #fff; --foreground: #000; --card: #fff; --border: #bbb; }
  html.dark { --background: #fff; --foreground: #000; --card: #fff; --border: #bbb; --muted: #f2f2f2; --muted-foreground: #333; }
  .site-header, .nav, .nav-toggle, .hero-actions, .filter-bar, .pager, .copy-btn, .site-footer { display: none !important; }
  body { font-size: 11pt; }
  section { page-break-inside: avoid; border-bottom: 0; padding: 1rem 0; }
  .card, .table-wrap, .callout, .pipe-row { box-shadow: none; break-inside: avoid; }
  a::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; }
  .table-wrap::after { display: none; }
}
