:root {
  --night: #070e21;
  --panel: #101e32;
  --blue: #00325b;
  --sky: #009ee3;
  --lime: #d3d800;
  --text: #f4f7fb;
  --muted: #b4c6d9;
  --line: #9bc0dd38;
  --soft: #ffffff0a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(ellipse at 73% 14%, #00325b75, transparent 52%), var(--night);
  font: 16px/1.56 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1, h2 { font-weight: 650; letter-spacing: -.055em; line-height: 1.04; }
h1 { font-size: clamp(3.55rem, 7vw, 6.05rem); }
h1 em { color: #a6dffe; font-style: normal; }
h1 em span { color: var(--lime); }
h2 { font-size: clamp(2.2rem, 4vw, 3.75rem); }
h3 { font-size: 1.15rem; font-weight: 680; line-height: 1.25; }
p, small { color: var(--muted); }
a { color: inherit; text-decoration: none; }
a, button, select, summary { touch-action: manipulation; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid #8cdafa; outline-offset: 4px; }
[hidden] { display: none !important; }
.wrap { width: min(1180px, calc(100% - 64px)); margin-inline: auto; }
.skip { position: absolute; top: -100px; left: 20px; z-index: 10; background: var(--text); color: var(--blue); padding: 10px; }
.skip:focus { top: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.topbar { border-bottom: 1px solid var(--line); background: #070e21b8; }
.header-row { display: flex; align-items: center; justify-content: space-between; min-height: 68px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 710; }
.brand-mark { display: inline-grid; place-content: center; grid-auto-flow: column; align-items: center; width: 35px; height: 35px; border-radius: 10px; background: var(--blue); border: 1px solid #72bcf06b; }
.brand-mark span { color: var(--lime); }
.topbar nav, .footer nav { display: flex; gap: 16px; align-items: center; }
.topbar nav a, .footer nav a { color: var(--muted); font-size: .82rem; }
.topbar .header-action { color: var(--text); padding: 8px 13px; border: 1px solid var(--line); border-radius: 9px; }
.hero { display: grid; grid-template-columns: 1.08fr 1fr; align-items: center; gap: clamp(24px, 6vw, 80px); padding: 78px 0 84px; }
.eyebrow { color: var(--lime); font-size: .71rem; letter-spacing: .115em; text-transform: uppercase; font-weight: 750; margin-bottom: 13px; }
.lead { max-width: 42ch; margin: 24px 0 27px; font-size: clamp(1rem, 1.55vw, 1.17rem); }
.primary, .quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: .86rem;
  line-height: 1.3;
  font-weight: 700;
  transition: background .2s, border-color .2s, transform .2s;
}
.primary { background: var(--lime); color: #082a44; }
.primary:hover { background: #e7ec52; transform: translateY(-1px); }
.quiet { background: var(--soft); border-color: var(--line); color: var(--text); }
.quiet:hover { background: #74bbe726; border-color: #74bbe780; }
.hero-card, .panel {
  min-width: 0;
  background: linear-gradient(135deg, #163450bb, #101e32e8 74%);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 16px 48px #0002;
}
.hero-card { padding: clamp(15px, 3vw, 32px); }
.hero-card .eyebrow { color: #a6dffe; }
.milestone { display: grid; grid-template-columns: 39px 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.milestone-age { display: grid; place-items: center; height: 37px; width: 37px; border-radius: 50%; border: 1px solid #87d0f3aa; font-weight: 700; color: #bdedff; }
.milestone-focus { color: var(--blue); background: var(--lime); border-color: var(--lime); }
.milestone small { display: block; font-size: .77rem; }
.milestone b { color: #d8efff; font-variant-numeric: tabular-nums; }
.hero-total { padding-top: 20px; }
.hero-total span, .hero-total small { display: block; font-size: .82rem; }
.hero-total strong { display: block; line-height: 1.15; letter-spacing: -.05em; font-size: clamp(2.2rem, 4.4vw, 3.8rem); color: var(--lime); }

.simulation { padding-bottom: 34px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 24px; }
.configuration { margin-bottom: 24px; }
details > summary { cursor: pointer; font-weight: 680; padding: 14px 18px; min-height: 45px; }
details[open] > summary { border-bottom: 1px solid var(--line); }
.configuration form { padding: 16px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); }
.field { display: grid; align-content: start; gap: 6px; min-width: 0; color: var(--muted); font-size: .82rem; }
.field input, .field select, #age-direct {
  display: block; width: 100%; min-height: 44px; border: 1px solid #6586a276; background: #091629; color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-size: 1rem; min-width: 0;
}
.field input[aria-invalid="true"] { border-color: #ffb38a; }
.workspace { display: grid; grid-template-columns: minmax(275px, .72fr) minmax(0, 1.45fr); gap: 20px; align-items: start; }
.timeline-panel { padding: 15px; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 10px; padding: 3px 3px 13px; }
.panel-heading p { font-size: .81rem; margin-top: 4px; }
.age-badge { flex: none; font-size: .75rem; color: var(--lime); background: #d3d80018; border: 1px solid #d3d80056; border-radius: 20px; padding: 5px 9px; font-weight: 750; }
.timeline-viewport { max-height: min(55vh, 515px); min-height: 185px; overflow-y: auto; scrollbar-color: #5d85a3 #142439; padding: 0 7px 0 0; border-block: 1px solid var(--line); }
.timeline-track { position: relative; margin: 30px 0; min-height: 1px; }
.timeline-scale, .timeline-events { position: absolute; inset: 0; pointer-events: none; }
.tick { position: absolute; left: 0; width: 40px; border-radius: 5px; transform: translateY(-50%); color: var(--muted); font-size: .72rem; text-align: center; }
.tick.selected { color: var(--lime); }
.timeline-slider { position: absolute; top: -20px; bottom: -20px; left: 41px; width: 48px; touch-action: none; cursor: ns-resize; outline-offset: 0; }
.timeline-line { position: absolute; inset: 20px 18px; border-radius: 30px; background: #f4f7fb3d; min-height: 2px; box-shadow: 0 0 12px #f4f7fb27; }
.timeline-indicator { position: absolute; top: 20px; left: 3px; width: 42px; height: 42px; display: grid; place-items: center; transform: translateY(-50%); color: var(--blue); background: var(--lime); font-size: .93rem; font-weight: 850; border-radius: 50%; box-shadow: 0 0 22px #d3d80065; }
.timeline-slider:not(.dragging) .timeline-indicator { transition: top .17s ease-out; }
.event-stack { position: absolute; left: 96px; right: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; transform: translateY(-50%); }
.event-marker { display: flex; align-items: center; gap: 7px; min-width: 0; min-height: 38px; width: 100%; border: 1px solid #90bce138; border-radius: 8px; padding: 4px 7px; text-align: left; background: #0c2138; color: var(--text); font-size: .73rem; pointer-events: auto; }
.event-marker:hover, .event-marker[aria-current="true"] { border-color: var(--sky); background: #00325b; }
.marker-icon { flex: none; display: inline-grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; border: 1px solid #78c7f998; color: #b0e2ff; line-height: 1; }
.marker-icon.purchase { background: #d3d80026; border-color: var(--lime); color: var(--lime); }
.marker-icon.sale { background: #009ee32c; border-color: #65cfff; color: #c5eeff; }
.event-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.timeline-tools { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; gap: 8px; padding-top: 13px; }
.age-step { padding: 0; font-size: 1.2rem; }
.add-action { margin-top: 10px; width: 100%; justify-content: space-between; }
.results { display: grid; gap: 13px; min-width: 0; }
.result-summary, .warnings, .properties { padding: clamp(15px, 3vw, 26px); }
.result-summary #result-title { color: var(--muted); }
#net-worth { display: block; margin: 2px 0 5px; font-size: clamp(2rem, 5vw, 4.4rem); font-weight: 690; letter-spacing: -.065em; line-height: 1.1; color: var(--lime); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.result-context { min-height: 1.25em; margin-bottom: 14px; font-size: .82rem; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 125px), 1fr)); gap: 8px; }
.metric { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; gap: 5px; padding: 10px 12px; min-height: 68px; border: 1px solid var(--line); background: #070e213f; border-radius: 9px; }
.metric span { color: var(--muted); font-size: .74rem; line-height: 1.3; }
.metric strong { color: var(--text); font-variant-numeric: tabular-nums; font-size: clamp(1rem, 1.8vw, 1.26rem); line-height: 1.15; overflow-wrap: anywhere; }
.breakdown .result-grid { padding: 12px; }
.warnings { border-color: #f0af5891; background: #54372162; }
.warnings h3 { color: #ffd494; }
.warnings ul { margin: 9px 0 0; padding-left: 19px; color: #f8e4ca; font-size: .87rem; }
.warnings li + li { margin-top: 5px; }
.properties h3 { margin-bottom: 10px; }
.property { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; background: var(--soft); }
.property summary { display: flex; justify-content: space-between; gap: 10px; }
.property .result-grid { padding: 10px; }
.property .hint { padding: 0 10px 10px; }
.event-list, .assumptions { margin-top: 16px; }
#event-list, #assumption-notes { padding: 14px 18px; }
#assumption-notes { font-size: .88rem; }
#assumption-notes p + p { margin-top: 8px; }
#assumption-notes a { color: #a6dffe; text-decoration: underline; text-underline-offset: 3px; }
.event-row { display: flex; width: 100%; justify-content: space-between; text-align: left; gap: 12px; margin-bottom: 7px; }
.event-row small { flex: none; }
.message { padding: 10px; border: 1px solid #e2a76b7d; border-radius: 8px; background: #533517a8; color: #ffe2bf; margin-top: 10px; font-size: .86rem; }
.hint { font-size: .77rem; }
.footer { border-top: 1px solid var(--line); padding: 22px 0; display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.footer nav { flex-wrap: wrap; font-weight: 400; }

dialog { max-height: 90dvh; max-width: min(92vw, 730px); width: 100%; padding: 0; margin: auto; border-radius: 16px; border: 1px solid #70a4cc80; color: var(--text); background: #101e32; }
dialog::backdrop { background: #000a; }
body:has(dialog[open]) { overflow: hidden; }
#event-form { padding: 16px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.dialog-head h2 { font-size: 1.65rem; }
.close { width: 44px; padding: 0; font-size: 1.45rem; }
.dialog-fields { display: grid; gap: 14px; }
.dialog-fields details { border: 1px solid var(--line); border-radius: 9px; }
.dialog-fields details .fields { padding: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; flex-wrap: wrap; }
.danger { color: #ffd5bc; }
@media (max-width: 900px) {
  .wrap { width: calc(100% - 40px); }
  .hero { padding: 58px 0 60px; }
  .workspace { grid-template-columns: minmax(245px, 1fr) minmax(0, 1.55fr); gap: 12px; }
}
@media (max-width: 650px) {
  .wrap { width: calc(100% - 28px); }
  .header-row { min-height: 56px; }
  .topbar nav { gap: 0; }
  .header-action { display: none; }
  .hero { grid-template-columns: 1fr; gap: 22px; padding: 37px 0 46px; }
  h1 { font-size: clamp(2.7rem, 10.6vw, 4.8rem); }
  .lead { margin: 14px 0 17px; }
  .section-head { flex-direction: column; align-items: start; gap: 13px; }
  .configuration { margin-bottom: 13px; }
  .workspace { grid-template-columns: 1fr; }
  .timeline-viewport { max-height: 240px; min-height: 145px; }
  .timeline-panel { padding: 12px; }
  .timeline-tools { padding-top: 10px; }
  .event-marker { min-height: 42px; }
  .fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .result-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .result-summary { padding: 13px; }
  .result-context { margin-bottom: 9px; }
  .metric { padding: 8px; min-height: 60px; }
  .footer { font-size: .78rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
.timeline-status { display: grid; justify-items: end; gap: 3px; }
#timeline-net-worth { color: var(--text); font-size: .71rem; font-weight: 680; white-space: nowrap; }
.advanced-inputs { margin-top: 12px; border: 1px solid var(--line); border-radius: 9px; }
.advanced-inputs > summary { font-size: .87rem; }
.advanced-inputs > .fields { padding: 12px; }
.check-field { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 5px 10px; font-size: .85rem; color: var(--muted); }
.check-field input { width: 20px; height: 20px; flex: none; accent-color: var(--lime); }
.advanced-inputs .hint, .dialog-fields details .hint { padding: 6px 12px 12px; }
.event-row span { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 450px) {
  .event-row { align-items: start; flex-direction: column; gap: 3px; }
}
.pair-link { justify-self: start; }
