/* ============================================================
   Finance Calculator X — Design System
   Calm, analytical, trustworthy. Light + dark.
   ============================================================ */

/* ---------- Fonts (self-hosted) ---------- */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/fraunces-latin-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --font-ui: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #F5F7F6;
  --surface: #FFFFFF;
  --surface-2: #EDF1EF;
  --surface-3: #E4EAE7;
  --ink: #182420;
  --ink-2: #46554E;
  --ink-3: #64726B;
  --line: #DCE3DF;
  --line-strong: #C4CEC9;

  --brand: #0B6B57;
  --brand-strong: #095A49;
  --brand-ink: #0A5245;
  --brand-soft: #E1EFEA;
  --brand-softer: #EDF5F2;
  --gold: #9A6A14;
  --gold-soft: #F5EBD8;
  --danger: #AF3B31;
  --danger-soft: #F9E9E7;
  --ok: #1E7A4C;

  --c1: #0E7A63;  /* chart: teal */
  --c2: #C2903A;  /* chart: gold */
  --c3: #4C6E9C;  /* chart: slate blue */
  --c4: #A85468;  /* chart: muted rose */
  --c5: #7B8A82;  /* chart: sage grey */

  --shadow-1: 0 1px 2px rgba(24, 36, 32, .05), 0 1px 6px rgba(24, 36, 32, .04);
  --shadow-2: 0 2px 6px rgba(24, 36, 32, .06), 0 10px 28px rgba(24, 36, 32, .08);
  --shadow-3: 0 6px 16px rgba(24, 36, 32, .1), 0 24px 60px rgba(24, 36, 32, .14);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --content-w: 1120px;
  --prose-w: 760px;

  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4.5px var(--brand);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0E1513;
  --surface: #171F1C;
  --surface-2: #1E2823;
  --surface-3: #26312C;
  --ink: #E6ECE9;
  --ink-2: #AEBCB5;
  --ink-3: #8C9A93;
  --line: #2A3530;
  --line-strong: #3B4842;

  --brand: #4CB39A;
  --brand-strong: #67C6AE;
  --brand-ink: #8ED8C4;
  --brand-soft: #17332C;
  --brand-softer: #142822;
  --gold: #D9A94F;
  --gold-soft: #322916;
  --danger: #E08379;
  --danger-soft: #3A211E;
  --ok: #5FBF8F;

  --c1: #3FAE93;
  --c2: #D3A452;
  --c3: #7C9CC9;
  --c4: #C97E93;
  --c5: #8CA096;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 6px rgba(0, 0, 0, .25);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .35);
  --shadow-3: 0 6px 16px rgba(0, 0, 0, .4), 0 24px 60px rgba(0, 0, 0, .5);

  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4.5px var(--brand);
  color-scheme: dark;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--brand-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2.5px; }
