/* Know Your Pension — "Calm civic" (SPEC §9). One file, written from scratch, kp- prefix. */

:root {
  --kp-bg: #EEF2F5;
  --kp-surface: #FFFFFF;
  --kp-ink: #1F2A33;
  --kp-muted: #4A5863;
  --kp-accent: #1E5E3B;
  --kp-warn: #7A2E3A;
  --kp-line: #C9D3DB;
  --kp-mark: #DCEBDF;
  --kp-field: #6B7883;      /* input borders: 3:1 against the surface */
  --kp-zebra: #F5F8FA;
  --kp-on-accent: #FFFFFF;
  --kp-serif: Charter, "Sitka Text", Cambria, Georgia, serif;
  --kp-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --kp-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --kp-radius: 10px;
  --kp-wide: 72rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --kp-bg: #12181D;
    --kp-surface: #1A2228;
    --kp-ink: #E6ECF0;
    --kp-muted: #A9B6C0;
    --kp-accent: #6FBF8E;
    --kp-warn: #E08A97;
    --kp-line: #2E3A43;
    --kp-mark: #23402F;
    --kp-field: #7F8D97;
    --kp-zebra: #1E272E;
    --kp-on-accent: #0F1A14;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--kp-bg);
  color: var(--kp-ink);
  font: 18px/1.6 var(--kp-sans);
}
a { color: var(--kp-accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--kp-accent); outline-offset: 2px; }
h1, h2 { font-family: var(--kp-serif); font-weight: 700; line-height: 1.25; letter-spacing: -0.005em; }
h1 { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.4rem); margin: 0 0 0.4rem; }
h2 { font-size: clamp(1.35rem, 1.15rem + 0.8vw, 1.6rem); margin: 2.4rem 0 0.6rem; }
h3, .kp-extra-title { font-size: 1.05rem; margin: 0 0 0.5rem; }
.kp-extra-title { font-family: var(--kp-sans); line-height: 1.4; letter-spacing: 0; }
p, ul, ol { margin: 0 0 1rem; }
.kp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kp-skip { position: absolute; left: 1rem; top: -4rem; background: var(--kp-surface); padding: 0.5rem 1rem; z-index: 10; }
.kp-skip:focus { top: 1rem; }

/* Masthead and menu (D29): name centered, menu on its own row, wraps on phones. */
.kp-masthead { text-align: center; padding: 1.4rem 16px 1rem; }
.kp-brand { display: inline-flex; flex-direction: column; align-items: center; color: var(--kp-ink); text-decoration: none; }
.kp-brand-name { font: 700 clamp(1.6rem, 1.3rem + 1.2vw, 2rem)/1.15 var(--kp-serif); }
.kp-brand-tag { color: var(--kp-muted); font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; margin-top: 0.25rem; }
.kp-navrow { border-top: 1px solid var(--kp-line); border-bottom: 1px solid var(--kp-line); background: var(--kp-surface); }
.kp-navrow ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 0.25rem; list-style: none; margin: 0 auto; padding: 0.2rem 8px; max-width: var(--kp-wide); }
.kp-navrow a { display: block; padding: 0.55rem 0.7rem; color: var(--kp-ink); text-decoration: none; font-size: 0.95rem; border-bottom: 3px solid transparent; }
.kp-navrow a:hover { color: var(--kp-accent); }
.kp-navrow a[aria-current="page"] { border-bottom-color: var(--kp-accent); font-weight: 600; }

/* Page */
.kp-main { max-width: var(--kp-wide); margin: 0 auto; padding: 0 16px 3rem; }
.kp-crumbs { font-size: 17px; margin: 1.1rem 0 0.6rem; color: var(--kp-muted); }
.kp-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; margin: 0; padding: 0; }
.kp-crumbs li + li::before { content: "›"; margin: 0 0.5rem; color: var(--kp-muted); }
.kp-pagehead { margin: 1.4rem 0 1.2rem; }
.kp-type-hub .kp-pagehead { margin-top: 1.8rem; }
.kp-byline { color: var(--kp-muted); font-size: 0.9rem; margin: 0; }
.kp-article > p, .kp-article > ul, .kp-article > ol, .kp-article > h2, .kp-article > h3,
.kp-pagehead, .kp-sources > * { max-width: 70ch; }
.kp-muted { color: var(--kp-muted); }
.kp-hint { color: var(--kp-muted); font-size: 0.9rem; margin: 0.35rem 0 0; }
.kp-optional { font-weight: 400; color: var(--kp-muted); }
.kp-footnote { font-size: 0.9rem; color: var(--kp-muted); margin-top: 0.5rem; }

