:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --text: #1c1d1f;
  --muted: #5d6066;
  --line: #e3e3de;
  --accent: #0f6e5a;
  --accent-soft: #e3f2ee;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131416;
    --surface: #1c1d20;
    --text: #ecece9;
    --muted: #a3a6ab;
    --line: #2e3034;
    --accent: #4cc3a6;
    --accent-soft: #183a32;
    --danger: #ff8a80;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
}
a { color: var(--accent); }
.wrap, main { max-width: 760px; margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* header / footer */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.1rem; }
.logo-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--surface); font-weight: 800; }
.site-header nav { display: flex; gap: 18px; }
.site-header nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.site-header nav a:hover { color: var(--text); }
.site-footer { margin-top: 64px; padding: 28px 0 40px; border-top: 1px solid var(--line); color: var(--muted); }
.site-footer p { margin: 4px 0; }
.small { font-size: 0.85rem; }

/* page heads */
main { padding-top: 24px; }
.crumbs { font-size: 0.875rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; margin: 32px 0 8px; letter-spacing: -0.01em; }
.lede { color: var(--muted); font-size: 1.05rem; margin: 0 0 20px; }
.hero { padding: 24px 0 8px; }
.search input { width: 100%; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; }

/* cards */
.cat-section h2 a { color: var(--text); text-decoration: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.15s; }
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card span:last-child { color: var(--muted); font-size: 0.9rem; }
.card-cat { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent) !important; font-weight: 600; }

/* calculator */
.calc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.calc-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.field { margin: 0; padding: 0; border: 0; min-width: 0; }
.field[hidden] { display: none; }
fieldset.field { grid-column: 1 / -1; }
.field label, .field legend { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; padding: 0; }
.field input, .field select { width: 100%; padding: 11px 12px; font: inherit; font-size: 1.05rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.field input:focus, .field select:focus, .search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.hint { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.affix { display: flex; align-items: stretch; }
.affix .pre, .affix .suf { display: grid; place-items: center; padding: 0 12px; background: var(--line); color: var(--muted); font-weight: 600; }
.affix .pre { border-radius: 10px 0 0 10px; }
.affix .suf { border-radius: 0 10px 10px 0; }
.affix .pre + input { border-radius: 0 10px 10px 0; }
.affix input:has(+ .suf) { border-radius: 10px 0 0 10px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.seg-opt { flex: 1 1 auto; margin: 0 !important; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span { display: block; text-align: center; padding: 8px 12px; border-radius: 9px; cursor: pointer; font-weight: 500; font-size: 0.95rem; color: var(--muted); }
.seg-opt input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); outline: 1px solid var(--line); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); }

.calc-result { margin-top: 20px; padding: 16px; border-radius: 12px; background: var(--accent-soft); min-height: 64px; }
.result-rows { margin: 0; }
.result-rows .row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid rgba(0, 0, 0, 0.06); }
.result-rows .row:last-child { border-bottom: 0; }
.result-rows dt { color: var(--muted); }
.result-rows dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.result-rows .row.big dt { color: var(--text); font-weight: 600; align-self: center; }
.result-rows .row.big dd { font-size: 1.6rem; color: var(--accent); letter-spacing: -0.01em; }
.result-error { margin: 0; color: var(--danger); font-weight: 500; }
.result-note { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
th, td { padding: 8px 6px; text-align: right; border-bottom: 1px solid rgba(0, 0, 0, 0.07); white-space: nowrap; }
th:first-child, tbody th { text-align: left; font-weight: 500; }
tbody tr:last-child { font-weight: 700; }
thead th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.calc-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-ghost { font: inherit; font-size: 0.9rem; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; }
.btn-ghost:hover { border-color: var(--accent); }

/* content */
.content ul { padding-left: 20px; }
.faqs details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faqs summary { cursor: pointer; font-weight: 600; }
.faqs p { margin: 8px 0 0; color: var(--muted); }
.disclaimer { margin-top: 24px; font-size: 0.85rem; color: var(--muted); padding: 12px 14px; border-left: 3px solid var(--line); }
.related ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.related a { display: inline-block; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; }

/* ads: reserved space so the page doesn't jump when ads load */
.ad-slot { min-height: 250px; margin: 24px 0; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

@media (max-width: 560px) {
  .site-header nav { gap: 12px; font-size: 0.9rem; }
  .calc { padding: 16px; }
  .result-rows .row.big dd { font-size: 1.35rem; }
  table { font-size: 0.85rem; }
  th, td { padding: 8px 4px; }
  tbody th { white-space: normal; }
  .wrap, main { padding: 0 14px; }
  main { padding-top: 20px; }
  .calc { padding: 14px; }
  .calc-result { padding: 12px; }
  th:nth-child(4), td:nth-child(4) { display: none; } /* drop the weekly column on phones */
}
