/* armless site. Dark, one typeface, state by brightness, colour only for failure.
   Space Mono throughout (SIL OFL, self-hosted). */

@font-face { font-family: "Space Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/SpaceMono-400.woff2") format("woff2"); }
@font-face { font-family: "Space Mono"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/SpaceMono-700.woff2") format("woff2"); }

:root {
  --ground:  oklch(0.13 0.008 70);
  --surface: oklch(0.17 0.009 70);
  --raised:  oklch(0.23 0.009 70);
  --line:    oklch(0.28 0.010 70);
  --edge:    oklch(0.36 0.010 70);

  --text:    oklch(0.96 0.012 70);
  --muted:   oklch(0.74 0.010 70);
  --faint:   oklch(0.66 0.009 70);
  --error:   oklch(0.66 0.17 28);

  --console: oklch(0.1 0.008 70);
  --console-ink: oklch(0.93 0.012 70);
  --console-select: oklch(0.34 0.012 70);

  --mono: "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(1.1rem, 4vw, 2.5rem);
  color-scheme: dark;
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--text);
  font: 400 0.9375rem/1.7 var(--mono);
  caret-color: var(--text);
}
::selection { background: var(--edge); color: var(--text); }
a { color: var(--text); text-underline-offset: 0.2em; text-decoration-thickness: 1px; text-decoration-color: var(--edge); transition: text-decoration-color 150ms var(--out); }
a:hover { text-decoration-color: var(--text); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
code { font: inherit; font-size: 0.93em; background: var(--raised); padding: 0 0.25em; overflow-wrap: break-word; }
code.nw { white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
button { font: inherit; }

.skip { position: absolute; left: 0.5rem; top: -4rem; z-index: 20; background: var(--text); color: var(--ground); padding: 0.6rem 1rem; }
.skip:focus { top: 0.5rem; }

/* Buttons: stable size, quiet until pointed at */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.25rem;
  padding: 0.25rem 0.9rem; background: none; border: 1px solid transparent; color: var(--faint);
  font: inherit; font-size: 0.875rem; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: color 150ms var(--out), background 150ms var(--out), border-color 150ms var(--out);
}
.btn:hover { color: var(--text); background: var(--raised); }
.btn-primary { background: var(--text); color: var(--ground); border-color: var(--text); font-weight: 700; }
.btn-primary:hover { background: var(--muted); border-color: var(--muted); color: var(--ground); }
a.btn:not(.btn-primary) { border-color: var(--line); color: var(--muted); }
@media (max-width: 46rem) { .btn { min-height: 2.75rem; } }

/* Top bar */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 80rem; margin: 0 auto; padding: 1.1rem var(--gutter); }
.name { font-weight: 700; text-decoration: none; letter-spacing: 0.02em; }
.bar nav, .foot nav { display: flex; gap: 1.4rem; }
.bar nav a, .foot nav a { color: var(--faint); text-decoration: none; padding: 0.4rem 0; font-size: 0.875rem; }
.bar nav a:hover, .foot nav a:hover, .bar nav a[aria-current] { color: var(--text); }
.bar nav a[aria-current] { text-decoration: underline; text-decoration-color: var(--edge); text-underline-offset: 0.35em; }

.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.8rem 2rem; max-width: 80rem; margin: 0 auto; padding: 2rem var(--gutter) 3rem; border-top: 1px solid var(--line); color: var(--faint); font-size: 0.8125rem; }
.foot a { color: var(--muted); }

/* ===== Landing ===== */
.hero { max-width: 80rem; margin: 0 auto; padding: clamp(2.5rem, 6vw, 4.5rem) var(--gutter) clamp(2rem, 4vw, 3rem); }
.hero h1 { margin: 0; font: 700 clamp(2.2rem, 1.2rem + 4.6vw, 4.6rem)/1.04 var(--mono); letter-spacing: -0.03em; text-wrap: balance; }
.sub { margin: 1.5rem 0 0; max-width: 46ch; color: var(--muted); font-size: 1.0625rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 2rem 0 0; }

