/* Keep What You've Earned — Pension & Inheritance Planner */
:root {
  --navy: #0a1628;
  --navy-2: #132340;
  --navy-3: #1c3054;
  --gold: #cfa64f;
  --gold-2: #e2c98f;
  --gold-deep: #a8873f;
  --cream: #f6f2ea;
  --paper: #fffdf8;
  --ink: #16202e;
  --ink-2: #445063;
  --ink-3: #74809a;
  --line: rgba(10, 22, 40, 0.12);
  --line-soft: rgba(10, 22, 40, 0.07);
  --ok: #1f7a4d;
  --warn: #b7791f;
  --bad: #b3362b;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(10, 22, 40, .06), 0 8px 24px -12px rgba(10, 22, 40, .18);
  --max: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--cream);
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

h1, h2, h3, h4 { margin: 0; line-height: 1.15; font-weight: 400; }
h1, h2 { font-family: var(--font-display); letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 0.95rem; font-weight: 600; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
a { color: var(--navy-3); text-decoration-color: var(--gold); text-underline-offset: 3px; }
a:hover { color: var(--gold-deep); }
small, .small { font-size: 0.875rem; }
.muted { color: var(--ink-2); }
.eyebrow { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-deep); font-weight: 600; }
.on-dark .eyebrow { color: var(--gold); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--gold); color: var(--navy); padding: 8px 12px; border-radius: var(--r-sm); z-index: 100; }
.skip:focus { left: 8px; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.wrap { width: min(var(--max), 100% - 2.5rem); margin-inline: auto; }

/* Header */
.site-header {
  background: var(--navy);
  color: #fff;
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid rgba(201, 169, 110, .25);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; }
.brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.brand-mark { width: 40px; height: auto; flex: none; }
.brand-name { font-family: var(--font-display); font-size: 1.15rem; line-height: 1; }
.brand-sub { display: block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin-top: 4px; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav a { color: rgba(255,255,255,.82); text-decoration: none; font-size: .875rem; padding: .5rem .7rem; border-radius: var(--r-sm); }
.nav a:hover, .nav a[aria-current="true"] { color: #fff; background: rgba(255,255,255,.08); }
@media (max-width: 760px) { .nav { display: none; } }
@media (max-width: 520px) { .brand-sub-long { display: none; } }

/* Hero */
.hero { background: var(--navy); color: #fff; padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(2rem, 5vw, 4rem); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset: auto -10% -60% auto; width: 60vw; height: 60vw; max-width: 720px; max-height: 720px; border: 1px solid rgba(201,169,110,.18); transform: rotate(45deg); pointer-events: none; }
.hero .wrap { display: grid; grid-template-columns: 1.2fr .8fr; gap: 3rem; align-items: end; position: relative; z-index: 1; }
.hero p.lead { font-size: 1.15rem; color: rgba(255,255,255,.8); max-width: 34em; margin-top: 1rem; }
.hero .cta { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.75rem; }
.hero-facts { display: grid; gap: .75rem; }
.fact { border: 1px solid rgba(201,169,110,.3); border-radius: var(--r-md); padding: .9rem 1rem; background: rgba(255,255,255,.03); }
.fact .num { font-size: 1.5rem; color: var(--gold-2); display: block; }
.fact .small { color: rgba(255,255,255,.72); }
@media (max-width: 860px) { .hero .wrap { grid-template-columns: 1fr; } .hero-facts { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .hero-facts { grid-template-columns: 1fr; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: 0 1.15rem; border-radius: var(--r-sm); font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; border: 1px solid transparent; text-decoration: none; transition: background .15s, color .15s, border-color .15s; }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: var(--gold-2); color: var(--navy); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.btn-ghost:hover { border-color: #fff; color: #fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-3); color: #fff; }
.btn-outline { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }
.btn-sm { min-height: 36px; padding: 0 .85rem; font-size: .85rem; }

/* Sections */
section.block { padding: clamp(2.5rem, 5vw, 4.5rem) 0; }
section.block + section.block { border-top: 1px solid var(--line-soft); }
.section-head { display: grid; grid-template-columns: 1fr; gap: .5rem; margin-bottom: 1.75rem; max-width: 42em; }
.section-head p { color: var(--ink-2); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: start; }
.col-5-7 { display: grid; grid-template-columns: 5fr 7fr; gap: 2rem; align-items: start; }
@media (max-width: 860px) { .two-col, .col-5-7 { grid-template-columns: 1fr; } }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.5rem; box-shadow: var(--shadow); }
.card-dark { background: var(--navy); color: #fff; border-color: rgba(201,169,110,.3); }
.card-dark .muted { color: rgba(255,255,255,.7); }
.card + .card { margin-top: 1rem; }

/* Ask */
.ask-form { display: flex; gap: .5rem; }
.ask-form input { flex: 1; min-height: 48px; font: inherit; font-size: 1rem; padding: 0 1rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; color: var(--ink); }
.ask-form input:focus { border-color: var(--navy); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.chip { background: transparent; border: 1px solid var(--line); color: var(--ink-2); border-radius: 999px; padding: .4rem .8rem; font: inherit; font-size: .82rem; cursor: pointer; }
.chip:hover { border-color: var(--gold-deep); color: var(--navy); }
.answers { display: grid; gap: 1rem; margin-top: 1.5rem; }
.answer { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1.25rem 1.4rem; }
.answer h3 { margin-bottom: .5rem; }
.answer .tag { display: inline-block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-deep); font-weight: 600; margin-bottom: .5rem; }
.answer ul { margin: .5rem 0 0; padding-left: 1.2rem; }
.answer li { margin-bottom: .3rem; }
.answer .src { font-size: .8rem; color: var(--ink-3); margin-top: .75rem; }
.empty { color: var(--ink-2); padding: 1rem 0; }

/* Forms */
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field label, .field .lbl { font-size: .875rem; font-weight: 600; color: var(--ink); }
.field .hint { font-size: .8rem; color: var(--ink-3); font-weight: 400; }
.field input[type="number"], .field input[type="text"], .field select {
  min-height: 44px; font: inherit; font-size: 1rem; padding: 0 .85rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--navy); }
.money { position: relative; }
.money::before { content: "£"; position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 600; }
.money input { padding-left: 1.75rem !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }
.seg { display: flex; flex-wrap: wrap; gap: .5rem; }
.seg label { display: inline-flex; align-items: center; min-height: 40px; padding: 0 .9rem; border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; font-size: .9rem; font-weight: 500; background: #fff; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { border-color: var(--navy); background: var(--navy); color: #fff; }
.seg label:has(input:checked) span { color: #fff; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
.checks { display: grid; gap: .5rem; }
.checks label { display: flex; gap: .6rem; align-items: flex-start; font-size: .95rem; font-weight: 400; cursor: pointer; }
.checks input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--navy); }
.toggle { display: inline-flex; gap: .6rem; align-items: center; font-size: .9rem; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--navy); }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
legend { font-size: .875rem; font-weight: 600; margin-bottom: .5rem; padding: 0; }

/* Result panels */
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 520px) { .result-grid { grid-template-columns: 1fr; } }
.kpi { border: 1px solid rgba(201,169,110,.3); border-radius: var(--r-md); padding: 1rem 1.1rem; }
.kpi .lbl { font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); font-weight: 600; display: block; margin-bottom: .3rem; }
.kpi .num { font-size: 1.7rem; color: #fff; display: block; line-height: 1.1; }
.kpi .sub { font-size: .8rem; color: rgba(255,255,255,.65); display: block; margin-top: .3rem; }
.kpi.alert .num { color: var(--gold-2); }
.breakdown { margin-top: 1.25rem; border-top: 1px solid rgba(255,255,255,.12); padding-top: 1rem; font-size: .9rem; }
.breakdown .row { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px dashed rgba(255,255,255,.1); }
.breakdown .row:last-child { border-bottom: 0; }
.breakdown .row.total { font-weight: 600; border-top: 1px solid rgba(255,255,255,.2); margin-top: .3rem; padding-top: .6rem; }
.note { font-size: .85rem; color: rgba(255,255,255,.7); margin-top: 1rem; }
.bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,.08); margin: 1rem 0 .5rem; }
.bar span { display: block; height: 100%; }
.bar .b-free { background: var(--ok); }
.bar .b-rnrb { background: #2f9a68; }
.bar .b-tax { background: var(--bad); }
.bar .b-keep { background: rgba(255,255,255,.28); }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .78rem; color: rgba(255,255,255,.75); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .4rem; vertical-align: -1px; }

/* Planner steps */
.steps { display: flex; gap: .4rem; margin-bottom: 1.5rem; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps span.done { background: var(--gold); }
.step { display: none; }
.step.active { display: block; }
.step h3 { margin-bottom: 1rem; }
.step-nav { display: flex; justify-content: space-between; gap: .75rem; margin-top: 1.25rem; }

.actions { display: grid; gap: .75rem; }
.action { display: grid; grid-template-columns: auto 1fr; gap: .9rem; padding: 1rem 1.1rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); }
.action .pri { font-family: var(--font-mono); font-size: .75rem; font-weight: 600; letter-spacing: .05em; padding: .25rem .5rem; border-radius: 4px; height: fit-content; white-space: nowrap; }
.pri.p1 { background: rgba(179,54,43,.1); color: var(--bad); }
.pri.p2 { background: rgba(183,121,31,.12); color: var(--warn); }
.pri.p3 { background: rgba(31,122,77,.1); color: var(--ok); }
.action h4 { margin-bottom: .25rem; }
.action p { font-size: .92rem; color: var(--ink-2); }
.action .who { font-size: .78rem; color: var(--ink-3); margin-top: .4rem; }
.checklist { columns: 2; column-gap: 2rem; padding-left: 1.2rem; margin: 0; font-size: .92rem; }
.checklist li { break-inside: avoid; margin-bottom: .4rem; }
@media (max-width: 640px) { .checklist { columns: 1; } }

/* Knowledge grid */
.kb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 960px) { .kb-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .kb-grid { grid-template-columns: 1fr; } }
.rule { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1.1rem 1.2rem; }
.rule .num { font-size: 1.4rem; color: var(--navy); display: block; margin: .2rem 0 .3rem; }
.rule .lbl { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-deep); font-weight: 600; }
.rule p { font-size: .88rem; color: var(--ink-2); }
.rule.change { border-color: rgba(183,121,31,.45); background: #fff9ec; }
.rule.change .lbl { color: var(--warn); }

details.faq { border-bottom: 1px solid var(--line); }
details.faq summary { cursor: pointer; padding: 1rem 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; color: var(--gold-deep); font-weight: 400; font-size: 1.3rem; line-height: 1; }
details.faq[open] summary::after { content: "–"; }
details.faq .body { padding: 0 0 1.25rem; color: var(--ink-2); font-size: .95rem; }
details.faq .body ul { padding-left: 1.2rem; margin: .5rem 0; }

/* Advice section */
.adviser-types { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 700px) { .adviser-types { grid-template-columns: 1fr; } }
.adviser-types .card h3 { margin-bottom: .4rem; }
.adviser-types .card p, .adviser-types .card li { font-size: .92rem; color: var(--ink-2); }
.adviser-types ul { padding-left: 1.1rem; margin: .5rem 0 0; }
.qlist { counter-reset: q; list-style: none; padding: 0; margin: 0; }
.qlist li { counter-increment: q; display: grid; grid-template-columns: 2rem 1fr; gap: .5rem; padding: .6rem 0; border-bottom: 1px dashed var(--line); font-size: .95rem; }
.qlist li::before { content: counter(q, decimal-leading-zero); font-family: var(--font-mono); color: var(--gold-deep); font-size: .85rem; padding-top: .15rem; }

/* Footer */
.site-footer { background: var(--navy); color: rgba(255,255,255,.75); padding: 3rem 0 2rem; font-size: .875rem; }
.site-footer .wrap { display: grid; grid-template-columns: 1.3fr 1fr; gap: 2rem; }
@media (max-width: 760px) { .site-footer .wrap { grid-template-columns: 1fr; } .notice .wrap { padding: .5rem 0; } }
.site-footer h4 { color: var(--gold); font-weight: 600; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: .6rem; }
.site-footer a { color: #fff; }
.disclaimer { border: 1px solid rgba(201,169,110,.3); border-radius: var(--r-md); padding: 1rem 1.1rem; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media print {
  .site-header, .hero, #ask, #knowledge, #advice, .site-footer, .step-nav, .steps, .btn { display: none !important; }
  body { background: #fff; }
  .card-dark { background: #fff; color: #000; border: 1px solid #000; }
  .kpi .num, .kpi .lbl, .kpi .sub, .note, .legend, .breakdown { color: #000 !important; }
}

/* ---------- Warnings & disclaimers ---------- */
.notice { background: #fff3d6; color: #5a3d05; border-bottom: 1px solid rgba(183,121,31,.35); font-size: .85rem; }
.notice .wrap { display: flex; gap: .75rem; align-items: flex-start; padding: .6rem 0; }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--warn); }
.notice strong { color: #3f2a02; }
.warn { display: flex; gap: .7rem; align-items: flex-start; border: 1px solid rgba(183,121,31,.5); background: rgba(255,243,214,.9); color: #5a3d05; border-radius: var(--r-md); padding: .75rem .9rem; font-size: .82rem; line-height: 1.45; margin-top: 1rem; }
.warn svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--warn); }
.card-dark .warn { background: rgba(255,243,214,.12); border-color: rgba(226,201,143,.45); color: #f3e6c8; }
.card-dark .warn svg { color: var(--gold-2); }
.ai-tag { display: inline-flex; align-items: center; gap: .4rem; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; color: var(--gold); border: 1px solid rgba(201,169,110,.45); border-radius: 999px; padding: .25rem .6rem; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(10,22,40,.72); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding: 1rem; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--paper); color: var(--ink); border-radius: var(--r-lg); max-width: 640px; width: 100%; margin: 1.5rem auto auto; padding: 1.75rem; box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); border-top: 4px solid var(--warn); }
.modal h2 { font-size: 1.5rem; margin-bottom: .75rem; }
.modal ul { padding-left: 1.2rem; margin: .5rem 0 1rem; font-size: .93rem; color: var(--ink-2); }
.modal li { margin-bottom: .45rem; }
.modal .modal-actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
body.modal-open { overflow: hidden; }

/* ---------- Chat ---------- */
.chat { margin-top: 1.5rem; }
.chat-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 1rem; }
.chat-head h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; }
.chat-log { display: grid; gap: .9rem; max-height: 520px; overflow-y: auto; padding-right: .25rem; scroll-behavior: smooth; }
.msg { display: grid; gap: .35rem; max-width: 92%; }
.msg .who { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; color: var(--gold); }
.msg .bubble { padding: .85rem 1rem; border-radius: var(--r-md); font-size: .95rem; line-height: 1.55; }
.msg.user { justify-self: end; }
.msg.user .who { text-align: right; color: rgba(255,255,255,.6); }
.msg.user .bubble { background: rgba(255,255,255,.1); color: #fff; }
.msg.ai .bubble { background: #fff; color: var(--ink); border: 1px solid rgba(201,169,110,.35); }
.msg.ai .bubble p { margin: 0 0 .6em; }
.msg.ai .bubble p:last-child { margin: 0; }
.msg.ai .bubble ul { margin: .3em 0 .6em; padding-left: 1.2em; }
.msg.ai .bubble table { border-collapse: collapse; font-size: .88rem; margin: .4em 0 .6em; }
.msg.ai .bubble td, .msg.ai .bubble th { border: 1px solid var(--line); padding: .3em .6em; text-align: left; }
.msg .cites { font-size: .78rem; color: rgba(255,255,255,.7); }
.msg .cites a { color: var(--gold-2); }
.msg .ai-disc { font-size: .75rem; color: rgba(255,255,255,.62); line-height: 1.4; }
.msg.err .bubble { background: rgba(179,54,43,.18); color: #ffd9d4; border: 1px solid rgba(179,54,43,.5); }
.typing { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: pulse 1s infinite; margin-left: 4px; }
@keyframes pulse { 0%,100% { opacity: .2 } 50% { opacity: 1 } }
.chat-form { display: flex; gap: .5rem; margin-top: 1rem; }
.chat-form input { flex: 1; min-height: 46px; font: inherit; font-size: 1rem; padding: 0 1rem; border: 1px solid rgba(201,169,110,.4); border-radius: var(--r-sm); background: rgba(255,255,255,.06); color: #fff; }
.chat-form input::placeholder { color: rgba(255,255,255,.45); }
.chat-form input:focus { border-color: var(--gold); }
.chat-form button[disabled] { opacity: .5; cursor: wait; }
.chat .chips .chip { border-color: rgba(255,255,255,.25); color: rgba(255,255,255,.8); }
.chat .chips .chip:hover { border-color: var(--gold); color: #fff; }
.chat-off { font-size: .85rem; color: rgba(255,255,255,.7); }

.print-only { display: none; }
@media print {
  .print-only { display: block; border: 2px solid #000; padding: 1rem; margin: 1rem 0; font-size: .85rem; }
  .notice, .modal-backdrop, .chat { display: none !important; }
}