/* Home: tools and data status */
.kp-tools { list-style: none; padding: 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); max-width: none !important; }
.kp-tools li { background: var(--kp-surface); border: 1px solid var(--kp-line); border-radius: var(--kp-radius); padding: 1rem 1.1rem; }
.kp-tool-name { display: block; font: 700 1.1rem/1.3 var(--kp-serif); margin-bottom: 0.3rem; }
.kp-tool-desc { color: var(--kp-muted); font-size: 0.95rem; }

/* Calculators: numbered steps, big fields, result card */
.kp-calc { margin: 1.6rem 0 2rem; display: grid; gap: 1.2rem; }
.kp-calc > * { min-width: 0; }
@media (min-width: 64rem) {
  .kp-calc { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; column-gap: 1.6rem; }
  .kp-calc > .kp-form { grid-column: 1; grid-row: 1 / span 2; }
  .kp-calc > .kp-result { grid-column: 2; grid-row: 1; position: sticky; top: 1rem; }
  .kp-calc > .kp-extras { grid-column: 2; grid-row: 2; }
  .kp-calc > .kp-calcper, .kp-calc > .kp-privacy, .kp-calc > .kp-actions { grid-column: 1 / -1; }
}
.kp-form { display: grid; gap: 1rem; }
.kp-step { background: var(--kp-surface); border: 1px solid var(--kp-line); border-radius: var(--kp-radius); padding: 0.4rem 1.2rem 1.2rem; margin: 0; min-width: 0; }
.kp-step legend { display: flex; align-items: center; gap: 0.7rem; padding: 0 0.4rem; margin-left: -0.4rem; font-weight: 700; }
.kp-stepnum { display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--kp-accent); color: var(--kp-on-accent); font: 700 1.35rem/1 var(--kp-serif); }
.kp-steptitle { font-size: 1.05rem; }
.kp-fields { display: flex; flex-wrap: wrap; gap: 0.9rem 1rem; margin-top: 0.6rem; }
.kp-field { flex: 1 1 12rem; min-width: 0; margin-top: 0.6rem; }
.kp-fields > .kp-field { margin-top: 0; }
.kp-field-wide { flex-basis: 100%; }
.kp-field-short { flex: 0 1 9rem; }
.kp-field label, .kp-label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.3rem; }
.kp-field input:not([type="radio"]):not([type="checkbox"]), .kp-field select {
  width: 100%; max-width: 100%; min-height: 48px; font: inherit; font-size: 18px; color: var(--kp-ink);
  background: var(--kp-surface); border: 1px solid var(--kp-field); border-radius: 8px; padding: 0.5rem 0.7rem;
}
.kp-field select:disabled { opacity: 0.7; }
.kp-field input[aria-invalid="true"] { border: 2px solid var(--kp-warn); }
.kp-error { color: var(--kp-warn); font-size: 0.92rem; font-weight: 600; margin: 0.35rem 0 0; }
.kp-choices { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; }
.kp-choices-stack { flex-direction: column; }
.kp-field label.kp-choice, .kp-field label.kp-check, .kp-choice, .kp-check { display: inline-flex; margin: 0; align-items: center; gap: 0.55rem; min-height: 44px; font-weight: 400; cursor: pointer; }
.kp-choice input, .kp-check input { width: 1.3rem; height: 1.3rem; accent-color: var(--kp-accent); margin: 0; }

