/* The Product 360 Handbook. Dark-first reading design. */

:root,
:root[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-2: #0f1218;
  --surface: #141822;
  --surface-2: #1a1f2c;
  --border: #252b3a;
  --border-2: #313849;
  --text: #e7e9ef;
  --text-2: #c3c8d4;
  --muted: #8b93a7;
  --faint: #5d657a;
  --a1: #7aa2ff;   /* signal blue */
  --a2: #4fd1c5;   /* teal */
  --a3: #f2b45e;   /* amber */
  --a4: #f28b82;   /* coral, warnings */
  --link: #9cb8ff;
  --mark: rgba(242, 180, 94, .18);
  --code-bg: #10131b;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 40px rgba(0,0,0,.35);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f7f5f0;
  --bg-2: #f1eee7;
  --surface: #ffffff;
  --surface-2: #f4f2ec;
  --border: #e2ddd2;
  --border-2: #d3cdc0;
  --text: #1d2130;
  --text-2: #363b4b;
  --muted: #646b7d;
  --faint: #9a9fac;
  --a1: #3d63d9;
  --a2: #11897f;
  --a3: #b56f0b;
  --a4: #c2433a;
  --link: #2f55c9;
  --mark: rgba(181, 111, 11, .14);
  --code-bg: #f4f1ea;
  --shadow: 0 1px 2px rgba(30,30,40,.05), 0 8px 28px rgba(30,30,40,.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
::selection { background: color-mix(in srgb, var(--a1) 35%, transparent); }
kbd {
  font: 500 11px/1 "JetBrains Mono", ui-monospace, monospace;
  padding: 3px 5px; border-radius: 4px; border: 1px solid var(--border-2);
  background: var(--surface-2); color: var(--muted);
}

/* ---------- top bar ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 60; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--a1), var(--a2), var(--a3)); }
.top {
  position: sticky; top: 0; z-index: 50; height: 56px;
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo { width: 26px; height: 26px; }
.brand-t { white-space: nowrap; font-weight: 600; letter-spacing: -.01em; font-size: 16px; }
.brand-t b { font-weight: 700; background: linear-gradient(90deg, var(--a1), var(--a2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-s { color: var(--muted); font-size: 14px; border-left: 1px solid var(--border-2); padding-left: 10px; }
.top-r { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.ibtn {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 11px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font: 500 13px Inter, sans-serif; cursor: pointer;
}
.ibtn:hover { border-color: var(--border-2); color: var(--text); text-decoration: none; }
.search-btn { min-width: 160px; }
.search-btn kbd { margin-left: auto; }
.menu { display: none; font-size: 16px; }
.curator { color: var(--muted); font-size: 13.5px; margin-right: 8px; white-space: nowrap; }
.curator a { color: var(--text-2); border-bottom: 1px solid var(--border-2); padding-bottom: 1px; }
.curator a:hover { color: var(--text); border-color: var(--a2); text-decoration: none; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.has-rail .shell { grid-template-columns: 300px minmax(0, 1fr) 240px; }
.side {
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
  border-right: 1px solid var(--border); background: var(--bg-2);
  padding: 18px 12px 40px; scrollbar-width: thin; scrollbar-color: var(--border-2) transparent;
}
.scrim { display: none; }
.main { min-width: 0; padding: 0 clamp(18px, 4vw, 56px) 80px; }

/* sidebar nav: parts collapse with a +/− like a course outline */
.nav-g { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.nav-p { border-radius: 10px; margin: 2px 0; }
.nav-p summary {
  list-style: none; cursor: pointer; display: grid; grid-template-columns: 18px auto; column-gap: 8px;
  padding: 9px 10px; border-radius: 8px; color: var(--text-2);
}
.nav-p summary::-webkit-details-marker { display: none; }
.nav-p summary:hover { background: var(--surface); }
.nav-pm { grid-row: span 2; align-self: center; width: 18px; height: 18px; position: relative; }
.nav-pm::before, .nav-pm::after { content: ""; position: absolute; left: 3px; right: 3px; top: 8px; height: 2px; border-radius: 1px; background: var(--muted); transition: transform .18s; }
.nav-pm::after { transform: rotate(90deg); }
.nav-p[open] .nav-pm::after { transform: rotate(0); }
.nav-pn { font: 600 10.5px/1.4 Inter, sans-serif; letter-spacing: .09em; text-transform: uppercase; color: var(--a2); }
.nav-pt { font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--text); }
.nav-p[open] { background: color-mix(in srgb, var(--surface) 55%, transparent); }
.nav-p[open] > summary { color: var(--text); }
.nav-p > .nav-l { margin-left: 18px; }
.nav-l {
  display: grid; grid-template-columns: 26px 1fr; gap: 6px; align-items: baseline;
  padding: 6px 10px; border-radius: 7px; color: var(--text-2); font-size: 13.5px; line-height: 1.35;
  border-left: 2px solid transparent;
}
.nav-l:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-l.on { background: var(--surface-2); color: var(--text); border-left-color: var(--a2); }
.nav-l.soon { color: var(--muted); }
.nav-n { font: 500 11.5px "JetBrains Mono", monospace; color: var(--faint); }
.nav-l.on .nav-n { color: var(--a2); }

/* right rail */
.rail { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; padding: 40px 20px 40px 8px; }
.rail-h { font: 600 11px Inter, sans-serif; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.rail-l { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.rail-l a { display: block; padding: 4px 0 4px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); font-size: 13px; line-height: 1.4; }
.rail-l .l3 a { padding-left: 24px; font-size: 12.5px; }
.rail-l a:hover { color: var(--text); text-decoration: none; }
.rail-l a.on { color: var(--text); border-left-color: var(--a1); }

/* ---------- chapter ---------- */
.ch { max-width: 760px; margin: 0 auto; }
.ch-head { position: relative; padding: 64px 0 34px; margin-bottom: 36px; border-bottom: 1px solid var(--border); }
.ch-num {
  position: absolute; right: 0; top: 30px; font: 700 128px/1 Inter, sans-serif; letter-spacing: -.06em;
  background: linear-gradient(160deg, color-mix(in srgb, var(--a1) 40%, transparent), transparent 70%);
  -webkit-background-clip: text; background-clip: text; color: transparent; pointer-events: none; user-select: none;
}
.ch-kicker { font: 600 12px Inter, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--a2); margin-bottom: 14px; position: relative; }
.ch-head h1 { position: relative; margin: 0 0 14px; font: 700 clamp(32px, 4.6vw, 46px)/1.08 Inter, sans-serif; letter-spacing: -.028em; max-width: 620px; }
.ch-sum { position: relative; margin: 0; font: 400 20px/1.5 Literata, Georgia, serif; color: var(--text-2); max-width: 620px; }
.ch-meta { position: relative; margin-top: 18px; color: var(--muted); font-size: 13px; }

/* prose: the reading column */
.prose { font: 400 18px/1.75 Literata, Georgia, serif; color: var(--text-2); font-optical-sizing: auto; }
.prose > * { max-width: 70ch; }
.prose p { margin: 0 0 1.15em; }
.prose strong { color: var(--text); font-weight: 600; }
.prose h2 {
  font: 700 28px/1.2 Inter, sans-serif; letter-spacing: -.02em; color: var(--text);
  margin: 2.4em 0 .7em; padding-top: .2em;
}
.prose h2::before { content: ""; display: block; width: 36px; height: 3px; border-radius: 2px; margin-bottom: 16px; background: linear-gradient(90deg, var(--a1), var(--a2)); }
.prose h3 { font: 650 21px/1.3 Inter, sans-serif; letter-spacing: -.012em; color: var(--text); margin: 1.9em 0 .55em; }
.prose h4 { font: 600 16px/1.4 Inter, sans-serif; color: var(--text); margin: 1.6em 0 .4em; text-transform: none; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--faint); }
.prose ol li::marker { font: 600 .85em Inter, sans-serif; color: var(--a2); }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); text-underline-offset: 3px; }
.prose blockquote {
  margin: 1.6em 0; padding: 4px 0 4px 22px; border-left: 3px solid var(--a3);
  font-style: italic; color: var(--text);
}
.prose code { font: 500 .84em "JetBrains Mono", monospace; background: var(--code-bg); border: 1px solid var(--border); padding: .1em .38em; border-radius: 5px; color: var(--text); }
.prose pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; overflow-x: auto; }
.prose pre code { background: none; border: 0; padding: 0; font-size: 13.5px; line-height: 1.6; }
.prose hr { border: 0; height: 1px; background: var(--border); margin: 3em 0; }
.prose img, .prose svg { max-width: 100%; }
.prose .lead { font-size: 21px; line-height: 1.6; color: var(--text); }

