/* digitaltwin-os.com — shared stylesheet. Brand tokens are imported verbatim from the brand kit. */
@import url("../brand/web/brand-tokens.css");

/* ---------- Fonts (self-hosted, OFL) ---------- */
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../brand/fonts/Outfit-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../brand/fonts/Outfit-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../brand/fonts/GeistMono-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../brand/fonts/GeistMono-Bold.woff2") format("woff2");
}
/* Metric-matched fallbacks so the swap does not shift layout (values from scripts/fonts-to-woff2.py metrics). */
@font-face {
  font-family: "Outfit Fallback";
  src: local("Arial"), local("Helvetica Neue"), local("Helvetica");
  size-adjust: 98.3%;
  ascent-override: 100%;
  descent-override: 26%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Geist Mono Fallback";
  src: local("Menlo"), local("Consolas"), local("Courier New");
  size-adjust: 100%;
  ascent-override: 100.5%;
  descent-override: 29.5%;
  line-gap-override: 0%;
}

/* ---------- Theme tokens ---------- */
:root {
  --font-sans: "Outfit", "Outfit Fallback", Inter, Arial, sans-serif;
  --font-mono: "Geist Mono", "Geist Mono Fallback", "SFMono-Regular", Menlo, Consolas, monospace;

  --bg: var(--digitaltwin-white);
  --bg-alt: var(--digitaltwin-mist);
  --surface: var(--digitaltwin-white);
  --text: var(--digitaltwin-ink);
  --heading: var(--digitaltwin-navy);
  --muted: #3F4A63; /* 8.3:1 on mist, 9.5:1 on white */
  --line: #D6DEF0;
  --line-strong: var(--digitaltwin-navy);
  --accent: var(--digitaltwin-blue);
  --accent-text: #0B4BB5; /* accent for small text and links: 7.8:1 on white, 7.35:1 on mist; fills and borders keep --accent */
  --on-accent: var(--digitaltwin-white);
  --hero-bg: var(--digitaltwin-navy);
  --on-hero: var(--digitaltwin-white);
  --on-hero-muted: #BFCBEA;
  --on-hero-accent: #8DB6FA; /* 8.25:1 on navy */
  --footer-bg: var(--digitaltwin-ink);
  --on-footer: var(--digitaltwin-mist);
  --on-footer-muted: #A3AFCB; /* 8.6:1 on ink */
  --footer-line: #1E2A4F;
  --placeholder-bg: #FFF4D6;
  --placeholder-text: #6B4E00;
  --placeholder-line: #E4C56A;
  --code-bg: #0B1735;
  --code-text: #F5F8FF;
  --code-muted: #A9B4D0;
  --show-light: inline-block;
  --show-dark: none;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--digitaltwin-ink);
    --bg-alt: #0B1735;
    --surface: #0B1735;
    --text: var(--digitaltwin-mist);
    --heading: var(--digitaltwin-white);
    --muted: #A9B4D0;
    --line: #1E2A4F;
    --line-strong: var(--digitaltwin-mist);
    --accent-text: #8DB6FA; /* 9.2:1 on ink */
    --placeholder-bg: #2A2410;
    --placeholder-text: #F1D98A;
    --placeholder-line: #6B5A1E;
    --code-bg: #08111F;
    --show-light: none;
    --show-dark: inline-block;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img, svg, picture { max-width: 100%; display: block; }
