/* Two-Year Lookback. Ledger + staircase. No web fonts. */
:root {
  --paper: #f7f4ec;
  --surface: #fffdf8;
  --ink: #1f2430;
  --muted: #555b69;
  --rule: #d9d3c4;
  --rule-strong: #b9b1a0;
  --accent: #0d5c58;
  --accent-ink: #ffffff;
  --accent-soft: #e2efec;
  --ochre: #8f5a0c;
  --ochre-soft: #f6ead3;
  --focus: #1b6fd1;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --step: 8px;
  --read: 41rem;
  --wide: 62rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #13171d;
    --surface: #1b2028;
    --ink: #ece7da;
    --muted: #a9adb8;
    --rule: #333a45;
    --rule-strong: #4a5260;
    --accent: #5fc4bb;
    --accent-ink: #0d1716;
    --accent-soft: #19302e;
    --ochre: #e0a94a;
    --ochre-soft: #33280f;
    --focus: #8cc2ff;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 18px/1.6 var(--sans);
  font-variant-numeric: tabular-nums;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }

.wrap { max-width: var(--wide); margin: 0 auto; padding: 0 16px; }
.read { max-width: var(--read); }

/* Header */
.masthead { border-bottom: 1px solid var(--rule); background: var(--paper); }
.masthead .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-top: 14px; padding-bottom: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--serif); font-size: 1.3rem; font-weight: 700; letter-spacing: 0.005em; }
.brand svg { width: 30px; height: 22px; flex: none; }
.brand .mark-step { fill: var(--accent); }
.primary-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; padding: 0; font-size: 0.95rem; }
.primary-nav a { color: var(--ink); text-decoration: none; padding: 6px 0; display: inline-block; border-bottom: 2px solid transparent; }
.primary-nav a:hover, .primary-nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.notice-strip { font-size: 0.85rem; color: var(--muted); border-bottom: 1px solid var(--rule); }
.notice-strip .wrap { padding-top: 6px; padding-bottom: 6px; }

/* Type */
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; font-weight: 700; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 1.4rem + 2.2vw, 2.7rem); margin: 0.2em 0 0.3em; letter-spacing: -0.005em; }
h2 { font-size: 1.6rem; margin: 2.4rem 0 0.6rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
h3 { font-size: 1.22rem; margin: 1.8rem 0 0.4rem; }
p, ul, ol { margin: 0 0 1rem; }
li { margin-bottom: 0.35rem; }
.lead { font-size: 1.12rem; color: var(--ink); max-width: var(--read); }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.byline { font-size: 0.9rem; color: var(--muted); margin: 0 0 1.2rem; }
strong { font-weight: 650; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }

.crumbs { font-size: 0.88rem; color: var(--muted); margin: 18px 0 0; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 0; }
.crumbs li { margin: 0; }
.crumbs li + li::before { content: "/"; margin-right: 4px; color: var(--rule-strong); }

main { padding-bottom: 3rem; }
article > section:not(.tool), .prose { max-width: var(--read); }

/* Tables: almanac style */
.table-wrap { overflow-x: auto; margin: 0.6rem 0 1.2rem; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
caption { text-align: left; font-family: var(--serif); font-weight: 700; font-size: 1.05rem; padding: 10px 0 6px; caption-side: top; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--rule-strong); }
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.is-you td { background: var(--accent-soft); font-weight: 600; }
tr.is-you td:first-child { box-shadow: inset 4px 0 0 var(--accent); }

.source { font-size: 0.85rem; color: var(--muted); margin-top: -0.4rem; }

/* Callouts */
.note { border-left: 4px solid var(--ochre); background: var(--ochre-soft); padding: 12px 16px; margin: 1.2rem 0; max-width: var(--read); }
.note p:last-child { margin-bottom: 0; }
.keyfact { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; margin: 1.2rem 0; max-width: var(--read); }
.keyfact p:last-child { margin-bottom: 0; }

/* Tool */
.tool { background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 6px; padding: 20px; margin: 1.2rem 0 1.6rem; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 760px) { .tool-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; } .tool { padding: 16px; } }
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
legend, .label { display: block; font-weight: 650; font-size: 0.95rem; margin-bottom: 6px; padding: 0; }
.hint { font-size: 0.85rem; color: var(--muted); margin: 4px 0 0; }
label { cursor: pointer; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 650; font-size: 0.95rem; margin-bottom: 6px; }
select, input[type="text"], input[type="number"], input[type="month"] {
  width: 100%; font: inherit; font-size: 1.05rem; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule-strong); border-radius: 4px; padding: 10px 12px; min-height: 46px;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 34px; }
