/* Layout: Haynes handbook bones in a modern skin. Sticky chapter sidebar left, card sections right, one reading column. */
:root {
  --bg: #ffffff;
  --surface: #f5f6f7;      /* card fill, cool stone grey */
  --line: #dfe2e5;
  --ink: #1d2226;
  --ink-2: #545c63;
  --ink-3: #848b92;
  --accent: #2c6e8f;       /* links, active chapter, tips */
  --tip-bg: #eaf3f7;
  --tip-line: #2c6e8f;
  --warn-bg: #fdf1e3;
  --warn-line: #c46a12;
  --warn-ink: #8a4608;
  /* drawing tokens */
  --d-soil: #b9a58a;
  --d-stone: #9aa1a8;
  --d-stone-2: #7d858d;
  --d-sand: #e2cf9c;
  --d-concrete: #c9cdd1;
  --d-ph: #eceef0;
  --d-topsoil: #7a5e45;
  --d-compost: #4f3b2a;
  --d-grass: #6f9a4f;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181b; --surface: #1d2125; --line: #2e343a;
    --ink: #e7eaed; --ink-2: #b0b7be; --ink-3: #868e96;
    --accent: #7cb8d6; --tip-bg: #17303c; --tip-line: #7cb8d6;
    --warn-bg: #3a2814; --warn-line: #e39a4c; --warn-ink: #f2c08a;
    --d-soil: #6f604d; --d-stone: #6b737b; --d-stone-2: #8c949c;
    --d-sand: #8f7f55; --d-concrete: #9097a0; --d-ph: #22272c;
    --d-topsoil: #5a4535; --d-compost: #3a2c20; --d-grass: #4d7238;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15181b; --surface: #1d2125; --line: #2e343a;
  --ink: #e7eaed; --ink-2: #b0b7be; --ink-3: #868e96;
  --accent: #7cb8d6; --tip-bg: #17303c; --tip-line: #7cb8d6;
  --warn-bg: #3a2814; --warn-line: #e39a4c; --warn-ink: #f2c08a;
  --d-soil: #6f604d; --d-stone: #6b737b; --d-stone-2: #8c949c;
  --d-sand: #8f7f55; --d-concrete: #9097a0; --d-ph: #22272c;
    --d-topsoil: #5a4535; --d-compost: #3a2c20; --d-grass: #4d7238;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.6;
  padding-inline: 16px;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.mono, .size { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.size { white-space: nowrap; font-weight: 500; }

.shell {
  max-width: 1120px; margin: 0 auto; padding-block: 24px 64px;
  display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 24px);
  display: flex; flex-direction: column; gap: 20px; font-size: 14px;
}
.brand { font-weight: 600; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.toc { display: flex; flex-direction: column; gap: 14px; }
.toc details > summary {
  list-style: none; cursor: pointer; font-weight: 600; color: var(--ink);
  display: flex; gap: 8px; align-items: baseline;
}
.toc details > summary::-webkit-details-marker { display: none; }
.toc details > summary::before { content: "▸"; color: var(--ink-3); font-size: 11px; transition: transform .15s; display: inline-block; }
.toc details[open] > summary::before { transform: rotate(90deg); }
.toc .chnum { font-family: var(--font-mono); color: var(--ink-3); font-weight: 500; }
.toc ul { list-style: none; margin: 8px 0 0; padding: 0 0 0 18px; display: flex; flex-direction: column; gap: 2px; }
.toc li a, .toc li span {
  display: flex; gap: 8px; padding: 4px 8px; border-radius: 6px;
  color: var(--ink-2); text-decoration: none;
}
.toc li span { color: var(--ink-3); cursor: default; }
.toc li a:hover { background: var(--surface); color: var(--ink); }
.toc li a[aria-current="page"] { background: var(--tip-bg); color: var(--accent); font-weight: 600; }
.toc li .n { font-family: var(--font-mono); font-size: 13px; min-width: 2.2em; }
.onpage { border-top: 1px solid var(--line); padding-top: 16px; }
.onpage h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 8px; font-weight: 600; }
.onpage ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.onpage a { display: block; padding: 3px 8px; border-left: 2px solid var(--line); color: var(--ink-2); text-decoration: none; }
.onpage a.active { border-left-color: var(--accent); color: var(--ink); }

.controls { border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ctl-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--surface); }
.seg button {
  font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--ink-2);
  padding: 4px 10px; border-radius: 6px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg select { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--ink); padding: 4px 6px; }

