/* Components — shared across all pages */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  width: var(--page-wide); margin-inline: auto; min-height: 64px;
  display: flex; align-items: center; gap: var(--sp-4);
}
.brand { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 800; font-size: var(--fs-500); color: var(--text); text-decoration: none; letter-spacing: -.04em; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; color: white; box-shadow: var(--shadow-sm); flex: none; }
.brand .mark svg { width: 18px; height: 18px; }
.nav-main { display: flex; gap: var(--sp-1); margin-inline-start: auto; }
.nav-main a { color: var(--text-muted); text-decoration: none; font-size: var(--fs-300); font-weight: 650; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); transition: color var(--t-fast), background var(--t-fast); }
.nav-main a:hover, .nav-main a[aria-current="page"] { color: var(--text); background: var(--accent-soft); }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer; transition: transform var(--t-fast), color var(--t-fast), border-color var(--t-fast); }
.icon-btn:hover { color: var(--text); border-color: var(--accent); transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

/* Hero */
.hero { position: relative; overflow: hidden; padding-block: var(--sp-12) var(--sp-10); border-bottom: 1px solid var(--border); background: var(--hero-pattern); }
.hero::after { content: ""; position: absolute; inset: auto 0 0; height: 1px; background: linear-gradient(90deg, transparent, var(--accent-line), transparent); }
.hero .page { position: relative; z-index: 1; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(280px, .95fr); gap: var(--sp-10); align-items: start; }
.hero h1 { max-width: 20ch; margin-bottom: var(--sp-4); }
.hero .eyebrow { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-300); font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: var(--sp-4); }
.hero .eyebrow::before { content: ""; width: 20px; height: 2px; background: currentColor; border-radius: 2px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: var(--sp-5); margin-top: var(--sp-6); font-size: var(--fs-300); color: var(--text-muted); }
.hero-stats b { color: var(--text); }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }

/* Cards and glass panels */
.card, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
}
.card { padding: var(--sp-6); }
.card-hover { transition: transform var(--t-med), box-shadow var(--t-med), border-color var(--t-med); }
.card-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--accent-line); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: var(--sp-5); }
.card h3 { margin-top: 0; font-size: var(--fs-500); }
.card p { color: var(--text-muted); font-size: var(--fs-300); }
.pill, .badge { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-300); font-weight: 700; padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); }

/* Calculator panel */
.calc-panel { padding: clamp(var(--sp-5), 3vw, var(--sp-8)); border-radius: var(--r-xl); position: relative; }
.calc-panel::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; border-radius: var(--r-xl) var(--r-xl) 0 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.calc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.calc-head h2 { margin: 0; font-size: var(--fs-600); }
.calc-head p { margin: var(--sp-1) 0 0; color: var(--text-muted); font-size: var(--fs-300); }
.calc-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .9fr); gap: var(--sp-8); align-items: start; }
@media (max-width: 960px) { .calc-body { grid-template-columns: 1fr; gap: var(--sp-6); } }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .field .label { font-size: var(--fs-300); font-weight: 700; color: var(--text); }
.field .hint { font-size: var(--fs-300); color: var(--text-muted); line-height: 1.4; }
.field .err { font-size: var(--fs-300); color: #b42318; min-height: 0; font-weight: 650; }
.field.invalid .err { display: block; }
.field:not(.invalid) .err { display: none; }
input[type="number"], input[type="text"], input[type="date"], select {
  width: 100%; min-height: 44px; padding: var(--sp-2) var(--sp-3);
  font: inherit; font-size: var(--fs-400); color: var(--text);
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:hover, select:hover { border-color: var(--accent); }
input:focus, select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.invalid input { border-color: #b42318; }
.input-money { position: relative; }
.input-money span { position: absolute; left: var(--sp-3); top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.input-money input { padding-left: 1.9rem; font-family: var(--font-num); }
.segmented { display: inline-flex; flex-wrap: wrap; gap: var(--sp-1); padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: inline-block; padding: var(--sp-2) var(--sp-3); border-radius: 7px; font-size: var(--fs-300); font-weight: 700; color: var(--text-muted); cursor: pointer; transition: background var(--t-fast), color var(--t-fast); }
.segmented input:checked + span { background: var(--surface-solid); color: var(--accent); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.check { display: flex; gap: var(--sp-2); align-items: flex-start; font-size: var(--fs-300); font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.slider-row { display: flex; align-items: center; gap: var(--sp-3); }
input[type="range"] { accent-color: var(--accent); width: 100%; }
.slider-value { font-family: var(--font-num); font-weight: 750; min-width: 5ch; text-align: right; }
.calc-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-5); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 42px; padding: var(--sp-2) var(--sp-4); border-radius: var(--r-sm);
  font: inherit; font-size: var(--fs-300); font-weight: 750; cursor: pointer; text-decoration: none;
  border: 1px solid var(--border-strong); background: var(--surface-solid); color: var(--text);
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: var(--accent); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn-primary:hover { color: #fff; filter: brightness(1.08); }
.btn-ghost { background: transparent; }

/* Results */
.results { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); }
.results h3 { margin-top: 0; font-size: var(--fs-500); }
.result-hero { display: flex; flex-direction: column; gap: var(--sp-1); padding-bottom: var(--sp-4); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-4); }
.result-hero .amount { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; letter-spacing: -.05em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--accent); }
.result-hero .sub { font-size: var(--fs-300); color: var(--text-muted); }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.result-item { background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-3); }
.result-item dt { font-size: var(--fs-300); color: var(--text-muted); }
.result-item dd { margin: var(--sp-1) 0 0; font-weight: 800; font-variant-numeric: tabular-nums; font-size: var(--fs-500); }
.result-note { font-size: var(--fs-300); color: var(--text-muted); margin-top: var(--sp-4); }
.chart-box { margin-top: var(--sp-5); }
.chart-box canvas { width: 100%; height: auto; aspect-ratio: 16 / 7; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-2); font-size: var(--fs-300); color: var(--text-muted); }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: var(--sp-1); }