.money-input { position: relative; }
.money-input span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money-input input { padding-left: 26px; }
input[aria-invalid="true"] { border-color: var(--ochre); box-shadow: 0 0 0 1px var(--ochre); }
.error { color: var(--ochre); font-size: 0.88rem; margin: 6px 0 0; min-height: 0; }

.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--rule-strong); border-radius: 4px; overflow: hidden; }
.seg label { display: block; padding: 8px 10px; text-align: center; font-size: 0.92rem; line-height: 1.3; background: var(--paper); }
.seg label + label { border-left: 1px solid var(--rule-strong); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg input:checked + span { font-weight: 700; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }
.seg small { display: block; font-size: 0.78rem; opacity: 0.85; }

.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; font-size: 0.95rem; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.radio-list .check { margin-bottom: 10px; }

details.helper { margin: 8px 0 0; font-size: 0.92rem; }
details.helper summary { cursor: pointer; color: var(--accent); }
details.helper .inner { padding: 10px 0 0; }

button, .button {
  font: inherit; font-size: 0.95rem; font-weight: 600; border-radius: 4px; padding: 9px 14px; min-height: 44px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button.secondary { background: transparent; color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; align-items: center; }
.status-msg { font-size: 0.88rem; color: var(--muted); }

/* Result */
.result { min-height: 30rem; }
.verdict { font-family: var(--serif); font-size: 1.45rem; line-height: 1.3; margin: 0 0 12px; }
.verdict b { color: var(--accent); }
.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--rule); margin: 0 0 14px; }
.figures div { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); }
.figures dt { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.figures dd { margin: 2px 0 0; font-size: 1.25rem; font-weight: 650; }
.figures dd small { display: block; font-size: 0.8rem; font-weight: 400; color: var(--muted); }
@media (max-width: 420px) { .figures { grid-template-columns: 1fr; } }
.headroom { list-style: none; padding: 0; margin: 0 0 12px; }
.headroom li { padding: 8px 0 8px 22px; position: relative; border-bottom: 1px dashed var(--rule); margin: 0; }
.headroom li::before { content: ""; position: absolute; left: 2px; top: 17px; width: 10px; height: 10px; border: 2px solid var(--ochre); border-radius: 0; transform: rotate(45deg); }
.headroom li.up::before { border-color: var(--ochre); }
.headroom li.down::before { border-color: var(--accent); }

/* Staircase chart */
.stairs { margin: 6px 0 12px; }
.stairs svg { display: block; width: 100%; height: auto; }
.stairs .step { fill: var(--accent-soft); stroke: var(--rule-strong); stroke-width: 1; }
.stairs .step.on { fill: var(--accent); }
.stairs .cliff { stroke: var(--ochre); stroke-width: 2; stroke-dasharray: 3 3; }
.stairs text { fill: var(--muted); font: 12px var(--sans); }
.stairs .you-line { stroke: var(--ink); stroke-width: 2; }
.stairs .you-label { fill: var(--ink); font-weight: 700; }

/* Steps list (SSA-44 sheet) */
.sheet { border: 1px solid var(--rule-strong); background: var(--surface); padding: 18px 20px; border-radius: 6px; margin: 1rem 0; }
.sheet h3 { margin-top: 1.2rem; }
.sheet h3:first-child { margin-top: 0; }
.box { display: inline-block; border: 1px solid var(--rule-strong); padding: 1px 8px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--paper); }
.q { border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 14px; }
.q[hidden] { display: none; }