.machine { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; max-width: calc(80rem - 2 * var(--gutter)); margin: 0 auto; border: 1px solid var(--line); background: var(--line); width: calc(100% - 2 * var(--gutter)); }
@media (min-width: 64rem) { .machine { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.pane { background: var(--ground); display: flex; flex-direction: column; min-width: 0; }
.pane-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 0.2rem 1rem; min-height: 2.6rem; padding: 0.15rem 0.5rem 0.15rem 1rem; border-bottom: 1px solid var(--line); font-size: 0.8125rem; color: var(--faint); }
.pane-name { color: var(--text); }
.pane-note { color: var(--faint); }
.pane-bar .end { margin-left: auto; padding-right: 0.5rem; }
.keys { display: flex; flex-wrap: wrap; margin-left: auto; }
.keys + .end { margin-left: 0; }
.keys .btn { min-height: 2rem; padding: 0.1rem 0.6rem; font-size: 0.8125rem; }
@media (max-width: 46rem) {
  .keys { order: 3; width: 100%; margin: 0 0 0 -0.6rem; }
  .keys .btn { min-height: 2.75rem; }
  .pane-bar .end, .keys + .end { margin-left: auto; }
}

#status::before { content: ""; display: inline-block; width: 0.5rem; height: 0.5rem; margin-right: 0.5rem; border: 1px solid var(--faint); border-radius: 50%; vertical-align: 0.02em; }
#status[data-state="ready"]::before { background: var(--text); border-color: var(--text); }
#status[data-state="error"]::before, #status[data-state="stopped"]::before { background: var(--error); border-color: var(--error); }

.console { background: var(--console); color: var(--console-ink); padding: 0.8rem 0.5rem 0.5rem 1rem; flex: 1; min-height: 28rem; display: flex; flex-direction: column; }
#terminal { flex: 1; min-height: 26rem; }
.console .xterm { padding: 0; }
.console:focus-within { outline: 2px solid var(--text); outline-offset: -2px; }
.console .xterm-viewport { background: transparent !important; }
.fallback { margin: 0.5rem 0; color: var(--muted); font-size: 0.875rem; }
.fallback .btn { margin-left: 0.5rem; border-color: var(--line); color: var(--muted); }

.memory { padding: 1.25rem 1rem 1.5rem; }
.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem 1.5rem; margin: 0 0 1.75rem; }
.figures > div { margin: 0; }
.figures .wide { grid-column: 1 / -1; }
.figures dt { font-size: 0.75rem; color: var(--faint); }
.figures dd { margin: 0.15rem 0 0; font-size: 1.5rem; line-height: 1.2; font-variant-numeric: tabular-nums; font-weight: 700; }
.figures dd small { margin-left: 0.4rem; font-size: 0.75rem; font-weight: 400; color: var(--faint); }
.figures .wide dd:first-of-type { font-size: 2.4rem; letter-spacing: -0.02em; }
.figures dd.note { margin-top: 0.2rem; font-size: 0.75rem; font-weight: 400; color: var(--faint); }
.chart { margin: 0; }
.chart svg { display: block; width: 100%; height: auto; }
.chart figcaption { margin-top: 0.6rem; font-size: 0.75rem; color: var(--faint); }
.chart .key { display: inline-block; width: 1.2rem; height: 0; vertical-align: middle; margin: 0 0.4rem 0 0.8rem; border-top: 2px solid var(--text); }
.chart .key:first-child { margin-left: 0; }
.chart .key.peak { border-top: 2px dashed var(--faint); }
svg .grid { stroke: var(--line); stroke-width: 1; }
svg .axis { font: 400 13px var(--mono); fill: var(--faint); }
svg .live { fill: none; stroke: var(--text); stroke-width: 1.75; }
svg .peak { fill: none; stroke: var(--faint); stroke-width: 1.25; stroke-dasharray: 4 4; }

