/* =========================================================================
   IVAI OS — design system
   -------------------------------------------------------------------------
   One stylesheet. No imports, no external fonts, no remote assets.
   Authored dark-first; the light scheme is a first-class variant.
   ========================================================================= */

/* ---------- Tokens ---------- */

:root {
  color-scheme: dark light;

  --bg: #0a0c10;
  --bg-sunken: #07090c;
  --surface: #11151c;
  --surface-2: #161b24;
  --line: #1f2630;
  --line-strong: #2c3542;
  --fg: #e9ecf2;
  --fg-muted: #9aa5b6;
  --fg-dim: #808b9b;

  --accent: #e8b04b;
  --accent-quiet: #b9873220;
  --accent-line: #e8b04b66;
  --on-accent: #1a1206;

  /* The four-stage metaphor. One colour per stage, used everywhere. */
  --observe: #7ba7f5;
  --authorize: #e8b04b;
  --execute: #c9d3e2;
  --verify: #56c99b;
  --halt: #f07e6e;

  --brand-ink: var(--fg);
  --brand-accent: var(--accent);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", "Noto Sans Arabic", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --container: 74rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --section-y: clamp(3.75rem, 8vw, 7rem);
  --radius: 4px;
  --radius-lg: 8px;

  --shadow-panel: 0 1px 0 rgb(255 255 255 / 3%) inset;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbfaf8;
    --bg-sunken: #f2f1ec;
    --surface: #ffffff;
    --surface-2: #f7f6f2;
    --line: #e2e0d8;
    --line-strong: #cbc8bd;
    --fg: #14171c;
    --fg-muted: #545c69;
    --fg-dim: #6b7381;

    --accent: #8a5f12;
    --accent-quiet: #8a5f1214;
    --accent-line: #8a5f1255;
    --on-accent: #fffdf7;

    --observe: #1f4fa8;
    --authorize: #8a5f12;
    --execute: #3d4553;
    --verify: #0f6b47;
    --halt: #a33322;

    --shadow-panel: 0 1px 2px rgb(20 23 28 / 4%);
  }
}

/* ---------- Reset ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

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

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

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

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

button {
  font: inherit;
  color: inherit;
}

table {
  border-collapse: collapse;
  width: 100%;
}

:target {
  scroll-margin-top: 6rem;
}

/* ---------- Focus & skip link ---------- */

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: 0.5rem;
  z-index: 100;
  transform: translateY(-160%);
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.6rem 1rem;
  font: 600 0.875rem/1 var(--font-sans);
  border-radius: var(--radius);
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- Layout ---------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: var(--section-y);
  border-top: 1px solid var(--line);
}

.section--flush {
  border-top: 0;
}

.section--sunken {
  background: var(--bg-sunken);
}

.stack > * + * {
  margin-top: 1.15em;
}

.stack-lg > * + * {
  margin-top: clamp(2rem, 4vw, 3rem);
}

.measure {
  max-width: 68ch;
}

.measure-narrow {
  max-width: 54ch;
}

/* ---------- Typography ---------- */

.eyebrow {
  font: 500 0.75rem/1.2 var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin: 0;
}

.eyebrow--accent {
  color: var(--accent);
}