a:hover { color: var(--brand-strong); }
h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .55em; color: var(--ink); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-family: var(--font-display); font-size: clamp(1.85rem, 1.3rem + 2.2vw, 2.7rem); }
h2 { font-family: var(--font-display); font-size: clamp(1.4rem, 1.2rem + .8vw, 1.75rem); margin-top: 1.9em; }
h3 { font-size: 1.16rem; margin-top: 1.6em; }
h4 { font-size: 1rem; margin-top: 1.4em; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
code { font-family: var(--font-mono); font-size: .92em; background: var(--surface-2); border-radius: 5px; padding: .12em .35em; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px; }
::selection { background: var(--brand-soft); }
[hidden] { display: none !important; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--brand); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.wrap { max-width: var(--content-w); margin: 0 auto; padding: 0 20px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: .9rem; min-height: 62px; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.04rem; letter-spacing: -.01em; white-space: nowrap; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.brand .x { color: var(--brand); }
.main-nav { display: flex; gap: .15rem; margin-left: .6rem; }
.main-nav a {
  text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: .95rem;
  padding: .42rem .7rem; border-radius: 8px;
}
.main-nav a:hover { color: var(--ink); background: var(--surface-2); }
.main-nav a[aria-current="true"] { color: var(--brand-ink); background: var(--brand-softer); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: .45rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  min-height: 38px; min-width: 38px; padding: 0 .55rem; border-radius: 10px;
  font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; flex: none; }
.search-btn { min-width: 0; }
.search-btn .kbd { font-size: .72rem; color: var(--ink-3); border: 1px solid var(--line); padding: .05rem .3rem; border-radius: 5px; background: var(--surface-2); }
.nav-toggle { display: none; }

@media (max-width: 880px) {
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    flex-direction: column; padding: .6rem 1rem 1rem; box-shadow: var(--shadow-2);
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: .7rem .7rem; font-size: 1rem; }
  .nav-toggle { display: inline-flex; }
  .search-btn .label, .search-btn .kbd { display: none; }
}

/* menus (currency / theme) */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; z-index: 80;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-2); padding: .4rem; display: none;
}
.menu.open { display: block; }
.menu .menu-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); padding: .45rem .6rem .25rem; font-weight: 600; }
.menu button {
  display: flex; width: 100%; align-items: center; gap: .55rem; text-align: left;
  background: none; border: 0; font: inherit; font-size: .92rem; color: var(--ink);
  padding: .5rem .6rem; border-radius: 8px; cursor: pointer;
}
.menu button:hover { background: var(--surface-2); }
.menu button[aria-checked="true"] { background: var(--brand-softer); color: var(--brand-ink); font-weight: 600; }
.menu button .sym { width: 2.1em; flex: none; color: var(--ink-3); font-weight: 600; }
.menu button[aria-checked="true"] .sym { color: inherit; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 4.5rem; border-top: 1px solid var(--line); background: var(--surface); }
.footer-grid { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: 2rem; padding: 2.8rem 0 2rem; }
.footer-grid h2 { font-family: var(--font-ui); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 .8rem; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.footer-grid a { color: var(--ink-2); text-decoration: none; font-size: .93rem; }
.footer-grid a:hover { color: var(--brand-ink); text-decoration: underline; }
.footer-about p { color: var(--ink-2); font-size: .93rem; max-width: 34ch; }
.footer-legal { border-top: 1px solid var(--line); padding: 1.2rem 0 1.6rem; font-size: .84rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; align-items: center; }
.footer-legal p { margin: 0; }
@media (max-width: 880px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none;
  border-radius: 10px; padding: .62rem 1.15rem; border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }
[data-theme="dark"] .btn-primary { color: #08221C; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn-soft { background: var(--brand-softer); color: var(--brand-ink); }
.btn-soft:hover { background: var(--brand-soft); }
.btn-sm { font-size: .85rem; padding: .42rem .8rem; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.tool-card {
  display: flex; flex-direction: column; gap: .35rem; padding: 1.1rem 1.15rem 1.05rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow-1);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.tool-card:hover { border-color: var(--brand); box-shadow: var(--shadow-2); transform: translateY(-2px); color: var(--ink); }
.tool-card .t { font-weight: 600; font-size: 1rem; letter-spacing: -.01em; display: flex; align-items: center; gap: .5rem; }
.tool-card .d { color: var(--ink-2); font-size: .875rem; line-height: 1.5; }
.tool-card .cat { margin-top: auto; padding-top: .5rem; font-size: .75rem; font-weight: 600; color: var(--brand-ink); text-transform: uppercase; letter-spacing: .05em; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  background: var(--brand-softer); color: var(--brand-ink);
  border-radius: 99px; padding: .18rem .6rem;
}
.badge-gold { background: var(--gold-soft); color: var(--gold); }

/* ---------- Section headers ---------- */
.section { margin-top: 3.6rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.15rem; }
.section-head h2 { margin: 0; }
.section-head .more { font-size: .92rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.section-head .more:hover { text-decoration: underline; }
.kicker { font-size: .78rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--brand-ink); margin-bottom: .5rem; }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { font-size: .84rem; color: var(--ink-3); margin: 1.3rem 0 .9rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: 0; }
.breadcrumbs li { display: flex; gap: .35rem; align-items: center; }
.breadcrumbs li + li::before { content: "/"; color: var(--line-strong); }
.breadcrumbs a { color: var(--ink-3); text-decoration: none; padding: .35rem .15rem; margin: -.35rem -.15rem; }
.breadcrumbs a:hover { color: var(--brand-ink); text-decoration: underline; }
.breadcrumbs [aria-current] { color: var(--ink-2); font-weight: 500; }

/* ---------- Page hero ---------- */
.page-head { max-width: var(--prose-w); margin-bottom: 1.6rem; }
.page-head .lede { font-size: 1.08rem; color: var(--ink-2); margin: 0; }
.review-line { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; align-items: center; margin-top: .85rem; font-size: .8rem; color: var(--ink-3); }
.review-line a { color: inherit; display: inline-block; padding: .4rem .1rem; margin: -.4rem -.1rem; }
/* enlarged tap targets for small in-article links (WCAG 2.2 target size) */
.calc-article nav a, .prose .kicker a, .footer-legal a { display: inline-block; padding: .35rem .1rem; margin: -.35rem -.1rem; }

/* ============================================================
   CALCULATOR LAYOUT
   ============================================================ */
.calc-layout { display: grid; grid-template-columns: minmax(360px, 5fr) 7fr; gap: 1.4rem; align-items: start; margin: 1.4rem 0 .4rem; }
@media (max-width: 980px) { .calc-layout { grid-template-columns: 1fr; } }

.calc-card { padding: 1.4rem 1.4rem 1.5rem; border-radius: var(--r-lg); position: sticky; top: 78px; }
@media (max-width: 980px) { .calc-card { position: static; } }
.calc-card h2 { font-family: var(--font-ui); font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 1.1rem; }
.calc-form { display: grid; gap: 1.05rem; }

/* fields */
.field { display: grid; gap: .38rem; }
.field-label { display: flex; align-items: center; gap: .4rem; font-size: .875rem; font-weight: 600; color: var(--ink-2); }
.field-label .tip {
  border: 0; background: var(--surface-2); color: var(--ink-3); border-radius: 50%;
  width: 17px; height: 17px; font-size: .68rem; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; cursor: help; padding: 0;
}
.field-hint { font-size: .78rem; color: var(--ink-3); margin: 0; }
.field-error { font-size: .8rem; color: var(--danger); margin: 0; font-weight: 500; }
.control { position: relative; display: flex; align-items: stretch; }
.control input[type="text"], .control input[type="number"], .control select {
  width: 100%; font: inherit; font-size: 1.02rem; font-weight: 500; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: .58rem .8rem; min-height: 46px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.control select { cursor: pointer; appearance: none; -webkit-appearance: none; padding-right: 2.1rem; }
.control .select-caret { position: absolute; right: .8rem; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-3); }
.control input:hover, .control select:hover { border-color: var(--ink-3); }
.control input:focus-visible, .control select:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--brand) 22%, transparent); outline: none; }
.field.invalid .control input { border-color: var(--danger); }
.field.invalid .control input:focus-visible { box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--danger) 20%, transparent); }
.control .affix {
  display: flex; align-items: center; padding: 0 .8rem; font-size: .92rem; font-weight: 600; color: var(--ink-3);
  background: var(--surface-2); border: 1px solid var(--line-strong); white-space: nowrap;
}
.control .affix.pre { border-right: 0; border-radius: 10px 0 0 10px; }
.control .affix.post { border-left: 0; border-radius: 0 10px 10px 0; }
.control .affix.pre + input { border-radius: 0 10px 10px 0; }
.control input.has-post { border-radius: 10px 0 0 10px; }
.control input.has-pre-post { border-radius: 0; }