.caption { max-width: 80rem; margin: 0.9rem auto 0; padding: 0 var(--gutter); color: var(--muted); font-size: 0.875rem; }

.embed { max-width: 80rem; margin: 0 auto; padding: clamp(3rem, 8vw, 6rem) var(--gutter) clamp(3rem, 8vw, 5rem); }
.embed h2 { margin: 0 0 1.2rem; font-size: 1.125rem; font-weight: 700; letter-spacing: -0.01em; }
.embed pre { max-width: 58rem; }
.embed p { margin: 1.2rem 0 0; font-size: 0.875rem; }

pre {
  font-family: var(--mono);
  margin: 1.2rem 0; padding: 1rem 1.2rem; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  font-size: 0.8125rem; line-height: 1.7; tab-size: 2;
}
pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; white-space: pre; }
.code { position: relative; margin: 1.2rem 0; }
.code pre { margin: 0; padding-right: 5rem; }
.embed .code { max-width: 58rem; }
.copy { position: absolute; top: 0.4rem; right: 0.4rem; min-height: 2rem; padding: 0.1rem 0.6rem; font-size: 0.75rem; background: var(--surface); }
@media (max-width: 46rem) { .copy { min-height: 2.75rem; } }

/* ===== Docs ===== */
.shell { display: block; max-width: 80rem; margin: 0 auto; padding: 0 var(--gutter); }
@media (min-width: 52rem) { .shell { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 0 3rem; align-items: start; } }
@media (min-width: 76rem) { .shell:has(.toc) { grid-template-columns: 13rem minmax(0, 1fr) 13rem; } }

.side { display: none; }
.pages-m, .toc-m { margin: 0 0 1.5rem; border: 1px solid var(--line); }
.pages-m summary, .toc-m summary { cursor: pointer; padding: 0.6rem 0.9rem; min-height: 2.75rem; font-size: 0.8125rem; color: var(--muted); list-style: none; }
.pages-m summary::-webkit-details-marker, .toc-m summary::-webkit-details-marker { display: none; }
.pages-m summary::before, .toc-m summary::before { content: "+ "; color: var(--faint); }
.pages-m[open] summary::before, .toc-m[open] summary::before { content: "- "; }
.pages-m summary span { color: var(--text); }
.pages-m nav, .toc-m ul { padding: 0 0.9rem 0.9rem; }
.pages-m .nav-group:first-child { margin-top: 0.2rem; }
.pages-m a, .toc-m a { display: block; padding: 0.55rem 0; color: var(--faint); text-decoration: none; font-size: 0.875rem; }
.pages-m a[aria-current="page"] { color: var(--text); text-decoration: underline; text-decoration-color: var(--edge); text-underline-offset: 0.35em; }
.toc-m ul { list-style: none; margin: 0; }
.toc-m .l3 a { padding-left: 1rem; }
.pages-m { margin-top: 0.5rem; }
@media (min-width: 52rem) { .side { display: block; } .pages-m { display: none; } }
@media (min-width: 76rem) { .toc-m { display: none; } }
@media (min-width: 52rem) { .side { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1rem 0; } }
.side ul, .toc ul { list-style: none; margin: 0; padding: 0; }
.nav-group { margin: 1.6rem 0 0.3rem; font-size: 0.75rem; color: var(--faint); }
.side > .nav-group:first-child { margin-top: 0; }
.side a, .toc a { display: block; padding: 0.25rem 0; color: var(--faint); text-decoration: none; font-size: 0.8125rem; line-height: 1.4; }
.side a:hover, .toc a:hover { color: var(--text); }
.side a[aria-current="page"] { color: var(--text); text-decoration: underline; text-decoration-color: var(--edge); text-underline-offset: 0.35em; }
.toc { display: none; }
@media (min-width: 76rem) { .toc { display: block; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1rem 0; } .toc .nav-group { margin-top: 0; } }
.toc .l3 a { padding-left: 1rem; }

