/* years-in-your-phone — "1:47 AM": the bedroom glow of a phone. */
:root {
  color-scheme: dark;
  --bg: #0b0e13;
  --bg-soft: #11151d;
  --ink: #f2ead8;
  --muted: #b3a88f;
  --faint: #7d7666;
  --line: #2c313d;
  --line-soft: #21262f;
  --accent: #ffb224;
  --accent-deep: #c77f0a;
  --on-accent: #1a1206;
  --teal: #7fd4c1;
  --teal-deep: #2c7a6b;
  --cell-past: #3a3f4b;
  --cell-future: #1c212b;
  --sleep: #4a5878;
  --card: #121722;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --topbar-h: 3rem;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f1e4;
  --bg-soft: #efe7d4;
  --ink: #1d1a13;
  --muted: #5d5645;
  --faint: #8a8271;
  --line: #d8cdb4;
  --line-soft: #e6dcc6;
  --accent: #8a5a00;
  --accent-deep: #8a5a00;
  --on-accent: #fff8ea;
  --teal: #0f766e;
  --teal-deep: #0f766e;
  --cell-past: #b9ac8d;
  --cell-future: #e3d9c2;
  --sleep: #7c8db5;
  --card: #fffaf0;
  --shadow: 0 18px 50px rgba(90, 70, 20, .18);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html:focus-within { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html, html:focus-within { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.075rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 72rem; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2rem); }
.prose { max-width: 40rem; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.12; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: clamp(2.4rem, 7vw, 4.3rem); margin: 0.6rem 0 1rem; }
h2 { font-size: clamp(1.6rem, 4.4vw, 2.4rem); margin: 0 0 0.6rem; }
.kicker {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--accent-deep);
  margin: 0;
  font-weight: 600;
}
[data-theme="light"] .kicker { color: var(--accent); }
a { color: inherit; text-decoration-color: var(--accent-deep); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
section[id], footer[id] { scroll-margin-top: calc(var(--topbar-h) + 3.2rem); }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0 clamp(0.75rem, 3vw, 1.5rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.95rem;
  white-space: nowrap;
}
.topbar .home { font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.topnav { display: flex; gap: 0.2rem; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { text-decoration: none; color: var(--muted); padding: 0.35rem 0.6rem; border-radius: 999px; }
.topnav a:hover { color: var(--ink); }
.topnav a[aria-current="true"] { color: var(--ink); background: var(--line-soft); }
.spacer { flex: 1 1 auto; }
.chip {
  text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.28rem 0.8rem; font-size: 0.85rem; font-weight: 600;
}
.chip:hover { border-color: var(--accent-deep); }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  cursor: pointer; flex: 0 0 auto;
}
.icon-btn:hover { border-color: var(--accent-deep); }
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }
.skip {
  position: absolute; left: 0.75rem; top: -4rem; z-index: 99;
  background: var(--accent); color: var(--on-accent); font-weight: 700;
  padding: 0.6rem 1rem; border-radius: 0 0 0.6rem 0.6rem; text-decoration: none;
  transition: top 0.15s ease;
}
.skip:focus { top: 0; }

/* ---------- hero + calculator ---------- */
.hero { padding: clamp(1.2rem, 4vh, 3rem) 0 1rem; }
.hero .deck { font-size: clamp(1.1rem, 2.6vw, 1.35rem); color: var(--muted); max-width: 44rem; text-wrap: pretty; }
.calc {
  display: grid; gap: 1.5rem;
  grid-template-columns: 1fr;
  margin-top: 1.75rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  padding: clamp(1.1rem, 3.5vw, 2rem);
  box-shadow: var(--shadow);
}
@media (min-width: 56rem) {
  .calc { grid-template-columns: minmax(17rem, 23rem) 1fr; gap: 2.25rem; align-items: start; }
}
.field { margin: 0 0 1.4rem; }
.field label { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-weight: 700; }
.field label output { font-variant-numeric: tabular-nums; color: var(--accent-deep); font-size: 1.25rem; }
[data-theme="light"] .field label output { color: var(--accent); }
.field input[type="range"] { width: 100%; accent-color: var(--accent-deep); height: 2.75rem; margin: 0; }
.field input[type="number"] {
  width: 100%; font: inherit; font-variant-numeric: tabular-nums;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 0.6rem;
  padding: 0.55rem 0.75rem; margin-top: 0.35rem;
}
.field .unit { color: var(--faint); font-weight: 400; font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.95rem; margin: 0.25rem 0 0; }
.hint + .hint { margin-top: 0.5rem; }
html:not(.js) .needs-js { display: none !important; }
html.js .static-example { display: none !important; }
.static-example { color: var(--muted); border-left: 3px solid var(--accent-deep); padding-left: 0.8rem; }
.bignum { border-top: 1px solid var(--line-soft); padding-top: 1rem; }
@media (min-width: 56rem) { .bignum { border-top: 0; padding-top: 0; } }
.bignum .figure { font-family: var(--font-display); font-weight: 600; font-size: clamp(3rem, 8vw, 5rem); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.bignum .figure .n { color: var(--accent-deep); }
[data-theme="light"] .bignum .figure .n { color: var(--accent); }
.bignum .suffix { font-family: var(--font-display); font-size: clamp(1.3rem, 3.4vw, 1.9rem); margin-top: 0.3rem; }
.bignum .echo { color: var(--muted); margin: 0.5rem 0 0; }
.lifebar { margin-top: 1.2rem; }
.lifebar svg { display: block; width: 100%; height: auto; }
.lifebar figcaption { color: var(--muted); font-size: 0.92rem; margin-top: 0.5rem; }
.lb-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; list-style: none; margin: 0.6rem 0 0; padding: 0; font-size: 0.9rem; color: var(--muted); }
.lb-legend i { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 0.2em; margin-right: 0.35em; vertical-align: baseline; }
.ofcom { max-width: 44rem; color: var(--muted); font-size: 0.98rem; border-left: 3px solid var(--line); padding-left: 1rem; margin: 1.5rem 0 0; }

/* ---------- sticky reader HUD ---------- */
.hud {
  position: sticky; top: var(--topbar-h); z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
  opacity: 0; transform: translateY(-0.4rem); pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.hud.on { opacity: 1; transform: none; pointer-events: auto; }
.hud .wrap { display: flex; align-items: baseline; gap: 0.6rem; padding-top: 0.45rem; padding-bottom: 0.45rem; }
.hud b { font-family: var(--font-display); font-size: 1.3rem; color: var(--accent-deep); }
[data-theme="light"] .hud b { color: var(--accent); }
.hud span { color: var(--muted); font-size: 0.92rem; }
.hud a { margin-left: auto; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }

/* ---------- chapters ---------- */
.chapter { padding: clamp(2.5rem, 7vh, 4.5rem) 0; border-top: 1px solid var(--line-soft); }
.chapter:first-of-type { border-top: 0; }
.chapter-head { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; margin-bottom: 1rem; }
.chapter-head .kicker { flex: 1 1 100%; }
.chapter-head h2 { flex: 1 1 auto; margin: 0; min-width: min(100%, 20rem); }
.permalink { color: var(--faint); text-decoration: none; font-size: 1.1rem; padding: 0.4rem; margin: -0.4rem; min-width: 2.75rem; min-height: 2.75rem; display: inline-grid; place-items: center; }
.permalink:hover { color: var(--accent-deep); }
.daybar svg { display: block; width: 100%; height: auto; margin-top: 1rem; }
.daybar figcaption { color: var(--muted); margin-top: 0.6rem; }
.daybar figcaption b { color: var(--ink); font-variant-numeric: tabular-nums; }
.yearfield svg { display: block; width: 100%; height: auto; margin-top: 1rem; }
.yearfield figcaption { color: var(--muted); margin-top: 0.6rem; }
.yearfield figcaption b { color: var(--accent-deep); font-variant-numeric: tabular-nums; }
[data-theme="light"] .yearfield figcaption b { color: var(--accent); }
.statrows { list-style: none; margin: 1.5rem 0 0; padding: 0; border-top: 1px solid var(--line); }
.statrows li { display: grid; grid-template-columns: 1fr; gap: 0.2rem; padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
@media (min-width: 46rem) { .statrows li { grid-template-columns: minmax(12rem, 20rem) 1fr; gap: 1.5rem; align-items: baseline; } }
.statrows .n { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.7rem, 4vw, 2.4rem); font-variant-numeric: tabular-nums; color: var(--accent-deep); line-height: 1.1; }
[data-theme="light"] .statrows .n { color: var(--accent); }
.statrows p { margin: 0; color: var(--muted); }
.statrows p b { color: var(--ink); font-weight: 600; }
.tag { display: inline-block; font-size: 0.82rem; font-weight: 600; color: var(--faint); border: 1px solid var(--line); border-radius: 999px; padding: 0.15rem 0.7rem; margin-top: 1rem; }
.mechanics { list-style: none; margin: 1.25rem 0 0; padding: 0; }
.mechanics li { padding: 0.9rem 0 0.9rem 1.1rem; border-left: 3px solid var(--accent-deep); margin-bottom: 1rem; }
.mechanics b { display: block; font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
.mechanics p { margin: 0.25rem 0 0; color: var(--muted); }
.trylist { margin: 1.25rem 0 0; padding: 0; list-style: none; counter-reset: try; }
.trylist li { counter-increment: try; display: grid; grid-template-columns: 3rem 1fr; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--line); }
.trylist li::before {
  content: counter(try, decimal-leading-zero);
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 600;
  color: var(--teal-deep); font-variant-numeric: tabular-nums;
}
.trylist b { display: block; font-size: 1.15rem; }
.trylist p { margin: 0.25rem 0 0; color: var(--muted); }
.methodlist { margin: 1rem 0 0; padding-left: 1.25rem; color: var(--muted); }
.methodlist li { margin-bottom: 0.6rem; }
.methodlist b { color: var(--ink); }

/* ---------- share ---------- */
.share { padding: 0 0 0.5rem; }
.share-row { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; scroll-margin: 4.75rem; }
.share-row .lab { color: var(--muted); font-size: 0.95rem; margin-right: 0.3rem; }
.share-row a, .share-row button {
  display: inline-grid; place-items: center;
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  border: 1px solid var(--line-soft); background: transparent; color: var(--ink);
  cursor: pointer; padding: 0;
}
@media (pointer: coarse) { .share-row a, .share-row button { width: 2.75rem; height: 2.75rem; } }
.share-row a:hover, .share-row button:hover { border-color: var(--accent-deep); color: var(--accent-deep); }
.share-status { color: var(--muted); font-size: 0.9rem; min-height: 1.4em; margin: 0.4rem 0 0; }

/* ---------- svg scenes ---------- */
.lifebar rect.p { fill: var(--cell-past); }
.lifebar rect.f { fill: var(--cell-future); }
.lifebar rect.l { fill: var(--accent-deep); }
.daybar rect.s { fill: var(--sleep); }
.daybar rect.p { fill: var(--accent-deep); }
.daybar rect.r { fill: var(--cell-future); stroke: var(--line); stroke-width: 1; }
.daybar text.dl { font-family: var(--font-body); font-size: 13px; font-weight: 600; }
.daybar text.ts { fill: #ffffff; }
.daybar text.tp { fill: var(--on-accent); }
.daybar text.tr { fill: var(--ink); }
.daybar text.do { fill: var(--muted); font-size: 12.5px; }
.yearfield rect.l { fill: var(--accent-deep); }
.yearfield rect.f { fill: var(--cell-future); }

/* ---------- footer ---------- */
footer.site { border-top: 1px solid var(--line-soft); padding: 2rem 0 4rem; color: var(--muted); font-size: 0.95rem; }
footer.site p { margin: 0.4rem 0; }
footer.site .totop { font-weight: 600; }
