:root {
  --ink: #102a27;
  --ink-soft: #36524e;
  --paper: #f7f5ed;
  --surface: #fffef9;
  --line: #d5d8ca;
  --teal: #0f665d;
  --teal-dark: #094c46;
  --lime: #cde84a;
  --amber: #f0b84b;
  --rust: #b65135;
  --blue: #5f86a3;
  --shadow: 0 20px 55px rgba(16, 42, 39, .11);
  font-family: Geist, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); line-height: 1.5; }
button, input, select { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.skip-link { position: fixed; left: 16px; top: -100px; z-index: 100; padding: 10px 14px; background: var(--ink); color: white; border-radius: 4px; }
.skip-link:focus { top: 12px; }

.topbar { width: min(1480px, calc(100% - 32px)); min-height: 64px; margin: 14px auto 0; padding: 10px 12px; display: flex; align-items: center; gap: 18px; position: sticky; top: 12px; z-index: 20; background: rgba(255, 254, 249, .9); border: 1px solid rgba(16, 42, 39, .15); border-radius: 8px; backdrop-filter: blur(16px); box-shadow: 0 8px 28px rgba(16, 42, 39, .08); }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; text-decoration: none; margin-right: auto; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; background: var(--ink); color: var(--lime); border-radius: 5px; }
nav { display: flex; gap: 18px; }
nav a { font-size: .88rem; color: var(--ink-soft); text-decoration: none; font-weight: 650; }
nav a:hover { color: var(--teal); }

main { width: min(1420px, calc(100% - 40px)); margin: 0 auto; overflow-x: clip; }
.intro { min-height: 300px; padding: 92px 2vw 52px; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr); gap: 64px; align-items: end; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 9px; color: var(--teal); font-size: .74rem; font-weight: 850; text-transform: uppercase; letter-spacing: .1em; }
h1, h2, h3, p { overflow-wrap: break-word; }
h1 { margin: 0; max-width: 18ch; font-size: clamp(2.25rem, 5vw, 4.6rem); line-height: .98; letter-spacing: 0; }
.intro-copy { margin: 0; max-width: 42ch; color: var(--ink-soft); font-size: 1.06rem; }

.dense-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-flow: dense; }
.calculator-shell { margin-top: 42px; gap: 18px; align-items: start; }
.control-panel, .results-panel, .chart-card, .sensitivity-card, .scenario-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.control-panel { grid-column: span 4; padding: 24px; position: sticky; top: 92px; }
.results-panel { grid-column: span 8; padding: 28px; box-shadow: var(--shadow); }
.panel-heading, .section-heading, .result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.panel-heading h2, .section-heading h2, .section-heading h3, .method-intro h2, .guidance h2 { margin: 0; letter-spacing: 0; }
.panel-heading h2 { font-size: 1.4rem; }
.local-note, .saved-count { color: var(--ink-soft); font-size: .78rem; white-space: nowrap; }

.preset-group { margin: 24px 0 18px; display: grid; gap: 8px; }
.preset-group > span, label { color: var(--ink-soft); font-size: .78rem; font-weight: 750; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); padding: 3px; border-radius: 6px; background: #f1f1e8; }
.segmented button { min-height: 38px; border: 0; background: transparent; color: var(--ink-soft); border-radius: 4px; cursor: pointer; font-weight: 800; }
.segmented button.active { background: var(--ink); color: white; }