/* slider under a field */
.field input[type="range"] {
  width: 100%; margin: .15rem 0 0; accent-color: var(--brand); height: 22px; cursor: pointer;
  background: transparent;
}

/* segmented control */
.segment { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.segment button {
  font: inherit; font-size: .86rem; font-weight: 600; color: var(--ink-2); background: transparent;
  border: 0; border-radius: 7px; padding: .42rem .5rem; cursor: pointer; min-height: 36px;
}
.segment button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* toggle row */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-strong); transition: background .15s ease; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-1); transition: transform .15s ease; border: 1px solid var(--line); }
.switch input:checked ~ .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked ~ .thumb { transform: translateX(18px); }
.switch input:focus-visible ~ .track { box-shadow: var(--focus-ring); }

/* dynamic rows (debt list) */
.row-list { display: grid; gap: .7rem; }
.row-item { border: 1px solid var(--line); border-radius: var(--r-md); padding: .85rem .9rem; display: grid; gap: .7rem; background: var(--surface); }
.row-item .row-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.row-item .row-head input { font: inherit; font-weight: 600; border: 0; background: transparent; color: var(--ink); width: 100%; padding: .15rem .3rem; border-radius: 6px; }
.row-item .row-head input:hover { background: var(--surface-2); }
.row-item .row-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
@media (max-width: 560px) { .row-item .row-fields { grid-template-columns: 1fr; } }
.row-remove { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: .8rem; font-weight: 600; padding: .25rem .45rem; border-radius: 6px; flex: none; }
.row-remove:hover { color: var(--danger); background: var(--danger-soft); }

.calc-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .4rem; }