.kp-result { background: var(--kp-surface); border: 1px solid var(--kp-line); border-left: 6px solid var(--kp-accent); border-radius: var(--kp-radius); padding: 1.1rem 1.3rem; }
.kp-result-label { color: var(--kp-muted); font-size: 0.92rem; margin: 0 0 0.2rem; }
.kp-total { font: 700 clamp(2.1rem, 1.6rem + 2vw, 2.7rem)/1.15 var(--kp-serif); margin: 0 0 0.8rem; font-variant-numeric: tabular-nums; }
.kp-total-text { font-size: clamp(1.4rem, 1.2rem + 1vw, 1.8rem); }
.kp-total-unit { font: 400 1rem var(--kp-sans); color: var(--kp-muted); }
.kp-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.6rem 1.2rem; margin: 0 0 1rem; }
.kp-figures div { border-top: 1px solid var(--kp-line); padding-top: 0.4rem; }
.kp-figures dt { font-size: 0.85rem; color: var(--kp-muted); }
.kp-figures dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.kp-note { border-left: 3px solid var(--kp-line); padding-left: 0.8rem; font-size: 0.95rem; }
.kp-note-warn { border-left-color: var(--kp-warn); }
.kp-formula { font: 0.9rem/1.55 var(--kp-mono); background: var(--kp-bg); border-radius: 8px; padding: 0.7rem 0.9rem; overflow-wrap: anywhere; }
.kp-formula p { margin: 0; }
.kp-formula-note { color: var(--kp-muted); font-family: var(--kp-sans); font-size: 0.85rem; }
.kp-formula-note::before { content: "— "; }
.kp-extras { display: grid; gap: 1rem; min-width: 0; }
.kp-extra { background: var(--kp-surface); border: 1px solid var(--kp-line); border-radius: var(--kp-radius); padding: 1rem 1.2rem; min-width: 0; }
.kp-extra > :last-child, .kp-result > :last-child { margin-bottom: 0; }
.kp-calcper, .kp-privacy { font-size: 0.92rem; color: var(--kp-muted); margin: 0; }
.kp-calcper { color: var(--kp-ink); }
.kp-actions { margin: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.kp-raterow { border-top: 1px solid var(--kp-line); padding-top: 0.8rem; margin-top: 0.8rem; }
.kp-raterow:first-child { border-top: 0; margin-top: 0; }
.kp-rowactions { margin: 0.6rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.kp-fill { background: var(--kp-bg); border-radius: 8px; padding: 0.2rem 0.9rem 0.9rem; margin-top: 0.6rem; }
.kp-fill p { margin: 0.8rem 0 0; }

.kp-btn { display: inline-flex; align-items: center; min-height: 48px; padding: 0.5rem 1.1rem; font: 600 1rem var(--kp-sans); color: var(--kp-on-accent); background: var(--kp-accent); border: 2px solid var(--kp-accent); border-radius: 8px; cursor: pointer; }
.kp-btn:hover { filter: brightness(1.1); }
.kp-btn-quiet { color: var(--kp-accent); background: transparent; }
.kp-btn-quiet:hover { background: var(--kp-mark); filter: none; }

/* Tables: caption, zebra, sticky head on desktop, scroll inside the wrapper on phones */
.kp-tablewrap { margin: 1rem 0 1.4rem; position: relative; }
.kp-tabletool { margin: 1.4rem 0 2rem; }
.kp-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 0.8rem 1.4rem; margin-bottom: 0.4rem; }
.kp-controls .kp-field { flex: 1 1 22rem; margin: 0; }
.kp-table { width: 100%; border-collapse: collapse; background: var(--kp-surface); font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.kp-table caption { caption-side: top; text-align: left; font: 700 1rem/1.4 var(--kp-serif); padding: 0 0 0.5rem; }
.kp-table th, .kp-table td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--kp-line); text-align: left; vertical-align: top; }
.kp-table thead th { background: var(--kp-surface); border-bottom: 2px solid var(--kp-ink); font-size: 0.88rem; vertical-align: bottom; }
.kp-table tbody tr:nth-child(even) > * { background: var(--kp-zebra); }
.kp-table tbody th { font-weight: 600; }
.kp-table .kp-num, .kp-grid td { text-align: right; white-space: nowrap; }
.kp-table-narrow { width: auto; min-width: 22rem; }
.kp-table-compact { font-size: 0.92rem; }
.kp-table .kp-group th { background: var(--kp-bg) !important; font: 700 0.85rem var(--kp-sans); text-transform: uppercase; letter-spacing: 0.05em; color: var(--kp-muted); }
.kp-table .kp-total-row > * { font-weight: 700; border-top: 2px solid var(--kp-ink); }
.kp-table .kp-date { white-space: nowrap; }
.kp-sub { display: block; font-weight: 400; font-size: 0.85rem; color: var(--kp-muted); }
.kp-grid td { cursor: pointer; }
.kp-grid thead th:not(:first-child) { text-align: right; }
.kp-grid tr.kp-mark-row > *, .kp-grid .kp-mark-col { background: var(--kp-mark) !important; }
.kp-grid thead th.kp-mark-col { background: var(--kp-mark); }
.kp-grid td.kp-mark-cell { background: var(--kp-mark) !important; outline: 2px solid var(--kp-accent); outline-offset: -2px; font-weight: 700; }
.kp-delta { display: block; font-size: 0.78rem; color: var(--kp-accent); }
.kp-wgi { color: var(--kp-muted); }
.kp-sort { font: inherit; font-weight: 700; color: var(--kp-accent); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; min-height: 32px; }
th[aria-sort="ascending"] .kp-sort::after { content: " ▲"; }
th[aria-sort="descending"] .kp-sort::after { content: " ▼"; }
@media (min-width: 50rem) {
  .kp-table thead th { position: sticky; top: 0; z-index: 1; }
}
@media (max-width: 49.99rem) {
  .kp-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .kp-table { font-size: 0.9rem; }
  .kp-table th, .kp-table td { padding: 0.45rem 0.55rem; }
  .kp-table-narrow { min-width: 0; }
  .kp-table-text { min-width: 40rem; }
  /* the caption stays within the screen; only the table scrolls sideways */
  .kp-tablewrap { container-type: inline-size; }
  .kp-tablewrap > .kp-table > caption { position: sticky; left: 0; max-width: 100cqi; }
}

