/* calcfig.com: navy / gold / soft grey. Mobile first, no web fonts. */
:root {
  --navy: #14213D; --navy-2: #24345C; --gold: #E9B949; --gold-deep: #7A5300; --gold-soft: #FBF2D5;
  --grey: #F1F3F7; --line: #D6DBE5; --ink: #18213A; --muted: #4F5A70; --white: #fff;
  --surface: #fff; --bar: #14213D; --on-navy: #fff; --adbg: #E8EBF1; --adline: #B8C0CF;
  --radius: 16px; --shadow: 0 1px 2px rgba(20,33,61,.06), 0 6px 20px rgba(20,33,61,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 1.0625rem; line-height: 1.6; color: var(--ink); background: var(--grey); }
a { color: var(--navy-2); text-underline-offset: 2px; }
a:hover { color: var(--navy); }
h1, h2, h3 { line-height: 1.2; color: var(--navy); }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.35rem); margin: .3em 0 .35em; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; margin: 1.2em 0 .5em; }
h3 { font-size: 1.1rem; margin: 1.2em 0 .4em; }
.h-small { font-size: 1.05rem; margin: 0 0 .6em; }
.small, .hint { font-size: .9rem; color: var(--muted); }
.hint { margin: .35em 0 0; }
.lede { font-size: 1.12rem; color: var(--muted); margin-top: 0; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; background: var(--surface); padding: 8px 12px; z-index: 10; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* header */
.site-header { background: var(--bar); color: var(--white); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--white); text-decoration: none; }
.brand .fig-mark { box-shadow: 0 0 0 1px rgba(255,255,255,.15); border-radius: 9px; }
.wordmark { font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em; }
.wordmark b, .footer-brand b { color: var(--gold); font-weight: 700; }
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; order: 3; width: 100%; overflow-x: auto; }
.main-nav a { color: #DCE2EE; text-decoration: none; padding: 8px 12px; border-radius: 999px; font-size: .95rem; white-space: nowrap; }
.main-nav a:hover { background: rgba(255,255,255,.08); color: var(--white); }
.main-nav a[aria-current] { color: var(--white); font-weight: 600; box-shadow: inset 0 -2px 0 var(--gold); border-radius: 0; }
.region { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; background: rgba(255,255,255,.08); border-radius: 999px; padding: 3px; }
.region a { color: #DCE2EE; text-decoration: none; font-weight: 600; font-size: .9rem; padding: 6px 11px; border-radius: 999px; min-width: 44px; text-align: center; }
.region a[aria-current] { background: #fff; color: #14213D; }
@media (min-width: 860px) { .main-nav { order: 0; width: auto; } }

/* layout */
.layout, .layout-wide { display: grid; gap: 32px; padding-top: 8px; padding-bottom: 48px; max-width: 780px; }
.sidebar { display: none !important; }
@media (min-width: 1100px) {
  .has-side-ad .layout { grid-template-columns: minmax(0, 1fr) 300px; max-width: 1140px; }
  .has-side-ad .sidebar { display: grid !important; }
}
.content { min-width: 0; }
.sidebar { display: grid; gap: 16px; align-content: start; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin: 0 0 24px; }
@media (min-width: 640px) { .card { padding: 26px; } }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 10px 0 0; font-size: .88rem; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: #A0A8B8; }
.crumbs a { color: var(--muted); }
.related ul, .link-list { list-style: none; padding: 0; margin: 0; }
.related li, .link-list li { padding: 6px 0; border-bottom: 1px solid var(--grey); }
.related li:last-child, .link-list li:last-child { border-bottom: 0; }
@media (min-width: 700px) { .link-list.cols { columns: 2; column-gap: 28px; } .link-list.cols li { break-inside: avoid; } }

/* ads: space reserved only when an ad is actually shown */
.ad { margin: 12px 0 20px; text-align: center; }
.ad-side { min-height: 600px; position: sticky; top: 16px; margin-top: 0; }
.ad-content, .ad-end { min-height: 250px; }
.ad-preview { display: grid; place-items: center; border: 2px dashed var(--adline); border-radius: 12px; background: var(--adbg); color: var(--muted); font-size: .9rem; }
.ad-preview::before { content: attr(data-label); }

/* home */
.tool-grid { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 20px; }
@media (min-width: 600px) { .tool-grid { grid-template-columns: 1fr 1fr; } }
.tool-card { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; text-decoration: none; color: var(--ink); margin: 0; transition: transform .15s ease, box-shadow .15s ease; }
.tool-card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(20,33,61,.08), 0 12px 28px rgba(20,33,61,.1); }
.tool-icon { grid-row: span 2; }
.tool-name { font-weight: 700; color: var(--navy); font-size: 1.08rem; }
.tool-blurb { color: var(--muted); font-size: .95rem; }

/* forms */
.tool { }
.field { margin: 0 0 18px; }
.field.inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.field.inline label { margin: 0; }
label, .label { display: block; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
input[type=text], select {
  font: inherit; font-size: 1.15rem; width: 100%; min-height: 52px; padding: 10px 14px; color: var(--ink);
  background: var(--surface); border: 2px solid var(--line); border-radius: 12px; transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--navy) 50%), linear-gradient(135deg, var(--navy) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
input[type=text]:focus, select:focus { border-color: var(--navy); box-shadow: 0 0 0 4px rgba(233,185,73,.35); outline: none; }
.affix { display: flex; align-items: stretch; }
.affix .pre, .affix .post { display: grid; place-items: center; padding: 0 14px; background: var(--grey); border: 2px solid var(--line); color: var(--muted); font-weight: 600; font-size: 1.1rem; }
.affix .pre { border-right: 0; border-radius: 12px 0 0 12px; }
.affix .post { border-left: 0; border-radius: 0 12px 12px 0; }
.affix .pre + input { border-radius: 0 12px 12px 0; }
.affix input:has(+ .post) { border-radius: 12px 0 0 12px; }
.affix.narrow { max-width: 200px; }
.narrow-input { max-width: 140px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { font: inherit; font-weight: 600; min-height: 44px; min-width: 60px; padding: 8px 16px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface); color: var(--navy); cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.chip:hover { border-color: var(--navy); }
.chip[aria-pressed=true] { background: var(--navy); border-color: var(--navy); color: var(--on-navy); }
.stepper { display: inline-flex; align-items: stretch; }
.stepper button { font: inherit; font-size: 1.4rem; width: 52px; min-height: 52px; border: 2px solid var(--line); background: var(--grey); color: var(--navy); cursor: pointer; }
.stepper button:first-child { border-radius: 12px 0 0 12px; border-right: 0; }
.stepper button:last-child { border-radius: 0 12px 12px 0; border-left: 0; }
.stepper input { width: 80px; text-align: center; border-radius: 0; }
.check, .mini-check { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); margin: 0 0 14px; cursor: pointer; }
.check input, .mini-check input { width: 22px; height: 22px; accent-color: var(--navy); flex: none; }
.mini-check { font-size: .85rem; margin: 0; gap: 6px; white-space: nowrap; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; background: var(--grey); padding: 5px; border-radius: 14px; margin: 0 0 18px; }
.seg label { flex: 1 1 auto; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--muted); min-height: 44px; }
.seg input:checked + span { background: var(--surface); color: var(--navy); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 3px solid var(--gold); }
.btn-secondary { font: inherit; font-weight: 600; min-height: 44px; padding: 8px 16px; border: 2px dashed var(--line); border-radius: 12px; background: transparent; color: var(--navy); cursor: pointer; margin: 4px 0 18px; }
.btn-secondary:hover { border-color: var(--navy); }
.small-btn { font-size: .92rem; min-height: 40px; }
.linkish { font: inherit; background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; }

/* repeating rows (grade tools) */
.rows { display: grid; gap: 8px; margin-bottom: 10px; }
.row { display: grid; gap: 8px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, .8fr) auto auto; align-items: center; }
.row input[type=text], .row select { min-height: 46px; font-size: 1.02rem; padding: 8px 10px; }
.row select { padding-right: 32px; }
.row-head { font-size: .82rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.row-x { font-size: 1.4rem; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.row-x:hover { background: var(--grey); color: var(--navy); }
.row-au { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, .8fr) auto auto; }
.row-uk { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
@media (max-width: 560px) {
  .row, .row-au { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .row > [data-f=name] { grid-column: 1 / -1; }
  .row-head { display: none; }
  .row > span:empty { display: none; }
  .row .mini-check { grid-column: 1 / 3; }
  .row-x { grid-row: 1; grid-column: 3; }
  .row [data-f=name] { grid-column: 1 / 3; }
}
.year { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 4px; margin: 0 0 14px; }
.year legend { font-weight: 700; color: var(--navy); padding: 0 6px; }

/* result */
.result { margin: 12px 0 0; padding: 20px; border-radius: 14px; background: var(--gold-soft); }
.result-grid { display: flex; flex-direction: column; gap: 6px; }
.r { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.r-label { font-size: .95rem; color: var(--muted); }
.r output { font-size: 1.1rem; font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; text-align: right; word-break: break-word; }
.r-main { order: -1; flex-direction: column; align-items: flex-start; gap: 0; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.r-main .r-label { font-weight: 600; }
.r-main output { font-size: 2.4rem; font-weight: 700; text-align: left; line-height: 1.15; }
.result-note { margin: 10px 0 0; font-size: .95rem; color: var(--ink); min-height: 0; }
.result-note:empty { display: none; }
.result figcaption, .worked figcaption, caption { font-size: .85rem; color: var(--muted); margin-top: 10px; text-align: left; }
.fig-no { font-weight: 700; color: var(--gold-deep); margin-right: 4px; }
.result.has-result .r-main::after { content: ""; }
.pop { animation: pop .32s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { opacity: .2; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pop { animation: none; } .tool-card { transition: none; } }
.state-note:empty { display: none; }
.assumptions { margin-top: 18px; font-size: .95rem; }
.assumptions summary { cursor: pointer; color: var(--navy-2); font-weight: 600; }
.assumptions[open] summary { margin-bottom: 8px; }
.assumptions ul { padding-left: 1.2em; margin: 0 0 10px; }
.checked { font-size: .88rem; color: var(--muted); }

/* worked example + tables */
.worked table, .rates { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.worked th, .worked td, .rates th, .rates td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--grey); vertical-align: top; }
.worked td { text-align: right; font-weight: 600; }
.worked tr.total th, .worked tr.total td { border-bottom: 0; color: var(--navy); font-size: 1.1rem; font-weight: 700; }
.rates td:nth-child(2) { white-space: nowrap; font-weight: 600; }
.rates td:nth-child(3) { font-size: .88rem; color: var(--muted); }
.table-wrap { overflow-x: auto; }
caption { caption-side: bottom; }

/* guide */
.guide p, .prose p { margin: 0 0 .9em; }
.guide h2:first-child, .prose h2:first-child { margin-top: 0; }
.faq { border-bottom: 1px solid var(--grey); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; color: var(--navy); list-style-position: outside; }
.faq p { margin: 8px 0 0; }
.leaf-rule { border: 0; height: 24px; margin: 24px 0 8px; background:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 24'%3E%3Cpath d='M20 22c0-6 0-9-4-13-3-2-7-2-8-1 1 5 4 7 8 8-4 0-6-1-8-2 0 4 4 6 8 6h4zm0 0c0-6 0-9 4-13 3-2 7-2 8-1-1 5-4 7-8 8 4 0 6-1 8-2 0 4-4 6-8 6h-4z' fill='%23E9B949'/%3E%3C/svg%3E") center / 40px 24px no-repeat,
  linear-gradient(var(--line), var(--line)) center / 100% 1px no-repeat; }

/* footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 26px 0 30px; }
.footer-inner { display: grid; gap: 10px; }
.footer-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--navy); flex-wrap: wrap; }
.footer-line { font-weight: 400; font-style: italic; color: var(--muted); font-size: .95rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-footer nav a, .site-footer nav button { color: var(--navy-2); font-size: .95rem; }

/* working, actions, feedback, comparison */
.working { margin: 12px 0 0; font-size: .92rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.working:empty { display: none; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 0; }
.act { font: inherit; font-size: .92rem; font-weight: 600; min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--navy); cursor: pointer; }
.act:hover { border-color: var(--navy); }
.act-status { font-size: .9rem; color: var(--gold-deep); font-weight: 600; }
.feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 18px 0 0; font-size: .95rem; color: var(--muted); }
.feedback .act { min-height: 36px; padding: 4px 14px; }
.fb-thanks { color: var(--navy); }
.trust { font-size: .85rem; color: var(--muted); margin: 8px 0 0; }
.compare { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.compare table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .97rem; }
.compare th, .compare td { padding: 8px 6px; border-bottom: 1px solid var(--grey); text-align: right; }
.compare th:first-child { text-align: left; }
.compare thead th { font-size: .82rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.compare tbody th { font-weight: 600; color: var(--navy); }
.compare tr.current th, .compare tr.current td { background: var(--gold-soft); }
.compare-cap { font-size: .85rem; color: var(--muted); margin: 8px 0 0; }
/* keep ads well clear of the buttons above them */
.ad-content { margin-top: 36px; }

/* theme toggle (shown by app.js) */
.theme-toggle { margin-left: auto; width: 40px; height: 40px; display: inline-grid; place-items: center; border: 0; border-radius: 999px; background: rgba(255,255,255,.08); color: #DCE2EE; cursor: pointer; }
.theme-toggle:hover { background: rgba(255,255,255,.16); color: #fff; }
.theme-toggle[hidden] { display: none; }
.region + .theme-toggle { margin-left: 0; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* dark theme */
:root[data-theme="dark"] {
  color-scheme: dark;
  --navy: #E6EBF7; --navy-2: #9DB6F0; --gold-deep: #E9B949; --gold-soft: #2A2716;
  --grey: #0D1322; --surface: #161F35; --line: #2B3856; --ink: #E3E8F3; --muted: #A3AEC4;
  --on-navy: #14213D; --adbg: #1B2540; --adline: #3A4A70;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
}
:root[data-theme="dark"] .crumbs li + li::before { color: #6F7B94; }
:root[data-theme="dark"] .tool-card:hover { box-shadow: 0 2px 4px rgba(0,0,0,.4), 0 12px 28px rgba(0,0,0,.45); }
:root[data-theme="dark"] input[type=text]:focus, :root[data-theme="dark"] select:focus { box-shadow: 0 0 0 4px rgba(233,185,73,.3); }

.disclaimer { margin: 14px 0 0; padding: 12px 14px; border-left: 3px solid var(--gold); background: var(--surface); border-radius: 0 10px 10px 0; color: var(--muted); }
.disclaimer strong { color: var(--navy); }