img { height: auto; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--heading); outline-offset: 3px; }
.hero :focus-visible, footer :focus-visible, .preview-badge:focus-visible { outline-color: var(--on-hero); } /* the ring sits outside the element (offset 3px), so its contrast is against the surrounding surface */
.btn-primary:focus-visible, .skip-link:focus-visible { outline-color: var(--heading); }
.hero .btn-primary:focus-visible { outline-color: var(--on-hero); }
::selection { background: var(--accent); color: var(--on-accent); }
.skip-link {
  position: absolute; left: 1rem; top: -100%;
  background: var(--accent); color: var(--on-accent);
  padding: 0.6rem 1rem; border-radius: 6px; z-index: 40; text-decoration: none;
}
.skip-link:focus { top: 1rem; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin: 0 0 1rem;
}
h1, h2, h3, h4 { color: var(--heading); font-weight: 700; line-height: 1.12; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.1rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); }
h3 { font-size: 1.25rem; line-height: 1.2; }
h4 { font-size: 1.05rem; line-height: 1.25; }
p { margin: 0; }
.lede { font-size: clamp(1.05rem, 1rem + 0.35vw, 1.15rem); color: var(--muted); max-width: 34rem; } /* ~69 characters at 18.4px */
.prose { max-width: 50ch; display: grid; gap: 1rem; } /* ~75 characters: 1ch of Outfit is ~1.49 running characters */
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.4rem; }
.prose a { color: var(--accent-text); text-underline-offset: 0.15em; }

.wrap { width: min(1120px, 100%); margin-inline: auto; }
section { padding: 3.5rem 1.25rem; }
@media (min-width: 800px) { section { padding: 6rem 1.25rem; } }
.nav, footer { padding-inline: 1.25rem; }
section.alt { background: var(--bg-alt); }
.section-head { display: grid; gap: 1rem; max-width: 46rem; margin-bottom: clamp(2rem, 5vw, 3.5rem); }
.section-head > .lede { margin-top: 0.25rem; }

/* Placeholder marker: visible, honest, easy to grep */
.ph {
  display: inline;
  background: var(--placeholder-bg);
  color: var(--placeholder-text);
  border: 1px dashed var(--placeholder-line);
  border-radius: 3px;
  padding: 0.32em 0.65em; /* >=4px vertical and >=8px horizontal at the chip's 13-14px size */
  line-height: 1.4;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
  font-family: var(--font-mono);
  font-size: 0.875em;
}