/* ---------- Main ---------- */
main { display: flex; flex-direction: column; gap: 28px; min-width: 0; max-width: 760px; }
.crumb { font-size: 13px; color: var(--ink-3); display: flex; gap: 6px; flex-wrap: wrap; }
.title-block { display: flex; flex-direction: column; gap: 8px; }
.title-block h1 {
  margin: 0; font-size: clamp(28px, 4vw, 38px); line-height: 1.15; font-weight: 700; letter-spacing: -.01em;
  text-wrap: balance; display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap;
}
.title-block h1 .secnum { font-family: var(--font-mono); font-weight: 500; color: var(--accent); }
.lede { margin: 0; font-size: 18px; color: var(--ink-2); max-width: 60ch; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.card h2, .section h2 {
  margin: 0 0 14px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; color: var(--ink-2);
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
}
.card h2 .note { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink-3); font-size: 13px; }

/* hero drawing */
figure { margin: 0; }
.hero { padding: 0; overflow: hidden; }
.hero svg { display: block; width: 100%; height: auto; }
.hero figcaption { padding: 12px 22px; font-size: 13px; color: var(--ink-3); border-top: 1px solid var(--line); }
.svg-label { font-family: var(--font-sans); font-size: 14px; fill: var(--ink); }
.svg-sub { font-family: var(--font-mono); font-size: 12.5px; fill: var(--ink-2); }
.svg-num { font-family: var(--font-mono); font-size: 13px; font-weight: 500; fill: var(--bg); }
.svg-dim { stroke: var(--ink-3); stroke-width: 1; fill: none; }
.svg-dimtext { font-family: var(--font-mono); font-size: 12px; fill: var(--ink-2); }

/* at a glance */
.glance { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px; margin: 0; }
.glance > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.glance dt { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.glance dd { margin: 0; }
.dots { display: inline-flex; gap: 4px; vertical-align: middle; margin-right: 8px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--ink-2); }
.dots i.on { background: var(--ink-2); }
.layers { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.layers li { display: flex; gap: 10px; align-items: center; }
.swatch { width: 14px; height: 14px; border-radius: 3px; flex: none; border: 1px solid var(--line); }

/* table */
.tablewrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.qty { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
th.qty { text-align: right; }
td .alt { display: block; color: var(--ink-3); font-size: 13px; }
.or td { padding-top: 0; }
.or td:first-child { color: var(--ink-3); font-size: 13px; }

/* why box */
.why { border-left: 3px solid var(--ink); background: var(--bg); }
.why h2 { color: var(--ink); }
.why-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.why-grid > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.why-grid .size { font-size: 20px; }
.why-grid p { margin: 0; color: var(--ink-2); }

/* steps */
.section { display: flex; flex-direction: column; gap: 0; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 20px; counter-reset: step; }
.step {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(0, 220px); gap: 16px; align-items: start;
  padding-bottom: 20px; border-bottom: 1px solid var(--line);
}
.step:last-child { border-bottom: 0; padding-bottom: 0; }
.step .num {
  width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: var(--bg);
  display: grid; place-items: center; font-family: var(--font-mono); font-weight: 500;
}
.step h3 { margin: 4px 0 4px; font-size: 17px; font-weight: 600; text-wrap: balance; }
.step p { margin: 0; color: var(--ink-2); }
.photo { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.photo svg { display: block; width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); background: var(--d-ph); }
.photo figcaption { font-size: 12px; color: var(--ink-3); }
.photo img { display: block; width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); background: var(--d-ph); }
.ill { color: var(--ink-3); opacity: .8; }
.ill::before { content: "· "; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 12px; }
.gallery .size { font-size: 14px; }

/* tip & warning */
.callouts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.box { border-radius: var(--radius); padding: 16px 18px; border-left: 4px solid; display: flex; flex-direction: column; gap: 6px; }
.box strong { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.box p { margin: 0; }
.box.tip { background: var(--tip-bg); border-color: var(--tip-line); }
.box.tip strong { color: var(--accent); }
.box.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.box.warn strong { color: var(--warn-ink); }
.step .box { margin-top: 10px; padding: 10px 14px; }

/* specs */
details.specs { padding: 0; }
details.specs > summary {
  cursor: pointer; list-style: none; padding: 16px 22px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  font-size: 13px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; color: var(--ink-2);
}
details.specs > summary::-webkit-details-marker { display: none; }
details.specs > summary .chev { transition: transform .15s; font-size: 12px; }
details.specs[open] > summary .chev { transform: rotate(180deg); }
details.specs .inner { padding: 0 22px 20px; display: flex; flex-direction: column; gap: 16px; }
details.specs h3 { margin: 0 0 6px; font-size: 15px; }
details.specs p { margin: 0; color: var(--ink-2); }

/* sources & find */
.sources ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); font-size: 15px; }
.sources .mono { color: var(--ink); }
.find { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 18px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 14px; }
.find a { text-decoration: none; font-weight: 500; }
.find a:hover { text-decoration: underline; }

