@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500;600&family=Space+Mono:wght@400;700&display=swap');

/* ── Design tokens ── */
:root {
  --bg: #F8F7F4;
  --bg-card: #EDEAE4;
  --bg-input: #FFFFFF;
  --bg-result: #11111A;
  --text: #11111A;
  --text-muted: #6A6778;
  --accent: #E8490F;
  --accent-hover: #C83C0A;
  --border: #DDD9D1;
  --white: #FFFFFF;
  --green: #15803D;
  --red: #B91C1C;
  --font-display: 'DM Serif Display', serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.06);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Layout ── */
.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.container--narrow { max-width: 720px; margin: 0 auto; padding: 0 24px; }

/* ── Header / Nav ── */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.site-header .inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.logo {
  font-family: var(--font-mono);
  font-size: 15px; font-weight: 700;
  letter-spacing: -.02em;
  display: flex; align-items: center; gap: 8px;
}
.logo span { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  padding: 6px 10px; border-radius: 6px;
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--text); background: var(--bg-card); }
.nav a.active { color: var(--text); }
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 6px; }
.nav-toggle span { display: block; width: 20px; height: 2px; background: var(--text); margin: 4px 0; transition: .2s; }

/* ── Hero ── */
.hero {
  padding: 64px 0 48px;
  text-align: center;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -.02em;
  margin-bottom: 16px;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p {
  color: var(--text-muted); font-size: 17px;
  max-width: 480px; margin: 0 auto 32px;
}

/* ── Calculator Hub Tabs ── */
.calc-tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  margin-bottom: 32px;
}
.calc-tabs button {
  font-family: var(--font-body);
  font-size: 13px; font-weight: 500;
  padding: 8px 16px; border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--white); color: var(--text-muted);
  cursor: pointer; transition: all .15s;
}
.calc-tabs button:hover { border-color: var(--accent); color: var(--accent); }
.calc-tabs button.active {
  background: var(--accent); border-color: var(--accent);
  color: var(--white);
}

/* ── Calculator Card ── */
.calc-panel { display: none; }
.calc-panel.active { display: block; }

.calc-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow);
  max-width: 640px; margin: 0 auto;
}
.calc-card h2 {
  font-family: var(--font-display);
  font-size: 1.5rem; margin-bottom: 8px;
}
.calc-card .subtitle {
  color: var(--text-muted); font-size: 14px; margin-bottom: 28px;
}

/* ── Inputs ── */
.field-row { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.field { flex: 1; min-width: 120px; }
.field label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px;
  font-family: var(--font-mono); font-size: 15px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius); outline: none;
  color: var(--text); transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
.field input::placeholder { color: var(--text-muted); opacity: .5; }

.connector {
  display: flex; align-items: flex-end; padding-bottom: 13px;
  font-size: 13px; color: var(--text-muted); font-weight: 500;
  flex-shrink: 0;
}

/* ── Calc Button ── */
.btn-calc {
  width: 100%; padding: 14px;
  background: var(--accent); color: var(--white);
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
  border: none; border-radius: var(--radius); cursor: pointer;
  transition: background .15s, transform .1s;
  margin-top: 4px;
}
.btn-calc:hover { background: var(--accent-hover); }
.btn-calc:active { transform: scale(.99); }