/* ---------- Buttons: flat, crisp, 44px on touch ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 44px;
  padding: 0.7rem 1.3rem;
  border-radius: 6px;
  font-weight: 400; font-size: 1rem; line-height: 1.1;
  text-decoration: none; cursor: pointer;
  border: 2px solid transparent;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--digitaltwin-navy); border-color: var(--digitaltwin-navy); color: var(--digitaltwin-white); }
.btn-ghost { background: transparent; color: var(--heading); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-text); }
.btn-ghost-hero { background: transparent; color: var(--on-hero); border-color: var(--on-hero-muted); }
.btn-ghost-hero:hover { border-color: var(--digitaltwin-white); }
.btn-sm { padding: 0.5rem 0.9rem; font-size: 0.92rem; }
.btn-block { width: 100%; }

/* ---------- Nav ---------- */
:root { --nav-h: 84px; }
@media (max-width: 599px) { :root { --nav-h: 68px; } }
.nav {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; gap: 2.5rem; min-height: var(--nav-h); padding: 0.5rem 0; }
.nav-logo { display: inline-flex; align-items: center; min-height: 44px; flex: none; }
.nav-logo img { height: 52px; width: auto; }
.nav-logo-light { display: var(--show-light); }
.nav-logo-dark { display: var(--show-dark); }
.nav-primary { margin-left: auto; }
.nav-links { display: flex; align-items: center; gap: 0.25rem; list-style: none; margin: 0; padding: 0; }
.nav-links a:not(.btn), .nav-drop-btn {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px; padding: 0 0.85rem;
  text-decoration: none; color: var(--text); font: inherit; font-size: 1rem; line-height: 1.1;
  border-radius: 6px; white-space: nowrap; background: none; border: 0; cursor: pointer;
}
.nav-links a:not(.btn):hover, .nav-drop-btn:hover, .nav-links a[aria-current="page"], .nav-drop-btn[aria-current="page"] { color: var(--accent-text); }
.nav-links a[aria-current="page"], .nav-drop-btn[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.3em; text-decoration-thickness: 2px; } /* the cue survives colour loss */
.nav-drop-btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-drop.is-open > .nav-drop-btn svg { transform: rotate(180deg); }
.nav-drop { position: relative; }
.nav-group-label { display: none; }
/* The dropdown: a bordered panel on the page background; shown on hover, on keyboard focus without JS, and by nav.js on tap */
.nav-menu {
  display: none; position: absolute; top: 100%; left: 0; z-index: 21;
  min-width: 16rem; margin: 0; padding: 0.5rem; list-style: none;
  background: var(--bg); border: 2px solid var(--line-strong); border-radius: 8px;
}
.nav-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -0.6rem; height: 0.6rem; } /* keeps hover alive across the gap */
.nav-menu a { display: flex; min-height: 44px; padding: 0 0.85rem; }
.nav-menu a:hover { background: var(--bg-alt); }
.nav-drop:hover > .nav-menu, .nav-drop.is-open > .nav-menu, .nav:not(.js) .nav-drop:focus-within > .nav-menu { display: block; }
.nav-cta { flex: none; white-space: nowrap; }
.nav-links-cta { display: none; }
.nav-toggle { display: none; }
.nav-toggle summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: 44px; min-width: 44px; padding: 0 0.7rem;
  border: 2px solid var(--line-strong); border-radius: 6px;
  color: var(--heading); font-size: 0.92rem;
}
.nav-toggle summary::-webkit-details-marker { display: none; }
.nav-toggle svg { width: 18px; height: 18px; }
.nav-toggle svg line { stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.nav-toggle[open] summary { border-color: var(--accent); color: var(--accent-text); }
@media (max-width: 1023px) {
  .nav .wrap { flex-wrap: wrap; gap: 0.75rem 1rem; }
  .nav-logo { margin-right: auto; }
  .nav-cta { order: 2; }
  .nav-toggle { display: block; order: 3; }
  .nav-primary { order: 4; flex-basis: 100%; margin-left: 0; }
  .nav-links {
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 0.5rem 0 0.75rem; border-top: 1px solid var(--line);
  }
  .nav-links a:not(.btn), .nav-drop-btn { min-height: 48px; padding: 0 0.5rem; }
  /* The About group is listed flat inside the mobile menu */
  .nav-drop-btn { display: none; }
  .nav-group-label {
    display: block; padding: 1rem 0.5rem 0.25rem;
    font-family: var(--font-mono); font-size: 0.875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-text);
  }
  .nav-menu { display: block; position: static; min-width: 0; padding: 0.25rem 0.5rem; border: 0; border-radius: 0; background: none; }
  .nav-menu::before { display: none; }
  .nav-menu a { padding-left: 0.75rem; } /* 8px list inset + 12px = the same 20px text indent as a 1.25rem padding */
  .nav-menu a:hover { background: none; }
  .nav-links .nav-links-cta { margin-top: 0.75rem; }
  .nav-links .nav-links-cta a { justify-content: center; }
  /* Closed by default; the <details> summary toggles it without JavaScript. */
  .nav:has(.nav-toggle:not([open])) .nav-primary { display: none; }
  @supports not selector(:has(a)) { .nav-toggle { display: none; } }
}
@media (max-width: 599px) {
  .nav-logo img { height: 40px; }
  .nav-cta { display: none; }
  .nav-links-cta { display: block; }
}
@media (max-width: 479px) {
  .nav .wrap { gap: 0.5rem; }
  .nav-toggle summary { padding: 0 0.75rem; }
  .nav-toggle .nav-toggle-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (pointer: coarse) {
  .btn, .nav-links a, .nav-drop-btn, .faq summary, .form input { min-height: 48px; }
}
section[id] { scroll-margin-top: var(--nav-h); }

/* ---------- Hero: navy in both themes ---------- */
.hero { background: var(--hero-bg); color: var(--on-hero); padding: 3rem 1.25rem; }
@media (min-width: 800px) { .hero { padding: 6.5rem 1.25rem; } }
.hero .wrap { display: grid; gap: 2rem; }
.hero h1 { color: var(--on-hero); max-width: 18ch; }
.hero .lede { max-width: 34rem; }
.hero .lede { color: var(--on-hero-muted); }
.hero .eyebrow { color: var(--on-hero-accent); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.hero-split .wrap { gap: 2.5rem; }
.hero-copy { display: grid; gap: 2rem; }
.hero-art { margin: 0; width: 100%; max-width: 560px; }
.hero-art picture, .hero-art img { width: 100%; height: auto; }
@media (min-width: 1024px) {
  .hero-split .wrap { grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); align-items: center; gap: 3.5rem; }
  .hero-art { max-width: none; justify-self: end; }
}
.hero.hero-compact { padding: 2.5rem 1.25rem; }
@media (min-width: 800px) { .hero.hero-compact { padding: 4.5rem 1.25rem; } }
.hero.hero-compact .wrap { gap: 1.2rem; }

/* ---------- Diagrams ---------- */
.figure { margin: 0 0 clamp(2rem, 5vw, 3.5rem); display: grid; gap: 0.75rem; }
.figure picture, .figure img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.figure figcaption { font-size: 1rem; color: var(--muted); max-width: 50ch; } /* 1ch of Outfit is ~1.49 running characters, so 50ch is ~75 characters per line */

/* ---------- Four-item groups always read as two pairs, including phones ---------- */
.explain { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem 1.5rem; }
.explain .figure { margin: 0; align-content: start; }
.explain .figure h3 { margin-bottom: 0.25rem; }
.doc-section .figure { margin: 0.5rem 0; }
.doc-section .figure figcaption { color: var(--muted); }

/* ---------- Paired cards: solid = human system, dotted = modeled twin ---------- */
.mechanism { margin: 1.5rem 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 0.6rem 2rem; max-width: 62rem; }
.mechanism li { display: grid; grid-template-columns: 9rem 1fr; gap: 0.75rem; padding: 0.6rem 0; border-top: 1px solid var(--line); font-size: 1rem; }
.mechanism li span:first-child { font-weight: 700; color: var(--heading); }
.mechanism li span:last-child { color: var(--muted); }
.mechanism li .ph { color: var(--placeholder-text); } /* outranks the span:last-child colour above */
@media (max-width: 599px) { .mechanism li { grid-template-columns: 1fr; gap: 0.2rem; } }
/* Pricing page: one column, each part gets a full measure */
.mechanism-page { grid-template-columns: 1fr; max-width: 46rem; gap: 0; }
.mechanism-page li { grid-template-columns: 10rem 1fr; padding: 0.9rem 0; }
.mechanism-page li span:last-child { max-width: 50ch; }
@media (max-width: 599px) { .mechanism-page li { grid-template-columns: 1fr; } }
.prose-line { max-width: 48ch; }
.prose-line a, .prose-line + * a { color: var(--accent-text); text-underline-offset: 0.15em; }
.notice { border: 2px dotted var(--accent); border-radius: 8px; padding: 1.2rem 1.4rem; display: grid; gap: 0.5rem; background: var(--surface); max-width: 48ch; }
.notice p { color: var(--text); }
.pairs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 1.25rem; align-items: stretch; }
.pairs > .card { display: grid; grid-template-rows: subgrid; grid-row: span 3; align-content: start; }
/* Cards with more than three children (the pricing illustrations) lay out their own rows; a subgrid cannot add implicit tracks */
.pairs-free > .card { grid-template-rows: none; grid-row: auto; }
.card {
  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  padding: 1.6rem 1.5rem;
  display: grid; gap: 0.8rem; align-content: start;
}
.card.twin { border-style: dotted; border-color: var(--accent); }
.card.pair { border-left: 2px solid var(--line-strong); border-right: 2px dotted var(--accent); border-top-color: var(--line); border-bottom-color: var(--line); border-top-width: 1px; border-bottom-width: 1px; }
.card .eyebrow { margin: 0; }
.card p { color: var(--muted); }
.card p a { color: var(--accent-text); text-underline-offset: 0.15em; }
/* Inline links inside running text keep their text-height box (WCAG 2.5.8 inline exception); padding them into neighbouring lines put their hit area under the placeholder chips */
.notice p a, .form-hint a { white-space: nowrap; } /* short call-to-action links stay on one line so their box is one rectangle */
.notice p a.ph { white-space: normal; } /* the placeholder address chip wraps like any chip */

