@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 200 900; font-display: swap; src: url("fonts/source-serif-4-normal-latin.woff2?v=2a24bad466") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 200 900; font-display: swap; src: url("fonts/source-serif-4-normal-latin-ext.woff2?v=a0cd390d01") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 200 900; font-display: swap; src: url("fonts/source-serif-4-italic-latin.woff2?v=011e0ca2bd") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F; }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 200 900; font-display: swap; src: url("fonts/source-serif-4-italic-latin-ext.woff2?v=513549ab98") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F; }

:root {
  --paper: #f5f0e6; --paper-2: #ebe3d2; --ink: #1c1a17; --muted: #4d4639; --rule: #cdc1aa;
  --accent: #b3380e; --accent-ink: #ffffff; --link: #9a3009;
  --dot: #8a7f69; --dot-old: #bdb29b; --dot-live: #5a5243; --you: #d2410f;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --bar: 3rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111217; --paper-2: #1a1c23; --ink: #eee8dc; --muted: #c0b7a6; --rule: #343844;
    --accent: #ff8a5c; --accent-ink: #1a0c05; --link: #ffa37f;
    --dot: #857c68; --dot-old: #4a473f; --dot-live: #cfc6b4; --you: #ff7a45;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111217; --paper-2: #1a1c23; --ink: #eee8dc; --muted: #c0b7a6; --rule: #343844;
  --accent: #ff8a5c; --accent-ink: #1a0c05; --link: #ffa37f;
  --dot: #857c68; --dot-old: #4a473f; --dot-live: #cfc6b4; --you: #ff7a45;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 1.1875rem/1.6 var(--serif); }
a { color: var(--link); text-underline-offset: 0.15em; overflow-wrap: anywhere; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; z-index: 50; }
.skip:focus { left: 0.5rem; }
b, strong { font-weight: 650; }
.num { font-variant-numeric: tabular-nums; }

/* one-line bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 0.9rem; height: var(--bar); padding: 0 1rem; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); font: 500 0.9rem/1 var(--sans); white-space: nowrap; }
.topbar a { color: var(--ink); text-decoration: none; }
.topbar .home { font-weight: 700; }
.topnav { display: flex; gap: 0.9rem; overflow-x: auto; scrollbar-width: none; min-width: 0; flex: 1 1 auto; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { padding: 0.9rem 0.1rem; border-bottom: 2px solid transparent; }
.topnav a[aria-current] { border-bottom-color: var(--accent); }
.chip { border: 1px solid var(--rule); border-radius: 999px; padding: 0.35rem 0.7rem; flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; margin-right: -0.5rem; border: 0; background: none; color: var(--ink); border-radius: 50%; cursor: pointer; flex: none; }
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }
@media (max-width: 560px) { .topbar .home { display: none; } }

/* reading rail */
.rail { position: fixed; right: 0.9rem; top: 50%; transform: translateY(-50%); z-index: 15; display: none; flex-direction: column; gap: 0.2rem; font: 500 0.78rem/1.2 var(--sans); }
.rail a { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; min-height: 1.9rem; color: var(--muted); text-decoration: none; }
.rail a span { opacity: 0; transition: opacity .2s; background: var(--paper); padding: 0.1rem 0.3rem; }
.rail a i { width: 0.55rem; height: 0.55rem; border-radius: 50%; border: 1.5px solid currentColor; }
.rail:hover a span, .rail a:focus-visible span, .rail a[aria-current] span { opacity: 1; }
.rail a[aria-current] { color: var(--accent); }
.rail a[aria-current] i { background: currentColor; }
@media (min-width: 1180px) { .rail { display: flex; } }

/* blocks */
main { display: block; }
.block { max-width: 40rem; margin: 0 auto; padding: 0 1rem; }
.block.wide { max-width: 62rem; }
section.block { padding-top: 3.5rem; padding-bottom: 1rem; scroll-margin-top: var(--bar); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.1rem, 6.5vw, 3.6rem); font-weight: 700; margin: 0 0 0.8rem; }
h2 { font-size: clamp(1.55rem, 4vw, 2.1rem); font-weight: 680; margin: 0 0 1rem; }
h2 a.anchor { color: inherit; text-decoration: none; }
h2 a.anchor:hover::after { content: " #"; color: var(--muted); font-weight: 400; }
h3 { font-size: 1.2rem; margin: 1.8rem 0 0.5rem; }
p { margin: 0 0 1.05rem; }
.deck { font-size: 1.28rem; color: var(--muted); line-height: 1.45; }
.kicker { font: 600 0.8rem/1.2 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin: 0 0 0.9rem; }
.note { font: 400 0.95rem/1.5 var(--sans); color: var(--muted); }
figure { margin: 1.5rem 0; }
figcaption { font: 400 0.9rem/1.45 var(--sans); color: var(--muted); margin-top: 0.5rem; }