h1,
.h1 {
  font-size: clamp(2.35rem, 1.5rem + 3.4vw, 4rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 600;
}

h2,
.h2 {
  font-size: clamp(1.7rem, 1.25rem + 1.75vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -0.028em;
  font-weight: 600;
}

h3,
.h3 {
  font-size: clamp(1.15rem, 1.05rem + 0.4vw, 1.35rem);
  line-height: 1.3;
  letter-spacing: -0.015em;
  font-weight: 600;
}

h4,
.h4 {
  font-size: 1rem;
  line-height: 1.4;
  letter-spacing: -0.008em;
  font-weight: 600;
}

.lead {
  font-size: clamp(1.1rem, 1.02rem + 0.45vw, 1.3rem);
  line-height: 1.55;
  color: var(--fg-muted);
  letter-spacing: -0.011em;
}

.muted {
  color: var(--fg-muted);
}

.dim {
  color: var(--fg-dim);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.small {
  font-size: 0.9375rem;
  line-height: 1.6;
}

.xsmall {
  font-size: 0.8125rem;
  line-height: 1.55;
}

strong,
b {
  font-weight: 600;
  color: var(--fg);
}

.arabic {
  font-family: "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", "Traditional Arabic", serif;
  direction: rtl;
  unicode-bidi: isolate;
  font-size: 1.05em;
  line-height: 1.8;
}

/* ---------- Section headers ---------- */

.section-head {
  display: grid;
  gap: 0.85rem;
  padding-top: 0.35rem;
  margin-bottom: clamp(2rem, 4vw, 3.25rem);
  border-top: 1px solid var(--line-strong);
}

.section-head__index {
  font: 500 0.75rem/1 var(--font-mono);
  letter-spacing: 0.16em;
  color: var(--accent);
}

.section-head__title {
  max-width: 26ch;
}

.section-head__intro {
  max-width: 62ch;
  color: var(--fg-muted);
}

/* ---------- Links ---------- */

.link {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
  transition: text-decoration-color 140ms ease, color 140ms ease;
}

.link:hover {
  text-decoration-color: var(--accent);
}

.arrow-link {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  font: 500 0.9375rem/1.4 var(--font-sans);
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 0.3rem;
  transition: border-color 140ms ease, color 140ms ease;
}

.arrow-link::after {
  content: "→";
  color: var(--accent);
  transition: transform 160ms ease;
}

.arrow-link:hover {
  border-color: var(--accent);
}

.arrow-link:hover::after {
  transform: translateX(3px);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.72rem 1.15rem;
  font: 600 0.9375rem/1.2 var(--font-sans);
  letter-spacing: -0.005em;
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

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

.btn--primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, var(--fg));
}

.btn--ghost {
  border-color: var(--line-strong);
  color: var(--fg);
}

.btn--ghost:hover {
  border-color: var(--accent);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 4.25rem;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  flex: 0 0 auto;
}

.brand-link .lockup {
  height: 24px;
  width: auto;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font: 500 0.6875rem/1 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  white-space: nowrap;
}

.status-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.nav-desktop {
  margin-left: auto;
  display: none;
}

.nav-desktop ul {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 1.6vw, 1.5rem);
}

.nav-desktop a {
  display: block;
  padding: 0.4rem 0;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 140ms ease, border-color 140ms ease;
}

.nav-desktop a:hover {
  color: var(--fg);
}

.nav-desktop a[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.nav-cta {
  display: none;
}

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

.nav-mobile > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font: 500 0.8125rem/1 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg);
}

.nav-mobile > summary::-webkit-details-marker {
  display: none;
}

.nav-mobile > summary::after {
  content: "+";
  font-size: 1rem;
  line-height: 1;
  color: var(--accent);
}

.nav-mobile[open] > summary::after {
  content: "−";
}

.nav-mobile__panel {
  position: absolute;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  padding: 0.5rem var(--gutter) 1.25rem;
}

.nav-mobile__panel ul {
  max-width: var(--container);
  margin-inline: auto;
}

.nav-mobile__panel a {
  display: block;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--fg);
}

.nav-mobile__panel a[aria-current="page"] {
  color: var(--accent);
}

@media (min-width: 62rem) {
  .nav-desktop {
    display: block;
  }
  .nav-mobile {
    display: none;
  }
  .nav-cta {
    display: inline-flex;
  }
}

@media (max-width: 32rem) {
  .brand-link .status-chip {
    display: none;
  }
}

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

.hero {
  position: relative;
  padding-block: clamp(3.5rem, 9vw, 7.5rem) clamp(3rem, 7vw, 5.5rem);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 88px 88px;
  mask-image: radial-gradient(120% 90% at 18% 0%, #000 0%, transparent 72%);
  opacity: 0.55;
}

.hero__inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(2.5rem, 5vw, 4rem);
}

@media (min-width: 66rem) {
  .hero__inner {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    align-items: center;
  }
}

.hero__title {
  margin-top: 1.1rem;
  max-width: 16ch;
}

.hero__title em {
  font-style: normal;
  color: var(--accent);
}

.hero__lead {
  margin-top: 1.35rem;
  max-width: 52ch;
}