/* ---------- Steps: a real sequence, so numbers carry meaning ---------- */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 1.5rem 2.5rem; }
.step { display: grid; grid-template-rows: subgrid; grid-row: span 3; gap: 0.7rem; padding-top: 1.2rem; border-top: 2px dotted var(--accent); align-content: start; }
.step > :nth-child(n+4) { grid-row: auto; }
.step .num { font-family: var(--font-mono); font-size: 0.875rem; color: var(--accent-text); letter-spacing: 0.08em; }
.step p { color: var(--muted); font-size: 1rem; }

/* ---------- Portal sentence ---------- */
.portal-note { display: grid; gap: 1rem; grid-template-columns: 1fr auto; align-items: center; padding: 1.5rem; border: 2px dotted var(--accent); border-radius: 8px; background: var(--surface); }
.portal-note p { max-width: 47ch; }
@media (max-width: 720px) { .portal-note { grid-template-columns: 1fr; } }

/* ---------- FAQ ---------- */
.faq { display: grid; gap: 0.75rem; max-width: 52rem; }
.faq details { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.faq summary {
  cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem; min-height: 44px;
  font-weight: 700; color: var(--heading); font-size: 1.05rem; line-height: 1.3;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary h3 { font-size: inherit; line-height: inherit; margin: 0; text-wrap: balance; }
.faq summary::after { content: "+"; font-family: var(--font-mono); color: var(--accent-text); flex: none; font-size: 1.2rem; }
.faq details[open] summary::after { content: "\2212"; }
.faq .answer { padding: 0 1.25rem 1.25rem; color: var(--muted); max-width: 50ch; display: grid; gap: 0.6rem; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 480px; font-size: 1rem; }
th, td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--font-mono); font-weight: 400; font-size: 0.875rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
tr:last-child td { border-bottom: 0; }

/* ---------- Forms (account page) ---------- */
.form { display: grid; gap: 1rem; }
.form .field { display: grid; gap: 0.4rem; }
@media (min-width: 640px) { .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; } }
.form label { display: grid; gap: 0.4rem; font-weight: 400; color: var(--heading); font-size: 1rem; }
.form input {
  width: 100%; min-height: 44px;
  padding: 0.7rem 1rem; font: inherit; font-size: 1rem;
  border: 2px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--text);
}
.form textarea {
  width: 100%; min-height: 9rem; resize: vertical;
  padding: 0.7rem 1rem; font: inherit; font-size: 1rem; line-height: 1.5;
  border: 2px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--text);
}
.form input:focus, .form textarea:focus { border-color: var(--accent); }
.form input:focus-visible, .form textarea:focus-visible { outline: 3px solid var(--heading); outline-offset: 2px; }
.form input::placeholder, .form textarea::placeholder { color: var(--muted); opacity: 1; }
.form-hint { font-size: 1rem; color: var(--muted); max-width: 50ch; }
.form-status {
  font-size: 1rem; color: var(--placeholder-text);
  background: var(--placeholder-bg); border: 1px dashed var(--placeholder-line); border-radius: 4px;
  padding: 0.6rem 0.8rem;
}
.form-status[hidden] { display: none; }
.auth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 1.5rem; align-items: start; }
.auth-panel { display: grid; gap: 1.2rem; padding: 1.6rem 1.5rem; border: 2px solid var(--line-strong); border-radius: 8px; background: var(--surface); }
.auth-panel.twin { border-style: dotted; border-color: var(--accent); }
.auth-panel h2 { font-size: 1.4rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

/* ---------- Code blocks (developers page) ---------- */
pre {
  margin: 0; padding: 1rem 1.2rem; overflow-x: auto;
  background: var(--code-bg); color: var(--code-text);
  border-radius: 8px; border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 0.875rem; line-height: 1.55;
  tab-size: 2;
}
code { font-family: var(--font-mono); font-size: 0.92em; }
p code, li code, td code { background: var(--bg-alt); border: 1px solid var(--line); border-radius: 4px; padding: 0.05em 0.35em; }
pre code { background: none; border: 0; padding: 0; font-size: inherit; }
pre .c { color: var(--code-muted); }
.doc-grid { display: grid; grid-template-columns: 220px 1fr; gap: 3rem; align-items: start; }
.doc-toc { position: sticky; top: calc(var(--nav-h) + 1rem); display: grid; gap: 0.2rem; }
.doc-toc a { display: block; padding: 0.45rem 0.6rem; min-height: 44px; display: flex; align-items: center; text-decoration: none; color: var(--muted); border-left: 2px solid var(--line); font-size: 0.95rem; }
.doc-toc a:hover { color: var(--accent-text); border-left-color: var(--accent); }
.doc-body { display: grid; gap: clamp(2.5rem, 5vw, 4rem); }
.doc-section { display: grid; gap: 1rem; max-width: 50ch; scroll-margin-top: calc(var(--nav-h) + 1rem); }
.doc-section h2 { font-size: clamp(1.4rem, 2.4vw, 1.8rem); }
.doc-section p, .doc-section li { color: var(--text); }
.doc-section ul, .doc-section ol { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.4rem; }
.doc-section table { min-width: 0; }
@media (max-width: 860px) { .doc-grid { grid-template-columns: 1fr; gap: 1.5rem; } .doc-toc { position: static; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); } .doc-toc a { border-left: 0; border-bottom: 1px solid var(--line); } }
.breadcrumb { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; font-family: var(--font-mono); font-size: 0.875rem; letter-spacing: 0.04em; color: var(--on-hero-muted); }
.breadcrumb { align-items: center; }
.breadcrumb a { color: inherit; display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; margin-block: -10px; margin-inline-start: -6px; padding-inline: 6px; } /* 44px hit area; negative margins keep the text where it was */
.breadcrumb li + li::before { content: "/"; margin-right: 0.5rem; color: var(--on-hero-accent); }

