:root {
  color-scheme: light; /* always the cream page, even when the device is in dark mode */
  --paper: #F5F4EF; --paper-2: #FBFAF7; --ground: #ECEAE3; --ground-hover: #E3E1D9;
  --ink: #1C2128; --ink-2: #3A4049; --muted: #5F646B;
  --hairline: #D9D7D0; --hairline-2: #C4C2BA;
  --ember: #B8431A; --ember-ink: #93350F; --ember-soft: rgba(184,67,26,.10);
  --display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --text: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --fs-0: .8125rem; --fs-1: .875rem; --fs-2: 1rem; --fs-3: 1.125rem; --fs-4: 1.3rem;
  --fs-5: clamp(1.7rem, 1.3rem + 1.6vw, 2.2rem);
  --fs-6: clamp(2.1rem, 1.4rem + 3.2vw, 3.6rem);
  --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem; --s-8: 4rem; --s-9: 5.5rem;
  --r-1: 3px; --r-2: 6px;
  --measure: 64ch; --container: 1120px; --gutter: 1.25rem; --rail: 200px;
  --section-gap: var(--s-8);
  --strip-h: 48px;
}
@media (min-width: 768px) { :root { font-size: 17px; --gutter: 2rem; --section-gap: var(--s-9); } }
@media (min-width: 1100px) { :root { --gutter: 3rem; } }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 400 var(--fs-2)/1.6 var(--text); font-synthesis: none; -webkit-font-smoothing: antialiased; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; color: var(--ink); text-wrap: balance; }
h1 { font-size: var(--fs-6); line-height: 1.02; letter-spacing: -.02em; max-width: 14ch; }
h2 { font-size: var(--fs-5); line-height: 1.15; letter-spacing: -.02em; }
h3 { font-size: var(--fs-4); line-height: 1.3; letter-spacing: -.01em; }
p { margin: 0 0 1em; max-width: var(--measure); color: var(--ink-2); }
p:last-child { margin-bottom: 0; }
p.lede { font-size: var(--fs-3); line-height: 1.55; color: var(--ink); }
strong, b { font-weight: 600; color: var(--ink); }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--hairline-2); text-underline-offset: .18em; overflow-wrap: anywhere; }
a:hover { text-decoration-color: var(--ember); }
:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ember); border-radius: var(--r-1); }
.mono, .meta, figcaption, .badge, .receipts dd, .kicker, .proofline, .state, .when { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: var(--gutter); top: -4rem; background: var(--ink); color: var(--paper); padding: .5rem .75rem; border-radius: var(--r-1); z-index: 10; }
.skip:focus { top: .5rem; }

.wrap { max-width: var(--container); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }

/* hero */
.hero { padding-top: var(--s-6); padding-bottom: var(--s-7); display: grid; gap: var(--s-5); }
.hero .name { font-family: var(--mono); font-size: var(--fs-1); color: var(--muted); margin: 0 0 var(--s-4); }
.hero .lede { margin-top: var(--s-4); }
.cta { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-5); align-items: center; margin-top: var(--s-4); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: .7rem 1.1rem; background: var(--ink); color: var(--paper); font-weight: 600; text-decoration: none; border-radius: var(--r-1); }
.btn:hover { background: var(--ember); color: #fff; }
.cta a.plain { font-size: var(--fs-1); }
.problems { margin-top: var(--s-5); border-top: 1px solid var(--hairline); }
.problems li { padding: var(--s-4) 0; border-bottom: 1px solid var(--hairline); }
.problems .pnum { font-family: var(--mono); font-size: var(--fs-0); color: var(--muted); display: block; margin-bottom: .2rem; }
.problems h2 { font-size: var(--fs-4); margin-bottom: .3rem; }
.problems h2 a { text-decoration: none; }
.problems h2 a:hover { color: var(--ember-ink); }
.problems p { font-size: var(--fs-1); margin: 0; max-width: 60ch; }
.problems .proofline { font-size: var(--fs-0); color: var(--ink); margin-top: .45rem; }
.hero .media { margin-top: var(--s-2); }
.hero .plist { margin-top: var(--s-2); }
@media (min-width: 1100px) {
  .hero { grid-template-columns: minmax(0,7fr) minmax(0,5fr); grid-template-areas: "head media" "plist media"; column-gap: var(--s-7); row-gap: var(--s-4); align-items: start; }
  .hero .head { grid-area: head; }
  .hero .media { grid-area: media; margin-top: 2.4rem; }
  .hero .plist { grid-area: plist; }
}

/* media */
figure { margin: 0; }
.vid { position: relative; border-radius: var(--r-2); overflow: hidden; background: #111; }
.vid.wide { aspect-ratio: 16 / 9; }
.vid.tall { aspect-ratio: 9 / 16; max-width: 280px; }
.vid video { width: 100%; height: 100%; object-fit: contain; background: #111; }
.vid .len { position: absolute; right: .6rem; top: .6rem; font-family: var(--mono); font-size: var(--fs-0); color: #F5F4EF; background: rgba(20,22,25,.7); padding: .1rem .4rem; border-radius: var(--r-1); pointer-events: none; }
figcaption { font-size: var(--fs-1); color: var(--muted); margin-top: .5rem; line-height: 1.5; }
.photo img { width: 100%; border-radius: var(--r-2); }
.photo { margin-top: var(--s-5); }

/* status strip */
.status { border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); background: var(--paper-2); }
.status .wrap { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-6); padding-top: var(--s-4); padding-bottom: var(--s-4); align-items: baseline; }
.status .k { font-size: var(--fs-0); color: var(--muted); display: block; font-family: var(--mono); }
.status .v { font-family: var(--mono); font-size: var(--fs-3); color: var(--ink); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ember); margin-right: .4rem; vertical-align: 1px; }
.status .src { font-size: var(--fs-0); color: var(--muted); margin-left: auto; font-family: var(--mono); }

/* chapters */
.chapter { position: relative; padding-top: var(--s-6); padding-bottom: var(--section-gap); border-top: 1px solid var(--hairline); }
.chapter-head { margin-bottom: var(--s-4); }
.chapter-head .meta { margin: .3rem 0 0; }
.meta { font-size: var(--fs-1); color: var(--muted); line-height: 1.6; max-width: none; }
.chapter-body > * + * { margin-top: var(--s-5); }
.prose > * + * { margin-top: 1em; }
.prose h3 { margin-top: 1.6em; }
.prose h3:first-child { margin-top: 0; }
@media (min-width: 768px) {
  .chapter.wrap { display: grid; grid-template-columns: 150px minmax(0,1fr); column-gap: var(--s-6); }
}
@media (min-width: 1100px) {
  .chapter.wrap { grid-template-columns: var(--rail) minmax(0,1fr); column-gap: var(--s-7); }
}

/* built table */
.built { width: 100%; border-collapse: collapse; font-size: var(--fs-1); }
.built th, .built td { text-align: left; vertical-align: top; padding: .75rem .75rem .75rem 0; border-top: 1px solid var(--hairline); }
.built th { font-family: var(--mono); font-weight: 400; color: var(--muted); font-size: var(--fs-0); border-top: 0; padding-top: 0; }
.built td:first-child { font-weight: 600; color: var(--ink); white-space: nowrap; }
.built td { color: var(--ink-2); }
@media (max-width: 767px) {
  .built thead { display: none; }
  .built, .built tbody, .built tr, .built td { display: block; }
  .built tr { border-top: 1px solid var(--hairline); padding: .75rem 0; }
  .built td { border: 0; padding: .15rem 0; white-space: normal; }
  .built td:first-child { white-space: normal; }
  .built td.with:empty { display: none; }
}

.aibox { background: var(--paper-2); border: 1px solid var(--hairline); border-radius: var(--r-2); padding: var(--s-5); }
.aibox h3 { font-size: var(--fs-3); margin-bottom: .5rem; }
.aibox .meta { margin-bottom: .75rem; }
ul.plain { list-style: disc; padding-left: 1.2rem; max-width: var(--measure); color: var(--ink-2); }
ul.plain li { margin: .35rem 0; }

/* readings table */
.readings { border-collapse: collapse; font-family: var(--mono); font-size: var(--fs-1); margin-top: .6rem; }
.readings th, .readings td { text-align: right; padding: .5rem .9rem .5rem 0; border-bottom: 1px solid var(--hairline); }
.readings th { font-weight: 400; color: var(--muted); font-size: var(--fs-0); }
.readings td:first-child, .readings th:first-child { text-align: left; }
.readings td.up { color: var(--ember-ink); }
.readings caption { caption-side: bottom; text-align: left; font-family: var(--text); font-size: var(--fs-1); color: var(--muted); padding-top: .5rem; }

/* data panel */
.data { border: 1px solid var(--hairline); border-radius: var(--r-2); background: var(--paper-2); padding: var(--s-5); display: grid; gap: var(--s-4); }
.data h3 { font-size: var(--fs-3); }
.spark { width: 100%; max-width: 480px; height: auto; color: var(--ember); }
.split { display: grid; gap: var(--s-5); }
@media (min-width: 768px) { .split { grid-template-columns: 1fr 1fr; } }
.label { font-family: var(--mono); font-size: var(--fs-0); color: var(--muted); margin: 0 0 .5rem; }
.data ul li { font-size: var(--fs-1); color: var(--ink-2); padding: .35rem 0; border-top: 1px solid var(--hairline); }
.data ul li:first-child { border-top: 0; padding-top: 0; }
.caveat { border-left: 2px solid var(--ember); padding-left: var(--s-4); }

.receipts { margin: 0; display: grid; gap: .2rem; }
.receipts > div { display: flex; align-items: baseline; gap: .5rem; min-height: 40px; }
.receipts dt { font-size: var(--fs-1); flex: 0 1 auto; }
.receipts .lead { flex: 1 1 1rem; border-bottom: 1px dotted var(--hairline-2); transform: translateY(-.35em); }
.receipts dd { margin: 0; font-size: var(--fs-1); color: var(--muted); max-width: 55%; text-align: right; }

.credits li { padding: .7rem 0; border-top: 1px solid var(--hairline); font-size: var(--fs-1); color: var(--ink-2); max-width: var(--measure); }
.credits li:first-child { border-top: 0; padding-top: 0; }

.log li { display: grid; grid-template-columns: 7.2rem minmax(0,1fr); gap: var(--s-3); padding: .5rem 0; border-top: 1px solid var(--hairline); font-size: var(--fs-1); color: var(--ink-2); max-width: var(--measure); }
.log li:first-child { border-top: 0; padding-top: 0; }
.log .when { color: var(--muted); font-size: var(--fs-0); padding-top: .15rem; }
@media (max-width: 480px) { .log li { grid-template-columns: 1fr; gap: .1rem; } }

/* other work rows */
.works li { display: grid; gap: .3rem var(--s-6); padding: var(--s-5) 0; border-top: 1px solid var(--hairline); }
.works li:first-child { border-top: 0; padding-top: 0; }
@media (min-width: 768px) { .works li { grid-template-columns: 220px minmax(0,1fr); } }
.works h3 { font-size: var(--fs-3); }
.works .kicker { font-size: var(--fs-0); color: var(--muted); margin: .2rem 0 0; }
.works p { font-size: var(--fs-1); }
.works .proofline { font-size: var(--fs-0); color: var(--ink); margin-top: .5rem; }
.works .more { font-size: var(--fs-1); margin-top: .4rem; display: inline-block; }

.unfinished li { padding: var(--s-3) 0; display: grid; grid-template-columns: 7rem minmax(0,1fr); gap: var(--s-3); font-size: var(--fs-2); color: var(--ink-2); max-width: var(--measure); }
.unfinished li + li { border-top: 1px solid var(--hairline); }
.unfinished .state { font-size: var(--fs-1); color: var(--muted); }
@media (max-width: 480px) { .unfinished li { grid-template-columns: 1fr; gap: .1rem; } }

.onpaper { font-family: var(--mono); font-size: var(--fs-1); color: var(--muted); max-width: none; }

.site-footer { border-top: 1px solid var(--hairline); padding-top: var(--s-6); padding-bottom: var(--s-8); display: grid; gap: var(--s-5); font-size: var(--fs-1); }
.site-footer p { max-width: none; }
.site-footer .receipts dd { max-width: 70%; }
.colophon { font-size: var(--fs-0); color: var(--muted); grid-column: 1 / -1; max-width: 72ch; }
@media (min-width: 768px) { .site-footer { grid-template-columns: 1.1fr 1fr 1fr; } }

/* ---------- mobile pass ---------- */
@media (min-width: 768px) { section[id], div[id] { scroll-margin-top: 64px; } }
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); min-height: 44px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h3 { margin: 0; }
details.fold > summary::after { content: "Show"; font-family: var(--mono); font-size: var(--fs-0); color: var(--muted); border: 1px solid var(--hairline-2); border-radius: var(--r-1); padding: .15rem .5rem; flex: none; }
details.fold[open] > summary::after { content: "Hide"; }
details.fold[open] > summary { margin-bottom: 1em; }
.works .more { padding: .6rem 0; }
@media (min-width: 768px) {
  details.fold > summary::after { display: none; }
  details.fold > summary { cursor: default; pointer-events: none; min-height: 0; }
}
@media (max-width: 767px) {
  :root { --gutter: 1.1rem; }
  .hero { padding-top: var(--s-4); gap: var(--s-4); }
  h1 { font-size: 2.15rem; }
  .btn { width: 100%; }
  .cta { gap: var(--s-2); }
  .cta a.plain { padding: .5rem 0; }
  .chapter { padding-top: var(--s-5); padding-bottom: var(--s-7); }
  .chapter-head h2 { font-size: 1.85rem; }
  .prose h3 { font-size: 1.2rem; }
  /* receipts: label above link, no dotted leader, no mid-word breaks */
  .receipts > div { display: block; padding: .55rem 0; border-top: 1px solid var(--hairline); min-height: 0; }
  .receipts > div:first-child { border-top: 0; }
  .receipts .lead { display: none; }
  .receipts dt { color: var(--ink-2); }
  .receipts dd, .site-footer .receipts dd { max-width: none; text-align: left; margin-top: .15rem; }
  .receipts dd a { overflow-wrap: normal; word-break: normal; display: inline-block; padding: .2rem 0; }
  /* status strip: tidy 3-column grid */
  .status .wrap { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); }
  .status .src { grid-column: 1 / -1; margin-left: 0; }
  /* media */
  .vid.tall { max-width: 230px; }
  .split { gap: var(--s-4); }
  .data { padding: var(--s-4); }
  .readings { font-size: .8rem; }
  .readings th, .readings td { padding-right: .55rem; }
  .works li { padding: var(--s-4) 0; }
  .site-footer { gap: var(--s-4); }
}