form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
input[type="number"], select { width: 100%; height: 44px; border: 1px solid #b9c0b5; background: white; color: var(--ink); border-radius: 5px; padding: 0 11px; }
.money-input, .suffix-input { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; border: 1px solid #b9c0b5; background: white; border-radius: 5px; overflow: hidden; }
.suffix-input { grid-template-columns: minmax(0, 1fr) auto; }
.money-input > span, .suffix-input > span { min-width: 42px; padding: 0 10px; color: var(--ink-soft); font-weight: 800; text-align: center; }
.money-input input, .suffix-input input { border: 0; border-radius: 0; }
.range-field { display: grid; gap: 6px; }
.range-field label { display: flex; justify-content: space-between; gap: 12px; }
output { color: var(--ink); font-weight: 850; }
input[type="range"] { width: 100%; height: 24px; accent-color: var(--teal); cursor: pointer; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }
.validation { margin: 0; padding: 10px 12px; color: #7d2d1c; background: #fae5dd; border-left: 4px solid var(--rust); border-radius: 4px; }

.result-head { padding: 5px 0 24px; border-bottom: 1px solid var(--line); }
.result-head h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.7rem); line-height: 1.05; }
.result-head p:last-child { margin: 8px 0 0; color: var(--ink-soft); }
.status-chip { padding: 8px 11px; background: #e5f0e3; color: #21582a; border-radius: 4px; font-size: .8rem; font-weight: 850; white-space: nowrap; }
.status-chip.over { background: #fae5dd; color: #7d2d1c; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 22px 0; background: var(--line); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.metric-grid article { padding: 20px; background: #f5f5ec; min-height: 126px; }
.metric-grid span, .metric-grid small { display: block; color: var(--ink-soft); }
.metric-grid span { font-size: .78rem; font-weight: 750; }
.metric-grid strong { display: block; margin: 10px 0 4px; font-size: clamp(1.15rem, 2vw, 1.65rem); }
.cap-warning { min-height: 46px; padding: 12px 14px; border: 1px solid #d7b060; background: #fff5d9; color: #684607; border-radius: 5px; }
.cap-warning.ok { border-color: #9fc5a4; background: #ebf5e8; color: #28572c; }

.age-comparison { margin-top: 28px; padding-top: 25px; border-top: 1px solid var(--line); }
.section-heading { margin-bottom: 18px; align-items: end; }
.section-heading h3 { font-size: 1.35rem; }
.section-heading > span { color: var(--ink-soft); font-size: .8rem; }
.age-bars { display: grid; gap: 10px; }
.age-bar { display: grid; grid-template-columns: 58px minmax(0, 1fr) minmax(105px, auto); gap: 12px; align-items: center; }
.age-bar > span:first-child { font-weight: 850; }
.age-bar-track { height: 15px; background: #e8e9df; border-radius: 2px; overflow: hidden; }
.age-bar-fill { height: 100%; background: var(--teal); transform-origin: left; transition: width .35s ease; }
.age-bar.active .age-bar-fill { background: var(--lime); box-shadow: inset 0 0 0 1px rgba(16,42,39,.2); }
.age-bar strong { font-size: .86rem; text-align: right; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.button { min-height: 42px; padding: 0 16px; border-radius: 5px; border: 1px solid transparent; cursor: pointer; font-weight: 800; }
.button.primary { background: var(--ink); color: white; }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { background: var(--lime); color: var(--ink); border-color: #a9bf32; }
.button.secondary:hover { background: #bddb32; }
.button.quiet { background: transparent; color: var(--ink); border-color: #aab3a6; }
.button.quiet:hover { background: #eceee5; }
.button.compact { min-height: 38px; padding: 0 13px; }

.projection-section, .analysis-grid, .method-section, .guidance { padding: 120px 0 0; }
.section-heading.wide { align-items: end; }
.section-heading.wide h2, .sensitivity-card h2, .scenario-card h2, .method-intro h2, .guidance h2 { font-size: clamp(1.8rem, 3vw, 2.8rem); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; color: var(--ink-soft); font-size: .8rem; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 18px; height: 4px; display: inline-block; }
.nominal-dot { background: var(--teal); }
.real-dot { background: var(--amber); }
.chart-card { padding: 18px; min-height: 360px; overflow: hidden; position: relative; }
#growthChart { width: 100%; height: auto; min-height: 300px; display: block; }
.chart-grid { stroke: #dfe2d7; stroke-width: 1; }
.chart-axis-label { fill: #58706b; font-size: 12px; }
.nominal-line, .real-line { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.nominal-line { stroke: var(--teal); }
.real-line { stroke: var(--amber); }
.target-line { stroke: var(--rust); stroke-width: 1.5; stroke-dasharray: 7 6; }
.chart-point { fill: var(--surface); stroke-width: 3; cursor: pointer; }
.chart-tooltip { position: absolute; min-width: 150px; padding: 9px 11px; background: var(--ink); color: white; border-radius: 4px; font-size: .78rem; pointer-events: none; box-shadow: var(--shadow); }
.table-disclosure { margin-top: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.table-disclosure summary { cursor: pointer; padding: 15px 17px; font-weight: 800; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { padding: 12px 14px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; font-size: .82rem; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--ink-soft); background: #f1f2e9; font-weight: 850; }

.analysis-grid { gap: 18px; }
.sensitivity-card { grid-column: span 7; padding: 26px; }
.scenario-card { grid-column: span 5; padding: 26px; }
.sensitivity-card > p { color: var(--ink-soft); max-width: 64ch; }
.compact-table { border: 1px solid var(--line); border-radius: 5px; }
.compact-table table { min-width: 560px; }
.heat-0 { background: #e8f3e5; }
.heat-1 { background: #f3f2df; }
.heat-2 { background: #fff0d6; }
.scenario-list { display: grid; gap: 10px; }
.empty-state { color: var(--ink-soft); padding: 28px 0; border-top: 1px solid var(--line); }
.scenario-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 5px; background: #f6f6ee; }
.scenario-item strong, .scenario-item small { display: block; }
.scenario-item small { color: var(--ink-soft); margin-top: 3px; }
.scenario-actions { display: flex; gap: 6px; align-items: center; }
.icon-button { min-width: 56px; min-height: 36px; padding: 0 9px; border: 1px solid #aab3a6; background: white; color: var(--ink); border-radius: 4px; cursor: pointer; font-size: .75rem; font-weight: 800; }
.icon-button.danger { color: #7d2d1c; border-color: #d8aa9f; }

.method-section { display: grid; grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr); gap: 68px; }
.method-intro p:last-child, .guidance-copy { color: var(--ink-soft); }
.method-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.method-steps article { padding: 20px; border-top: 4px solid var(--teal); background: var(--surface); }
.method-steps strong { color: var(--teal); }
.method-steps h3 { margin: 16px 0 7px; font-size: 1rem; }
.method-steps p { margin: 0; color: var(--ink-soft); font-size: .88rem; }
.formula-box { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(240px, .8fr); gap: 24px; align-items: center; padding: 24px; background: var(--ink); color: white; border-radius: 7px; }
.formula-box code { font-size: clamp(.9rem, 2vw, 1.15rem); white-space: normal; color: var(--lime); }
.formula-box p { margin: 0; color: #d6e1de; }
.maturity-note { grid-column: 1 / -1; padding: 22px 24px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; }
.maturity-note h3 { margin: 0 0 8px; }
.maturity-note p { margin: 0; color: var(--ink-soft); max-width: 95ch; }

.guidance { margin: 120px 0 0; padding: 46px; display: grid; grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); gap: 64px; background: #e7eadf; border: 1px solid #c9cec0; border-radius: 8px; }
.guidance-copy p:first-child { margin-top: 0; }
.guidance-copy p:last-child { margin-bottom: 0; }
footer { width: min(1420px, calc(100% - 40px)); margin: 90px auto 0; padding: 30px 0 42px; display: flex; justify-content: space-between; gap: 24px; border-top: 1px solid var(--line); color: var(--ink-soft); }
footer p { margin: 0; }
footer a { font-weight: 800; }
.noscript { padding: 16px; background: #fff0d6; }

@media (max-width: 1040px) {
  .control-panel { grid-column: span 5; }
  .results-panel { grid-column: span 7; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-grid article { min-height: auto; }
  .sensitivity-card, .scenario-card { grid-column: 1 / -1; }
  .method-section { grid-template-columns: 1fr; gap: 32px; }
}

@media (max-width: 760px) {
  .topbar { width: calc(100% - 20px); top: 7px; min-height: 58px; }
  nav { display: none; }
  main { width: min(100% - 24px, 1420px); }
  .intro { padding: 68px 3px 38px; min-height: 0; grid-template-columns: 1fr; gap: 24px; }
  h1 { max-width: 14ch; }
  .calculator-shell { margin-top: 20px; }
  .control-panel, .results-panel { grid-column: 1 / -1; position: static; padding: 19px; }
  .field-pair { grid-template-columns: 1fr; }
  .result-head { display: grid; }
  .status-chip { justify-self: start; }
  .age-bar { grid-template-columns: 46px minmax(0, 1fr); }
  .age-bar strong { grid-column: 2; text-align: left; }
  .projection-section, .analysis-grid, .method-section, .guidance { padding-top: 84px; }
  .section-heading.wide { display: grid; }
  .chart-card { padding: 4px; min-height: 280px; }
  #growthChart { min-height: 260px; }
  .sensitivity-card, .scenario-card { padding: 18px; }
  .method-steps { grid-template-columns: 1fr; }
  .formula-box { grid-template-columns: 1fr; }
  .guidance { margin-top: 84px; padding: 26px; grid-template-columns: 1fr; gap: 24px; }
  footer { width: calc(100% - 24px); margin-top: 64px; flex-direction: column; }
}

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