/* ---------- Footer ---------- */
footer { background: var(--footer-bg); color: var(--on-footer); padding: 3.5rem 1.25rem 2.5rem; }
.foot-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 2.5rem; align-items: start; }
@media (max-width: 720px) { .foot-grid { grid-template-columns: 1fr; } }
.foot-icon img { height: 64px; width: auto; }
.foot-tagline { margin-top: 1rem; max-width: 30rem; color: var(--on-footer-muted); }
footer h2 { margin: 0 0 0.8rem; font-family: var(--font-mono); font-weight: 400; font-size: 0.875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--on-footer-muted); }
footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
footer li { color: var(--on-footer); }
footer a { text-decoration: none; color: var(--on-footer); display: inline-flex; align-items: center; min-height: 44px; }
footer a:hover { color: var(--on-hero-accent); }
.foot-bottom { margin-top: 2.5rem; padding-top: 1.2rem; border-top: 1px solid var(--footer-line); display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; font-size: 0.875rem; color: var(--on-footer-muted); }
footer .ph { background: #2A2410; color: #F1D98A; border-color: #6B5A1E; }

/* ---------- Preview badge ---------- */
.preview-badge {
  position: fixed; right: 1rem; bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 30; /* takes pointer events: an overlay that is transparent to hit-testing reads as occluded text to detectors and screen-reader hit tests */
  background: var(--digitaltwin-blue); color: var(--digitaltwin-white);
  font-family: var(--font-mono);
  font-size: 0.875rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.5rem 0.8rem; border-radius: 4px;
}
@media (max-width: 1023px) { .preview-badge { display: none; } } /* on phones and tablets the fixed badge would sit over the single content column; the footer line carries the preview notice there */

/* Explicit four-item rule: never let auto-fit turn four peers into a 3+1 layout. */
.four-up,
:is(.pairs, .steps, .explain):has(> :nth-child(4):last-child) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(0.75rem, 3vw, 2.5rem);
}
.four-up > * { min-width: 0; }
.steps.four-up > .step { grid-template-rows: subgrid; grid-row: span 4; }
.stage-details { align-self: start; min-width: 0; }
.stage-details summary, .diagram-details summary, .diagram-downloads summary {
  cursor: pointer; min-height: 44px; padding: 0.6rem 0;
  color: var(--accent-text); font-size: 1rem; line-height: 1.5;
}
.stage-details p { padding-top: 0.5rem; }