.proto-note { font-size: 12px; color: var(--ink-3); }

/* ---------- Narrow ---------- */
.menu-btn { display: none; }
@media (max-width: 880px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-block: 12px 48px; }
  .sidebar {
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
    background: var(--bg); border-bottom: 1px solid var(--line); padding-block: 10px; gap: 12px;
  }
  .sidebar .bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .menu-btn {
    display: inline-flex; font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--surface);
    color: var(--ink); border-radius: 8px; padding: 6px 12px; cursor: pointer;
  }
  .sidebar .drawer { display: none; flex-direction: column; gap: 16px; max-height: 70vh; overflow-y: auto; padding-bottom: 6px; }
  .sidebar.open .drawer { display: flex; }
  .onpage { display: none; }
  .step { grid-template-columns: 40px minmax(0, 1fr); }
  .step .photo { grid-column: 2; }
}
@media (min-width: 881px) {
  .sidebar .bar .menu-btn { display: none; }
  .sidebar .drawer { display: flex; flex-direction: column; gap: 20px; }
}
@media (max-width: 560px) {
  .glance, .why-grid, .callouts { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; }
}

/* ---------- Added for the chapter pages ---------- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.crumb a { color: var(--ink-3); }
.sources h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; color: var(--ink-2); }
.sources li a { word-break: break-word; }
.sources .note { font-size: 13px; color: var(--ink-3); margin: 10px 0 0; }
.pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pager a {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: var(--ink); min-width: 0;
}
.pager a:hover { background: var(--surface); }
.pager a.next { text-align: right; grid-column: 2; }
.pager small { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.pager .n { font-family: var(--font-mono); color: var(--accent); }

/* stone size checker (3.4) */
.calc { display: flex; flex-direction: column; gap: 16px; }
.calc-in { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.calc-in label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink-2); }
.calc-in input {
  font: inherit; font-family: var(--font-mono); font-size: 16px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%;
}
.calc-out { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.calc-out .big { font-family: var(--font-mono); font-size: 22px; font-weight: 500; }
.calc-out ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.calc-out .limit { color: var(--ink); font-weight: 600; }

/* chapter index */
.chapter-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.chapter-list a {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 4px 12px; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); background: var(--surface);
}
.chapter-list a:hover { border-color: var(--accent); }
.chapter-list .n { font-family: var(--font-mono); font-weight: 500; color: var(--accent); font-size: 18px; grid-row: span 2; }
.chapter-list strong { font-size: 17px; }
.chapter-list span.d { color: var(--ink-2); font-size: 15px; }
@media (max-width: 560px) {
  .calc-in, .pager { grid-template-columns: minmax(0, 1fr); }
  .pager a.next { grid-column: 1; }
}