/* ---------- header: title bar + sticky tab strip (tabs from design B, colours from A) ---------- */
html { scroll-padding-top: calc(var(--strip-h) + 12px); }
section[id], main[id], footer[id], div[id], figure[id] { scroll-margin-top: calc(var(--strip-h) + 12px); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.titlebar { background: var(--ground); }
.titlebar-inner { height: 44px; display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }
.titlebar .brand { font-family: var(--display); font-weight: 600; font-size: .98rem; text-decoration: none; white-space: nowrap; letter-spacing: -.01em; }
.titlebar nav { display: flex; gap: var(--s-5); font-size: var(--fs-1); }
.titlebar nav a { padding: .7rem 0; text-decoration: none; color: var(--ink-2); white-space: nowrap; }
.titlebar nav a:hover { text-decoration: underline; color: var(--ink); }
@media (max-width: 767px) { .titlebar nav .wide { display: none; } }

.stripbar { position: sticky; top: 0; z-index: 30; background: var(--ground); border-bottom: 1px solid var(--hairline); padding-top: env(safe-area-inset-top, 0px); }
.stripbar-inner { display: flex; align-items: flex-end; gap: var(--s-2); height: var(--strip-h); }
.strip-scroll { flex: 1 1 auto; min-width: 0; height: 100%; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; display: flex; align-items: flex-end;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.strip-scroll.at-end { -webkit-mask-image: none; mask-image: none; }
.strip-scroll::-webkit-scrollbar { display: none; }
.tabs { display: flex; align-items: flex-end; height: 100%; }
.tab { position: relative; flex: none; display: flex; align-items: center; height: 42px; margin-bottom: -1px; padding: 0 .95rem; border: 1px solid transparent; border-bottom: 0; border-radius: var(--r-2) var(--r-2) 0 0;
  font-size: var(--fs-1); color: var(--muted); text-decoration: none; white-space: nowrap; transition: background-color .15s, color .15s; }
.tab:hover { background: var(--ground-hover); color: var(--ink); }
.tab.active { background: var(--paper); color: var(--ink); border-color: var(--hairline); font-weight: 600; }
.tab.active::before { content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 2px; background: var(--ember); border-radius: var(--r-2) var(--r-2) 0 0; }
.tab:focus-visible { box-shadow: inset 0 0 0 2px var(--ember); }
.alltabs { flex: none; align-self: center; font: 600 var(--fs-0)/1 var(--text); color: var(--ink-2); background: var(--paper-2); border: 1px solid var(--hairline-2); border-radius: var(--r-1); min-height: 34px; padding: 0 .7rem; cursor: pointer; }
.alltabs:hover { border-color: var(--ink); color: var(--ink); }

/* all tabs sheet */
.sheet { border: 1px solid var(--hairline-2); border-radius: 10px; padding: 0; background: var(--paper); color: var(--ink); width: min(420px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 48px)); box-shadow: 0 10px 30px rgba(20,22,25,.18); }
.sheet::backdrop { background: rgba(20,22,25,.35); }
.sh-head { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--hairline); position: sticky; top: 0; background: var(--paper); }
.sh-head h2 { font-size: var(--fs-3); }
.sh-body { display: grid; padding: .25rem 1rem 1rem; }
.sh-body a { display: flex; align-items: center; min-height: 48px; border-bottom: 1px solid var(--hairline); text-decoration: none; font-family: var(--display); font-weight: 600; }
.sh-body a.sub { padding-left: 1rem; font-family: var(--text); font-weight: 400; color: var(--ink-2); }
.sh-body a.active { color: var(--ember-ink); }
.sbtn, .copy { font: 600 var(--fs-0)/1 var(--text); color: var(--ink-2); background: var(--paper-2); border: 1px solid var(--hairline-2); border-radius: var(--r-1); min-height: 36px; min-width: 44px; padding: 0 .6rem; cursor: pointer; }
.sbtn:hover, .copy:hover { border-color: var(--ink); color: var(--ink); }
.copy { min-height: 28px; vertical-align: 1px; margin-left: .25rem; }
@media (max-width: 600px) {
  .sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 12px 12px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .sheet[open] { animation: sheetup 220ms cubic-bezier(.215,.61,.355,1); }
}
@keyframes sheetup { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } .tab { transition: none; } }