/* Native text retains normal font sizing; diagrams never scale text down like an image. */
.explain .assurance-diagram {
  grid-template-rows: minmax(3rem, auto) 28rem minmax(3.1rem, auto) auto auto;
  gap: 0.75rem;
}
.assurance-diagram h3 { font-size: 1.25rem; line-height: 1.2; }
.diagram-surface {
  height: 28rem; min-width: 0; padding: 0.75rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.diagram-nodes {
  display: grid; grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 1.75rem;
  height: 100%; margin: 0; padding: 0; list-style: none;
}
.diagram-node {
  position: relative; display: flex; flex-direction: column; justify-content: center;
  gap: 0.25rem; min-width: 0; padding: 0.5rem 0.25rem;
  border: 2px solid var(--line-strong); border-radius: 6px;
  font-size: 1rem; line-height: 1.25; text-align: center;
  color: var(--text); background: var(--bg); overflow-wrap: break-word;
}
.diagram-node[data-node-type="workflow"], .diagram-node[data-node-type="record"],
.diagram-node[data-node-type="access"] { border-style: dotted; border-color: var(--accent); }
.diagram-node > span:not(.diagram-connector) { color: var(--muted); }
.diagram-connector {
  position: absolute; bottom: -1.75rem; left: 0; width: 100%; height: 1.75rem;
  display: flex; align-items: center; justify-content: center; gap: 0.25rem;
  font-size: 0.875rem; line-height: 1; color: var(--accent-text);
}
.diagram-connector svg { flex: 0 0 16px; }
.diagram-details { align-self: start; min-width: 0; font-size: 1rem; }
.diagram-details ul { margin: 0.5rem 0 0; padding-left: 1rem; }
.diagram-details li + li { margin-top: 0.75rem; }
.diagram-details h4 { margin-top: 1rem; }
.diagram-details li { overflow-wrap: anywhere; }
.diagram-trace { width: 100%; padding: 0.5rem; min-height: 44px; align-self: start; font-size: 1rem; }
.diagram-trace[hidden] { display: none; }
.diagram-trace:disabled { cursor: default; color: var(--muted); border-color: var(--line); }
.diagram-downloads { margin-top: 2rem; font-size: 1rem; }
.diagram-downloads a { color: var(--accent-text); text-underline-offset: 0.15em; }
.assurance-diagram[data-tracing] .diagram-node {
  animation: trace-node 700ms ease-out var(--trace-delay) 1;
}
@keyframes trace-node {
  0%, 85% { outline: 3px solid var(--accent-text); outline-offset: 3px; }
  100% { outline: 3px solid transparent; outline-offset: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  .assurance-diagram[data-tracing] .diagram-node { animation: none; }
}
@media (max-width: 479px) {
  .diagram-surface { padding: 0.5rem; }
  .assurance-diagram h3 { min-height: 3rem; }
}