/* ---------- Results ---------- */
.results { display: grid; gap: 1.4rem; min-width: 0; }
.result-hero { padding: 1.5rem 1.5rem 1.35rem; border-radius: var(--r-lg); background: linear-gradient(160deg, var(--brand-softer), var(--surface) 70%); border: 1px solid var(--line); }
.result-hero .rh-label { font-size: .85rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
.result-hero .rh-value { font-family: var(--font-display); font-size: clamp(2rem, 1.5rem + 2.4vw, 3rem); font-weight: 600; letter-spacing: -.02em; color: var(--brand-ink); line-height: 1.1; margin: .2rem 0 .1rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result-hero .rh-sub { color: var(--ink-2); font-size: .92rem; margin: 0; }
.result-invalid { border-color: var(--danger); background: var(--danger-soft); border-radius: var(--r-md); padding: .9rem 1.1rem; color: var(--danger); font-weight: 500; font-size: .93rem; border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: .85rem .95rem; min-width: 0; }
.metric .m-label { font-size: .78rem; color: var(--ink-3); font-weight: 600; }
.metric .m-value { font-size: 1.18rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: .1rem; color: var(--ink); overflow-wrap: anywhere; }
.metric .m-hint { font-size: .75rem; color: var(--ink-3); margin-top: .1rem; }

.explain-box { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: var(--r-md); padding: 1rem 1.2rem; color: var(--ink-2); font-size: .95rem; }
.explain-box p { margin: 0 0 .6em; } .explain-box p:last-child { margin: 0; }
.explain-box strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Chart ---------- */
.chart-card { padding: 1.2rem 1.3rem 1.1rem; }
.chart-card h2, .table-card h2, .scenario-card > h2 { font-family: var(--font-ui); font-size: 1.02rem; margin: 0 0 .9rem; letter-spacing: -.01em; }
.chart-box { position: relative; }
.chart-box svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin-top: .8rem; font-size: .83rem; color: var(--ink-2); }
.chart-legend .li { display: inline-flex; align-items: center; gap: .45rem; }
.chart-legend .sw { width: 11px; height: 11px; border-radius: 3.5px; flex: none; }
.chart-tip {
  position: fixed; z-index: 90; pointer-events: none; display: none;
  background: var(--ink); color: var(--bg); font-size: .8rem; line-height: 1.45;
  border-radius: 8px; padding: .5rem .7rem; box-shadow: var(--shadow-2); max-width: 260px;
}
.chart-tip .tt { font-weight: 700; margin-bottom: .15rem; }
.chart-tip .tr { display: flex; justify-content: space-between; gap: .9rem; font-variant-numeric: tabular-nums; }
.chart-note { font-size: .8rem; color: var(--ink-3); margin: .6rem 0 0; }

/* ---------- Tables ---------- */
.table-card { padding: 1.2rem 1.3rem 1.3rem; }
.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .9rem; }
.table-tools .spacer { flex: 1; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); max-height: 480px; overflow-y: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .875rem; min-width: 520px; }
table.data th, table.data td { padding: .55rem .85rem; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--ink-2); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; z-index: 2; }
table.data tbody tr { border-top: 1px solid var(--line); }
table.data tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
table.data tbody tr.year-row { background: var(--brand-softer); font-weight: 600; }
table.data tfoot td { border-top: 2px solid var(--line-strong); font-weight: 700; background: var(--surface-2); }