/* pieces the design drew inline */
.spark .sv { font-family: var(--mono); font-size: 7px; fill: var(--muted); }
.prose ul:not([class]) { list-style: disc; padding-left: 1.2rem; max-width: var(--measure); color: var(--ink-2); }
.prose ul:not([class]) li { margin: .35rem 0; }
.works .more { padding: .6rem 0; }
@media (min-width: 1100px) {
  .chapter-head { position: sticky; top: calc(var(--strip-h) + 1.5rem); align-self: start; }
  .hero .media { position: sticky; top: calc(var(--strip-h) + 1.5rem); }
}
@media (max-width: 767px) {
  .titlebar-inner { height: 42px; }
  .tab { padding: 0 .8rem; height: 40px; }
  .built td.with::before { content: attr(data-prefix); font-family: var(--mono); font-size: var(--fs-0); color: var(--muted); }
  .built.cols-2 td:first-child { color: var(--muted); font-family: var(--mono); font-size: var(--fs-0); font-weight: 400; }
}

/* ---------- quiet motion: things settle in as you reach them ---------- */
.reveal { opacity: 0; transform: translateY(8px); transition: opacity .6s cubic-bezier(.215,.61,.355,1), transform .6s cubic-bezier(.215,.61,.355,1); }
.reveal.in { opacity: 1; transform: none; }
.status .dot { animation: breathe 2.8s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(184,67,26,.45); }
  50% { box-shadow: 0 0 0 5px rgba(184,67,26,0); }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .status .dot { animation: none; }
}
