:root {
  --ink: #0d1b2b;
  --muted: #607080;
  --paper: #f4f7f8;
  --card: #ffffff;
  --line: #dce5e8;
  --navy: #07111f;
  --navy-2: #0c2237;
  --teal: #0e8f89;
  --teal-light: #69ddd1;
  --amber: #f2a63b;
  --green: #218c64;
  --blue: #2f72dd;
  --shadow: 0 18px 50px rgba(14, 37, 54, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
a { color: inherit; }
.shell { width: min(1180px, calc(100% - 36px)); margin-inline: auto; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 99; transform: translateY(-150%); background: white; padding: .7rem 1rem; border-radius: 10px; }
.skip-link:focus { transform: translateY(0); }
.noscript { padding: 12px 18px; background: #fff1d6; color: #5c3a00; text-align: center; font-weight: 700; }

.hero {
  position: relative;
  min-height: 590px;
  overflow: hidden;
  color: #f7fcff;
  background:
    radial-gradient(circle at 76% 34%, rgba(32, 197, 181, .18), transparent 26%),
    radial-gradient(circle at 15% 15%, rgba(47, 114, 221, .18), transparent 24%),
    linear-gradient(145deg, var(--navy) 0%, #0a1d30 58%, #0a2b3a 100%);
}
.hero::after { content: ""; position: absolute; inset: auto 0 0; height: 130px; background: linear-gradient(180deg, transparent, rgba(244,247,248,.06)); }
.nav { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding-block: 26px; }
.brand { display: inline-flex; align-items: center; gap: .75rem; text-decoration: none; font-size: 1.02rem; font-weight: 760; letter-spacing: .02em; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(105,221,209,.55); border-radius: 12px; color: var(--teal-light); font-family: Georgia, serif; font-size: 1.5rem; }
.nav-link { color: #b9cad7; text-decoration: none; font-size: .9rem; }
.nav-link:hover { color: white; }
.hero-content { position: relative; z-index: 2; padding-top: 76px; padding-bottom: 126px; }
.eyebrow, .kicker { color: var(--teal); text-transform: uppercase; letter-spacing: .16em; font-size: .72rem; font-weight: 780; }
.hero .eyebrow { color: var(--teal-light); }
.hero h1 { max-width: 800px; margin: 18px 0 22px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3rem, 7vw, 5.8rem); font-weight: 400; line-height: .98; letter-spacing: -.045em; }
.hero-copy { max-width: 680px; margin: 0; color: #c0d0dc; font-size: clamp(1rem, 2vw, 1.2rem); }
.hero-badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.hero-badges span { padding: .55rem .78rem; border: 1px solid rgba(255,255,255,.13); border-radius: 999px; color: #d8e4ea; background: rgba(255,255,255,.04); font-size: .78rem; }
.hero-orbit { position: absolute; border: 1px solid rgba(105,221,209,.18); border-radius: 50%; }
.orbit-one { width: 580px; height: 580px; right: -170px; top: 18px; }
.orbit-two { width: 420px; height: 420px; right: -76px; top: 98px; border-color: rgba(242,166,59,.15); }

.main-shell { position: relative; z-index: 3; margin-top: -62px; padding-bottom: 80px; }
.control-panel, .panel { background: var(--card); border: 1px solid rgba(220,229,232,.95); border-radius: var(--radius); box-shadow: var(--shadow); }
.control-panel { padding: 28px; margin-bottom: 70px; }
.section-heading, .panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.compact-heading { align-items: center; margin-bottom: 22px; }
.section-heading h2, .panel-heading h2, .methodology h2 { margin: 5px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.8rem, 4vw, 2.7rem); font-weight: 400; letter-spacing: -.025em; line-height: 1.08; }
.compact-heading h2 { font-size: 1.55rem; }
.kicker { margin: 0; }
.text-button { border: 0; background: transparent; color: var(--teal); cursor: pointer; font-weight: 700; padding: .5rem; }
.text-button:hover { text-decoration: underline; }

.control-grid { display: grid; grid-template-columns: 1.5fr 1fr .7fr; gap: 22px; align-items: end; }
.control label { display: block; margin-bottom: 8px; color: #33485c; font-size: .82rem; font-weight: 720; }
.label-row { display: flex; align-items: center; justify-content: space-between; }
.label-row output { min-width: 48px; padding: .28rem .55rem; border-radius: 9px; background: #e8f8f5; color: #087770; font-weight: 800; text-align: center; }
select { width: 100%; height: 48px; border: 1px solid #cddade; border-radius: 12px; padding: 0 40px 0 13px; color: var(--ink); background: white; }
select:focus, input:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid rgba(47,114,221,.25); outline-offset: 2px; }
input[type="range"] { width: 100%; margin: 10px 0 1px; accent-color: var(--teal); }
.range-scale { display: flex; justify-content: space-between; color: #91a0aa; font-size: .68rem; }
.dataset-note { margin: 16px 0 0; color: var(--muted); font-size: .78rem; }

.context-pill { padding: .52rem .8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.65); font-size: .78rem; white-space: nowrap; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 70px; }
.metric-card { min-height: 190px; padding: 22px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); border-top: 4px solid #8ea2b1; box-shadow: 0 10px 30px rgba(16,42,60,.045); }
.metric-remaining { border-top-color: var(--teal); }
.metric-total { border-top-color: var(--amber); }
.metric-dividend { border-top-color: var(--green); }
.metric-label { margin: 0; color: var(--muted); font-size: .76rem; font-weight: 780; text-transform: uppercase; letter-spacing: .09em; }
.metric-value { display: flex; align-items: baseline; gap: 8px; margin: 18px 0 10px; font-size: clamp(2.2rem, 5vw, 3.35rem); font-weight: 780; line-height: 1; letter-spacing: -.04em; }
.metric-value small { color: #81909b; font-size: .8rem; font-weight: 650; letter-spacing: 0; }
.metric-caption { margin: 0; color: var(--muted); font-size: .78rem; }

.panel { padding: 30px; margin-bottom: 26px; }
.panel-heading { align-items: center; }
.panel-heading h2 { font-size: 1.9rem; }
.formula-chip, .legend { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; }
.formula-chip { padding: .5rem .7rem; border-radius: 10px; background: #f0f5f6; }
.journey-panel { overflow: hidden; }
.cohort-layout { display: grid; grid-template-columns: 1.05fr .95fr; gap: 24px; }
.cohort-card, .selection-card { border: 1px solid var(--line); border-radius: 18px; }
.cohort-card { padding: 22px; background: #f8fbfb; }
.cohort-grid { display: grid; grid-template-columns: repeat(20, 1fr); gap: 6px; }
.cohort-square { aspect-ratio: 1; border-radius: 4px; }
.cohort-square.survived { background: linear-gradient(145deg, var(--teal), #52c9be); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.cohort-square.lost { background: #efb5aa; box-shadow: inset 0 0 0 1px rgba(142,65,49,.08); }
.cohort-legend { display: flex; flex-wrap: wrap; gap: 12px 22px; margin-top: 18px; color: var(--muted); font-size: .73rem; }
.cohort-legend span { display: inline-flex; align-items: center; gap: 7px; }
.cohort-legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend-survived { background: var(--teal); }
.legend-lost { background: #efb5aa; }
.selection-card { display: flex; flex-direction: column; padding: 24px; background: var(--navy-2); color: white; }
.selection-label { margin: 0; color: var(--teal-light); font-size: .68rem; font-weight: 780; letter-spacing: .13em; text-transform: uppercase; }
.selection-headline { margin: 13px 0 10px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1.15; }
.selection-explanation { margin: 0; color: #bacbd6; font-size: .82rem; }
.selection-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; padding-top: 22px; }
.selection-numbers div { padding-top: 13px; border-top: 1px solid rgba(255,255,255,.14); }
.selection-numbers span { display: block; color: var(--teal-light); font-size: 1.35rem; font-weight: 800; }
.selection-numbers small { display: block; margin-top: 4px; color: #9fb3c0; font-size: .67rem; line-height: 1.35; }
.journey-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 34px 0 16px; }
.journey-intro h3 { margin: 0 0 5px; font-size: 1.1rem; }
.journey-intro p { max-width: 790px; margin: 0; color: var(--muted); font-size: .78rem; }
.journey-key { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.passed-dot { background: var(--teal); }
.current-dot { background: var(--amber); }
.ahead-dot { background: #a7b4bc; }
.risk-stage-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.risk-stage { position: relative; min-width: 0; padding: 15px 13px; border: 1px solid var(--line); border-top: 4px solid #a7b4bc; border-radius: 13px; background: #fbfcfc; }
.risk-stage.passed { border-top-color: var(--teal); background: #f2faf8; }
.risk-stage.current { border-top-color: var(--amber); background: #fff8eb; box-shadow: 0 8px 24px rgba(158,101,18,.10); }
.risk-stage-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.stage-status { color: var(--muted); font-size: .6rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.risk-stage.current .stage-status { color: #9a620f; }
.risk-stage.passed .stage-status { color: #087770; }
.stage-ages { color: #82919b; font-family: ui-monospace, monospace; font-size: .62rem; }
.risk-stage h3 { min-height: 38px; margin: 9px 0 10px; font-size: .82rem; line-height: 1.2; }
.stage-risk strong { display: block; font-size: 1.45rem; line-height: 1; }
.stage-risk span { display: block; min-height: 42px; margin-top: 5px; color: var(--muted); font-size: .62rem; line-height: 1.35; }
.cause-label { margin: 11px 0 4px; color: #7b8b96; font-size: .56rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.cause-list { margin: 0; color: #415567; font-size: .64rem; line-height: 1.45; }
.research-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 22px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--line); }
.research-strip > div { padding: 18px; background: #f8fbfb; }
.research-strip strong, .research-strip span, .research-strip small { display: block; }
.research-strip strong { color: var(--teal); font-size: 1.55rem; }
.research-strip span { font-weight: 760; }
.research-strip small { margin-top: 2px; color: var(--muted); font-size: .65rem; }
.research-strip > p { grid-column: 1 / -1; margin: 0; padding: 11px 18px; color: var(--muted); background: white; font-size: .68rem; }
.research-strip a, .sources-body a { color: #087770; font-weight: 700; }
.milestone-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; }
.milestone { padding: 16px 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfc; text-align: center; }
.milestone-age { color: var(--muted); font-size: .72rem; font-weight: 760; text-transform: uppercase; }
.milestone-value { margin: 8px 0 10px; font-size: 1.45rem; font-weight: 800; }
.milestone-bar { height: 6px; overflow: hidden; border-radius: 99px; background: #e5edef; }
.milestone-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--teal-light)); }
.milestone.reached { background: #eef8f6; }
.milestone.reached .milestone-value { color: var(--teal); font-size: 1rem; }

.legend { display: flex; align-items: center; gap: 8px; font-family: inherit; }
.legend span { width: 22px; height: 3px; border-radius: 4px; background: var(--teal); }
.chart { width: 100%; min-height: 360px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-note { margin: 8px 0 0; color: var(--muted); font-size: .78rem; }

.comparison-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin: -2px 0 20px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: #f8fbfb; }
.comparison-controls label span { color: #8a99a3; font-weight: 500; }
.comparison-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; min-height: 25px; color: var(--muted); font-size: .72rem; }
.comparison-legend > span { display: inline-flex; align-items: center; gap: 7px; }
.comparison-legend i { width: 11px; height: 11px; border-radius: 50%; }
.sex-line-key { margin-left: auto; }
.sex-line-key + .sex-line-key { margin-left: 0; }
.sex-line-key b { width: 24px; height: 3px; border-radius: 4px; background: #506272; }
.sex-line-key.male-key b { height: 0; border-top: 3px dashed #506272; background: transparent; }
.comparison-chart { min-height: 390px; margin-top: 4px; }
.comparison-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 6px; }
.comparison-summary article { padding: 15px 17px; border: 1px solid var(--line); border-top: 4px solid var(--country-color); border-radius: 13px; background: #fbfcfc; }
.comparison-summary h3 { margin: 0 0 10px; font-size: .82rem; }
.comparison-summary article > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 4px 0; color: var(--muted); font-size: .72rem; }
.comparison-summary strong { color: var(--ink); font-size: 1.05rem; }
.comparison-summary p { margin: 9px 0 0; color: var(--muted); font-size: .66rem; }

.primary-button { border: 0; border-radius: 11px; padding: .7rem 1rem; color: white; background: var(--navy-2); cursor: pointer; font-weight: 720; }
.primary-button:hover { background: #12324f; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { color: #46596a; background: #f4f8f8; font-size: .7rem; text-transform: uppercase; letter-spacing: .055em; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.active-row { background: #edf9f7; color: #066e69; font-weight: 760; }

.methodology { padding: 68px 0 8px; }
.method-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-top: 30px; }
.method-grid article { padding: 24px 0; border-top: 1px solid #cbd8dc; }
.method-number { color: var(--teal); font-family: ui-monospace, monospace; font-size: .75rem; }
.method-grid h3 { margin: 12px 0 8px; font-size: 1rem; }
.method-grid p { margin: 0; color: var(--muted); font-size: .86rem; }
.sources { margin-top: 30px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.sources summary { cursor: pointer; padding: 16px 18px; font-weight: 720; }
.sources-body { padding: 0 18px 18px; color: var(--muted); font-size: .82rem; }

footer { color: #afbfca; background: var(--navy); }
.footer-inner { display: flex; justify-content: space-between; gap: 24px; padding-block: 32px; }
.footer-inner div { display: flex; gap: 13px; }
.footer-inner strong { color: white; }
.footer-inner p, .footer-inner span { margin: 0; font-size: .78rem; }

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 900px) {
  .control-grid { grid-template-columns: 1fr 1fr; }
  .age-control { grid-column: 1 / -1; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .milestone-grid { grid-template-columns: repeat(4, 1fr); }
  .risk-stage-grid { grid-template-columns: repeat(4, 1fr); }
  .comparison-summary { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 1180px); }
  .hero { min-height: 560px; }
  .hero-content { padding-top: 58px; }
  .hero h1 { font-size: 3.1rem; }
  .main-shell { margin-top: -46px; }
  .control-panel, .panel { padding: 20px; border-radius: 17px; }
  .control-grid, .metric-grid, .method-grid, .cohort-layout { grid-template-columns: 1fr; }
  .milestone-grid { grid-template-columns: repeat(2, 1fr); }
  .cohort-grid { grid-template-columns: repeat(10, 1fr); gap: 5px; }
  .selection-numbers { margin-top: 8px; }
  .journey-intro { align-items: flex-start; flex-direction: column; gap: 10px; }
  .risk-stage-grid { grid-template-columns: repeat(2, 1fr); }
  .research-strip { grid-template-columns: 1fr; }
  .research-strip > p { grid-column: 1; }
  .comparison-controls { grid-template-columns: 1fr; }
  .sex-line-key { margin-left: 0; }
  .section-heading, .panel-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .compact-heading { flex-direction: row; align-items: center; }
  .metric-card { min-height: 158px; }
  .context-pill { white-space: normal; }
  .legend, .formula-chip { display: none; }
  .footer-inner, .footer-inner div { flex-direction: column; gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .hero { min-height: auto; color: var(--ink); background: white; }
  .hero-content { padding: 30px 0; }
  .hero-copy, .nav-link { color: var(--ink); }
  .hero-orbit, .hero-badges, .text-button, .primary-button { display: none; }
  .main-shell { margin-top: 0; }
  .panel, .control-panel, .metric-card { box-shadow: none; break-inside: avoid; }
}