/* Shared site frame: start page link, brand link, start page */
.brand a { color: inherit; text-decoration: none; }
.toc-home { display: block; padding: 6px 8px; border-radius: 6px; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.toc-home:hover { background: var(--surface); color: var(--ink); }
.toc-home[aria-current="page"] { background: var(--tip-bg); color: var(--accent); }
.start-ch h2 a { color: inherit; text-decoration: none; }
.start-ch h2 a:hover { color: var(--accent); }
.start-ch p { color: var(--ink-2); margin: 0 0 10px; }
.start-secs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; }
.start-secs a, .start-secs .todo { display: flex; gap: 8px; padding: 4px 0; text-decoration: none; color: var(--ink); }
.start-secs a:hover { color: var(--accent); }
.start-secs .todo { color: var(--ink-3); }
.start-secs .n { font-family: var(--font-mono); color: var(--accent); min-width: 2.2em; }
.start-how { margin: 0 0 12px; padding-left: 20px; color: var(--ink-2); }
.start-how li { margin: 4px 0; }

/* Chapter groups in the sidebar and on the start page */
.toc-group { margin: 14px 8px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.start-group { margin: 28px 0 10px; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

/* Fixed branding: tagline next to the name, and the site footer line */
.brand .tagline { font-weight: 500; color: var(--ink-3); opacity: .8; margin-left: .35em; }
.site-foot { margin: 24px 0 8px; font-size: 13px; letter-spacing: .04em; color: var(--ink-3); text-align: center; }
.site-foot a { color: inherit; text-decoration: none; font-weight: 600; }

/* Shared front page at /: dark band with brand and grading strip, then the country picker */
body.front { display: block; padding: 0; margin: 0; min-height: 100vh; }
.front-wrap { max-width: 1040px; margin: 0 auto; padding-inline: max(20px, env(safe-area-inset-left)); }
.front-hero { background: #1d2226; color: #fff; padding: clamp(36px, 8vh, 72px) 0 72px; }
.front-hero .front-wrap { display: flex; flex-direction: column; gap: 14px; }
.front-mark { display: flex; align-items: center; gap: 12px; margin: 0 0 6px; font-family: var(--font-mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: #aab2b9; }
.front-mark img { width: 36px; height: 36px; }
.front-hero h1 { margin: 0; font-size: clamp(44px, 9vw, 92px); line-height: 1; font-weight: 700; letter-spacing: -.01em; }
.front-lede { margin: 0 0 18px; font-size: clamp(18px, 2.4vw, 23px); color: #aab2b9; max-width: 34ch; }
.front-hero .grading span { color: #d5dadf; }
.front-foot { padding-block: 40px; font-size: 13px; color: var(--ink-3); }
.front main { display: block; max-width: 1040px; margin-top: -32px; }
.country-pick { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.country-pick a { display: grid; grid-template-columns: 1fr auto; padding: 18px 20px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; color: var(--ink); text-decoration: none; box-shadow: 0 12px 30px -20px rgba(0,0,0,.55); transition: border-color .15s, transform .15s; }
.country-pick a:hover, .country-pick a:focus-visible { border-color: var(--ink-2); transform: translateY(-1px); }
.country-pick strong { font-size: 18px; font-weight: 600; }
.country-pick span { grid-row: 2; color: var(--ink-2); font-size: 14px; }
.country-pick i { grid-row: 1 / 3; grid-column: 2; align-self: center; font-style: normal; color: var(--ink-3); font-size: 20px; }
.country-pick a.likely { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), 0 12px 30px -20px rgba(0,0,0,.55); }
.country-pick a.likely i { color: var(--accent); }

/* Grading strip: sand to gabion stone, sizes in mm */
.grading { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: clamp(8px, 2vw, 24px); }
.grading li { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.grading img { display: block; width: 100%; max-width: 150px; height: auto; border-radius: 50%; box-shadow: 0 10px 24px -14px rgba(0,0,0,.6); }
.grading span { font-family: var(--font-mono); font-size: clamp(11px, 1.4vw, 14px); white-space: nowrap; }

/* Language start page: the title block becomes the same dark band */
.start-hero { background: #1d2226; color: #fff; border-radius: 14px; padding: clamp(24px, 4vw, 40px); gap: 12px; }
.start-hero h1 { color: #fff; }
.start-hero .lede { color: #c3c9cf; }
.start-hero .grading { margin-top: 16px; }
.start-hero .grading span { color: #d5dadf; }
main:has(.start-hero) > .crumb { display: none; }
@media (max-width: 600px) {
  .grading { gap: 6px; }
  .grading span { font-size: 10px; }
  .front-hero { padding-bottom: 64px; }
  .start-hero .lede { font-size: 16px; }
}
