:root {
  /* Light is the default because the page is documentation first. The dark block below is a
     comfort setting, not a second brand: it re-points the same six tokens and nothing else. */
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #141414;
  --lede: #333333;
  --muted: #666666;
  --line: #dedede;
  --soft: #f7f7f7;
  --accent: #111111;
  --on-accent: #ffffff;
  --screen: #0b1320;
  --max: 920px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --text: #e7e9ec;
    --lede: #c4c9d0;
    --muted: #949aa4;
    --line: #2b2f36;
    --soft: #171a1f;
    --accent: #e7e9ec;
    --on-accent: #0f1114;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  font-size: 16px;
  line-height: 1.65;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

code,
pre,
.formula,
.label,
table {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

code {
  padding: 0.1rem 0.28rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--soft);
  font-size: 0.92em;
}

pre {
  margin: 1rem 0 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  line-height: 1.55;
}

pre code {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.9rem;
}

.shell {
  width: min(calc(100% - 2rem), var(--max));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--text);
  background: var(--bg);
  transform: translateY(-200%);
}

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

.site-header {
  border-bottom: 1px solid var(--line);
}

.nav {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.25rem;
  font-size: 0.92rem;
}

main > section {
  padding: 4rem 0;
  border-bottom: 1px solid var(--line);
}

.hero {
  padding-top: 5.5rem;
}

.label {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

h1 {
  max-width: 760px;
  font-size: clamp(2.6rem, 8vw, 5rem);
}

h2 {
  margin-bottom: 1.35rem;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

p {
  max-width: 760px;
}

.lede {
  margin: 1.5rem 0 0;
  max-width: 720px;
  color: var(--lede);
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 2rem;
  align-items: center;
}

.actions a {
  font-weight: 700;
}

.actions .primary {
  display: inline-block;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--accent);
  color: var(--on-accent);
  text-decoration: none;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.steps li {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(240px, 1.5fr);
  gap: 1.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.steps span {
  color: var(--muted);
}

.formula {
  margin-top: 1.5rem;
  padding: 0.8rem 1rem;
  border-left: 3px solid var(--text);
  background: var(--soft);
  overflow-x: auto;
  white-space: nowrap;
}

.plain-list {
  margin: 0;
  padding-left: 1.25rem;
}

.plain-list li + li {
  margin-top: 0.65rem;
}

.walkthrough {
  margin: 1.5rem 0 0;
}

/* Twelve labelled stages do not survive being scaled to a phone, so the drawing keeps a legible
   width and pans sideways -- the same container the sandbox table uses. */
.walkthrough .pan {
  margin-top: 0;
}

/* The drawing is authored on its own dark ground, so it keeps that ground in both themes
   rather than becoming a bright slab on a dark page. */
.walkthrough img {
  display: block;
  width: 100%;
  min-width: 680px;
  height: auto;
  background: var(--screen);
}

.walkthrough figcaption {
  max-width: 760px;
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.table-wrap,
.pan {
  margin-top: 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

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

th {
  background: var(--soft);
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

table code {
  border: 0;
  background: transparent;
  padding: 0;
}

.note {
  max-width: 780px;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 2rem;
  max-width: 520px;
  padding-left: 1.1rem;
}

footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  padding-block: 2rem 3rem;
  color: var(--muted);
  font-size: 0.88rem;
}

/* 404 only: the same shell, held in the middle of the viewport instead of scrolling. */
.not-found {
  display: flex;
  align-items: center;
  min-height: calc(100dvh - 64px);
  padding-block: 3rem;
}

.not-found > section {
  border-bottom: 0;
  padding: 0;
}

@media (max-width: 680px) {
  .nav {
    align-items: flex-start;
    flex-direction: column;
    padding-block: 1rem;
  }

  .nav nav {
    gap: 0.55rem 1rem;
  }

  main > section {
    padding: 3rem 0;
  }

  .hero {
    padding-top: 4rem;
  }

  .steps li {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .links {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