.doc { padding: 1rem 0 3rem; min-width: 0; }
.doc h1 { margin: 0 0 1.8rem; font: 700 clamp(1.8rem, 1.2rem + 2.2vw, 2.6rem)/1.1 var(--mono); letter-spacing: -0.03em; text-wrap: balance; }
.prose { max-width: 50rem; }
.prose > p, .prose > ul, .prose > ol { max-width: 70ch; }
.prose p { margin: 0 0 1.1rem; }
.prose h2 { margin: 3rem 0 0.8rem; font: 700 1.25rem/1.3 var(--mono); letter-spacing: -0.02em; text-wrap: balance; }
.prose h3 { margin: 2.2rem 0 0.6rem; font: 700 1rem/1.4 var(--mono); }
.prose h2, .prose h3 { scroll-margin-top: 1.5rem; }
.prose ul, .prose ol { padding-left: 1.4rem; margin: 0 0 1.1rem; }
.prose li { margin-bottom: 0.5rem; padding-left: 0.2rem; }
.prose li::marker { color: var(--faint); }
.prose li > p { margin-bottom: 0.5rem; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
.prose strong { font-weight: 700; }
.prose blockquote { margin: 1.2rem 0; padding: 0 0 0 1rem; color: var(--muted); border-left: 1px solid var(--edge); }
.prose h3 code { background: none; padding: 0; }
.prose a { text-decoration-color: var(--faint); }
.anchor { margin-left: 0.5em; font-weight: 400; text-decoration: none; color: var(--faint); opacity: 0.5; }
@media (hover: hover) { .anchor { opacity: 0; } h2:hover .anchor, h3:hover .anchor, .anchor:focus-visible { opacity: 1; } }

.table-wrap { overflow-x: auto; margin: 1.2rem 0 1.6rem; border: 1px solid var(--line); }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 0.8125rem; line-height: 1.6; }
.prose th { text-align: left; font-weight: 400; color: var(--faint); padding: 0.6rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.prose td { vertical-align: top; padding: 0.65rem 1rem; border-bottom: 1px solid var(--line); }
.prose tr:last-child td { border-bottom: 0; }
.prose td:first-child, .prose td:first-child code { white-space: nowrap; }
.prose td:not(:first-child) { min-width: 12rem; }
.prose td code { background: var(--raised); }
.prose tr:target td { background: var(--surface); }
.prose tr[id] { scroll-margin-top: 1.5rem; }

.pager { display: flex; justify-content: space-between; gap: 1.5rem; margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); max-width: 70ch; }
.pager a { display: flex; flex-direction: column; gap: 0.15rem; text-decoration: none; }
.pager .next { align-items: flex-end; text-align: right; margin-left: auto; }
.pager .dir { font-size: 0.75rem; color: var(--faint); }
.pager-title { font-weight: 700; }
.pager a:hover .pager-title { text-decoration: underline; text-decoration-color: var(--edge); text-underline-offset: 0.2em; }
.edit { margin: 1.5rem 0 0; font-size: 0.75rem; color: var(--faint); }
.edit a { color: var(--faint); }

.lost-body { max-width: 40rem; margin: 3rem auto; padding: 0 var(--gutter); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) { .btn, pre, .table-wrap, .machine { border: 1px solid CanvasText; } }
@media print {
  .bar, .side, .toc, .pager, .skip, .machine, .foot { display: none; }
  body { background: #fff; color: #000; }
  pre { background: #fff; border: 1px solid #999; color: #000; }
}

/* Per-CPU bars in the machine pane */
.cpus { list-style: none; margin: 0 0 1.5rem; padding: 0; display: grid; gap: 0.45rem; }
.cpus li { display: grid; grid-template-columns: 3rem minmax(0, 1fr) 6.5rem; align-items: center; gap: 0.75rem; font-size: 0.75rem; color: var(--faint); }
.cpu-bar { height: 0.55rem; background: var(--raised); }
.cpu-bar span { display: block; height: 100%; width: 0; background: var(--text); transition: width 400ms var(--out); }
.cpu-rate { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .cpu-bar span { transition: none; } }
