:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1b1d1f;
  --muted: #5f6368;
  --line: #dcd9d1;
  --accent: #0b6b3a;
  --accent-ink: #ffffff;
  --bits-map: #11883a;
  --bits-pixel: #d1242f;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wide: 1180px;
  --text: 42rem;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121416;
    --surface: #1a1d20;
    --ink: #e8e6e1;
    --muted: #9aa0a6;
    --line: #2d3236;
    --accent: #4cc38a;
    --accent-ink: #0c1a12;
    --bits-map: #3ddc68;
    --bits-pixel: #ff6b6b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.65 var(--sans);
}
img, video, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.stripe { width: 100%; height: 6px; }

/* ---------- site header / footer ---------- */
header.site {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 18px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .02em;
  color: var(--ink);
  text-decoration: none;
}
nav.parts { display: flex; flex-wrap: wrap; gap: 6px; }
nav.parts a {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.2;
}
nav.parts a:hover { color: var(--ink); border-color: var(--muted); }
nav.parts a[aria-current="page"] { color: var(--ink); border-color: var(--accent); }
nav.parts .n {
  font-family: var(--mono); font-size: 12px;
  width: 20px; height: 20px; display: grid; place-items: center;
  border-radius: 4px; background: var(--line); color: var(--ink);
}
nav.parts a[aria-current="page"] .n { background: var(--accent); color: var(--accent-ink); }
@media (max-width: 720px) { nav.parts .t { display: none; } nav.parts a { padding: 5px; } }

footer.site {
  max-width: var(--wide);
  margin: 64px auto 0;
  padding: 24px 16px 48px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}
footer.site p { margin: 0 0 6px; }

.kicker {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}

/* ---------- home ---------- */
.home { max-width: var(--wide); margin: 0 auto; padding: 0 16px; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 48px;
  align-items: center;
  padding: 56px 0 40px;
}
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); line-height: 1.1; margin: 0 0 18px; letter-spacing: -.02em; }
.lede { font-size: 1.15rem; color: var(--muted); margin: 0 0 24px; }
.hero-img { margin: 0; }
.hero-img img { border-radius: 10px; width: 100%; }
.button {
  display: inline-block; padding: 10px 18px; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 600;
}
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 32px; } }

.home h2 { font-size: 1.4rem; margin: 0 0 18px; letter-spacing: -.01em; }
.specs { padding: 32px 0; border-top: 1px solid var(--line); }
.specs dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
  gap: 1px;
}
.specs dl div { background: var(--surface); padding: 14px 16px; }
.specs dt { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.specs dd { margin: 2px 0 0; font-weight: 600; }

.parts-list { padding: 32px 0; border-top: 1px solid var(--line); }
.cards {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 16px;
}
.card {
  display: flex; flex-direction: column; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  color: var(--ink); text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.card .meta { font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 14px 16px 0; text-transform: uppercase; letter-spacing: .04em; }
.card .title { font-weight: 700; font-size: 1.1rem; padding: 4px 16px 0; }
.card .sum { color: var(--muted); font-size: 15px; padding: 6px 16px 18px; line-height: 1.5; }

.about {
  padding: 32px 0 0; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 48px; align-items: start;
}
.about p { max-width: var(--text); }
.palette { margin: 0; }
.palette .grid { width: 100%; aspect-ratio: 1; border-radius: 8px; }
.palette figcaption { font-size: 14px; color: var(--muted); margin-top: 10px; }
@media (max-width: 820px) { .about { grid-template-columns: 1fr; gap: 24px; } .palette { max-width: 360px; } }

/* ---------- chapter ---------- */
.chapter { max-width: var(--wide); margin: 0 auto; padding: 0 16px; }
.chapter-head { padding: 48px 0 32px; max-width: 46rem; }
.chapter-head h1 { font-size: clamp(2rem, 4.5vw, 3rem); line-height: 1.1; margin: 0 0 16px; letter-spacing: -.02em; }
.chapter-head .lede { margin-bottom: 14px; }
.orig { font-size: 14px; color: var(--muted); margin: 0; font-style: italic; }

.chapter-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 56px;
  border-top: 1px solid var(--line);
  padding-top: 32px;
}
.toc { font-size: 14px; }
.toc details { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.toc summary {
  font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); cursor: pointer; margin-bottom: 8px;
}
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a { display: block; padding: 4px 0 4px 12px; color: var(--muted); text-decoration: none; line-height: 1.35; }
.toc li a:hover { color: var(--ink); }
@media (max-width: 900px) {
  .chapter-body { grid-template-columns: 1fr; gap: 24px; }
  .toc details { position: static; max-height: none; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; background: var(--surface); }
  .toc summary { margin: 0; }
  .toc details[open] summary { margin-bottom: 8px; }
}

.prose { max-width: 48rem; min-width: 0; }
.prose > p, .prose > ul, .prose > ol { max-width: var(--text); }
.prose p { margin: 0 0 1em; }
.prose h2 {
  font-size: 1.5rem; line-height: 1.25; letter-spacing: -.01em;
  margin: 2.2em 0 .6em; padding-top: .6em; border-top: 1px solid var(--line);
}
.prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h3 { font-size: 1.15rem; margin: 1.8em 0 .5em; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1em; }
.prose li { margin: .2em 0; }
.prose code { font-family: var(--mono); font-size: .9em; }
.prose .bits { font-weight: 600; }
.prose .bits-map { color: var(--bits-map); }
.prose .bits-pixel { color: var(--bits-pixel); }

.prose figure { margin: 1.4em 0 1.6em; }
.prose figure.img img, .prose figure.video video {
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
}
.prose figure.img.tall img { max-height: 640px; width: auto; }
.prose figcaption { font-size: 14px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.prose figure.video video { width: 100%; background: #000; }
.prose .gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 1.4em 0 1.6em; align-items: start; }
.prose .gallery figure { margin: 0; }
.prose .gallery figure.img.tall img { max-height: none; width: 100%; }
@media (max-width: 560px) { .prose .gallery { grid-template-columns: 1fr; } }
.zoom { display: block; cursor: zoom-in; width: fit-content; max-width: 100%; }

.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin: 56px 0 0; padding-top: 32px; border-top: 1px solid var(--line);
}
.pager a {
  display: block; padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600;
}
.pager a:hover { border-color: var(--accent); }
.pager a span { display: block; font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.pager .next { text-align: right; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager .next { text-align: left; } }

/* ---------- lightbox ---------- */
.lightbox {
  border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh; overflow: visible;
}
.lightbox::backdrop { background: rgba(0, 0, 0, .88); }
.lightbox img { max-width: 96vw; max-height: 92vh; width: auto; border-radius: 6px; cursor: zoom-out; }
.lightbox button {
  position: fixed; top: 12px; right: 16px; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer;
}
