:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #18212b;
  --ink: #18212b;
  --paper: #f6f7f9;
  --panel: #ffffff;
  --card: #ffffff;
  --muted: #52616f;
  --border: #c9d1d9;
  --line: #c9d1d9;
  --accent: #075ea8;
  --blue: #075ea8;
  --red: #8b3f2b;
  --code: #eef2f6;
  --notice: #e8f3ff;
  --warning: #fff4d6;
  --soft: #e8f3ff;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 "Segoe UI", Arial, sans-serif; }
a { color: var(--accent); text-underline-offset: .14em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; height: auto; }
code, pre, kbd { font-family: "Cascadia Mono", Consolas, "Courier New", monospace; }
code { font-size: .94em; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: .75rem; z-index: 20; }
.skip:focus { left: 1rem; top: 1rem; }

.site-bar { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-bar-inner { width: min(1180px, calc(100% - 2rem)); margin: auto; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.site-name { color: var(--text); text-decoration: none; font-weight: 650; }
.site-links { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .9rem; }
.site-links a { text-decoration: none; }
.site-links a:hover { text-decoration: underline; }

h1, h2, h3 { color: var(--text); font-family: "Segoe UI", Arial, sans-serif; letter-spacing: normal; }
h1 { margin: 0 0 .45rem; max-width: none; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.15; }
h2 { margin: 0 0 1rem; max-width: none; font-size: 1.65rem; line-height: 1.25; }
h3 { margin: 1.8rem 0 .7rem; font-size: 1.16rem; line-height: 1.3; }
p, li { max-width: 72ch; }
.tagline, .dek { color: var(--muted); max-width: 68rem; margin: 0; font-size: 1rem; }
.page-context { color: var(--muted); margin: 0 0 .35rem; font-size: .9rem; }

.manual-page > header, .project-page > header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner, .manual-page .layout, .project-page .layout { width: min(1180px, calc(100% - 2rem)); margin: auto; }
.header-inner { padding: 1.75rem 0 1.4rem; }
.header-links { margin-top: .8rem; display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .9rem; }

.experiment-page > header {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 1.75rem max(1rem, calc((100vw - 1000px) / 2));
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.experiment-page > header p { color: var(--muted); max-width: 68rem; font-size: 1rem; }
.experiment-page > main { width: min(1000px, calc(100% - 2rem)); margin: auto; padding: 2rem 0 4rem; }
.experiment-page > footer { width: auto; max-width: none; margin: 0; padding: 1.5rem max(1rem, calc((100vw - 1000px) / 2)); border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); text-align: left; font-size: .85rem; }

.manual-page .layout, .project-page .layout { display: grid; grid-template-columns: 230px minmax(0, 780px); gap: 2.5rem; padding: 2rem 0 4rem; justify-content: center; }
.manual-page nav, .project-page .page-nav { position: sticky; top: 1rem; align-self: start; max-height: calc(100vh - 2rem); overflow: auto; }
.manual-page nav h2, .project-page .page-nav h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.manual-page nav ul, .project-page .page-nav ul { list-style: none; margin: 0; padding: 0; }
.manual-page nav a, .project-page .page-nav a { display: block; padding: .32rem 0; text-decoration: none; }
.manual-page main, .project-page main { min-width: 0; }
.manual-page main section, .project-page main section { scroll-margin-top: 1rem; margin: 0 0 3rem; padding: 0; }

.document-links { margin: 1rem 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
.document-links a { font-weight: 600; }
.quick-facts { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.quick-facts th, .quick-facts td { text-align: left; padding: .5rem .65rem; border: 1px solid var(--border); }
.quick-facts th { width: 10rem; background: var(--code); }

section { scroll-margin-top: 1rem; }
article.prose { max-width: 780px; }
.prose { max-width: 780px; }
.lede { display: block; padding: 0; border: 0; font: inherit; }
.lede p:first-child, p.lede { font: inherit; font-size: 1.05rem; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 2rem; align-items: start; }
.grid > *, .prose { min-width: 0; max-width: 100%; }
.side { position: sticky; top: 1rem; }
.card, .contents, .incident, .summary-copy, .result-card, .experiment, .item {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  box-shadow: none;
}
.card + .card { margin-top: 1rem; }
.card p, .card li { font-size: .92rem; }
.callout, .notice, .takeaway, .note {
  border: 0;
  border-left: 5px solid var(--accent);
  border-radius: 0;
  padding: .9rem 1rem;
  background: var(--notice);
  color: var(--text);
  margin: 1rem 0;
}
.warning { border-left: 5px solid #ad7600; padding: .9rem 1rem; background: var(--warning); margin: 1rem 0; }

table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; margin: 1rem 0; font-size: .94rem; }
th, td { border: 1px solid var(--border); padding: .65rem; text-align: left; vertical-align: top; }
th { background: var(--code); color: var(--text); font-size: .88rem; text-transform: none; letter-spacing: normal; }

pre { overflow: auto; padding: 1rem; background: var(--code); border: 1px solid var(--border); border-radius: 6px; margin: 0; }
.code-wrap { position: relative; margin: 1rem 0; }
.copy { position: absolute; right: .5rem; top: .5rem; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); padding: .35rem .6rem; cursor: pointer; }

blockquote { margin: 1.25rem 0; padding: .75rem 1rem; border-left: 5px solid var(--border); background: var(--surface); font: inherit; font-size: 1.05rem; }
blockquote footer { margin-top: .5rem; color: var(--muted); font: .88rem/1.4 "Segoe UI", Arial, sans-serif; }
figure { margin: 1.5rem 0; background: transparent; color: var(--text); }
figure img { display: block; width: 100%; border: 1px solid var(--border); border-radius: 4px; }
figcaption { padding: .5rem 0; color: var(--muted); font: .84rem/1.45 "Segoe UI", Arial, sans-serif; }

.tag, .time, .recovery, .label {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: .82rem/1.4 "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}
a.time { color: var(--accent); text-decoration: underline; }
.controls { display: flex; gap: .6rem 1rem; flex-wrap: wrap; align-items: end; margin: 1rem 0; padding: .8rem; border: 1px solid var(--border); background: var(--surface); }
.controls label { font-size: .9rem; }
.controls input, .controls select, .controls button, button {
  font: inherit;
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}
button { cursor: pointer; }
details { border: 1px solid var(--border); border-radius: 6px; padding: .75rem 1rem; margin: 1rem 0; background: var(--surface); }
summary { cursor: pointer; font-weight: 600; }
.small, .meta, .source-note { color: var(--muted); font-size: .88rem; }

.collection-page > header, .collection-page > main, .collection-page > footer { width: min(1000px, calc(100% - 2rem)); margin-inline: auto; }
.collection-page > header { padding: 1.75rem 0 1.4rem; border-bottom: 1px solid var(--border); }
.collection-page > main { padding: 2rem 0 4rem; }
.collection-page > footer { padding: 1.5rem 0 2.5rem; border-top: 1px solid var(--border); color: var(--muted); }
.collection { display: block; }
.collection .item { display: grid; grid-template-columns: 2rem 1fr; gap: .8rem; margin-bottom: .75rem; }
.collection .number { font: 600 .9rem/1.4 "Cascadia Mono", Consolas, monospace; color: var(--muted); }
.collection .kind { color: var(--muted); font-size: .78rem; text-transform: none; letter-spacing: 0; }
.collection .item h2 { margin: 0 0 .25rem; font-size: 1.15rem; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 0; margin: 1.25rem 0 0; border: 1px solid var(--border); background: var(--surface); }
.fact { padding: .65rem; border-right: 1px solid var(--border); }
.fact:last-child { border-right: 0; }
.fact strong { display: block; font: 600 1.15rem/1.2 "Segoe UI", Arial, sans-serif; }
.fact span { color: var(--muted); font-size: .8rem; }

.project-page .download { font-weight: 600; }
.project-page .status-table td:first-child { white-space: nowrap; font-weight: 600; }
.project-page .screenshot-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.project-page .screenshot-grid figure { margin: 0; }
.project-page .experiment-list { list-style: none; padding: 0; }
.project-page .experiment-list li { max-width: none; padding: .85rem 0; border-top: 1px solid var(--border); }
.project-page .experiment-list li:last-child { border-bottom: 1px solid var(--border); }
.project-page .experiment-list h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.project-page .experiment-list p { margin: .25rem 0; max-width: none; }
.project-page .result { color: var(--muted); font-size: .9rem; }

.article { max-width: 780px; margin: auto; }
.article section { margin-bottom: 2.5rem; }
.article h2 { margin-top: 2.5rem; }
.article .grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: .75rem; }
.incident { margin: 1rem 0; }
.takeaway { margin: 1.5rem 0; }
footer.page { margin-top: 2rem; padding: 1.5rem max(1rem, calc((100vw - 1000px) / 2)); background: var(--surface); color: var(--muted); text-align: left; border-top: 1px solid var(--border); }

@media (max-width: 820px) {
  .manual-page .layout, .project-page .layout { grid-template-columns: 1fr; }
  .manual-page nav, .project-page .page-nav { position: static; max-height: none; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
  .manual-page nav ul, .project-page .page-nav ul { columns: 2; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .screenshot-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .site-bar-inner { align-items: flex-start; padding: .65rem 0; }
  .site-links { gap: .35rem .75rem; justify-content: flex-end; }
  .header-inner, .manual-page .layout, .project-page .layout { width: min(100% - 1.25rem, 1180px); }
  .experiment-page > main, .collection-page > header, .collection-page > main, .collection-page > footer { width: min(100% - 1.25rem, 1000px); }
  .manual-page nav ul, .project-page .page-nav ul { columns: 1; }
  .facts { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .fact:nth-child(2) { border-right: 0; }
  .fact:nth-child(n+3) { border-top: 1px solid var(--border); }
  .project-page .screenshot-grid, .article .grid { grid-template-columns: 1fr; }
  h1 { font-size: 2rem; }
}

@media print {
  .site-bar, nav, .page-nav, .copy, .skip, .controls { display: none !important; }
  body { background: #fff; color: #000; }
  .manual-page .layout, .project-page .layout { display: block; width: 100%; }
  .experiment-page > main { width: 100%; }
  section { break-inside: avoid; }
  pre { white-space: pre-wrap; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