/* tables */
.tbl { max-width: 100% !important; overflow-x: auto; margin: 1.6em 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.prose table { width: 100%; border-collapse: collapse; font: 400 14.5px/1.5 Inter, sans-serif; }
.prose th { text-align: left; font-weight: 600; color: var(--text); background: var(--surface-2); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.prose td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text-2); }
.prose tr:last-child td { border-bottom: 0; }
.prose td:first-child { color: var(--text); font-weight: 500; }

/* callouts */
.callout {
  max-width: 70ch; margin: 1.8em 0; padding: 18px 22px 6px; border-radius: 12px;
  background: color-mix(in srgb, var(--c) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 28%, var(--border));
  font-size: 16.5px; line-height: 1.65; --c: var(--a1);
}
.callout-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.callout-k { font: 700 11px Inter, sans-serif; letter-spacing: .09em; text-transform: uppercase; color: var(--c); }
.callout-t { font: 600 15.5px Inter, sans-serif; color: var(--text); }
.callout p { margin: 0 0 .9em; }
.callout ul, .callout ol { margin-bottom: .9em; }
.callout-ai { --c: var(--a2); }
.callout-warn { --c: var(--a4); }
.callout-example { --c: var(--a3); }
.callout-onramp { --c: #a78bfa; }
.callout-leader { --c: #c084fc; }
.callout-key { --c: var(--a1); background: linear-gradient(135deg, color-mix(in srgb, var(--a1) 10%, var(--surface)), color-mix(in srgb, var(--a2) 8%, var(--surface))); }

/* prompt and template blocks */
.blk { max-width: 100% !important; margin: 1.8em 0; border-radius: 12px; border: 1px solid var(--border); background: var(--code-bg); overflow: hidden; --c: var(--a3); }
.blk-template { --c: var(--a2); }
.blk-h { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); font-family: Inter, sans-serif; }
.blk-tag { font: 700 10.5px Inter, sans-serif; letter-spacing: .09em; text-transform: uppercase; color: var(--c); padding: 3px 8px; border-radius: 6px; background: color-mix(in srgb, var(--c) 13%, transparent); }
.blk-t { font-size: 14.5px; font-weight: 600; color: var(--text); flex: 1 1 200px; line-height: 1.35; }
.blk-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.blk-copy, .blk-toggle, .blk-dl, .blk-src {
  font: 500 12px Inter, sans-serif; height: 28px; padding: 0 10px; display: inline-flex; align-items: center;
  border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); cursor: pointer; text-decoration: none !important;
}
.blk-src { border-color: transparent; background: none; color: var(--muted); }
.blk-copy:hover, .blk-toggle:hover, .blk-dl:hover { border-color: var(--c); color: var(--text); }
.blk-copy.ok { border-color: var(--a2); color: var(--a2); }
.blk pre { margin: 0; border: 0; border-radius: 0; background: none; padding: 16px 18px; max-height: 520px; overflow: auto; }
.blk pre code { font: 400 13px/1.65 "JetBrains Mono", monospace; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.blk-fold pre { display: none; }
.blk-fold.open pre { display: block; }

/* checklists */
.prose li.chk { list-style: none; margin-left: -1.3em; }
.chk label { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.chk input { appearance: none; -webkit-appearance: none; flex: 0 0 20px; width: 20px; height: 20px; margin-top: 6px; border-radius: 6px; border: 1.5px solid var(--border-2); background: var(--surface); cursor: pointer; display: grid; place-content: center; }
.chk input::after { content: ""; width: 10px; height: 6px; border: solid var(--bg); border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.chk input:checked { background: var(--a2); border-color: var(--a2); }
.chk input:checked::after { opacity: 1; }
.chk input:checked + span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }

/* diagrams */
.fig { max-width: 100% !important; margin: 2em 0; padding: 22px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.fig svg { display: block; width: 100%; height: auto; font-family: Inter, sans-serif; }
.fig > a { display: block; border-radius: 8px; }
.fig img { display: block; width: 100%; height: auto; border-radius: 8px; }
.fig figcaption, .fig .cap { margin-top: 12px; font: 400 13.5px/1.5 Inter, sans-serif; color: var(--muted); }
.fig .t { fill: var(--text); font-size: 13px; font-weight: 600; }
.fig .s { fill: var(--muted); font-size: 11px; }
.fig .box { fill: var(--surface-2); stroke: var(--border-2); }
.fig .ln { stroke: var(--border-2); fill: none; }

/* pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 64px; padding-top: 28px; border-top: 1px solid var(--border); }
.pg { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
.pg:hover { border-color: var(--a1); text-decoration: none; }
.pg span { font-size: 12.5px; color: var(--muted); }
.pg b { font-weight: 600; font-size: 15px; line-height: 1.35; }
.pg-n { text-align: right; grid-column: 2; }

/* planned chapters */
.soon-card { padding: 26px 28px 10px; border: 1px dashed var(--border-2); border-radius: 14px; background: var(--surface); }
.soon-badge, .badge { display: inline-block; font: 700 10.5px Inter, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--a3); background: color-mix(in srgb, var(--a3) 13%, transparent); padding: 3px 8px; border-radius: 6px; }
.soon-card .soon-badge { margin-bottom: 12px; }
.soon-card h2 { margin-top: 1.2em; font-size: 20px; }
.soon-card h2::before { display: none; }

/* ---------- home ---------- */
.hero { max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; padding: 72px 0 56px; }
.eyebrow { font: 600 12px Inter, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: var(--a2); margin-bottom: 18px; }
.hero h1 { margin: 0 0 16px; font: 750 clamp(40px, 6vw, 66px)/1.02 Inter, sans-serif; letter-spacing: -.04em; }
.hero-sub { margin: 0 0 10px; font: 500 22px/1.4 Literata, Georgia, serif; color: var(--text); }
.hero-tag { margin: 0 0 28px; color: var(--muted); font-size: 16px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; height: 42px; padding: 0 18px; border-radius: 10px; font-weight: 600; font-size: 14.5px; color: #0b0d12; background: linear-gradient(90deg, var(--a1), var(--a2)); }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-g { background: var(--surface); color: var(--text); border: 1px solid var(--border-2); }
.hero-w a { display: block; }
.hero-infographic { display: block; width: 100%; height: auto; border-radius: 12px; }
.part-card { max-width: 1080px; margin: 0 auto 18px; display: grid; grid-template-columns: 260px 1fr; gap: 28px; padding: 26px 28px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.part-n { font: 700 11px Inter, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: var(--a2); }
.part-h h3 { margin: 6px 0 8px; font: 700 21px/1.25 Inter, sans-serif; letter-spacing: -.015em; }
.part-h p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.toc-g { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.toc-i { display: grid; grid-template-columns: 30px 1fr; gap: 8px; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.toc-i:hover { background: var(--surface-2); text-decoration: none; }
.toc-n { font: 500 13px "JetBrains Mono", monospace; color: var(--a1); padding-top: 1px; }
.toc-t { font-weight: 600; font-size: 14.5px; line-height: 1.35; margin-right: 6px; }
.toc-x { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 3px; }
.toc-i.soon .toc-t { color: var(--text-2); }
.toc-i .badge { vertical-align: 2px; font-size: 9px; padding: 2px 6px; }
.site-foot { margin: 72px calc(-1 * clamp(18px, 4vw, 56px)) -80px; border-top: 1px solid var(--border); background: var(--bg-2); }
.foot-in { max-width: 1080px; margin: 0 auto; padding: 22px clamp(18px, 4vw, 56px); display: flex; justify-content: space-between; align-items: center; gap: 14px 24px; flex-wrap: wrap; color: var(--muted); font-size: 13.5px; }
.foot-in a { color: var(--text-2); }
.foot-in a:hover { color: var(--a2); text-decoration: none; }
.foot-u { border-bottom: 1px solid var(--border-2); padding-bottom: 1px; }
.foot-r { display: inline-flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.foot-ic { display: inline-flex; align-items: center; gap: 7px; }

.print-cover { display: none; }

/* ---------- search ---------- */
.search-modal { position: fixed; inset: 0; z-index: 100; background: rgba(5, 6, 10, .6); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.search-modal[hidden] { display: none; }
.search-box { width: min(680px, 100%); background: var(--surface); border: 1px solid var(--border-2); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
#search-input { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); font: 400 18px Inter, sans-serif; padding: 18px 20px; outline: none; }
.search-results { max-height: 56vh; overflow-y: auto; padding: 6px; }
.sr { display: block; padding: 12px 14px; border-radius: 10px; color: var(--text); }
.sr:hover, .sr.on { background: var(--surface-2); text-decoration: none; }
.sr-c { font-size: 11.5px; color: var(--a2); font-weight: 600; letter-spacing: .03em; }
.sr-h { font-weight: 600; font-size: 15px; margin: 2px 0; }
.sr-x { font-size: 13px; color: var(--muted); line-height: 1.5; }
.sr-x mark { background: var(--mark); color: var(--text); border-radius: 3px; padding: 0 2px; }
.sr-empty { padding: 22px; color: var(--muted); text-align: center; font-size: 14px; }
.search-foot { padding: 10px 16px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12px; display: flex; gap: 6px; align-items: center; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .has-rail .shell { grid-template-columns: 280px minmax(0, 1fr); }
  .rail { display: none; }
  .shell { grid-template-columns: 280px minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .hide-md { display: none; }
}
@media (max-width: 960px) {
  .shell, .has-rail .shell { grid-template-columns: minmax(0, 1fr); }
  .menu { display: inline-flex; }
  .side { position: fixed; top: 56px; left: 0; bottom: 0; width: min(320px, 86vw); height: auto; z-index: 70; transform: translateX(-102%); transition: transform .22s ease; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .scrim { position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,.5); z-index: 65; display: none; }
  .scrim.open { display: block; }
  .hero { grid-template-columns: 1fr; padding-top: 44px; }
  .hero-w { width: 100%; max-width: 680px; margin: 0 auto; }
  .part-card { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 640px) {
  .main { padding: 0 16px 60px; }
  .site-foot { margin: 56px -16px -60px; }
  .top { gap: 8px; padding: 0 12px; }
  .top-r { gap: 6px; }
  .ibtn { padding: 0 9px; }
  .logo { width: 22px; height: 22px; }
  .hide-sm { display: none; }
  .search-btn { min-width: 0; }
  .toc-g { grid-template-columns: 1fr; }
  .part-card { padding: 20px 16px; }
  .ch-head { padding-top: 40px; }
  .ch-num { font-size: 84px; top: 22px; }
  .prose { font-size: 17px; }
  .fig { padding: 8px; }
  .prose h2 { font-size: 24px; }
  .pager { grid-template-columns: 1fr; }
  .prose td, .prose th { min-width: 150px; }
  .prose td:first-child, .prose th:first-child { min-width: 90px; }
  .pg-n { grid-column: 1; }
  .brand-s { display: none; }
}

/* ---------- print ---------- */
@media print {
  @page { size: Letter; margin: 18mm 16mm; }
  :root { --bg: #fff; --surface: #fff; --surface-2: #f5f5f3; --code-bg: #f7f6f2; --text: #111; --text-2: #222; --muted: #555; --border: #ddd; --border-2: #ccc; }
  body { background: #fff; }
  .site-foot,
  .top, .side, .rail, .pager, .progress, .search-modal, .scrim, .blk-actions, .menu { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .ch { max-width: none; }
  .print-ch { break-before: page; }
  .print-cover { display: flex !important; flex-direction: column; justify-content: center; min-height: 230mm; }
  .print-cover .logo { width: 64px; height: 64px; margin-bottom: 28px; }
  .print-cover .logo circle:first-of-type { stroke: #11897f; }
  .print-cover h1 { font: 750 52px/1.05 Inter, sans-serif; letter-spacing: -.035em; margin: 0 0 18px; }
  .cover-by { margin-top: 60px; color: #555; font-size: 14px; }
  .ch-num { color: #e3e3e3; background: none; -webkit-text-fill-color: #e8e8e8; }
  .blk pre { max-height: none; overflow: visible; }
  .blk-fold pre { display: block; }
  .callout, .blk, .fig, .tbl { break-inside: avoid; }
  .prose { font-size: 11pt; }
  a { color: inherit; }
}

/* Chapter briefs: the source for the concise print companion. */
.nav-group-title { margin: 8px 12px 10px; color: var(--text); font-size: 14px; font-weight: 600; }
.nav-reference-title { grid-row: span 2; align-self: center; }
.chapter-recap { margin: 64px 0 0; padding: clamp(20px, 4vw, 32px); border: 1px solid var(--border-2); border-radius: 12px; background: var(--surface); }
.prose .chapter-recap h2 { margin: 0 0 24px; padding: 0 0 18px; border-bottom: 1px solid var(--border); }
.prose .chapter-recap h2::before { display: none; }
.prose .chapter-recap h3 { margin: 22px 0 8px; font-size: 16px; color: var(--a2); }
.prose .chapter-recap p, .prose .chapter-recap li { font-size: 16.5px; line-height: 1.6; }
.prose .chapter-recap h3[id^="idea-in-brief"] + p { font-size: 20px; color: var(--text); }
.prose .chapter-recap ul { margin-bottom: 0; padding-left: 1.2em; }
.prose .chapter-recap li { padding-left: 5px; margin: 12px 0; }
.prose .chapter-recap li::marker { color: var(--a2); }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--a2); outline-offset: 4px; }
@media print {
  .chapter-recap { break-inside: avoid; margin-top: 28px; padding: 18px; }
  .prose .chapter-recap p, .prose .chapter-recap li { font-size: 10pt; }
}

/* Diagram Design: book fonts, semantic colors and readable local scrolling. */
.fig:has(.p360-diagram) { padding: 12px 0 0; border: 0; border-radius: 0; background: none; }
.fig:has(.p360-diagram) figcaption { border-top: 1px solid var(--border); padding-top: 14px; }
.diagram-scroll { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
.p360-diagram{display:block;width:100%;height:auto;font-family:Inter,system-ui,sans-serif}.p360-diagram text{fill:var(--text);font-size:14px}.p360-diagram .label{font-size:17px;font-weight:600;letter-spacing:-.2px}.p360-diagram .small{font-size:12px;fill:var(--muted)}.p360-diagram .muted{fill:var(--muted)}.p360-diagram .accent{fill:var(--a2)}.p360-diagram .blue{fill:var(--a1)}.p360-diagram .serif{font-family:Literata,Georgia,serif;font-size:24px}.p360-diagram .line{fill:none;stroke:var(--muted);stroke-width:1.5}.p360-diagram .rule{stroke:var(--border-2);stroke-width:1;fill:none}

.diagram-tools { margin: 8px 0 0; font: 400 12px/1.5 Inter, sans-serif; text-align: right; }
.diagram-tools a { color: var(--muted); text-decoration: none; }
.diagram-tools .diagram-open-light { display: none; }
:root[data-theme="light"] .diagram-tools .diagram-open-dark { display: none; }
:root[data-theme="light"] .diagram-tools .diagram-open-light { display: inline; }
.hero-w { min-width: 0; }
.hero-w .p360-diagram { min-width: 0 !important; }
@media print {
  .diagram-scroll { overflow: visible; }
  .p360-diagram { min-width: 0 !important; max-height: 195mm; }
  .diagram-tools { display: none; }
  :root, :root[data-theme="dark"], :root[data-theme="light"] { --a1: #3d63d9; --a2: #11897f; --a3: #b56f0b; --a4: #c2433a; }
}

/* Darken the site teal slightly for small SVG labels on warm paper (AA). */
:root[data-theme="light"] .p360-diagram { --a2: #0e7c73; }
@media print { .p360-diagram { --a2: #0e7c73; } }
