*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:       #0f2137;
  --navy-light: #1a3350;
  --amber:      #f5a623;
  --amber-dark: #d48b10;
  --ink:        #1a1a2e;
  --mist:       #f5f7fa;
  --card-bg:    #ffffff;
  --border:     #e2e8f0;
  --text-muted: #64748b;
  --green:      #22c55e;
  --red:        #ef4444;
  --blue:       #3b82f6;
  --purple:     #8b5cf6;
  --body-text:  #374151;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.07);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --transition: 200ms ease;
}

/* ── Dark mode tokens ───────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --navy:       #0d1b2a;
    --navy-light: #12263a;
    --ink:        #e8eaf0;
    --mist:       #111827;
    --card-bg:    #1e2535;
    --border:     #2d3748;
    --text-muted: #94a3b8;
    --body-text:  #cbd5e1;
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md:  0 4px 16px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.25);
  }
}

/* Manual dark override — wins over media query */
html.dark {
  --navy:       #0d1b2a;
  --navy-light: #12263a;
  --ink:        #e8eaf0;
  --mist:       #111827;
  --card-bg:    #1e2535;
  --border:     #2d3748;
  --text-muted: #94a3b8;
  --body-text:  #cbd5e1;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.25);
}

/* Manual light override — wins over media query */
html.light {
  --navy:       #0f2137;
  --navy-light: #1a3350;
  --ink:        #1a1a2e;
  --mist:       #f5f7fa;
  --card-bg:    #ffffff;
  --border:     #e2e8f0;
  --text-muted: #64748b;
  --body-text:  #374151;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
}
/* ────────────────────────────────────────────────────────────────────────── */

html { scroll-behavior: smooth; color-scheme: light dark; }

body {
  font-family: var(--font);
  background: var(--mist);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

.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;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

.site-header {
  background: var(--navy);
  padding: 1rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #fff;
}

.logo-icon {
  background: var(--amber);
  color: var(--navy);
  font-size: 1.1rem;
  font-weight: 700;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.logo-text strong { font-weight: 700; }

.header-tagline {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.8);
  display: none;
}

@media (min-width: 480px) {
  .header-tagline { display: block; }
}

.theme-toggle {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50px;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem 0.35rem 0.6rem;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.35);
}
.theme-toggle svg { flex-shrink: 0; }

.hero {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-light) 100%);
  padding: 2.5rem 1.25rem 3.5rem;
  text-align: center;
}

.hero-inner {
  max-width: 640px;
  margin: 0 auto;
}

.hero-title {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.hero-title span {
  color: var(--amber);
}

.hero-sub {
  font-size: 1rem;
  color: rgba(255,255,255,0.65);
  margin-bottom: 1.75rem;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border-radius: 50px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.22), 0 0 0 0 var(--amber);
  transition: box-shadow 250ms ease;
  overflow: hidden;
}

.search-wrap:focus-within {
  box-shadow: 0 4px 24px rgba(0,0,0,0.22), 0 0 0 3px var(--amber);
}

.search-icon {
  position: absolute;
  left: 1.1rem;
  color: var(--text-muted);
  display: flex;
  pointer-events: none;
}

.search-input {
  width: 100%;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--ink);
  padding: 0.9rem 3rem 0.9rem 3.2rem;
  background: transparent;
  -webkit-appearance: none;
}

.search-input::placeholder { color: var(--text-muted); }
.search-input::-webkit-search-cancel-button { display: none; }

.search-clear {
  position: absolute;
  right: 0.9rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 0.25rem;
  border-radius: 50%;
  transition: color var(--transition), background var(--transition);
}
.search-clear:hover { color: var(--ink); background: var(--mist); }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.filter-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.85);
  padding: 0.35rem 0.9rem;
  border-radius: 50px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.filter-btn:hover {
  background: rgba(255,255,255,0.22);
  color: #fff;
}

.filter-btn.active {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--navy);
}

.results-bar {
  max-width: 960px;
  margin: 1.5rem auto 0;
  padding: 0 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.terms-grid {
  max-width: 960px;
  margin: 1rem auto 3rem;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 580px) {
  .terms-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 860px) {
  .terms-grid { grid-template-columns: repeat(3, 1fr); }
}

.no-results {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
}

.term-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition), background var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
}

.term-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 1.2rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.card-header:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: -2px;
  border-radius: var(--radius-md);
}

.card-title-wrap { flex: 1; min-width: 0; }

.card-category {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.55rem;
  border-radius: 50px;
  margin-bottom: 0.35rem;
}