.hero__actions {
  margin-top: 2rem;
}

.hero__note {
  margin-top: 1.75rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  max-width: 52ch;
}

.hero-stages {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.hero-stage {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 0.15rem 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}

.hero-stage__index {
  font: 500 0.75rem/1.5 var(--font-mono);
  letter-spacing: 0.1em;
  color: var(--stage-color, var(--fg-dim));
}

.hero-stage__name {
  font-weight: 600;
  letter-spacing: -0.012em;
}

.hero-stage__line {
  grid-column: 2;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--fg-muted);
}

/* ---------- Panels ---------- */

.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(1.35rem, 2.6vw, 1.9rem);
  box-shadow: var(--shadow-panel);
}

.panel--quiet {
  background: transparent;
}

.panel--sunken {
  background: var(--bg-sunken);
}

/* Corner brackets echo the aperture in the symbol. */
.panel--framed::before,
.panel--framed::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--accent);
  border-style: solid;
  opacity: 0.8;
}

.panel--framed::before {
  top: -1px;
  left: -1px;
  border-width: 2px 0 0 2px;
  border-top-left-radius: var(--radius-lg);
}

.panel--framed::after {
  bottom: -1px;
  right: -1px;
  border-width: 0 2px 2px 0;
  border-bottom-right-radius: var(--radius-lg);
}

.panel__title {
  margin-bottom: 0.55rem;
}

.panel__index {
  font: 500 0.75rem/1 var(--font-mono);
  letter-spacing: 0.14em;
  color: var(--fg-dim);
  margin-bottom: 0.9rem;
}

/* ---------- Grids ---------- */

/* Every grid declares an explicit minmax(0, …) track and every grid child is
   allowed to shrink. Without this, a wide child (a table, a preformatted block)
   forces the whole document wider than the viewport on small screens instead of
   scrolling inside its own container.
   NOTE: this block must not name a selector whose multi-column media query is
   declared EARLIER in this file — a later rule of equal specificity would win
   and collapse it to one column at every width. `.hero__inner` therefore
   declares its own single-column base above, next to its media query. */
.grid,
.split,
.layers,
.env-grid,
.compare,
.defs__row,
.status-row,
.timeline__item,
.ladder__item,
.layer,
.site-footer__top,
.rail,
.bullets,
.qa {
  grid-template-columns: minmax(0, 1fr);
}

.grid > *,
.split > *,
.layers > *,
.env-grid > *,
.compare > *,
.defs__row > *,
.status-row > *,
.timeline__item > *,
.ladder__item > *,
.layer > *,
.hero__inner > *,
.site-footer__top > *,
.rail > *,
.steps > *,
.qa > * {
  min-width: 0;
}

.grid {
  display: grid;
  gap: clamp(1rem, 2vw, 1.5rem);
}

@media (min-width: 40rem) {
  .grid--2,
  .grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 56rem) {
  .grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.split {
  display: grid;
  gap: clamp(2rem, 5vw, 4rem);
}

@media (min-width: 62rem) {
  .split {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: start;
  }
  .split--even {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .split--sticky > :first-child {
    position: sticky;
    top: 6rem;
  }
}

/* ---------- Stage colouring ---------- */

.stage {
  --stage-color: var(--execute);
}
.stage--observe {
  --stage-color: var(--observe);
}
.stage--authorize {
  --stage-color: var(--authorize);
}
.stage--execute {
  --stage-color: var(--execute);
}
.stage--verify {
  --stage-color: var(--verify);
}
.stage--halt {
  --stage-color: var(--halt);
}

.stage-card {
  border-top: 2px solid var(--stage-color);
  background: var(--surface);
  border-inline: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.25rem 1.25rem 1.4rem;
  height: 100%;
}

.stage-card__index {
  font: 500 0.75rem/1 var(--font-mono);
  letter-spacing: 0.14em;
  color: var(--stage-color);
}

.stage-card__name {
  margin: 0.7rem 0 0.5rem;
}

/* ---------- Lists ---------- */

.bullets {
  display: grid;
  gap: 0.7rem;
}

.bullets li {
  position: relative;
  padding-left: 1.4rem;
}

.bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: var(--accent);
}

.bullets--check li::before {
  background: var(--verify);
}

.bullets--stop li::before {
  background: var(--halt);
}

.steps {
  counter-reset: step;
  display: grid;
  gap: 0;
}

.steps > li {
  counter-increment: step;
  position: relative;
  padding: 1.15rem 0 1.15rem 3.5rem;
  border-top: 1px solid var(--line);
}

.steps > li:last-child {
  border-bottom: 1px solid var(--line);
}

.steps > li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1.2rem;
  font: 500 0.8125rem/1 var(--font-mono);
  letter-spacing: 0.1em;
  color: var(--accent);
}