/* ── Result Box ── */
.result-box {
  margin-top: 20px; padding: 20px 24px;
  background: var(--bg-result); border-radius: var(--radius);
  display: none;
}
.result-box.show { display: block; }
.result-box .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #888; margin-bottom: 4px; }
.result-box .value {
  font-family: var(--font-mono); font-size: 2rem; font-weight: 700; color: var(--white);
}
.result-box .value.positive { color: #4ADE80; }
.result-box .value.negative { color: #F87171; }
.result-box .explanation { font-size: 13px; color: #aaa; margin-top: 6px; }

/* ── Info Section ── */
.info-pages {
  padding: 64px 0;
}
.info-pages h2 {
  font-family: var(--font-display);
  font-size: 1.75rem; margin-bottom: 8px;
}
.info-pages .sub { color: var(--text-muted); font-size: 15px; margin-bottom: 32px; }
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.info-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px;
  transition: border-color .2s, box-shadow .2s;
  display: block;
}
.info-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.info-card .icon { font-size: 24px; margin-bottom: 12px; }
.info-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.info-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ── Related Calcs ── */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 24px;
}
.related-card {
  display: block;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 20px;
  font-size: 14px; font-weight: 500;
  transition: border-color .15s;
}
.related-card:hover { border-color: var(--accent); color: var(--accent); }
.related-card .arr { float: right; color: var(--text-muted); }

/* ── Page Content ── */
.page-hero {
  padding: 48px 0 32px;
}
.page-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  line-height: 1.15; margin-bottom: 12px;
}
.page-hero p { color: var(--text-muted); font-size: 16px; max-width: 560px; }

/* ── Prose ── */
.prose { padding: 40px 0; }
.prose h2 {
  font-family: var(--font-display);
  font-size: 1.4rem; margin: 36px 0 12px;
}
.prose h2:first-child { margin-top: 0; }
.prose p { color: #333; margin-bottom: 14px; font-size: 15px; }
.prose ul { padding-left: 20px; margin-bottom: 14px; }
.prose li { font-size: 15px; color: #333; margin-bottom: 6px; }
.prose .formula {
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 14px 18px; margin: 20px 0;
  font-family: var(--font-mono); font-size: 14px;
}

/* ── FAQ ── */
.faq { padding: 40px 0; }
.faq h2 { font-family: var(--font-display); font-size: 1.5rem; margin-bottom: 20px; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item summary {
  padding: 16px 0;
  font-size: 15px; font-weight: 500;
  cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; align-items: center;
}
.faq-item summary::after {
  content: '+'; font-size: 18px; color: var(--text-muted);
  transition: transform .2s;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { padding: 0 0 16px; font-size: 14px; color: var(--text-muted); line-height: 1.7; }

/* ── Stat ── */
.stat-row { display: flex; gap: 24px; flex-wrap: wrap; margin: 32px 0; }
.stat-box {
  flex: 1; min-width: 160px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 24px;
}
.stat-box .val { font-family: var(--font-mono); font-size: 1.75rem; font-weight: 700; }
.stat-box .val.up { color: var(--green); }
.stat-box .val.down { color: var(--red); }
.stat-box .key { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-top: 4px; }

/* ── Historical table ── */
.hist-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 20px; }
.hist-table th { text-align: left; padding: 10px 12px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.hist-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.hist-table tr:last-child td { border-bottom: none; }
.hist-table .mono { font-family: var(--font-mono); }
.hist-table .up { color: var(--green); }
.hist-table .down { color: var(--red); }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  margin-top: 64px;
}
.footer-inner {
  display: flex; justify-content: space-between; align-items: start; gap: 32px; flex-wrap: wrap;
}
.footer-brand .logo { margin-bottom: 10px; }
.footer-brand p { font-size: 13px; color: var(--text-muted); max-width: 260px; }
.footer-links h4 { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 12px; }
.footer-links ul { list-style: none; }
.footer-links li { margin-bottom: 8px; }
.footer-links a { font-size: 13px; color: var(--text-muted); transition: color .15s; }
.footer-links a:hover { color: var(--accent); }
.footer-bottom { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 640px) {
  .calc-card { padding: 24px 20px; }
  .field-row { flex-direction: column; gap: 12px; }
  .connector { display: none; }
  .nav { display: none; }
  .nav.open { display: flex; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--border); padding: 12px; gap: 4px; }
  .nav-toggle { display: block; }
  .hero { padding: 40px 0 32px; }
  .info-grid { grid-template-columns: 1fr; }
  .stat-row { gap: 12px; }
  .stat-box { min-width: 100%; }
}