/* Content areas */
.prose { max-width: 76ch; }
.prose h2 { scroll-margin-top: 90px; }
.prose h3 { scroll-margin-top: 90px; }
.prose p, .prose li { color: var(--text-muted); }
.prose strong { color: var(--text); }
.toc { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-6); }
.toc a { font-size: var(--fs-300); font-weight: 650; text-decoration: none; padding: var(--sp-1) var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface); color: var(--text-muted); }
.toc a:hover { color: var(--accent); border-color: var(--accent); }
.notice { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: var(--sp-4); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: var(--fs-300); margin-block: var(--sp-5); }
.notice.warn { border-color: #b42318; background: rgba(180,35,24,.08); }
.notice strong { display: block; margin-bottom: var(--sp-1); }
.quick-answer { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--r-md); padding: var(--sp-4); margin-block: var(--sp-5); font-size: var(--fs-300); }
.quick-answer strong { display: block; margin-bottom: var(--sp-2); color: var(--accent); }
.hub-link { font-size: var(--fs-300); color: var(--text-muted); margin-block: var(--sp-4); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--sp-6); }
.faq details { background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: var(--sp-3); overflow: hidden; }
.faq summary { cursor: pointer; padding: var(--sp-4) var(--sp-5); font-weight: 700; font-size: var(--fs-400); list-style: none; display: flex; justify-content: space-between; gap: var(--sp-4); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.3em; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq .answer { padding: 0 var(--sp-5) var(--sp-4); color: var(--text-muted); font-size: var(--fs-300); }
.breadcrumb { font-size: var(--fs-300); color: var(--text-muted); padding-block: var(--sp-4); }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: var(--sp-2); list-style: none; padding: 0; margin: 0; }
.breadcrumb li + li::before { content: "/"; margin-right: var(--sp-2); color: var(--ink-400); }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.sources { font-size: var(--fs-300); color: var(--text-muted); }
.sources li { margin-bottom: var(--sp-1); }
.related-list { display: grid; gap: var(--sp-3); }
.related-list a { display: block; padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); text-decoration: none; color: var(--text); font-weight: 700; font-size: var(--fs-300); transition: border-color var(--t-fast), transform var(--t-fast); }
.related-list a:hover { border-color: var(--accent); transform: translateX(3px); }
.related-list small { display: block; font-weight: 400; color: var(--text-muted); margin-top: var(--sp-1); }

/* Homepage */
.home-hero { text-align: center; padding-block: var(--sp-16) var(--sp-12); position: relative; overflow: hidden; }
.home-hero::before { content: ""; position: absolute; width: 700px; height: 700px; border-radius: 50%; top: -400px; left: 50%; transform: translateX(-50%); background: radial-gradient(circle, var(--accent-soft), transparent 65%); pointer-events: none; }
.home-hero h1 { max-width: 18ch; margin-inline: auto; }
.home-hero .lead { margin-inline: auto; }
.home-search { max-width: 640px; margin: var(--sp-8) auto 0; position: relative; }
.home-search input { min-height: 56px; padding-inline: var(--sp-5) 8rem; border-radius: var(--r-pill); box-shadow: var(--shadow-md); }
.home-search button { position: absolute; right: 6px; top: 6px; height: 44px; border-radius: var(--r-pill); }
.hub-card { padding: var(--sp-6); text-decoration: none; color: var(--text); display: block; }
.hub-card .icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: var(--sp-4); }
.hub-card .icon svg { width: 22px; height: 22px; }
.hub-card small { color: var(--text-muted); }
.popular-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-3); }
.popular-list a { display: flex; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); font-size: var(--fs-300); font-weight: 700; }
.popular-list a:hover { border-color: var(--accent); }
.popular-list .pill { flex: none; align-self: start; }