/* ---------- Scenario compare ---------- */
.scenario-card { padding: 1.2rem 1.3rem 1.3rem; }
.scenario-intro { font-size: .9rem; color: var(--ink-2); margin: 0 0 .9rem; }
.scenario-slots { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-bottom: 1rem; }
@media (max-width: 560px) { .scenario-slots { grid-template-columns: 1fr; } }
.scenario-slot { border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); padding: .85rem .95rem; }
.scenario-slot.filled { border-style: solid; border-color: var(--brand); background: var(--brand-softer); }
.scenario-slot .s-name { font-weight: 700; font-size: .9rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.scenario-slot .s-desc { font-size: .8rem; color: var(--ink-2); margin: .25rem 0 .6rem; min-height: 1.1em; overflow-wrap: anywhere; }
.scenario-slot .s-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
table.compare { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.compare th, table.compare td { padding: .55rem .7rem; text-align: right; font-variant-numeric: tabular-nums; border-top: 1px solid var(--line); }
table.compare th:first-child, table.compare td:first-child { text-align: left; font-weight: 500; color: var(--ink-2); }
table.compare thead th { border-top: 0; color: var(--ink-3); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
table.compare .diff-pos { color: var(--ok); font-weight: 600; }
table.compare .diff-neg { color: var(--danger); font-weight: 600; }

/* ---------- Article / prose ---------- */
.prose { max-width: var(--prose-w); }
.prose > * { max-width: var(--prose-w); }
.prose ul, .prose ol { padding-left: 1.35rem; margin: 0 0 1.1em; }
.prose li { margin-bottom: .4em; }
.prose li::marker { color: var(--brand); }
.prose table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 0 0 1.4em; }
.prose table th, .prose table td { border: 1px solid var(--line); padding: .5rem .75rem; text-align: left; font-variant-numeric: tabular-nums; }
.prose table thead th { background: var(--surface-2); font-weight: 600; }
.prose .table-scroll { overflow-x: auto; margin: 0 0 1.4em; }
.prose .table-scroll table { margin: 0; min-width: 480px; }
.prose blockquote { margin: 0 0 1.2em; border-left: 3px solid var(--brand); background: var(--brand-softer); border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: .8rem 1.1rem; color: var(--ink-2); }
.prose blockquote p:last-child { margin: 0; }

.formula-block {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 1rem 1.2rem; margin: 0 0 1.3em; overflow-x: auto;
}
.formula-block .fx { font-family: var(--font-mono); font-size: 1.02rem; color: var(--brand-ink); font-weight: 600; white-space: nowrap; }
.formula-block .fx sub, .formula-block .fx sup { font-size: .68em; }
.formula-vars { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; gap: .3rem; font-size: .88rem; }
.formula-vars li { display: flex; gap: .7rem; }
.formula-vars code { flex: none; min-width: 2.6em; text-align: center; }

.callout { border-radius: var(--r-md); padding: 1rem 1.2rem; margin: 0 0 1.3em; border: 1px solid var(--line); background: var(--surface); font-size: .94rem; }
.callout.note { border-left: 3px solid var(--c3); }
.callout.warn { border-left: 3px solid var(--gold); background: color-mix(in srgb, var(--gold-soft) 45%, var(--surface)); }
.callout .c-title { font-weight: 700; display: block; margin-bottom: .3rem; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }

.example-block { border: 1px solid var(--line); border-radius: var(--r-md); margin: 0 0 1.3em; overflow: hidden; }
.example-block .ex-head { background: var(--surface-2); padding: .6rem 1.1rem; font-weight: 700; font-size: .9rem; }
.example-block .ex-body { padding: 1rem 1.2rem; background: var(--surface); }
.example-block .ex-body p:last-child { margin-bottom: 0; }

/* article section spacing on calculator pages */
.calc-article { margin-top: 3rem; }
.calc-article section { margin-bottom: 2.4rem; scroll-margin-top: 80px; }

/* FAQ */
.faq details { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); margin-bottom: .6rem; overflow: hidden; }
.faq summary { cursor: pointer; font-weight: 600; padding: .85rem 1.1rem; list-style: none; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.25rem; color: var(--ink-3); font-weight: 500; line-height: 1; transition: transform .15s ease; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq .faq-a { padding: 0 1.1rem 1rem; color: var(--ink-2); font-size: .95rem; }
.faq .faq-a p:last-child { margin-bottom: 0; }

/* Related */
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
@media (max-width: 880px) { .related-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .related-grid { grid-template-columns: 1fr; } }

/* ---------- Homepage ---------- */
.hero { padding: 3.6rem 0 1rem; text-align: center; }
.hero h1 { font-size: clamp(2.1rem, 1.4rem + 3.4vw, 3.4rem); max-width: 21ch; margin: 0 auto .6rem; }
.hero .sub { font-size: 1.12rem; color: var(--ink-2); max-width: 56ch; margin: 0 auto 1.7rem; }
.hero-search { max-width: 620px; margin: 0 auto; position: relative; }
.hero-search input {
  width: 100%; font: inherit; font-size: 1.05rem; padding: .95rem 1.15rem .95rem 3rem;
  border-radius: 14px; border: 1.5px solid var(--line-strong); background: var(--surface);
  color: var(--ink); box-shadow: var(--shadow-1);
}
.hero-search input:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 20%, transparent); outline: none; }
.hero-search .s-icon { position: absolute; left: 1.05rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 19px; height: 19px; }
.hero-chips { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: center; margin-top: 1rem; }
.hero-chips a { font-size: .84rem; font-weight: 500; color: var(--ink-2); text-decoration: none; background: var(--surface); border: 1px solid var(--line); padding: .32rem .8rem; border-radius: 99px; }
.hero-chips a:hover { border-color: var(--brand); color: var(--brand-ink); }