/* FAQ */
.faq details { border-bottom: 1px solid var(--rule); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 650; }
.faq details > div { padding-top: 8px; }

/* Lists of links */
.next-links { list-style: none; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--rule); }
.next-links li { margin: 0; border-bottom: 1px solid var(--rule); padding: 10px 0; }
.next-links a { font-weight: 600; }
.next-links span { display: block; color: var(--muted); font-size: 0.92rem; }

/* Footer */
.site-footer { border-top: 2px solid var(--ink); margin-top: 2rem; padding: 24px 0 40px; font-size: 0.9rem; color: var(--muted); }
.site-footer .cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 760px) { .site-footer .cols { grid-template-columns: 1fr; } }
.site-footer h2 { font-size: 1rem; border: 0; padding: 0; margin: 0 0 8px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer a { color: var(--ink); }
.disclaimer { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--rule); }

/* Range slider */
input[type="range"] { width: 100%; accent-color: var(--accent); height: 32px; }
output { font-weight: 700; }

@media print {
  .masthead, .site-footer, .no-print, .crumbs, .notice-strip { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .sheet { border: 1px solid #000; }
  a { color: #000; }
}
.figures dd.range-dd { font-size: 1rem; font-weight: 600; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.button { margin: 0.4rem 0 1rem; }
.calc-grid { grid-template-areas: "basics result" "options result"; grid-template-rows: auto 1fr; row-gap: 0; }
.calc-grid .basics { grid-area: basics; }
.calc-grid .options { grid-area: options; }
.calc-grid .result { grid-area: result; }
@media (max-width: 760px) { .calc-grid { grid-template-areas: "basics" "result" "options"; grid-template-rows: auto; row-gap: 20px; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ssa-result { min-height: 12rem; }
@media (max-width: 600px) {
  .masthead .wrap { padding-top: 10px; padding-bottom: 6px; gap: 2px 16px; }
  .brand { font-size: 1.15rem; }
  .primary-nav ul { gap: 2px 14px; font-size: 0.88rem; }
  .primary-nav a { padding: 4px 0; }
  .wide-only { display: none; }
  h1 { font-size: 1.75rem; }
  .lead { font-size: 1rem; }
  .tool { margin-top: 0.8rem; }
}
@media (max-width: 600px) {
  .primary-nav li:first-child { display: none; }
  h1 { font-size: 1.6rem; margin-bottom: 0.2em; }
  .notice-strip { font-size: 0.8rem; }
  .seg label { padding: 6px 8px; }
}
@media (max-width: 600px) { .verdict { font-size: 1.2rem; } }
table.brackets tbody th { font-weight: 500; text-align: left; white-space: nowrap; }
thead th { white-space: normal; }
.table-note { margin-top: -0.8rem; }
.stairs .you-tri { fill: var(--ink); }
.stairs .you-label { fill: var(--ink); font-weight: 700; }
.result table { font-size: 0.9rem; }
.result th, .result td { padding: 7px 8px; }
@media (max-width: 600px) {
  table { font-size: 0.85rem; }
  th, td, .result th, .result td { padding: 6px 5px; }
  table.brackets tbody th { white-space: normal; }
  thead th { font-size: 0.7rem; letter-spacing: 0.02em; }
}
@media (max-width: 600px) { thead th.num { white-space: normal; } }
/* Compact result under the MAGI field, phones only */
.quick { display: none; margin: 8px 0 0; padding: 10px 12px; background: var(--accent-soft); border-left: 4px solid var(--accent); font-size: 0.95rem; line-height: 1.45; }
@media (max-width: 760px) { .quick { display: block; } }
.stale { opacity: 0.35; filter: grayscale(1); transition: opacity 0.15s; }
/* The staircase chart's labels become too small on phones; the table carries the numbers there. */
@media (max-width: 480px) { .stairs { display: none; } }