.steps__title {
  font-weight: 600;
  display: block;
  margin-bottom: 0.2rem;
}

/* ---------- Definition rows ---------- */

.defs {
  border-top: 1px solid var(--line);
}

.defs__row {
  display: grid;
  gap: 0.35rem 2rem;
  padding: 1.05rem 0;
  border-bottom: 1px solid var(--line);
}

@media (min-width: 48rem) {
  .defs__row {
    grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  }
}

.defs__term {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.defs__desc {
  color: var(--fg-muted);
  margin: 0;
}

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

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.table-wrap:focus-visible {
  outline: 2px solid var(--accent);
}

table.data {
  font-size: 0.9375rem;
  min-width: 34rem;
}

table.data caption {
  text-align: left;
  padding: 1rem 1.15rem 0.35rem;
  font: 500 0.75rem/1.4 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

table.data th,
table.data td {
  text-align: left;
  vertical-align: top;
  padding: 0.8rem 1.15rem;
  border-bottom: 1px solid var(--line);
}

table.data thead th {
  font: 600 0.75rem/1.4 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  border-bottom-color: var(--line-strong);
  white-space: nowrap;
}

table.data tbody tr:last-child th,
table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data tbody th {
  font-weight: 600;
}

/* ---------- Callouts ---------- */

.callout {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
  padding: 1.1rem 1.35rem;
}

.callout--verify {
  border-left-color: var(--verify);
}

.callout--halt {
  border-left-color: var(--halt);
}

.callout--observe {
  border-left-color: var(--observe);
}

.callout__label {
  font: 600 0.6875rem/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 0.6rem;
}

/* ---------- Status block ---------- */

.status-block {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  padding: clamp(1.35rem, 3vw, 2.25rem);
}

.status-block__grid {
  display: grid;
  gap: 0 2rem;
  margin-top: 1.35rem;
  border-top: 1px solid var(--line);
}

.status-row {
  display: grid;
  gap: 0.2rem 1.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}

@media (min-width: 44rem) {
  .status-row {
    grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
  }
}

.status-row__key {
  font: 500 0.75rem/1.5 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.status-row__value {
  margin: 0;
}

.status-row__value--no {
  color: var(--fg-muted);
}

/* ---------- Timeline ---------- */

.timeline {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.timeline__item {
  display: grid;
  gap: 0.35rem 2rem;
  padding: 1.3rem 0;
  border-bottom: 1px solid var(--line);
  position: relative;
}

@media (min-width: 48rem) {
  .timeline__item {
    grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
  }
}

.timeline__when {
  font: 500 0.75rem/1.6 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.timeline__what {
  font-weight: 600;
  margin-bottom: 0.3rem;
}

/* ---------- Diagrams ---------- */

.figure {
  margin: 0;
}

.figure__frame {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-sunken);
  padding: clamp(1rem, 2.4vw, 1.75rem);
  overflow-x: auto;
}

.figure__frame > svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 20rem;
}

.figure figcaption {
  margin-top: 0.85rem;
  color: var(--fg-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.diagram-text {
  font-family: var(--font-sans);
  font-size: 13px;
  fill: var(--fg);
}

.diagram-text--mono {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  fill: var(--fg-dim);
}

.diagram-text--muted {
  fill: var(--fg-muted);
  font-size: 12px;
}

.diagram-node {
  fill: var(--surface);
  stroke: var(--line-strong);
  stroke-width: 1;
}

.diagram-node--accent {
  stroke: var(--accent);
}

.diagram-flow {
  stroke: var(--line-strong);
  stroke-width: 1.25;
  fill: none;
}

.diagram-flow--accent {
  stroke: var(--accent);
}

.diagram-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 1rem;
  font: 500 0.75rem/1.4 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.diagram-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.diagram-legend li::before {
  content: "";
  width: 10px;
  height: 3px;
  border-radius: 1px;
  background: var(--stage-color, var(--fg-dim));
}

/* ---------- Diagram: process rail ---------- */

.rail {
  display: grid;
}

.rail__item {
  position: relative;
  padding-left: 3rem;
  padding-bottom: 1.6rem;
}

.rail__item:last-child {
  padding-bottom: 0;
}

.rail__item::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 1.85rem;
  bottom: -0.35rem;
  width: 1px;
  background: var(--line-strong);
}

.rail__item:last-child::before {
  display: none;
}

.rail__item::after {
  content: "";
  position: absolute;
  left: 1px;
  top: 0.42rem;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  border: 2px solid var(--stage-color, var(--line-strong));
  background: var(--bg);
}

.rail__item--filled::after {
  background: var(--stage-color, var(--line-strong));
}

.rail__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
}

.rail__index {
  font: 500 0.75rem/1.6 var(--font-mono);
  letter-spacing: 0.12em;
  color: var(--stage-color, var(--fg-dim));
}

.rail__title {
  font-weight: 600;
  letter-spacing: -0.012em;
}

.rail__body {
  margin-top: 0.35rem;
  color: var(--fg-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
  max-width: 62ch;
}

.rail__note {
  margin-top: 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: 500 0.6875rem/1.4 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stage-color, var(--fg-dim));
}

/* ---------- Diagram: layered architecture ---------- */

.layers {
  display: grid;
  gap: 0.4rem;
}

.layer {
  border: 1px solid var(--line);
  border-left: 3px solid var(--stage-color, var(--line-strong));
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  display: grid;
  gap: 0.2rem 1.5rem;
}

@media (min-width: 46rem) {
  .layer {
    grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
    align-items: baseline;
  }
}

.layer__name {
  font-weight: 600;
  letter-spacing: -0.012em;
}

.layer__role {
  color: var(--fg-muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.layer--boundary {
  border-left-color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-quiet);
}

.layer--boundary .layer__name {
  color: var(--accent);
}

.layer-gap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0 0.4rem 0.35rem;
  font: 500 0.6875rem/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.layer-gap::before {
  content: "";
  width: 3px;
  height: 22px;
  border-radius: 2px;
  background: var(--line-strong);
  flex: 0 0 auto;
}

/* ---------- Diagram: escalation ladder ---------- */

.ladder {
  border-top: 1px solid var(--line);
  counter-reset: rung;
}

.ladder__item {
  counter-increment: rung;
  display: grid;
  gap: 0.2rem 1.25rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}

@media (min-width: 44rem) {
  .ladder__item {
    grid-template-columns: 2.5rem minmax(0, 17rem) minmax(0, 1fr) auto;
  }
}

.ladder__index {
  font: 500 0.75rem/1.7 var(--font-mono);
  letter-spacing: 0.1em;
  color: var(--accent);
}

.ladder__name {
  font-weight: 600;
}

.ladder__note {
  color: var(--fg-muted);
  font-size: 0.9375rem;
}

.ladder__cost {
  font: 500 0.6875rem/1.6 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  white-space: nowrap;
}

/* ---------- Diagram: environments ---------- */

.env-grid {
  display: grid;
  gap: 1rem;
  align-items: stretch;
}

@media (min-width: 58rem) {
  .env-grid {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0;
  }
}

.env-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 1.25rem 1.35rem 1.5rem;
}

.env-panel__title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.env-panel__where {
  font: 500 0.6875rem/1.4 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.env-panel ul {
  display: grid;
  gap: 0.45rem;
  margin-top: 1rem;
  font-size: 0.9375rem;
}

.env-panel li {
  position: relative;
  padding-left: 1.15rem;
  color: var(--fg-muted);
}

.env-panel li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--line-strong);
}

.env-link {
  display: grid;
  place-items: center;
  gap: 0.6rem;
  padding: 1rem;
  text-align: center;
}

.env-link__label {
  font: 500 0.6875rem/1.5 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  max-width: 12rem;
}

.env-link__bar {
  width: 100%;
  height: 1px;
  background: var(--line-strong);
  position: relative;
}

@media (min-width: 58rem) {
  .env-link {
    padding: 1rem 1.25rem;
    min-width: 11rem;
  }
}

/* ---------- Diagram: comparison ---------- */

.compare {
  display: grid;
  gap: 1rem;
}

@media (min-width: 50rem) {
  .compare {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.compare__col {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.4rem 1.6rem;
  background: var(--surface);
}

.compare__col--ours {
  border-color: var(--accent-line);
}

.compare__label {
  font: 600 0.6875rem/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 0.8rem;
}

.compare__col--ours .compare__label {
  color: var(--accent);
}

.compare__list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.1rem;
  font-size: 0.9375rem;
}

.compare__list li {
  position: relative;
  padding-left: 1.5rem;
  color: var(--fg-muted);
}

.compare__list li::before {
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.85;
}

.compare__col--theirs .compare__list li::before {
  content: "×";
  color: var(--halt);
}

.compare__col--ours .compare__list li::before {
  content: "→";
  color: var(--verify);
}

/* ---------- Code ---------- */

.code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.75;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  color: var(--fg-muted);
  white-space: pre;
  tab-size: 2;
}

.code b {
  color: var(--fg);
  font-weight: 500;
}

.code i {
  color: var(--accent);
  font-style: normal;
}

@media (max-width: 30rem) {
  .code {
    font-size: 0.75rem;
    padding: 0.9rem 1rem;
  }
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.08em 0.32em;
}

/* ---------- Q&A ---------- */

.qa {
  border-top: 1px solid var(--line);
}

.qa__item {
  border-bottom: 1px solid var(--line);
  padding: 1.5rem 0;
}

.qa__q {
  margin-bottom: 0.6rem;
}

/* ---------- Contact cards ---------- */

.contact-card {
  display: grid;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  height: 100%;
}

.contact-card__address {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  word-break: break-word;
}

.contact-card__address--lead {
  font-size: clamp(1.05rem, 0.95rem + 0.6vw, 1.35rem);
  letter-spacing: -0.01em;
  margin-block: 0.35rem 0.5rem;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-sunken);
  padding-block: clamp(3rem, 6vw, 4.5rem) 2rem;
  margin-top: 0;
}

.site-footer__top {
  display: grid;
  gap: clamp(2rem, 5vw, 3rem);
}

@media (min-width: 60rem) {
  .site-footer__top {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 2.4fr);
  }
}