.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 70;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-3); max-height: 420px; overflow-y: auto; padding: .4rem; text-align: left;
}
.search-results a { display: block; padding: .6rem .8rem; border-radius: 8px; text-decoration: none; color: var(--ink); }
.search-results a .st { font-weight: 600; font-size: .95rem; }
.search-results a .sd { font-size: .8rem; color: var(--ink-3); }
.search-results a:hover, .search-results a.active { background: var(--brand-softer); }
.search-results .none { padding: .8rem; color: var(--ink-3); font-size: .9rem; }

.cat-card { display: flex; flex-direction: column; gap: .3rem; padding: 1.25rem 1.25rem 1.15rem; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.cat-card:hover { border-color: var(--brand); box-shadow: var(--shadow-2); transform: translateY(-2px); color: var(--ink); }
.cat-card .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-softer); color: var(--brand-ink); display: flex; align-items: center; justify-content: center; margin-bottom: .45rem; }
.cat-card .ic svg { width: 20px; height: 20px; }
.cat-card .t { font-weight: 700; font-size: 1.04rem; letter-spacing: -.01em; }
.cat-card .d { color: var(--ink-2); font-size: .875rem; }
.cat-card .n { margin-top: .35rem; font-size: .78rem; font-weight: 600; color: var(--brand-ink); }

.task-card { display: flex; align-items: center; gap: .8rem; padding: .95rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); text-decoration: none; color: var(--ink); font-weight: 600; font-size: .95rem; transition: border-color .15s ease, transform .15s ease; }
.task-card:hover { border-color: var(--brand); transform: translateY(-2px); color: var(--brand-ink); }
.task-card .ar { margin-left: auto; color: var(--ink-3); }

.trust-band { margin-top: 3.6rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 2rem 2.2rem; display: grid; grid-template-columns: 1.2fr 1fr; gap: 2rem; align-items: center; }
@media (max-width: 880px) { .trust-band { grid-template-columns: 1fr; padding: 1.6rem 1.4rem; } }
.trust-band h2 { margin-top: 0; }
.trust-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.trust-list li { display: flex; gap: .65rem; align-items: flex-start; font-size: .95rem; color: var(--ink-2); }
.trust-list .ck { flex: none; width: 21px; height: 21px; border-radius: 50%; background: var(--brand-softer); color: var(--brand-ink); display: inline-flex; align-items: center; justify-content: center; margin-top: .1rem; }
.trust-list .ck svg { width: 12px; height: 12px; }

.guide-card { display: flex; flex-direction: column; gap: .3rem; padding: 1.15rem 1.2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-1); transition: border-color .15s ease, transform .15s ease; }
.guide-card:hover { border-color: var(--brand); transform: translateY(-2px); color: var(--ink); }
.guide-card .k { font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--gold); }
.guide-card .t { font-weight: 650; font-size: 1.02rem; line-height: 1.35; }
.guide-card .d { color: var(--ink-2); font-size: .875rem; }

/* ---------- Category page ---------- */
.cat-intro { max-width: var(--prose-w); }

/* ---------- Utility ---------- */
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.mt-0 { margin-top: 0; }
.center { text-align: center; }
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--bg); font-size: .9rem; font-weight: 500;
  border-radius: 10px; padding: .65rem 1.1rem; box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 120;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Print ---------- */
@media print {
  .site-header, .site-footer, .calc-actions, .table-tools, .scenario-card, .breadcrumbs,
  .related-grid, .faq, .hero-chips, .btn, .chart-note, #related, #faq { display: none !important; }
  body { background: #fff; color: #111; }
  .calc-layout { grid-template-columns: 1fr; gap: 1rem; }
  .calc-card { position: static; box-shadow: none; }
  .card, .result-hero, .metric, .table-wrap { box-shadow: none; border-color: #ccc; }
  .print-header { display: block !important; border-bottom: 2px solid #333; margin-bottom: 1rem; padding-bottom: .6rem; }
  .table-wrap { max-height: none; overflow: visible; }
  .calc-article { display: none; }
  a { color: #111; text-decoration: none; }
}
.print-header { display: none; }
.print-header .ph-brand { font-weight: 700; font-size: 1.1rem; }
.print-header .ph-meta { font-size: .8rem; color: #555; }