.cat-borrowing  { background: #fef3c7; color: #92400e; }
.cat-saving     { background: #dcfce7; color: #166534; }
.cat-credit     { background: #ede9fe; color: #5b21b6; }
.cat-mortgages  { background: #dbeafe; color: #1e40af; }
.cat-budgeting  { background: #fce7f3; color: #9d174d; }
.cat-economics  { background: #f0fdf4; color: #15803d; }
.cat-vehicles   { background: #fef9c3; color: #854d0e; }

/* Slightly richer category pills in dark mode */
html.dark .cat-borrowing, :root:has(html.dark) .cat-borrowing  { background: #451a03; color: #fcd34d; }
html.dark .cat-saving,    :root:has(html.dark) .cat-saving     { background: #052e16; color: #86efac; }
html.dark .cat-credit,    :root:has(html.dark) .cat-credit     { background: #2e1065; color: #c4b5fd; }
html.dark .cat-mortgages, :root:has(html.dark) .cat-mortgages  { background: #172554; color: #93c5fd; }
html.dark .cat-budgeting, :root:has(html.dark) .cat-budgeting  { background: #500724; color: #f9a8d4; }
html.dark .cat-economics, :root:has(html.dark) .cat-economics  { background: #052e16; color: #86efac; }
html.dark .cat-vehicles,  :root:has(html.dark) .cat-vehicles   { background: #422006; color: #fde68a; }

@media (prefers-color-scheme: dark) {
  html:not(.light) .cat-borrowing { background: #451a03; color: #fcd34d; }
  html:not(.light) .cat-saving    { background: #052e16; color: #86efac; }
  html:not(.light) .cat-credit    { background: #2e1065; color: #c4b5fd; }
  html:not(.light) .cat-mortgages { background: #172554; color: #93c5fd; }
  html:not(.light) .cat-budgeting { background: #500724; color: #f9a8d4; }
  html:not(.light) .cat-economics { background: #052e16; color: #86efac; }
  html:not(.light) .cat-vehicles  { background: #422006; color: #fde68a; }
}

.card-term {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.card-short {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  line-height: 1.4;
}

.card-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 280ms ease;
  margin-top: 0.15rem;
}

.term-card.open .card-chevron {
  transform: rotate(180deg);
}

.card-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 300ms ease;
}

.term-card.open .card-body {
  grid-template-rows: 1fr;
}

.card-body-inner {
  overflow: hidden;
}

.card-body-content {
  padding: 0 1.2rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.card-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.3rem;
}

.label-explanation { color: var(--blue); }
.label-example     { color: var(--green); }
.label-mistake     { color: var(--red); }
.label-related     { color: var(--purple); }

.card-section p {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--body-text);
}

.card-section.mistake-section p::before {
  content: "⚠️ ";
}

.related-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.related-chip {
  background: var(--mist);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.related-chip:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.site-footer {
  background: var(--navy);
  color: rgba(255,255,255,0.65);
  padding: 2rem 1.25rem;
  text-align: center;
}

.footer-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.footer-brand {
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.footer-brand strong { font-weight: 700; }

.logo-icon-sm {
  background: var(--amber);
  color: var(--navy);
  font-size: 0.75rem;
  font-weight: 700;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.footer-disclaimer {
  font-size: 0.82rem;
  line-height: 1.6;
  max-width: 480px;
  color: rgba(255,255,255,0.55);
}

.footer-disclaimer strong {
  color: var(--amber);
  font-weight: 600;
}

.footer-copy {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.3);
}

mark {
  background: #fef08a;
  color: #1a1a2e;
  border-radius: 2px;
  padding: 0 1px;
}

html.dark mark,
@media (prefers-color-scheme: dark) { html:not(.light) mark { background: #854d0e; color: #fef3c7; } }

html.dark mark { background: #854d0e; color: #fef3c7; }

[hidden] { display: none !important; }


.term-card--linked {
  cursor: pointer;
}

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.term-card--linked .card-header {
  cursor: pointer;
}

.term-card--linked:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.term-card--linked:hover .card-arrow {
  transform: translateX(3px);
}

.card-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 220ms ease, color 220ms ease;
  margin-top: 0.15rem;
}

.term-card--linked:hover .card-arrow {
  color: var(--amber);
}

.card-teaser {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.45rem;
  line-height: 1.5;
  font-style: italic;
}

.concept-back {
  max-width: 760px;
  margin: 1.5rem auto 0;
  padding: 0 1.25rem;
}

.concept-back a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.concept-back a:hover {
  color: var(--ink);
}

.concept-back svg {
  flex-shrink: 0;
}

.concept-hero {
  max-width: 760px;
  margin: 2rem auto 0;
  padding: 0 1.25rem;
}

.concept-category {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.22rem 0.65rem;
  border-radius: 50px;
  margin-bottom: 0.75rem;
}

.concept-title {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.75rem;
}

.concept-short {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 560px;
}

.concept-body {
  max-width: 760px;
  margin: 2.5rem auto 4rem;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.concept-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition);
}

.concept-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.6rem;
}

.concept-section p {
  font-size: 0.97rem;
  line-height: 1.7;
  color: var(--body-text);
}

.concept-section.mistake-block p::before {
  content: "⚠️ ";
}

.concept-related-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.concept-chip {
  background: var(--mist);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 0.3rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  display: inline-block;
}

.concept-chip:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.example-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

/* Calculator */
.calc-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition);
}

.calc-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 1rem;
  color: var(--amber-dark);
}

.calc-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 480px) {
  .calc-fields { grid-template-columns: 1fr; }
}

.calc-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.calc-field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--mist);
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  -webkit-appearance: none;
}

.calc-field input:focus {
  outline: none;
  border-color: var(--amber);
  background: var(--card-bg);
}

.calc-result {
  background: var(--navy);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}

.calc-result-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.calc-result-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.5);
}

.calc-result-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.calc-result-value.highlight {
  color: var(--amber);
}

.calc-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.85rem;
  line-height: 1.5;
}

/* ── About nav link ─────────────────────────────────────────────────────── */
.header-about {
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  flex-shrink: 0;
  transition: color var(--transition);
}
.header-about:hover {
  color: #fff;
}

/* ── About page layout ──────────────────────────────────────────────────── */
.about-hero {
  max-width: 760px;
  margin: 2rem auto 0;
  padding: 0 1.25rem;
}

.about-body {
  max-width: 760px;
  margin: 2rem auto 4rem;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.about-list {
  list-style: none;
  padding: 0;
  margin: 0.85rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.about-list li {
  font-size: 0.97rem;
  color: var(--body-text);
  line-height: 1.5;
  padding-left: 1rem;
  position: relative;
}

.about-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

.about-email {
  display: inline-block;
  margin-top: 0.85rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--amber);
  text-decoration: none;
  transition: color var(--transition);
}

.about-email:hover {
  color: var(--amber-dark);
}

.about-body .concept-section p + p {
  margin-top: 0.75rem;
}