/* Sources block and footer */
.kp-sources { margin-top: 2.6rem; border-top: 1px solid var(--kp-line); }
.kp-sources ul { padding-left: 1.2rem; font-size: 0.95rem; }
.kp-sources li { margin-bottom: 0.4rem; }
.kp-sources-all { font-size: 0.95rem; }
.kp-printfoot { display: none; }
.kp-footer { border-top: 1px solid var(--kp-line); background: var(--kp-surface); }
.kp-footer-inner { max-width: var(--kp-wide); margin: 0 auto; padding: 1.6rem 16px 2.2rem; font-size: 0.92rem; color: var(--kp-muted); }
.kp-disclaimer { border-left: 4px solid var(--kp-accent); padding: 0.2rem 0 0.2rem 0.9rem; color: var(--kp-ink); max-width: 70ch; }
.kp-footlinks { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; }
.kp-footlinks a { display: inline-block; padding: 0.3rem 0; }
.kp-reviewed { margin: 0; }

@media (max-width: 30rem) {
  body { font-size: 17px; }
  .kp-navrow a { padding: 0.5rem 0.5rem; font-size: 0.9rem; }
  .kp-step { padding: 0.3rem 0.9rem 1rem; }
  .kp-result { padding: 1rem; }
}

/* Print: no menu or input steps; the result or table, its source and the date. */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .kp-navrow, .kp-crumbs, .kp-skip, .kp-form, .kp-controls, .kp-actions, .kp-rowactions, .kp-footlinks,
  .kp-noprint-input .kp-field, .kp-hint, .kp-privacy { display: none !important; }
  .kp-masthead { padding: 0 0 0.5rem; text-align: left; }
  .kp-main { max-width: none; padding: 0; }
  .kp-calc { display: block; }
  .kp-result, .kp-extra, .kp-step { border-color: #999; break-inside: avoid; }
  .kp-result { border-left-color: #000; }
  .kp-tablewrap { overflow: visible; }
  .kp-table { font-size: 9pt; }
  .kp-table thead th { position: static; }
  .kp-grid tr.kp-mark-row > *, .kp-grid .kp-mark-col, .kp-grid td.kp-mark-cell { background: #e8e8e8 !important; }
  h1, h2, h3, caption { break-after: avoid; }
  .kp-printfoot { display: block; font-size: 9pt; color: #333; border-top: 1px solid #999; padding-top: 0.4rem; margin-top: 1rem; }
  a { color: #000; }
  .kp-print-focus .kp-article > :not(.kp-pagehead):not(.kp-print-target):not(.kp-sources):not(.kp-printfoot) { display: none !important; }
  .kp-print-focus .kp-footer { display: none; }
  .kp-extra:has([data-kp-out] > .kp-muted:only-child) { display: none; }
}
