:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --text: #1c2321;
  --muted: #5b6662;
  --line: #dcdcd4;
  --accent: #0f5c4d;
  --accent-soft: #e3efeb;
  --warn: #8a4b00;
  --warn-soft: #fbf0df;
  --good: #1f6f3a;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --surface: #1b2120;
    --text: #e8ece9;
    --muted: #9fa9a5;
    --line: #2f3836;
    --accent: #5fc2a8;
    --accent-soft: #1d3530;
    --warn: #f0b46a;
    --warn-soft: #3a2c19;
    --good: #7fd49a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.6 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; font-weight: 700; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 0.2em 0 0.3em; }
h2 { font-size: 1.45rem; margin: 2em 0 0.5em; }
h3 { font-size: 1.15rem; margin: 1.5em 0 0.4em; }
p, ul, ol { margin: 0 0 1em; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; }

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

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-top: 12px; padding-bottom: 12px; }
.brand { font-family: var(--serif); font-weight: 700; font-size: 1.25rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--surface); }
nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.95rem; }
nav a { color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--accent); text-decoration: underline; }

main { padding: 24px 0 48px; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 680px; }
.reviewed { font-size: 0.85rem; color: var(--muted); margin-top: -0.4em; }

/* Calculator layout */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 20px; margin: 24px 0 8px; align-items: start; }
@media (max-width: 820px) { .calc { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel h2 { margin-top: 0; font-size: 1.15rem; }

.field { margin-bottom: 16px; }
.field > label, .field > .label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.95rem; }
.hint { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 400; }
input[type="number"], input[type="text"], select {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.money { position: relative; }
.money::before { content: "£"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money input { padding-left: 26px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.checks label { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 4px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { flex: 1; text-align: center; padding: 8px; cursor: pointer; font-weight: 500; font-size: 0.95rem; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--surface); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Results */
.headline { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.headline div { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; }
.headline span { display: block; font-size: 0.8rem; color: var(--muted); }
.headline strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.headline .big { grid-column: 1 / -1; }
.headline .big strong { font-size: 2rem; }
@media (max-width: 420px) { .headline { grid-template-columns: 1fr 1fr; } }

table.breakdown { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.breakdown th, .breakdown td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.breakdown th:first-child, .breakdown td:first-child { text-align: left; }
.breakdown thead th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.breakdown tr.sub td { color: var(--muted); font-size: 0.88rem; }
.breakdown tr.sub td:first-child { padding-left: 16px; }
.breakdown tr.total td { font-weight: 700; border-bottom: 2px solid var(--text); }

.note { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 10px 14px; border-radius: 0 8px 8px 0; margin: 14px 0; font-size: 0.95rem; }
.note.warn { border-color: var(--warn); background: var(--warn-soft); }
.note p:last-child { margin-bottom: 0; }

/* Bar showing where each pound goes */
.split { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 6px 0 4px; background: var(--line); }
.split span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.82rem; color: var(--muted); margin-bottom: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* Home page cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 24px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--text); display: block; }
.card:hover { border-color: var(--accent); }
.card h2 { margin: 0 0 6px; font-size: 1.15rem; color: var(--accent); }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.article { max-width: 720px; }
.article table { border-collapse: collapse; width: 100%; margin: 0 0 1em; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.article th, .article td { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; }
.author-box { display: flex; gap: 14px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 24px 0; }
.author-box .avatar { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: var(--surface); display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: 1.2rem; }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 24px 0; font-size: 0.88rem; color: var(--muted); }
.footer-links a { color: var(--muted); }

@media print { .site-header nav, .site-footer { display: none; } }
@media (max-width: 480px) {
  .panel { padding: 16px 14px; }
  .breakdown th, .breakdown td { padding: 6px 2px; font-size: 0.85rem; }
  .seg label { font-size: 0.85rem; padding: 8px 4px; }
}

/* Tax receipt: white till-roll paper with dark ink, in light and dark mode alike */
.receipt-wrap { max-width: 640px; margin-top: 32px; }
.receipt-shadow { max-width: 460px; margin: 8px auto 16px; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.12)) drop-shadow(0 8px 16px rgba(0,0,0,0.12)); }
.receipt {
  --ink: #1d1d1b; --ink-soft: #6b6b66; --rule: #b9b9b2;
  background: #ffffff; color: var(--ink); color-scheme: light;
  padding: 26px 22px 34px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace; font-size: 0.88rem; line-height: 1.5;
  /* torn zigzag bottom edge */
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
}
.receipt .r-head { text-align: center; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; border-bottom: 1px dashed var(--ink); padding-bottom: 12px; margin-bottom: 8px; }
.receipt .r-head span { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-soft); font-size: 0.82rem; }
.receipt table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.receipt th { font-size: 0.72rem; color: var(--ink-soft); text-align: left; font-weight: 600; padding: 4px 0; text-transform: uppercase; letter-spacing: 0.05em; }
.receipt td { padding: 6px 0; vertical-align: top; border-bottom: 1px dotted var(--rule); }
.receipt .r-name { display: block; }
.receipt .hint { display: block; color: var(--ink-soft); font-size: 0.76rem; }
.receipt .r-bar { display: block; height: 3px; margin-top: 4px; background: var(--ink); opacity: 0.55; }
.receipt .r-pct { text-align: right; padding-left: 8px; color: var(--ink-soft); white-space: nowrap; width: 4.5em; }
.receipt .r-amt { text-align: right; padding-left: 12px; white-space: nowrap; width: 7em; }
.receipt tfoot td { font-weight: 700; font-size: 1rem; border-top: 1px dashed var(--ink); border-bottom: 3px double var(--ink); padding-top: 10px; }
.receipt .r-foot { text-align: center; color: var(--ink-soft); margin: 14px 0 0; font-size: 0.82rem; }
.receipt .r-thanks { text-align: center; margin: 10px 0 0; font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; }

/* Working week */
.week { margin: 8px 0 6px; }
.wk-day { display: grid; grid-template-columns: 3em 1fr; align-items: center; gap: 8px; margin-bottom: 6px; }
.wk-name { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.wk-bar { display: block; height: 22px; border-radius: 5px; background: var(--accent); overflow: hidden; }
.wk-state { display: block; height: 100%; background: #c0563b; }
.wk-axis { display: flex; justify-content: space-between; margin-left: calc(3em + 8px); font-size: 0.75rem; color: var(--muted); }
details summary { cursor: pointer; }

/* Income distribution chart */
.calc-wide { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.6fr); }
@media (max-width: 820px) { .calc-wide { grid-template-columns: minmax(0, 1fr); } }
svg.dist { width: 100%; height: auto; display: block; margin-bottom: 12px; font: 11px var(--font); }
.dist text { fill: var(--muted); }
.dist .g { stroke: var(--line); stroke-width: 1; }
.dist .a { fill: var(--accent-soft); }
.dist .c { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.dist .m { stroke: var(--muted); stroke-dasharray: 3 3; }
.dist .md { fill: var(--muted); }
.dist .ml { fill: var(--text); font-weight: 600; }
.dist .u { stroke: #c0563b; stroke-width: 1.5; stroke-dasharray: 5 3; }
.dist .ud { fill: #c0563b; stroke: var(--surface); stroke-width: 2; }
.dist .ul { fill: #c0563b; font-weight: 700; font-size: 13px; }
.dist .ax { font-size: 11px; }

/* Three-column row with a read-only calculated box */
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 420px) { .row3 { gap: 8px; } }
.readonly-box { display: block; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); background: transparent; font-variant-numeric: tabular-nums; }
.readonly-box::after { content: "  (auto)"; font-size: 0.8rem; }
.row3 .field { display: flex; flex-direction: column; justify-content: space-between; }

/* Taller stacked bars with a clearer legend */
.split.tall { height: 26px; border-radius: 6px; gap: 2px; background: transparent; }
.split.tall span:first-child { border-radius: 6px 0 0 6px; }
.split.tall span:last-child { border-radius: 0 6px 6px 0; }
.split.tall + .legend { gap: 6px 16px; font-size: 0.85rem; color: var(--text); }
.split.tall + .legend b { font-weight: 600; color: var(--muted); }
.bar-title { font-size: 0.9rem; font-weight: 600; margin: 4px 0 2px; }
.breakdown td:not(:first-child) { white-space: nowrap; }

/* Stamp duty comparison */
.sd-bars { display: grid; gap: 8px; margin: 8px 0 16px; }
.sd-bar { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 0.95rem; }
.sd-bar small { color: var(--muted); }
.sd-track { height: 14px; background: var(--line); border-radius: 7px; overflow: hidden; }
.sd-track span { display: block; height: 100%; background: var(--muted); border-radius: 7px; min-width: 2px; }
.sd-bar.me .sd-track span { background: var(--accent); }
.sd-bar.me .sd-name { font-weight: 600; }
.sd-details details { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
.sd-details summary { cursor: pointer; font-weight: 600; }
.sd-details table { margin-top: 8px; }
.sd-compare td:first-child { white-space: normal; }

/* House and buying-costs bar */
.house-chart { width: 100%; max-width: 460px; height: auto; display: block; margin: 8px 0 4px; overflow: visible; }
.house-chart .hc-house rect, .house-chart .hc-roof { fill: var(--accent-soft); stroke: var(--muted); stroke-width: 1.5; }
.house-chart .hc-roof { fill: var(--line); }
.house-chart .hc-win { fill: var(--surface); }
.house-chart .hc-door { fill: var(--muted); }
.house-chart .hc-ground { stroke: var(--muted); stroke-width: 1.5; }
.house-chart .hc-guide { stroke: var(--muted); stroke-dasharray: 4 3; stroke-width: 1; }
.house-chart .hc-lead { stroke: var(--muted); fill: none; stroke-width: 1; }
.house-chart text { fill: var(--text); font-family: var(--font); }
.house-chart .hc-name { font-size: 11px; fill: var(--muted); }
.house-chart .hc-amt { font-size: 12px; font-weight: 700; }
.house-chart .hc-pct { font-size: 11px; fill: var(--muted); }
.house-chart .hc-total { font-weight: 700; fill: var(--text); }

/* Number box with a unit after it, e.g. % */
.unit { position: relative; }
.unit input { padding-right: 34px; }
.unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 6px 0 0; }
.field output { float: right; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }

/* Compound interest chart */
.ci-chart { touch-action: pan-y; cursor: crosshair; margin-bottom: 4px; }
.ci-line { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; }
.ci-dot { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
.ci-readout { font-size: 0.9rem; min-height: 1.6em; margin: 0 0 12px; font-variant-numeric: tabular-nums; }
.ci-key { white-space: nowrap; margin-left: 10px; color: var(--muted); }
.ci-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.ci-facts { padding-left: 1.2em; font-size: 0.95rem; }
.ci-facts li { margin-bottom: 6px; }
.ci-years { margin-top: 12px; }

/* Home page sections */
.hub-section { scroll-margin-top: 12px; }
.hub-section > h2 { margin-bottom: 0.2em; }
.hub-section > p { color: var(--muted); max-width: 680px; margin-bottom: 0; }
.hub-section .cards { margin-top: 14px; }
.card.soon { border-style: dashed; background: transparent; cursor: default; }
.card.soon:hover { border-color: var(--line); }
.card.soon h3 { color: var(--muted); }
.card h3 { margin: 0 0 6px; font-size: 1.1rem; color: var(--accent); font-family: var(--serif); }
.tag { display: inline-block; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin-bottom: 6px; font-family: var(--font); }
.tag.new { color: var(--accent); border-color: var(--accent); }

/* Breadcrumb back to a section */
.crumbs { font-size: 0.88rem; margin-bottom: -12px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }

/* Logo: "Quid Pro Know", with "Know" highlighted so the pun on "quo" reads clearly */
.brand-name { white-space: nowrap; }
.brand-know { color: var(--accent); font-style: italic; border-bottom: 3px solid var(--accent); padding: 0 1px; line-height: 1; }