.footer-nav {
  display: grid;
  gap: 2rem 1.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 48rem) {
  .footer-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.footer-nav h2 {
  font: 600 0.6875rem/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 1rem;
}

.footer-nav ul {
  display: grid;
  gap: 0.6rem;
}

.footer-nav a {
  font-size: 0.9375rem;
  color: var(--fg-muted);
  text-decoration: none;
}

.footer-nav a:hover {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
}

.site-footer__legal {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 1rem;
}

@media (min-width: 60rem) {
  .site-footer__legal {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }
}

.owner-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.6rem;
}

/* ---------- Page header block ---------- */

.page-head {
  padding-block: clamp(3rem, 7vw, 5rem) clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}

.page-head::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 100% 88px;
  mask-image: linear-gradient(to bottom, #000, transparent);
  opacity: 0.5;
}

.page-head__inner {
  position: relative;
}

.page-head__title {
  margin-top: 1rem;
  max-width: 20ch;
}

.page-head__lead {
  margin-top: 1.25rem;
  max-width: 62ch;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font: 500 0.75rem/1.4 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.breadcrumbs a {
  color: var(--fg-dim);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--accent);
}

/* ---------- On-page contents ---------- */

.toc {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  background: var(--surface);
}

.toc h2 {
  font: 600 0.6875rem/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 0.9rem;
}

