/* Layout: single centered column; calculator pages split into form | results, stacking on phones. */
:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --fg: #16201c;
  --muted: #5b6b64;
  --line: #dbe3df;
  --accent: #0d6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1eb;
  --warn: #9a5b00;
  --ad: #eef1f0;
  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1513; --surface: #161e1b; --fg: #e6eeea; --muted: #97a8a0; --line: #2a3632;
    --accent: #4fc79c; --accent-ink: #062018; --accent-soft: #173229; --warn: #e0a64a; --ad: #1b2421;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1513; --surface: #161e1b; --fg: #e6eeea; --muted: #97a8a0; --line: #2a3632;
  --accent: #4fc79c; --accent-ink: #062018; --accent-soft: #173229; --warn: #e0a64a; --ad: #1b2421;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 var(--font-body);
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-block: 14px; }
.logo { font: 800 1.25rem/1 var(--font-display); color: var(--fg); text-decoration: none; letter-spacing: -0.01em; }
.logo span { color: var(--accent); }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.92rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }
.site-footer { margin-top: 56px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 0.88rem; }
.site-footer .wrap { padding-block: 24px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* Type */
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 32px 0 8px; }
h2 { font-size: 1.4rem; margin: 40px 0 12px; }
h3 { font-size: 1.1rem; margin: 24px 0 8px; }
.lede { color: var(--muted); max-width: 65ch; margin: 0 0 24px; font-size: 1.05rem; }
.prose { max-width: 70ch; }
.prose p, .prose li { color: var(--fg); }
.eyebrow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }

/* Ads: fixed min-heights prevent layout shift when real units load */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  background: var(--ad); border: 1px dashed var(--line); border-radius: 6px;
  color: var(--muted); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase;
  margin-block: 24px;
}
.ad-leaderboard { min-height: 100px; }
.ad-rect { min-height: 250px; }
.ad-inline { min-height: 120px; }

/* Home grid */
.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.calc-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px; text-decoration: none; color: var(--fg);
  transition: border-color .15s, transform .15s;
}
.calc-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.calc-card strong { font: 700 1.1rem/1.3 var(--font-display); }
.calc-card span { color: var(--muted); font-size: 0.92rem; }
.calc-card em { margin-top: auto; padding-top: 8px; font-style: normal; color: var(--accent); font-size: 0.88rem; font-weight: 600; }

/* Calculator layout */
.calc { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 24px; 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: 10px; padding: 20px; min-width: 0; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 340px) { .fields { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 0.85rem; font-weight: 600; }
.field .hint { font-size: 0.78rem; color: var(--muted); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .pre, .input-wrap .post { position: absolute; color: var(--muted); font-size: 0.9rem; pointer-events: none; }
.input-wrap .pre { left: 10px; }
.input-wrap .post { right: 10px; }
.input-wrap.has-pre input { padding-left: 24px; }
.input-wrap.has-post input { padding-right: 34px; }
input, select {
  width: 100%; font: 500 1rem/1.2 var(--font-body); color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px;
  font-variant-numeric: tabular-nums;
}
input:focus, select:focus { border-color: var(--accent); }

/* Results */
.headline { display: flex; flex-direction: column; gap: 2px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.headline .big { font: 700 clamp(2rem, 5vw, 2.8rem)/1.1 var(--font-num); color: var(--accent); font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 16px 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.kv .total { font-weight: 700; color: var(--fg); border-top: 1px solid var(--line); padding-top: 8px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: 0; }
.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin-top: 16px; background: var(--line); }
.bar span { display: block; height: 100%; }
.note { font-size: 0.82rem; color: var(--muted); margin-top: 14px; }
.warn { color: var(--warn); }

/* Chart + table */
.chart { width: 100%; height: auto; display: block; margin-top: 16px; }
.chart text { fill: var(--muted); font: 11px var(--font-body); }
.chart .grid { stroke: var(--line); }
.table-scroll { overflow-x: auto; margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; max-height: 420px; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
thead th { position: sticky; top: 0; background: var(--surface); font-weight: 600; color: var(--muted); }
tbody td { font-family: var(--font-num); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* DTI verdict + scale */
.verdict { display: inline-block; margin: 12px 0 0; padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; background: var(--accent-soft); color: var(--accent); }
.verdict.mid { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.verdict.bad { background: color-mix(in srgb, #c0392b 15%, transparent); color: #d9534f; }
.scale { position: relative; display: flex; height: 10px; border-radius: 5px; overflow: visible; margin-top: 20px; }
.scale span:nth-child(1) { background: var(--accent); border-radius: 5px 0 0 5px; }
.scale span:nth-child(2) { background: #e0c24a; }
.scale span:nth-child(3) { background: #e0a64a; }
.scale span:nth-child(4) { background: #d9534f; border-radius: 0 5px 5px 0; }
.scale i { position: absolute; top: -4px; width: 4px; height: 18px; margin-left: -2px; background: var(--fg); border-radius: 2px; }
.scale-labels { position: relative; height: 18px; font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.scale-labels span { position: absolute; transform: translateX(-50%); }
.scale-labels span:nth-child(1) { left: 0; transform: none; }
.scale-labels span:nth-child(2) { left: 60%; }
.scale-labels span:nth-child(3) { left: 71.67%; }
.scale-labels span:nth-child(4) { left: 83.33%; }
.scale-labels span:nth-child(5) { right: 0; transform: none; }
