.challenge { border: 1px solid #bdd8d5; border-left: 4px solid #237d78;
  border-radius: 6px; background: #f5faf9; padding: 1rem 1.3rem; margin: 1rem 0 2rem; }
.challenge > p:first-child { color: #145b56; font-size: 1.06em; margin-top: 0; }
.challenge > p:last-child { margin-bottom: 0; }
details.solution { margin: 1rem 0 2.5rem; border: 1px solid #c7dce9;
  border-radius: 6px; background: #f7fafc; padding: 0 1.2rem; }
details.solution > summary { cursor: pointer; padding: .9rem 0; color: #14507d;
  font-weight: 700; }
details.solution[open] > summary { border-bottom: 1px solid #c7dce9; margin-bottom: 1rem; }
details.solution > :last-child { margin-bottom: 1.2rem; }
details.solution:focus-within { outline: 2px solid #14507d; outline-offset: 3px; }
@media print { .challenge { break-inside: avoid; } }
/* Shared, offline-first screen theme for the Org exports and plot gallery. */
:root {
  color-scheme: light;
  --ink: #182d3d;
  --muted: #586a76;
  --blue: #14507d;
  --teal: #237d78;
  --line: #dce5e9;
  --soft: #f3f7f9;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html { background: #fff; color: var(--ink); scroll-padding-top: 7rem; }
body { margin: 0; font: 17px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--blue); text-underline-offset: .2em; }
a:hover { color: var(--teal); }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #ca7829; outline-offset: 4px; }
.skip-link { position: fixed; top: -6rem; left: 1rem; z-index: 100; padding: .6rem 1rem; background: white; }
.skip-link:focus { top: 1rem; }
.site-header { position: sticky; top: 0; z-index: 20; background: #fffffff5; border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1440px; margin: auto; padding: 1rem 3rem; display: flex; align-items: center; gap: 2rem; }
.site-brand { text-decoration: none; display: flex; align-items: center; gap: .7rem; color: var(--ink); font-size: 16px; font-weight: 750; white-space: nowrap; }
.brand-mark { display: block; width: 44px; height: 44px; flex: 0 0 44px; object-fit: contain; border-radius: 8px; background: white; }
.site-nav { margin-left: auto; display: flex; flex-wrap: wrap; gap: .3rem; }
.site-nav a { font-size: 14px; font-weight: 550; padding: .4rem .65rem; border-radius: 6px; text-decoration: none; color: var(--muted); }
.site-nav a:hover, .site-nav a[aria-current="page"] { background: #eaf2f7; color: var(--blue); }
.reading-progress { position: absolute; bottom: -1px; height: 2px; background: var(--teal); width: 0; }
.site-layout { max-width: 1440px; margin: auto; padding: 0 3rem; display: grid; grid-template-columns: 225px minmax(0, 850px); justify-content: center; gap: clamp(2rem, 5vw, 5rem); }
.chapter-sidebar { position: sticky; top: 6rem; align-self: start; max-height: calc(100vh - 7rem); overflow: auto; padding: 2.5rem .4rem 2rem 0; font-size: 13px; }
.sidebar-title, .eyebrow { font-size: 11px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; color: var(--teal); }
.chapter-sidebar input { width: 100%; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 7px; margin: 1rem 0; color: var(--ink); background: white; font-size: 13px; }
.chapter-sidebar ol { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--line); }
.chapter-sidebar li { margin: .15rem 0; }
.chapter-sidebar a { display: block; padding: .4rem .75rem; color: var(--muted); text-decoration: none; line-height: 1.5; border-left: 2px solid transparent; margin-left: -1px; }
.chapter-sidebar a:hover, .chapter-sidebar a[aria-current="location"] { border-left-color: var(--teal); color: var(--blue); background: var(--soft); }
.document-tools { display: flex; flex-wrap: wrap; gap: .5rem 1rem; padding-top: 1.5rem; margin-top: 1rem; border-top: 1px solid var(--line); }
.document-tools a { padding: 0; border: 0; color: var(--blue); font-weight: 600; }
.no-chapters { color: var(--muted); }
.chapter-mobile { display: none; }
#content { min-width: 0; width: 100%; padding: 3.5rem 0 5rem; }
.document-heading { border-bottom: 1px solid var(--line); padding-bottom: 2rem; margin-bottom: 2.5rem; }
h1.title { display: block; margin: .7rem 0 1rem; font-size: clamp(2.25rem, 4.2vw, 3.6rem); font-weight: 760; line-height: 1.12; letter-spacing: -.045em; overflow-wrap: anywhere; }
.document-heading .subtitle { display: block; margin-top: 1.3rem; font-size: clamp(1.1rem, 2vw, 1.3rem); font-weight: 400; line-height: 1.55; letter-spacing: 0; color: var(--muted); }
h1.title > br { display: none; }
.document-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; }
h2 { font-size: clamp(1.65rem, 3vw, 2.1rem); line-height: 1.25; letter-spacing: -.03em; margin: 0 0 1.25rem; }
h3 { font-size: 1.22rem; line-height: 1.4; margin: 2rem 0 .65rem; letter-spacing: -.015em; }
h4 { font-size: 1rem; margin-bottom: .4rem; }
:is(h2,h3,h4) { scroll-margin-top: 7rem; }
p { margin: .75rem 0 1.1rem; }
ul, ol { padding-left: 1.5rem; }
li { margin: .35rem 0; }
.outline-2 { margin: 0 0 3.5rem; padding-bottom: 2.5rem; border-bottom: 1px solid var(--line); }
.outline-2:last-child { border-bottom: 0; }
.outline-2.implementation { background: var(--soft); border-radius: 12px; padding: 1.5rem; }
.sheet { columns: auto; box-shadow: none; }
.sheet > .outline-text-2 { color: var(--muted); font-size: 13px; letter-spacing: .025em; }
.section-number-2, .section-number-3 { display: none; }
code, pre { font-family: var(--mono); }
code { font-size: .83em; padding: .12em .28em; border-radius: 4px; background: #edf3f6; overflow-wrap: anywhere; }
.org-src-container { margin: 1.4rem 0; border: 1px solid #cfdee7; border-radius: 10px; overflow: hidden; background: #f6f9fb; }
.org-src-name, .code-toolbar { display: flex; align-items: center; gap: .5rem; margin: 0; padding: .7rem 1rem; border-bottom: 1px solid #cfdee7; background: #e8f1f7; color: var(--blue); font-size: 13px; font-weight: 600; line-height: 1.5; }
.org-src-name { flex-wrap: wrap; }
.listing-number { font-weight: 750; white-space: nowrap; }
.org-src-name code { background: none; }
pre { margin: 1rem 0; padding: 1rem; background: var(--soft); color: #243d50; font-size: 12.5px; line-height: 1.65; overflow-x: auto; tab-size: 2; white-space: pre; }
.org-src-container pre { margin: 0; padding: 1rem 1.1rem 1.1rem; background: none; }
pre code { font: inherit; padding: 0; background: none; overflow-wrap: normal; }
.code-line { display: block; min-height: 1.65em; }
.numbered { counter-reset: code-line; }
.numbered .code-line::before { counter-increment: code-line; content: counter(code-line); display: inline-block; width: 2em; margin-right: 1.5em; color: #758592; text-align: right; user-select: none; font-size: 10px; }
.syntax-keyword, .org-keyword, .org-builtin, .org-type { color: #14507d; font-weight: 650; }
.syntax-string, .org-string { color: #9e541b; }
.syntax-comment, .org-comment, .org-comment-delimiter { color: #667f70; font-style: italic; }
.syntax-number, .org-constant, .org-variable-name { color: #79538f; }
.code-prompt { color: #707070; font-weight: normal; font-style: normal; }
.table-scroll { overflow-x: auto; margin: 1.2rem 0; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; border: 0; width: 100%; font-size: 14px; line-height: 1.55; }
th, td { border: 0; border-bottom: 1px solid var(--line); padding: .65rem .85rem; text-align: left; vertical-align: top; min-width: 4rem; }
th { background: #f1f6f8; color: var(--ink); font-weight: 650; }
tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: #fafcfd; }
td.org-right, th.org-right { text-align: right; }
.sheet td:first-child { width: 38%; }
td code { white-space: normal; }
.figure, figure { margin: 1.8rem 0; padding: 1.3rem; border: 1px solid var(--line); background: white; border-radius: 10px; text-align: center; }
.figure p { margin: 0; }
img { max-width: 100%; height: auto; }
.figure img, figure img { display: block; margin: 0 auto; }
.figure img { max-height: 620px; width: auto; }
.figure img[src*="spark"], figure img.spark { width: 240px; }
.figure img[src*="spider"], .figure img[src*="donut"], .figure img[src*="pie"] { max-height: 420px; }
.figure-number { font-weight: 700; }
figcaption, .figure p:last-child:not(:first-child) { margin-top: .8rem; color: var(--muted); font-size: 13px; }
blockquote { margin: 1.3rem 0; padding: .25rem 1.2rem; background: #f3f8f7; border-left: 3px solid var(--teal); color: #34565b; }
.notes { color: var(--muted); font-size: 14px; border-left: 2px solid var(--line); padding-left: 1rem; }
.sources { font-size: 12px; color: var(--muted); }
.site-footer { max-width: 1280px; margin: auto; padding: 1.5rem 3rem 2.5rem; border-top: 1px solid var(--line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; font-size: 12px; color: var(--muted); }
.home #content { max-width: 1200px; margin: auto; padding: 4rem 3rem; }
.home .document-heading, .home #table-of-contents { display: none; }
.hero { display: grid; grid-template-columns: 1.15fr 1fr; gap: 3.5rem; align-items: center; padding: 1rem 0 4rem; }
.hero h1 { font-size: clamp(2.8rem, 5.3vw, 4.6rem); line-height: 1.04; letter-spacing: -.055em; margin: 1rem 0 1.5rem; }
.hero h1 em { color: var(--blue); font-style: normal; }
.hero p { max-width: 32rem; color: var(--muted); }
.hero-visual { padding: 1.7rem 1.3rem; background: #f2f7fa; border-radius: 16px; border: 1px solid #dce8ef; }
.hero-visual img { display: block; width: 100%; }
.hero-visual p { font: 12px/1.7 var(--mono); color: var(--blue); border-top: 1px solid #cbdde8; padding-top: 1rem; margin-bottom: 0; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.6rem; }
.button { display: inline-block; padding: .7rem 1.1rem; border-radius: 7px; background: var(--blue); color: white; text-decoration: none; font-size: 14px; font-weight: 600; border: 1px solid var(--blue); }
.button:hover { background: #0b3e64; color: white; }
.button.secondary { background: white; color: var(--blue); border-color: #c9d9e3; }
.home-section { padding: 2.8rem 0; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 2rem; margin-bottom: 1.5rem; }
.section-heading h2 { margin: 0; }
.section-heading p { margin: 0; font-size: 14px; color: var(--muted); }
.course-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1.2rem; }
.course-card { display: flex; flex-direction: column; padding: 1.5rem; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.course-card:hover { border-color: var(--blue); transform: translateY(-3px); color: var(--ink); }
.card-tag { color: var(--teal); font: 11px/1.5 var(--mono); text-transform: uppercase; letter-spacing: .1em; }
.course-card h3 { margin: .9rem 0 .6rem; font-size: 1.35rem; }
.course-card p { margin: 0 0 1.5rem; color: var(--muted); font-size: 14px; }
.card-link { margin-top: auto; color: var(--blue); font-size: 13px; font-weight: 700; }
.principles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
.principles b { display: block; font-size: 16px; margin-bottom: .4rem; }
.principles p { margin: 0; font-size: 13px; color: var(--muted); }
.root-grid, .pair, .split { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1.5rem; }
.root-grid > div { background: var(--soft); padding: 1rem; border-radius: 8px; }
.root-grid .big { display: block; color: var(--teal); font-size: 2rem; }
.pair > *, .split > * { min-width: 0; }
.lede, .thesis { color: var(--muted); font-size: 1.15rem; }
.gallery-page #content { max-width: 1050px; margin: auto; padding: 3rem 2rem; }
.gallery-page figure { scroll-margin-top: 7rem; }
.gallery-page figure img { max-height: 500px; }
@media (max-width: 1000px) {
  .header-inner { padding: .8rem 1.5rem; gap: 1rem; }
  .site-layout { padding: 0 1.5rem; grid-template-columns: 185px minmax(0,1fr); gap: 2rem; }
  .hero { gap: 2rem; }
}
@media (max-width: 760px) {
  .header-inner { display: block; padding: .6rem 1rem; }
  .site-brand { font-size: 14px; }
  .site-nav { margin-top: .4rem; flex-wrap: nowrap; overflow-x: auto; gap: .1rem; }
  .site-nav a { font-size: 12px; white-space: nowrap; padding: .3rem .5rem; }
  .site-layout { display: block; padding: 0 1.2rem; }
  .chapter-sidebar { display: none; position: static; max-height: none; padding: 1rem 0; }
  .chapter-sidebar.open { display: block; }
  .chapter-mobile { display: block; margin: 1rem 0 0; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--blue); width: 100%; text-align: left; }
  #content { padding: 2rem 0 3rem; }
  h1.title { font-size: 2.3rem; }
  body { font-size: 16px; }
  .org-src-name { padding: .6rem .7rem; font-size: 12px; }
  .org-src-container pre { padding: .8rem .65rem; }
  .numbered .code-line::before { margin-right: 1em; }
  .figure, figure { padding: .65rem; }
  .site-footer { padding: 1.5rem 1.2rem; }
  .home #content { padding: 2rem 1.2rem; }
  .hero, .course-grid, .pair, .split { grid-template-columns: 1fr; }
  .hero { padding-bottom: 2.5rem; }
  .hero-visual { order: 2; }
  .section-heading { display: block; }
  .section-heading p { margin-top: .6rem; }
  .principles { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media print {
  .site-header, .chapter-sidebar, .chapter-mobile, .site-footer, .skip-link { display: none !important; }
  .site-layout { display: block; padding: 0; }
  #content, .home #content { padding: 0; max-width: none; }
  body { font-size: 10pt; background: white; }
  .outline-2 { break-before: page; border: 0; }
  .sheet { columns: 2; column-gap: 7mm; }
  .sheet > h2, .sheet > .outline-text-2 { column-span: all; }
  .org-src-container, .figure, figure { break-inside: avoid; }
  pre { white-space: pre-wrap; font-size: 8pt; }
  .table-scroll { overflow: visible; }
  a { color: inherit; }
  @page { size: A4; margin: 15mm; }
}

/* Softer line numbers; code remains fully opaque. */
.code-line::before { opacity: .45; }