.toc ol {
  display: grid;
  gap: 0.55rem;
  counter-reset: toc;
}

.toc li {
  counter-increment: toc;
}

.toc a {
  font-size: 0.9375rem;
  color: var(--fg-muted);
  text-decoration: none;
  display: flex;
  gap: 0.7rem;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  font: 500 0.6875rem/1.75 var(--font-mono);
  color: var(--accent);
  flex: 0 0 auto;
}

.toc a:hover {
  color: var(--fg);
}

/* ---------- Prose (legal pages) ---------- */

.prose {
  max-width: 70ch;
}

.prose h2 {
  font-size: clamp(1.3rem, 1.15rem + 0.6vw, 1.6rem);
  margin-top: 2.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.prose h3 {
  margin-top: 1.9rem;
}

.prose h2 + p,
.prose h3 + p {
  margin-top: 0.85rem;
}

.prose p + p,
.prose p + ul,
.prose ul + p,
.prose p + ol,
.prose ol + p {
  margin-top: 1rem;
}

.prose ul {
  display: grid;
  gap: 0.55rem;
}

.prose ul li {
  position: relative;
  padding-left: 1.3rem;
}

.prose ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.66em;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--line-strong);
}

.prose ol {
  display: grid;
  gap: 0.55rem;
  counter-reset: prose;
}