/* Search overlay */
.search-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(6, 10, 20, .68); backdrop-filter: blur(6px); display: none; padding: var(--sp-8) var(--sp-4); }
.search-overlay[hidden] { display: none; }
.search-overlay.open { display: block; }
.search-dialog { width: min(640px, 100%); margin: 5vh auto 0; background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: var(--sp-5); }
.search-dialog input { min-height: 50px; }
.search-results { list-style: none; padding: 0; margin: var(--sp-4) 0 0; max-height: 55vh; overflow: auto; }
.search-results li { border-bottom: 1px solid var(--border); }
.search-results a { display: block; padding: var(--sp-3); text-decoration: none; color: var(--text); }
.search-results a:hover, .search-results a:focus { background: var(--accent-soft); }
.search-results small { display: block; color: var(--text-muted); }

/* Keyword index */
.link-grid { list-style: none; padding: 0; margin: var(--sp-5) 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2) var(--sp-5); }
.link-grid li { break-inside: avoid; font-size: var(--fs-300); padding-block: 2px; }
.link-grid a { text-decoration: none; color: var(--text); }
.link-grid a:hover { color: var(--accent); text-decoration: underline; }
@media (max-width: 900px) { .link-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .link-grid { grid-template-columns: 1fr; } }

/* Footer */
.site-footer { margin-top: var(--sp-20); padding-block: var(--sp-12) var(--sp-8); border-top: 1px solid var(--border); background: var(--surface-2); }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: var(--sp-8); }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.site-footer h3 { font-size: var(--fs-300); text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: var(--sp-3); }
.site-footer ul { list-style: none; padding: 0; }
.site-footer li + li { margin-top: var(--sp-2); }
.site-footer a { color: var(--text-muted); text-decoration: none; font-size: var(--fs-300); }
.site-footer a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--border); margin-top: var(--sp-10); padding-top: var(--sp-5); font-size: var(--fs-300); color: var(--text-muted); display: flex; flex-wrap: wrap; gap: var(--sp-4); justify-content: space-between; }
@media (max-width: 640px) {
  .nav-main { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; background: var(--surface-solid); padding: var(--sp-4); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-md); }
  .nav-main.open { display: flex; }
  .menu-btn { display: inline-grid; }
  .field-grid, .field-grid.three { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
}

/* Shared calculator framework — Basic / Advanced / Compare, tooltips, scenarios */
.calc-framework { display: block; }
.calc-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: var(--sp-3); margin-bottom: var(--sp-4); padding-bottom: var(--sp-4); border-bottom: 1px solid var(--border); }
.calc-toolbar .mode-tabs { display: inline-flex; flex-wrap: wrap; gap: var(--sp-1); padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.calc-toolbar .mode-tab { min-height: 36px; padding: var(--sp-1) var(--sp-3); border: 0; border-radius: 7px; background: transparent; color: var(--text-muted); font: inherit; font-size: var(--fs-300); font-weight: 750; cursor: pointer; }
.calc-toolbar .mode-tab[aria-selected="true"] { background: var(--surface-solid); color: var(--accent); box-shadow: var(--shadow-sm); }
.calc-toolbar .year-control { display: flex; flex-direction: column; gap: 2px; margin-inline-start: auto; min-width: 150px; }
.calc-toolbar .year-control label { font-size: var(--fs-300); font-weight: 700; color: var(--text-muted); }
.calc-toolbar .year-control select { min-height: 36px; font-size: var(--fs-300); }
.calc-panel-mode[hidden] { display: none !important; }
.calc-advanced summary { cursor: pointer; font-size: var(--fs-300); font-weight: 750; color: var(--accent); padding: var(--sp-2) 0; }
.calc-advanced > div { padding-top: var(--sp-3); }
.tip-btn { display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; margin-inline-start: var(--sp-1); border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface-solid); color: var(--text-muted); font-size: 11px; font-weight: 800; line-height: 1; cursor: help; vertical-align: middle; }
.tip-btn:hover, .tip-btn:focus-visible { color: var(--accent); border-color: var(--accent); }
.tip-pop { position: absolute; z-index: 50; max-width: 260px; padding: var(--sp-3); background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: var(--r-sm); box-shadow: var(--shadow-md); font-size: var(--fs-300); font-weight: 500; color: var(--text); line-height: 1.45; }
.tip-pop[hidden] { display: none; }
.calc-rate-notice { margin-block: var(--sp-3); font-size: var(--fs-300); }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-3); }
.scenario-card { background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-4); }
.scenario-card h4 { margin: 0 0 var(--sp-2); font-size: var(--fs-400); }
.scenario-card p { font-size: var(--fs-300); color: var(--text-muted); }
.scenario-card .scenario-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }
.scenario-card .btn { min-height: 34px; padding: var(--sp-1) var(--sp-3); }
.empty-scenarios { font-size: var(--fs-300); color: var(--text-muted); }
@media print { .calc-toolbar { display: none; } }
