:root {
  --bg: #0a121b;
  --bg-2: #0e1823;
  --surface: #121e2b;
  --surface-2: #182636;
  --ink: #e4eaf0;
  --ink-2: #a9b6c4;
  --muted: #74838f;
  --line: #1f2e3e;
  --line-2: #2b3d50;
  --accent: #9cc3e6;
  --accent-ink: #0a121b;
  --danger: #e07a70;
  --night: #050c12;
  --radius: 6px;
  --max: 1080px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body.intro-open, body.no-scroll { overflow: hidden; }
body.intro-open { background: var(--night); }
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 600; margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: #2c4a68; }

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }

/* ---------- Intro ---------- */
.intro {
  position: fixed; inset: 0; z-index: 50;
  background: var(--night) url("/assets/water.png") center / cover no-repeat;
  cursor: pointer;
  transition: opacity .7s ease;
}
.intro.leaving { opacity: 0; pointer-events: none; }
.intro-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transition: opacity .3s; }
.intro-text {
  position: absolute; left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  text-align: center; color: #e9eef3;
  pointer-events: none;
  text-shadow: 0 1px 12px rgba(0,0,0,.5);
}
.intro-name { font-size: clamp(30px, 5vw, 52px); font-weight: 500; letter-spacing: .01em; }
.intro-role { margin-top: 6px; font-size: 15px; letter-spacing: .16em; text-transform: uppercase; color: #b4c0cc; }
.intro-enter {
  position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: none; border: 0; color: #9fb0c0; font: inherit; font-size: 14px;
  letter-spacing: .06em; cursor: pointer; padding: 8px 12px;
}
.intro-enter:hover, .intro-enter:focus-visible { color: #fff; }

/* One unbroken surface: the intro's water lies behind the book and fades into
   a single gradient that runs the full height of the page. */
.site {
  position: relative; isolation: isolate; min-height: 100vh;
  background: linear-gradient(180deg, #050c12 0, #0a121b 100svh, #0c1826 60%, #0a121b 100%);
}
.site::before {
  content: ""; position: absolute; z-index: -1; inset: 0 0 auto; height: 135svh;
  background: url("/assets/water.png") center top / cover no-repeat;
  opacity: .5; pointer-events: none;
  -webkit-mask-image: linear-gradient(#000 30%, transparent);
  mask-image: linear-gradient(#000 30%, transparent);
}

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: rgba(7,14,21,.8);
  backdrop-filter: blur(10px);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-weight: 600; color: var(--ink); text-decoration: none; font-size: 17px; }
.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a { color: var(--ink-2); text-decoration: none; font-size: 15px; }
.nav-links a:hover { color: var(--ink); }
.nav-toggle { display: none; }

.editbar { position: sticky; top: 60px; z-index: 19; background: #1a2b3d; color: var(--ink); font-size: 14px; border-bottom: 1px solid var(--line-2); }
.editbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding-top: 6px; padding-bottom: 6px; flex-wrap: wrap; }
.editbar-actions { display: flex; gap: 8px; }
.editbar.dirty #edit-status::before { content: "● "; color: #f2b84b; }

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 15px; font-weight: 500;
  padding: 9px 16px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .45; cursor: default; filter: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--ink-2); filter: none; }
.btn-small { padding: 5px 12px; font-size: 14px; }
.btn-danger { color: var(--danger); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--bg-2);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.form-error { color: var(--danger); font-size: 14px; min-height: 1.4em; margin: -4px 0 6px; }

/* ---------- Sections ---------- */
.section { padding: 72px 0; overflow-x: clip; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.section-title { font-size: 26px; }
.section-label { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

/* ---------- Book ---------- */
/* The book is the whole first screen: everything below the 60px navbar. */
.about { --edit-h: 0px; padding: 20px 28px 16px; }
.editing .about { --edit-h: 49px; }
.book-stage { display: flex; flex-direction: column; gap: 14px; height: calc(100svh - 96px - var(--edit-h)); min-height: 500px; }
.book-row {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 124px;
  width: 100%; max-width: min(1724px, calc(205svh + 124px)); margin: 0 auto;
}
.book-holder {
  position: relative; min-width: 0; min-height: 0;
  perspective: 2800px;
}
/* Only the open pages take clicks: the 3D layers around them would otherwise
   sit in front of the left-hand pages and swallow the pointer. */
.book { position: absolute; inset: 0; transform-style: preserve-3d; pointer-events: none; }
.book .page:not([inert]) { pointer-events: auto; }
.book-probe { position: absolute; top: 0; left: 0; visibility: hidden; pointer-events: none; }

.page {
  position: absolute; inset: 0; overflow: hidden;
  border: 1px solid var(--line-2);
  background: linear-gradient(90deg, #142233, #172739);
}
.page-inner {
  position: absolute; inset: 0; overflow-y: auto; scrollbar-width: thin;
  padding: clamp(28px, 5.5svh, 60px) clamp(28px, 4vw, 72px) 60px;
}
.page-inner > * { max-width: 62ch; }
.page-no { position: absolute; bottom: 18px; font-size: 13px; color: #8b9aa8; font-variant-numeric: tabular-nums; }
.editing .page-no { display: none; } /* pages can scroll while editing */
.page-title { font-size: clamp(26px, 2.4vw, 36px); margin-bottom: 24px; }
.page-more { font-size: 15px; font-weight: 400; color: #8b9aa8; }
.page-text { white-space: pre-line; color: #bcc8d4; font-size: 18px; line-height: 1.7; }
.page-text + .page-text { margin-top: 16px; }

/* darker towards the spine */
.side.left .page, .face.back .page { border-radius: 8px 2px 2px 8px; background: linear-gradient(90deg, #142233 0%, #172739 86%, #0d1824 100%); }
.side.right .page, .face.front .page { border-radius: 2px 8px 8px 2px; background: linear-gradient(90deg, #0d1824 0%, #172739 14%, #142233 100%); }
.side.left .page-no, .face.back .page-no { left: clamp(28px, 4vw, 72px); }
.side.right .page-no, .face.front .page-no { right: clamp(28px, 4vw, 72px); }

/* Sheets sit half a pixel apart in real 3D space, so the browser sorts the
   stack by depth on both sides, even while several sheets are turning. */
.side, .leaf { position: absolute; top: 0; bottom: 0; width: 50%; }
.side { transform: translateZ(calc((var(--leaves) + 1) * -.5px)); }
.side.left { left: 0; }
.side.right { left: 50%; }
.leaf {
  left: 50%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transform: rotateY(0deg) translateZ(calc((var(--leaves) - var(--i)) * .5px));
  transition: transform 1.2s cubic-bezier(.5,.05,.25,1);
}
.leaf.flipped { transform: rotateY(-180deg) translateZ(calc((var(--leaves) - var(--i)) * .5px)); }
.book.no-anim .leaf { transition: none; }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face.back { transform: rotateY(180deg); }

/* first spread: portrait facing the introduction */
.page-cover .page-inner { display: flex; align-items: center; justify-content: center; container-type: size; }
.page-cover .photo { width: min(92cqw, 72cqh, 500px); } /* sized by whichever side is shorter, so 4:5 always holds */
.page-intro .photo { width: min(150px, 22svh); margin-bottom: 20px; }
.page-intro h1 { font-size: clamp(38px, 4.2vw, 64px); letter-spacing: -.01em; }
.page-intro .intro-role-line { color: var(--accent); font-size: 19px; margin: 8px 0 22px; }
.page-text.page-lead { font-size: clamp(18px, 1.45vw, 21px); line-height: 1.6; color: var(--ink); margin-bottom: 20px; }
.book-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }

.photo {
  aspect-ratio: 4 / 5; border-radius: 4px;
  background: #0f1a26; overflow: hidden; position: relative;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 22px;
  border: 1px solid var(--line-2);
}
.photo img { width: 100%; height: 100%; object-fit: cover; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 6px 0; }
.kv-k { color: #8b9aa8; font-size: 16px; }
.kv-v { color: var(--ink); }
.skill-group { margin-bottom: 24px; }
.skill-group h4 { font-size: 19px; margin-bottom: 4px; }
.skill-group p { color: #bcc8d4; font-size: 18px; }
.entry { margin-bottom: 28px; }
.t-title { font-weight: 600; font-size: 20px; }
.t-org { color: #bcc8d4; }
.t-period { font-size: 15px; color: #8b9aa8; }
.t-detail { color: #bcc8d4; margin-top: 8px; white-space: pre-line; }

.book-controls { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.book-status { font-size: 14px; color: #8b9aa8; min-width: 120px; text-align: center; font-variant-numeric: tabular-nums; }

.book-stage.expanded {
  position: fixed; inset: 0; z-index: 40; height: auto; min-height: 0;
  background: #050c12; padding: 16px;
}
.book-stage.expanded .book-row { max-width: none; }
.one-spread .book-tabs, .one-spread .book-status,
.one-spread [data-book="prev"], .one-spread [data-book="next"], .one-spread [data-book="play"] { display: none; }
.one-spread .book-row { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }

/* index tabs on the book's outer edge */
.book-tabs { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-top: 34px; }
.book-tab {
  font: inherit; font-size: 14px; line-height: 1.25; text-align: left; color: #c3cfda; cursor: pointer;
  width: 104px; min-height: 38px; padding: 7px 10px 7px 12px;
  background: #1a2d41; border: 1px solid var(--line-2); border-left: 0; border-radius: 0 7px 7px 0;
  transition: width .25s, background-color .25s, color .25s;
}
.book-tab:hover { background: #24405c; color: #fff; }
.book-tab[aria-current] { width: 122px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }

/* one page at a time on small screens */
.book.single .page { display: none; border-radius: 2px 8px 8px 2px; transform-origin: left center; }
.book.single .page.current { display: block; }
.book.single .page .page-no { right: 24px; }
.book.single .page.turn-in { animation: turnIn .6s cubic-bezier(.3,.6,.3,1); }
.book.single .page.turn-back { animation: turnBack .6s cubic-bezier(.3,.6,.3,1); }
@keyframes turnIn { from { transform: rotateY(-75deg); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes turnBack { from { transform: rotateY(40deg); opacity: .3; } to { transform: none; opacity: 1; } }

/* ---------- Project tree ---------- */
.tree { position: relative; aspect-ratio: 1000 / 640; margin: 0 auto; max-width: 1000px; }
.tree-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tree-grid, .tree-axis { mask: url(#tree-fade); }
.tree-grid line { stroke: #16232f; stroke-width: 1; stroke-dasharray: 2 6; }
.tree-axis line { stroke: #34485c; stroke-width: 1.2; }
.trunk { fill: #233548; stroke: #2f465d; stroke-width: 1.5; }
.bark { fill: none; stroke: #16242f; stroke-width: 2; stroke-linecap: round; opacity: .8; }
.wood line, .branch line { stroke-linecap: round; }
.root line { stroke: #233548; }
.limb line { stroke: color-mix(in oklab, #2d4560, var(--group) var(--tint)); }
.twig line { stroke: #2a3f55; }
.limb-deco line { stroke: #1d2e40; }
.scatter { fill: #6f8fae; }
.scatter.faint { fill: #4a6684; }
.branch { cursor: pointer; transition: opacity .3s, filter .3s; }
.branch.unsized { opacity: .5; }
.node { fill: var(--group); }
.node-ring { fill: rgba(156,195,230,.08); stroke: var(--group); stroke-width: 1; stroke-dasharray: 3 3; transform-box: fill-box; transform-origin: center; transition: transform .3s, stroke .3s; }
.branch.hot { filter: brightness(1.35); }
.branch.hot .node-ring, .filtering .branch.match .node-ring { transform: scale(1.35); }
.filtering .branch.match { opacity: 1; filter: brightness(1.35); }
.filtering .branch:not(.match) { opacity: .16; }

.tree-key { display: flex; flex-wrap: wrap; gap: 12px 32px; margin-bottom: 20px; }
.key-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.key-name { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink-2); margin-right: 2px; }
.swatch { width: 18px; height: 6px; border-radius: 3px; }
.chip {
  font: inherit; font-size: 14px; color: var(--ink); cursor: pointer;
  padding: 3px 11px; min-height: 30px; border: 1px solid #41566c; border-radius: 15px; background: rgba(10,18,27,.6);
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.key-note { flex-basis: 100%; min-height: 1.6em; font-size: 15px; color: var(--ink-2); }

/* growth animation */
.tree .wood, .tree .branch line, .tree .branch circle, .tree-label { opacity: 0; }
.tree .wood { transition: opacity .8s ease; }
.tree .branch line { transition: opacity .25s ease var(--d, 0s); }
.tree .branch circle { transition: opacity .5s ease 1.4s; }
.tree-label { transition: opacity .5s ease 1.6s, color .2s, border-color .2s; }
.tree.grown .wood, .tree.grown .branch line, .tree.grown .branch circle, .tree.grown .tree-label { opacity: 1; }
.tree.grown .scatter.faint { opacity: .7; }
.tree.settled .tree-label, .tree.settled .branch line, .tree.settled .branch circle { transition-delay: 0s; }
.filtering .tree.grown .tree-label:not(.match), .filtering .legend li:not(.match) { opacity: .35; }
.legend li { transition: opacity .3s; }

.tree-label {
  position: absolute; display: flex; align-items: flex-start; gap: 10px;
  width: max-content; max-width: 200px; text-align: left;
  font: inherit; color: var(--ink); background: rgba(10,18,27,.78);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 8px 12px;
  cursor: pointer; backdrop-filter: blur(2px);
}
.tree-label:hover, .tree-label:focus-visible { border-color: var(--accent); outline: none; }
.tree-label.left { transform: translate(calc(-100% - 30px), -50%); }
.tree-label.right { transform: translate(30px, -50%); }
.tree-label.top { transform: translate(-50%, calc(-100% - 30px)); }
.tree-label.bottom { transform: translate(-50%, 30px); }
.tl-no { font-family: var(--mono); font-size: 12px; color: var(--accent); padding-top: 3px; }
.tl-text { display: flex; flex-direction: column; }
.tl-title { font-size: 15px; font-weight: 500; line-height: 1.3; }
.tl-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

.legend { list-style: none; margin: 34px 0 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.legend-open {
  all: unset; cursor: pointer; flex: 1; min-width: 240px;
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: baseline;
  padding: 10px 4px;
}
.legend-open:hover .legend-title, .legend-open:focus-visible .legend-title { color: var(--accent); }
.legend-title { font-weight: 500; }
.legend-meta { font-size: 14px; color: var(--muted); text-align: right; }
.legend-admin { display: flex; gap: 8px; padding: 8px 0; }

/* ---------- Timeline ---------- */
.years { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 64px; align-items: center; }
.rings { display: block; width: 100%; }
.ring-bark { fill: #16242f; stroke: #2f465d; stroke-width: 2; }
.ring { cursor: pointer; }
.ring-body { fill: #2b4259; stroke: #0f1b27; stroke-width: 1.5; transition: fill .25s; }
.ring-body.alt { fill: #223649; }
.ring-grain { fill: none; stroke: #0f1b27; stroke-opacity: .4; stroke-width: 1; pointer-events: none; }
.ring:hover .ring-body { fill: #3d5f81; }
.ring.on .ring-body { fill: #4779ab; stroke: var(--accent); }
.ring-pith { fill: #16242f; }
.year-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.year-btn {
  font: inherit; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--ink); cursor: pointer;
  padding: 5px 12px; background: rgba(10,18,27,.6); border: 1px solid #41566c; border-radius: var(--radius);
}
.year-btn:hover { border-color: var(--accent); }
.year-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.year-detail { min-height: 230px; }
.year-detail h3 { font-size: 40px; margin-bottom: 14px; }
.year-detail ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.year-detail li { display: flex; flex-direction: column; align-items: flex-start; }
.year-detail li span { color: var(--ink-2); font-size: 15px; }
.year-link { font: inherit; font-weight: 600; padding: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; text-align: left; }
.milestones { margin-top: 48px; max-width: 640px; }
.milestones h3 { font-size: 19px; margin-bottom: 6px; }
.milestone { display: grid; grid-template-columns: 70px 1fr; gap: 16px; margin-top: 18px; }

/* ---------- Stream ---------- */
main { position: relative; }
.stream { position: absolute; top: 0; left: 0; z-index: -1; pointer-events: none; overflow: visible; }
.strand { fill: none; stroke: #9cc3e6; stroke-width: 1.6; stroke-opacity: .75; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.strand.soft { stroke: #4b93dd; stroke-width: 1.2; stroke-opacity: .7; }
.strand.glow { stroke: #4b93dd; stroke-width: 16; stroke-opacity: .09; }
.stream-drop { fill: #e4f1fc; }
.pool ellipse {
  fill: none; stroke: #9cc3e6; stroke-width: 1.2; stroke-opacity: 0;
  transform-box: fill-box; transform-origin: center; transform: scale(.2);
  transition: transform 1.6s cubic-bezier(.2,.7,.3,1), stroke-opacity 1.2s;
}
.pool ellipse:nth-child(2) { transition-delay: .15s; }
.pool ellipse:nth-child(3) { transition-delay: .3s; }
.arrived .pool ellipse { transform: none; stroke-opacity: .55; }
.arrived .pool ellipse:nth-child(2) { stroke-opacity: .35; }
.arrived .pool ellipse:nth-child(3) { stroke-opacity: .18; }

/* ---------- Contact ---------- */
.contact-lead { font-size: 19px; color: var(--ink-2); max-width: 34em; margin-bottom: 24px; }
.contact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.contact-list li { display: grid; grid-template-columns: 110px 1fr; gap: 12px; }
.contact-list .k { color: var(--muted); font-size: 15px; }

.footer { padding: 28px 0; font-size: 14px; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; }
.footer a { color: var(--muted); }

/* ---------- Dialogs ---------- */
.dialog {
  border: 1px solid var(--line-2); border-radius: 8px; padding: 0;
  background: var(--surface); color: var(--ink);
  width: calc(100% - 32px); max-height: calc(100vh - 48px);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.dialog::backdrop { background: rgba(3,8,13,.75); backdrop-filter: blur(2px); }
.dialog-small { max-width: 400px; }
.dialog-small form { padding: 28px; }
.dialog-small h2 { font-size: 21px; margin-bottom: 6px; }
.dialog-small .muted { margin-bottom: 18px; font-size: 15px; }
.dialog-wide { max-width: 980px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.dialog[open] { animation: pop .25s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.pv { padding: 0 40px 40px; }
.pv-top {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin: 0 -40px; padding: 16px 40px 12px;
}
.pv h2 { font-size: clamp(22px, 3vw, 30px); overflow-wrap: anywhere; }
.pv-top .btn { flex: none; }
.pv-about { color: var(--ink-2); font-size: 15px; margin-bottom: 20px; }
.pv-cover { border-radius: var(--radius); margin-bottom: 24px; width: 100%; }
.pv-summary { font-size: 20px; line-height: 1.5; max-width: 62ch; }
.pv h3 { font-size: 22px; margin-bottom: 10px; }
.pv-images { margin: 40px 0 24px; }

.story { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 44px; margin-top: 36px; }
.story-nav { position: sticky; top: calc(var(--bar, 60px) + 16px); align-self: start; display: flex; flex-direction: column; gap: 22px; }
.story-nav button {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 0;
  font: inherit; font-size: 16px; color: var(--ink-2); background: none; border: 0; cursor: pointer; text-align: left;
}
.story-nav button:hover { color: var(--ink); }
/* the line between steps fills as the reader moves on */
.story-nav button + button::before {
  content: ""; position: absolute; left: 14px; bottom: calc(100% - 1px); width: 2px; height: 24px; background: var(--line-2);
}
.step-no {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; font-size: 14px;
  border: 2px solid var(--line-2); border-radius: 50%; background: var(--surface);
}
.story-nav .done .step-no { border-color: #4b93dd; }
.story-nav [aria-current] { color: var(--ink); font-weight: 600; }
.story-nav [aria-current] .step-no { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.story-nav .done + button::before { background: #4b93dd; }
.story-step { scroll-margin-top: calc(var(--bar, 60px) + 16px); }
.story-step + .story-step { margin-top: 48px; }
.story-step > p { white-space: pre-line; color: #bcc8d4; max-width: 62ch; }

/* ---------- Chart ---------- */
.chart { margin-top: 24px; }
.chart-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px 20px; margin-bottom: 14px; }
.chart-title { font-size: 17px; overflow-wrap: anywhere; }
.chart-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.chart-controls label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.chart select, .field select {
  font: inherit; font-size: 15px; color: var(--ink); max-width: 100%;
  padding: 5px 8px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--bg-2);
}
.field select { width: 100%; font-size: 16px; padding: 9px 8px; }
.chart-stage { position: relative; }
.chart-plot { min-height: 44px; touch-action: pan-y; border-radius: 4px; }
.chart-plot:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.chart-plot svg { display: block; }
.c-grid { stroke: #22344a; stroke-width: 1; }
.c-base, .c-hair { stroke: #5c7188; stroke-width: 1; }
.c-text { fill: #9aa9b8; font-size: 13px; font-variant-numeric: tabular-nums; }
.c-name { fill: var(--ink-2); font-size: 13px; }
.c-value { fill: var(--ink); font-size: 13px; }
.c-line { fill: none; stroke: #4b93dd; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.c-dot { fill: #4b93dd; stroke: var(--surface); stroke-width: 2; }
.c-bar { fill: #4b93dd; }
.c-bar.on { fill: #82b8ee; }
.chart-tip {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none;
  display: flex; flex-direction: column; width: max-content; max-width: 220px; padding: 8px 12px;
  font-size: 13px; line-height: 1.4; color: var(--ink-2); overflow-wrap: anywhere;
  background: #050c12; border: 1px solid #41566c; border-radius: 5px;
}
.chart-tip strong { font-size: 16px; color: var(--ink); }
.chart-note { font-size: 14px; color: var(--ink-2); margin-top: 8px; }
.chart-table { max-height: 320px; overflow: auto; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: 15px; }
.chart-table th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 500; }
.chart-table th, .chart-table td { padding: 6px 10px 6px 0; overflow-wrap: anywhere; }
.chart-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ed-chart { font-size: 16px; }

.pv-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 8px; }
.pv-gallery img { border-radius: 4px; border: 1px solid var(--line-2); cursor: zoom-in; }

.ed { padding: 28px 32px; }
.ed h2 { font-size: 22px; margin-bottom: 18px; }
.ed-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.ed-images { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 16px; }
.thumb { position: relative; width: 120px; height: 84px; border-radius: 4px; overflow: hidden; border: 1px solid var(--line-2); background: var(--bg-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button {
  position: absolute; top: 4px; right: 4px; border: 0; border-radius: 3px;
  background: rgba(0,0,0,.7); color: #fff; font-size: 12px; padding: 2px 6px; cursor: pointer;
}
.upload-btn { position: relative; overflow: hidden; }
.upload-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ed-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 4px; }

.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 24px; }
.lightbox img { max-height: 100%; max-width: 100%; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: var(--radius);
  font-size: 15px; opacity: 0; pointer-events: none; transition: .25s ease; z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- Edit mode ---------- */
.editing [data-path] {
  outline: 1px dashed transparent; outline-offset: 3px; border-radius: 2px;
  transition: outline-color .15s; min-width: 2em;
}
.editing [data-path]:hover { outline-color: #557089; }
.editing [data-path]:focus { outline: 2px solid var(--accent); }
.editing [data-path]:empty::before { content: attr(data-ph); color: #5d6d7c; }
.edit-only { display: none !important; }
.editing .edit-only { display: inline-flex !important; }
.editing .photo { cursor: pointer; }
.photo-hint {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.7); color: #fff;
  font-size: 12px; letter-spacing: 0; padding: 4px 8px; border-radius: 4px;
}
.item-remove {
  border: 0; background: none; color: var(--danger); font: inherit; font-size: 13px;
  cursor: pointer; padding: 0; margin-top: 4px; align-self: start;
}
.add-btn { margin-top: 16px; justify-self: start; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
}
@media (max-width: 1000px) {
  .about { padding-left: 16px; padding-right: 16px; }
  .book-stage:not(.one-spread) .book-row { grid-template-columns: minmax(0, 1fr); grid-template-rows: 40px minmax(0, 1fr); }
  .book-tabs { order: -1; flex-direction: row; align-items: flex-end; gap: 4px; padding: 0 8px; overflow-x: auto; scrollbar-width: none; }
  .book-tab, .book-tab[aria-current] {
    flex: none; width: auto; min-height: 36px; padding: 6px 12px; white-space: nowrap;
    border: 1px solid var(--line-2); border-bottom: 0; border-radius: 7px 7px 0 0;
  }
}
@media (max-width: 860px) {
  .story { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .story-nav { top: calc(var(--bar, 60px) - 1px); flex-direction: row; gap: 4px; margin: 0 -8px; padding: 8px; overflow-x: auto; scrollbar-width: none; background: var(--surface); z-index: 1; }
  .story-nav button { flex: none; padding: 4px 8px 4px 4px; }
  .story-nav button + button::before { display: none; }
  .story-step { scroll-margin-top: calc(var(--bar, 60px) + 64px); }
  .years { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .rings { max-width: 340px; margin: 0 auto; }
}
@media (max-width: 900px) {
  .tree-label { padding: 4px 7px; max-width: none; }
  .tree-label .tl-text { display: none; }
  .tree-label.left { transform: translate(calc(-100% - 14px), -50%); }
  .tree-label.right { transform: translate(14px, -50%); }
  .tree-label.top { transform: translate(-50%, calc(-100% - 14px)); }
  .tree-label.bottom { transform: translate(-50%, 14px); }
  .legend-open { grid-template-columns: 30px 1fr; }
  .legend-meta { grid-column: 2; text-align: left; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .container { padding: 0 16px; }
  .section { padding: 56px 0; }
  .about { padding: 12px 12px 8px; }
  .editing .about { --edit-h: 96px; }
  .book-stage { height: calc(100svh - 80px - var(--edit-h)); }
  .page-inner { padding: 28px 24px 52px; }
  .page-text, .skill-group p { font-size: 17px; }
  .book-controls { gap: 6px; }
  .book-controls .btn { padding: 5px 9px; }
  .book-status { order: -1; width: 100%; }
  .contact-lead { font-size: 17px; }
  #contact { padding-bottom: 110px; } /* room for the pool */
  .strand.glow { stroke-width: 8; }
  .nav-toggle { display: inline-flex; background: none; border: 1px solid var(--line-2); border-radius: var(--radius); font: inherit; font-size: 14px; padding: 5px 10px; color: var(--ink); }
  .nav-links {
    position: absolute; top: 60px; left: 0; right: 0; background: var(--bg);
    flex-direction: column; align-items: flex-start; gap: 0; padding: 8px 16px 16px;
    border-bottom: 1px solid var(--line); display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 0; width: 100%; }
  .contact-list li { grid-template-columns: 1fr; gap: 0; }
  .ed-row { grid-template-columns: 1fr; }
  .pv { padding: 0 20px 28px; }
  .pv-top { margin: 0 -20px; padding: 12px 20px; }
  .ed { padding: 24px 20px; }
  .book-stage.expanded { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .intro { transition: none; }
}