.prose ol li {
  counter-increment: prose;
  position: relative;
  padding-left: 2rem;
}

.prose ol li::before {
  content: counter(prose) ".";
  position: absolute;
  left: 0;
  top: 0;
  font: 500 0.875rem/1.75 var(--font-mono);
  color: var(--accent);
}

/* ---------- 404 ---------- */

.notfound {
  min-height: 58vh;
  display: grid;
  align-content: center;
  padding-block: clamp(3rem, 10vw, 7rem);
}

.notfound__code {
  font: 600 clamp(3.5rem, 12vw, 7rem) / 0.9 var(--font-mono);
  letter-spacing: -0.04em;
  color: var(--accent);
}

/* ---------- Spacing and width utilities ----------
   The content security policy forbids inline styles (style-src 'self'), so
   every spacing adjustment in the markup is a class. This is not a preference:
   an inline style attribute is silently dropped by the browser under this
   policy, which is exactly the kind of divergence the policy is meant to expose.
   ------------------------------------------------ */

.mt-1 {
  margin-top: 0.35rem;
}
.mt-2 {
  margin-top: 0.7rem;
}
.mt-3 {
  margin-top: 0.95rem;
}
.mt-4 {
  margin-top: 1.25rem;
}
.mt-5 {
  margin-top: 1.6rem;
}
.mt-6 {
  margin-top: 2rem;
}
.mt-7 {
  margin-top: 2.6rem;
}

.mb-1 {
  margin-bottom: 0.35rem;
}
.mb-2 {
  margin-bottom: 0.7rem;
}
.mb-3 {
  margin-bottom: 0.95rem;
}
.mb-4 {
  margin-bottom: 1.25rem;
}

.mw-18 {
  max-width: 18ch;
}
.mw-34 {
  max-width: 34ch;
}
.mw-52 {
  max-width: 52ch;
}
.mw-62 {
  max-width: 62ch;
}
.mw-70 {
  max-width: 70ch;
}
.mw-74 {
  max-width: 74ch;
}

.as-grid {
  display: grid;
}

/* ---------- Utilities ---------- */

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

.rule {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  font: 500 0.6875rem/1.3 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.tag--planned {
  border-color: var(--accent-line);
  color: var(--accent);
}

.tag--not-built {
  border-color: var(--line-strong);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  .hero__inner > * {
    animation: rise 620ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
  }
  .hero__inner > *:nth-child(2) {
    animation-delay: 90ms;
  }
  .accent-sweep {
    background-image: linear-gradient(
      90deg,
      transparent 0%,
      var(--accent) 22%,
      var(--accent) 78%,
      transparent 100%
    );
    background-size: 220% 100%;
    animation: sweep 7s ease-in-out infinite;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes sweep {
  0%,
  100% {
    background-position: 100% 0;
  }
  50% {
    background-position: 0 0;
  }
}

.accent-sweep {
  height: 2px;
  width: 100%;
  background: var(--accent);
  opacity: 0.85;
}

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

/* ---------- Print ---------- */

@media print {
  .site-header,
  .site-footer,
  .nav-mobile,
  .skip-link {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
}
