[hidden] { display: none !important; }
:root {
  --ink: #12211f; --muted: #5b6b68; --bg: #f6f4ee; --card: #ffffff; --line: #e3dfd3;
  --brand: #0f3d3e; --brand-2: #1f6f6b; --accent: #f2c14e; --good: #1d7a46; --warn: #a15c00; --bad: #b3261e;
  --sp: #2563eb; --bond: #7c3aed; --bill: #0d9488; --ss: #e2541b;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(15,61,62,.07);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand-2); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); } .small { font-size: .875rem; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h3.inline { display: inline; font-size: 1.05rem; }

.site-header { background: var(--brand); color: #fff; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.25rem; display: flex; align-items: center; gap: 8px; }
.brand .dot { color: var(--accent); }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--brand); font-size: 1rem; }
.site-header nav a { color: #d5e6e4; text-decoration: none; margin-left: 18px; font-size: .9rem; }
.site-header nav a:hover { color: #fff; }
.header-links { display: flex; align-items: center; gap: 18px; }
.coffee-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--brand); font-weight: 700; font-size: .88rem; text-decoration: none; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.coffee-pill:hover { background: #f6d07a; }

.hero { padding: 40px 0 28px; background: linear-gradient(180deg, #e9efe9 0%, var(--bg) 100%); }
.hero h1 { font-size: clamp(1.8rem, 4.5vw, 2.8rem); margin: 0 0 12px; max-width: 820px; }
.lede { font-size: 1.1rem; max-width: 760px; color: #2c3d3a; margin: 0 0 20px; }

.privacy-banner { display: flex; gap: 14px; align-items: flex-start; background: #e7f4ec; border: 1px solid #b9e0c8; color: #14462a; padding: 14px 16px; border-radius: var(--radius); max-width: 820px; margin-bottom: 20px; }
.privacy-banner svg { width: 28px; height: 28px; flex: none; fill: var(--good); margin-top: 2px; }

.upload-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; max-width: 820px; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed #b7c7c3; border-radius: 12px; padding: 30px 16px; cursor: pointer; text-align: center; transition: .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--brand-2); background: #f1f8f6; }
/* Visually hidden but still a real, tappable file input (never display:none, which some iOS versions won't open). */
.dropzone { position: relative; }
/* The real input is the tap target: full size, transparent, on top (issue #32). 16px font stops iOS zooming. */
.dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; font-size: 16px; z-index: 1; }
.dropzone:focus-within { outline: 3px solid var(--brand-2); outline-offset: 2px; }
.upload-status { margin-top: 12px; color: var(--muted); font-weight: 600; }
.debug-log { margin-top: 12px; padding: 8px 10px; border: 1px dashed #b7c7c3; border-radius: 8px; background: #f7faf9; font: 12px/1.45 ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; }
.paste-body textarea { width: 100%; box-sizing: border-box; font: 14px/1.4 ui-monospace, Menlo, monospace; margin: 8px 0; padding: 8px; border: 1px solid #b7c7c3; border-radius: 8px; }
@media print { .debug-log, .upload-status, .paste-info { display: none !important; } }
.dz-icon { font-size: 1.6rem; color: var(--brand-2); }
.dz-title { font-weight: 700; font-size: 1.1rem; }
.dz-sub { color: var(--muted); font-size: .9rem; }
.upload-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; margin-top: 14px; }
.howto { flex: 1 1 260px; font-size: .92rem; }
.howto summary { cursor: pointer; color: var(--brand-2); font-weight: 600; padding: 8px 0; }
.strip-info { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.strip-body { color: #2c3d3a; }
.strip-body h4 { margin: 16px 0 6px; font-size: .95rem; color: var(--ink); }
.strip-body p, .strip-body ul, .strip-body ol { margin: 0 0 10px; }
.strip-body li { margin-bottom: 4px; }
.strip-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; background: #f1f5f3; border-radius: 4px; padding: 1px 4px; overflow-wrap: anywhere; }
.strip-body pre { background: #f1f5f3; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 10px; overflow-x: auto; font-size: .85rem; line-height: 1.45; }
.strip-body pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.privacy-banner a { color: inherit; font-weight: 600; }
.support-line { max-width: 820px; margin: 14px 0 0; font-size: .95rem; color: var(--muted); }
.coffee-link { font-weight: 700; white-space: nowrap; }
.error { scroll-margin: 24px; overflow-wrap: anywhere; margin-top: 12px; background: #fdecea; color: var(--bad); border: 1px solid #f5c2bd; border-radius: 10px; padding: 10px 12px; }

.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 16px; border: 1px solid transparent; cursor: pointer; }
.btn-secondary { background: var(--brand); color: #fff; }
.btn-secondary:hover { background: var(--brand-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-coffee { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--brand); text-decoration: none; white-space: nowrap; }
.btn-coffee:hover { background: #f6d07a; }

.results { padding: 28px 0 10px; }
.results-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.results-head h2 { margin: 0; font-size: 1.8rem; }
.results-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.eyebrow { margin: 0 0 4px; color: var(--brand-2); font-weight: 700; text-transform: uppercase; font-size: .78rem; letter-spacing: .06em; }
.advice-note { margin: 14px 0 0; padding: 10px 14px; border-left: 4px solid var(--brand-2); background: #eef5f3; border-radius: 8px; font-size: .92rem; color: #2c3d3a; }
.warnings { background: #fff6e5; border: 1px solid #f2d7a1; color: #6b4300; border-radius: 10px; padding: 10px 14px; margin: 14px 0; font-size: .9rem; }
.warnings ul { margin: 0; padding-left: 18px; }

.settings { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; margin: 18px 0; }
.settings > summary { cursor: pointer; font-weight: 700; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 18px; margin-top: 14px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: .86rem; color: var(--muted); position: relative; }
.settings label.check { flex-direction: row; align-items: flex-start; gap: 8px; grid-column: span 2; color: var(--ink); }
@media (max-width: 560px) { .settings label.check { grid-column: auto; } }
.settings select, .settings input[type=number], .settings input[type=date] { font: inherit; color: var(--ink); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
.settings .unit { position: absolute; right: 12px; bottom: 9px; color: var(--muted); }
.settings .field-note { font-size: .8rem; line-height: 1.35; color: var(--ink); }
.adv { margin-top: 12px; } .adv summary { cursor: pointer; font-size: .9rem; color: var(--brand-2); }

.headline { background: var(--brand); color: #fff; border-radius: var(--radius); padding: 22px 24px; margin: 6px 0 16px; font-size: clamp(1.05rem, 2.4vw, 1.3rem); line-height: 1.5; }
.headline strong { color: var(--accent); }
.headline .sub { display: block; margin-top: 8px; font-size: .95rem; color: #cfe3e0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border-top: 4px solid var(--line); }
.card .label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.card .value { font-size: 1.65rem; font-weight: 800; margin: 2px 0; letter-spacing: -0.02em; }
.card .note { font-size: .82rem; color: var(--muted); }
.card.sp { border-top-color: var(--sp); } .card.bond { border-top-color: var(--bond); } .card.bill { border-top-color: var(--bill); } .card.ss { border-top-color: var(--ss); } .card.paid { border-top-color: #64748b; }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; min-width: 0; }
.panel h3 { margin: 0 0 6px; font-size: 1.1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.panel details > summary { cursor: pointer; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 300px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { font: inherit; font-size: .8rem; border: 0; background: #fff; padding: 6px 10px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--brand); color: #fff; }

/* Full-screen charts (issue #44). The same rules serve the Fullscreen API and the fixed-overlay fallback. */
.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chart-expand { font: inherit; font-size: .8rem; font-weight: 600; color: var(--brand-2); background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; cursor: pointer; white-space: nowrap; }
.chart-expand:hover { border-color: var(--brand-2); }
.chart-expand .ce-close, .chart-expand[aria-expanded="true"] .ce-open { display: none; }
.chart-expand[aria-expanded="true"] .ce-close { display: inline; }
.chart-panel.chart-full, .chart-panel:fullscreen { position: fixed; inset: 0; z-index: 1000; margin: 0; border-radius: 0; width: 100%; height: 100%; max-width: none;
  display: flex; flex-direction: column; background: #fff; overflow: hidden;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.chart-panel.chart-full .chart-box { flex: 1 1 auto; height: auto; min-height: 0; }
.chart-panel.chart-full .chart-expand { font-size: .95rem; padding: 8px 14px; background: var(--brand); color: #fff; border-color: var(--brand); }
.chart-panel.chart-full > p { margin: 0 0 6px; }
.chart-panel.chart-full .panel-head { margin-bottom: 8px; }
.chart-panel::backdrop { background: #fff; }
body.chart-open { overflow: hidden; }
/* Share card (issue #45). Sized in container units so it looks the same at any width, like an image. 4:5. */
.share-card { container-type: inline-size; width: min(100%, 420px); margin: 12px 0; }
.sc { aspect-ratio: 4 / 5; display: flex; flex-direction: column; padding: 6cqw 6.5cqw 5cqw; border-radius: 4cqw; color: #fff; overflow: hidden;
  background: linear-gradient(160deg, #0f3d3e 0%, #14504f 55%, #1f6f6b 100%); font-size: 3.3cqw; line-height: 1.32; }
.sc p { margin: 0; }
.sc-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 3.2cqw; color: #cfe3e0; }
.sc-brand { font-weight: 800; font-size: 4.8cqw; letter-spacing: -0.01em; color: #fff; }
.sc-brand .dot { color: var(--accent); }
.sc .sc-title { margin-top: 3.5cqw; font-size: 5.4cqw; font-weight: 750; line-height: 1.18; }
.sc-big { display: flex; align-items: center; gap: 3.2cqw; margin-top: 2.6cqw; }
.sc-big-num { font-size: 16cqw; font-weight: 850; color: var(--accent); line-height: 1.05; letter-spacing: -0.03em; }
.sc-big-label { font-size: 3.8cqw; line-height: 1.25; }
.sc .sc-big-sub { margin-top: 1cqw; color: #cfe3e0; }
.sc .sc-h { margin: 3.4cqw 0 0.8cqw; font-weight: 700; font-size: 3cqw; text-transform: uppercase; letter-spacing: .06em; color: #cfe3e0; }
.sc-row { display: grid; grid-template-columns: 40% 1fr 13%; align-items: center; gap: 2.2cqw; padding: 0.9cqw 0; }
.sc-row .sc-bar { height: 2.4cqw; border-radius: 1.2cqw; background: rgba(255,255,255,.14); overflow: hidden; }
.sc-row .sc-bar i { display: block; height: 100%; border-radius: 1.2cqw; }
.sc-row .sc-v { text-align: right; font-weight: 750; font-variant-numeric: tabular-nums; }
.sc .sc-value { margin-top: 2.6cqw; }
.sc-value strong { color: var(--accent); }
.sc .sc-settings { margin-top: auto; padding-top: 2.5cqw; color: #cfe3e0; font-size: 2.9cqw; }
.sc-foot { margin-top: 1.8cqw; padding-top: 2cqw; border-top: 0.25cqw solid rgba(255,255,255,.22); display: flex; justify-content: space-between; gap: 3cqw; font-size: 2.8cqw; color: #cfe3e0; }
.share-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { white-space: normal; vertical-align: bottom; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #faf9f5; position: sticky; top: 0; }
table.data tr.hl td { background: #fff8e6; font-weight: 600; }
table.data.small { font-size: .82rem; }
table.data td.dim { color: #9aa6a3; }
.breakevens { margin-top: 12px; font-size: .92rem; }
.breakevens li { margin: 4px 0; }
.fair ul { padding-left: 18px; margin: 6px 0 0; font-size: .93rem; }
.fair li { margin-bottom: 8px; }
.support { display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap; background: #fff8e6; border: 1px solid #f2dca0; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; }
.support p { margin: 0; flex: 1 1 320px; font-size: .95rem; }
.pos { color: var(--good); } .neg { color: var(--bad); }
.print-only { display: none; }
.print-qr { display: none; align-items: center; gap: 14px; font-size: .95rem; }
.print-qr img { width: 96px; height: 96px; flex: none; }

.info { padding: 30px 0; border-top: 1px solid var(--line); margin-top: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.steps li, .sources li { margin-bottom: 10px; }
.site-footer { background: #0b2a2b; color: #cfe0dd; padding: 24px 0; font-size: .92rem; }
.site-footer .muted { color: #93aaa6; }
.site-footer a { color: #e6f1ef; }
.footer-links a { margin-right: 14px; }
/* Static pages (privacy, terms) */
.doc { padding: 34px 0 40px; }
.doc .wrap { max-width: 760px; }
.doc h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin: 0 0 6px; }
.doc h2 { font-size: 1.2rem; margin: 26px 0 8px; }
.doc p, .doc ul { margin: 0 0 12px; }
.doc li { margin-bottom: 6px; }
.doc .summary { background: #e7f4ec; border: 1px solid #b9e0c8; color: #14462a; padding: 12px 16px; border-radius: var(--radius); }
@media (max-width: 560px) {
  .site-header nav { display: none; }
  .hero { padding-top: 26px; }
  .card .value { font-size: 1.4rem; }
  .chart-box { height: 260px; }
}

/* ---------- print / save as PDF ---------- */
@page { margin: 14mm 12mm; }
@media print {
  html, body { background: #fff; color: #000; font-size: 11pt; }
  .print-only { display: block; }
  .wrap { max-width: none; padding: 0; }
  a { color: inherit; }

  /* Screen-only chrome */
  .header-links, .results-actions, .seg, .btn, .chart-expand, .upload-card, .support-line, .settings > summary .muted, .adv:not([open]) { display: none !important; }
  body.has-results .hero { display: none; }
  .year-panel:has(> details:not([open])) { display: none; }

  .site-header { background: #fff; color: var(--ink); border-bottom: 2px solid var(--brand); }
  .header-inner { height: auto; padding: 0 0 6px; }
  .brand { color: var(--brand); }
  .brand { gap: 0; }
  .brand-mark { border: 2px solid var(--brand); margin-right: 8px; }
  .results { padding: 10px 0 0; }

  /* Flatten cards: no shadows, dark fills become outlines (browsers drop backgrounds by default). */
  .settings, .card, .panel, .headline, .support { box-shadow: none; border: 1px solid var(--line); background: #fff; }
  .card { border-top: 4px solid var(--line); }
  .headline { color: var(--ink); border-left: 6px solid var(--brand); }
  .headline strong { color: var(--brand); }
  .headline .sub { color: var(--muted); }
  /* Assumptions print as "label: value" text rather than form fields. */
  .settings-grid { grid-template-columns: repeat(3, 1fr); gap: 6px 14px; margin-top: 8px; }
  .settings > summary { list-style: none; }
  .settings > summary::-webkit-details-marker { display: none; }
  .settings label { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 0 4px; font-size: .8rem; }
  .settings label.check { grid-column: span 3; }
  .settings select, .settings input[type=number], .settings input[type=date] { flex: 1 0 100%; width: auto; max-width: 100%; border: 0; padding: 0; background: none; appearance: none; -webkit-appearance: none; color: var(--ink); font-weight: 600; font-size: .9rem; }
  .settings input[type=number] { flex: 0 0 3em; width: 3em; }
  .settings .unit { position: static; color: var(--ink); font-weight: 600; font-size: .9rem; }

  .headline, .card, .panel, .support, .settings, tr { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
  .card { padding: 10px; }
  .card .value { font-size: 1.25rem; }
  .chart-grid { display: block; }
  .share { display: none !important; }
  .chart-panel.chart-full { position: static; display: block; height: auto; padding: 18px; }
  .chart-panel.chart-full .chart-box { height: 260px; }
  /* Fixed size that fits Letter and A4, matching the chart resize in app.js, so canvases never stretch. */
  .chart-box { width: 100%; max-width: 680px; height: 260px; margin: 0 auto; }
  .chart-box canvas { max-width: 100% !important; height: auto !important; }

  .table-scroll { overflow: visible; }
  table.data { font-size: 8.5pt; }
  table.data th, table.data td { padding: 4px 5px; white-space: normal; }
  table.data thead th { position: static; }

  .support { display: flex; }
  .print-qr { display: flex; }
  .print-qr img { width: 1in; height: 1in; }

  .advice-note { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand); margin-top: 8px; break-inside: avoid; }
  .info { border-top: 1px solid var(--line); padding: 14px 0 0; margin-top: 8px; }
  .site-footer { background: #fff; color: var(--ink); border-top: 1px solid var(--line); padding: 10px 0 0; }
  .site-footer .muted { color: var(--muted); }
  /* Footer links print with their address, e.g. "Privacy (ssn.tips/privacy)". */
  .site-footer a { color: var(--ink); }
  .footer-links a::after { content: " (ssn.tips" attr(href) ")"; }
}