/* footer */
.foot { max-width: 40rem; margin: 4rem auto 0; padding: 1.5rem 1rem 5rem; border-top: 1px solid var(--rule); font: 400 0.9rem/1.5 var(--sans); color: var(--muted); }
.sources .srcs { font: 400 0.92rem/1.5 var(--sans); padding-left: 1.1rem; }
.sources .srcs li { margin-bottom: 0.45rem; }
.sources .method { font-size: 1rem; }
.related { padding-left: 1.1rem; }
.stamp { font: 400 0.85rem/1.4 var(--sans); color: var(--muted); }

/* controls */
button.btn, a.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 2.75rem; padding: 0.55rem 1.1rem; border-radius: 999px; border: 1.5px solid var(--ink); background: var(--ink); color: var(--paper); font: 600 0.95rem/1 var(--sans); cursor: pointer; text-decoration: none; }
button.btn.ghost, a.btn.ghost { background: transparent; color: var(--ink); }
input[type="date"], input[type="number"], select { min-height: 2.75rem; font: 500 1.05rem/1 var(--sans); padding: 0.4rem 0.7rem; border: 1.5px solid var(--ink); border-radius: 0.5rem; background: var(--paper); color: var(--ink); }

/* hero */
.hero { padding-top: 2.6rem; }
.ask { margin: 1.6rem 0 0.4rem; }
.ask label { display: block; font: 600 0.9rem/1.3 var(--sans); margin-bottom: 0.45rem; }
.ask-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.ask-row input { flex: 1 1 11rem; }
.result { margin: 1.2rem 0; padding: 1.2rem 1.2rem 0.4rem; border: 1.5px solid var(--rule); border-radius: 0.9rem; background: var(--paper-2); }
.r-lead { font: 500 1rem/1.3 var(--sans); color: var(--muted); margin: 0 0 0.2rem; }
.r-num { font-size: clamp(2rem, 8.5vw, 3.3rem); font-weight: 700; line-height: 1.05; color: var(--you); margin: 0 0 0.3rem; letter-spacing: -0.01em; }
.r-words { font-size: 1.15rem; margin-bottom: 0.7rem; }
.r-after { margin-bottom: 0.5rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0; }
.today-line { font: 400 0.98rem/1.5 var(--sans); color: var(--muted); }
.counter { display: block; margin-top: 0.2rem; }

/* tower */
.tower { position: relative; margin-top: 1rem; }
.tower-track { position: relative; max-width: 62rem; margin: 0 auto; }
.tower-stage { position: sticky; top: var(--bar); height: calc(100svh - var(--bar)); width: min(100%, 47.5rem); padding: 0; }
@media (min-width: 761px) { .tower-stage { width: min(calc(100% - 23rem), 44rem); } }
.tower-stage canvas { display: block; }
.tower-year { position: absolute; left: 0.6rem; top: 34%; transform: translateY(-50%); font: 700 1.05rem/1 var(--sans); color: var(--accent); background: var(--paper); padding: 0.25rem 0.3rem; border-radius: 0.3rem; pointer-events: none; }
.tower-cards { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; pointer-events: none; }
.tower-cards li { position: absolute; left: auto; right: 0.8rem; width: min(19rem, 42%); padding: 0.7rem 0.85rem; background: color-mix(in srgb, var(--paper) 94%, transparent); border: 1px solid var(--rule); border-left: 3px solid var(--accent); border-radius: 0.5rem; font: 400 0.95rem/1.45 var(--sans); pointer-events: auto; box-shadow: 0 2px 10px rgb(0 0 0 / 0.06); }
.tower-cards li.p { border-left-color: var(--muted); }
.tower-cards li[data-at="you"] { border-left-color: var(--you); }
@media (max-width: 760px) {
  .tower-cards li { left: 3.9rem; right: 0.6rem; width: auto; background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(3px); }
}
@media (min-width: 1180px) { .tower-cards li { right: 3.4rem; } }

/* living and dead */
.hundred svg { width: 100%; height: auto; max-width: 30rem; }
.hundred .dead { fill: var(--dot-old); }
.hundred .alive { fill: var(--you); }

/* your life */
.life { margin: 1.4rem 0; padding: 1.1rem 1.2rem; border-radius: 0.9rem; background: var(--paper-2); }
.life-big { font: 600 1.05rem/1.35 var(--sans); margin-bottom: 0.9rem; }
.lbars { display: grid; gap: 0.9rem; margin-bottom: 0.9rem; }
.lb { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "l v" "t t"; gap: 0.25rem 0.8rem; align-items: end; font: 400 0.95rem/1.3 var(--sans); }
.lb .ll { grid-area: l; color: var(--muted); }
.lb .lv { grid-area: v; font: 700 2.4rem/1 var(--serif); color: var(--you); }
.lb.births .lv { font-size: 1.6rem; color: var(--ink); }
.lb .lt { grid-area: t; height: 1.1rem; background: var(--paper); border: 1px solid var(--rule); border-radius: 0.3rem; overflow: hidden; }
.lb .lt i { display: block; height: 100%; background: var(--you); }
.lb.births .lt i { background: var(--dot-live); }

/* regions */
.rbars { list-style: none; padding: 0; margin: 0; font: 400 0.95rem/1.3 var(--sans); }
.rbars li { display: grid; grid-template-columns: minmax(7rem, 13rem) 1fr 3.6rem; gap: 0.6rem; align-items: center; margin-bottom: 0.4rem; }
.rbars .rb { height: 0.9rem; background: var(--paper-2); border-radius: 0.2rem; overflow: hidden; }
.rbars .rb i { display: block; height: 100%; background: var(--dot); min-width: 2px; }
.rbars li.ro .rb i { background: var(--you); }
.rbars .rv { text-align: right; }
@media (max-width: 480px) { .rbars li { grid-template-columns: 1fr 3.4rem; } .rbars .rb { grid-column: 1 / -1; grid-row: 2; } }

/* chain */
.chain svg { width: 100%; height: auto; font-family: var(--sans); }
.chain .grid { stroke: var(--rule); stroke-width: 1; }
.chain .tick { fill: var(--muted); font-size: 19px; text-anchor: middle; }
.chain .life { fill: var(--dot); }
.chain .life.open { fill: var(--dot); opacity: 0.85; }
.chain .life.you { fill: var(--you); }
.chain .nm { fill: var(--paper); font-size: 21px; font-weight: 650; }
.chain .you-t { fill: var(--accent-ink); }

/* assumptions */
.scen { margin: 1.5rem 0; padding: 1rem 1.1rem; border: 1.5px solid var(--rule); border-radius: 0.9rem; font: 400 0.95rem/1.4 var(--sans); }
.scen h3 { margin-top: 0; font-family: var(--serif); }
.scen fieldset { border: 0; padding: 0; margin: 0 0 0.8rem; }
.scen legend { font-weight: 650; margin-bottom: 0.3rem; }
.scen label { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.75rem; margin-right: 1rem; cursor: pointer; }
.scen input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.scen-out { font-weight: 600; margin: 0.4rem 0 0; }
