:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1b1d21;
  --muted: #5d6470;
  --border: #e2e3e0;
  --accent: #0b6e4f;
  --accent-soft: #e3f2ec;
  --neg: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121416; --surface: #1b1e21; --text: #e9eaec; --muted: #a2a8b1;
    --border: #2d3136; --accent: #4cc29a; --accent-soft: #173a2f; --neg: #f97066;
    --shadow: none; color-scheme: dark;
  }
}
* { 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); }
img, svg { max-width: 100%; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }

/* Header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 56px; gap: 16px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 24px; height: 24px; }
.site-nav { white-space: nowrap; }
.site-nav a { color: var(--muted); text-decoration: none; margin-left: 16px; font-size: 15px; }
.brand { white-space: nowrap; }
@media (max-width: 400px) { .site-nav a { margin-left: 12px; } .lede { font-size: 1rem; } }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); }
.site-footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 24px 0 40px; color: var(--muted); font-size: 14px; }
.site-footer nav a { color: var(--muted); margin-right: 16px; }

/* Typography */
h1 { font-size: clamp(1.75rem, 4vw, 2.4rem); line-height: 1.2; margin: 32px 0 8px; letter-spacing: -.01em; }
h2 { font-size: 1.4rem; line-height: 1.3; margin: 40px 0 12px; }
h3 { font-size: 1.1rem; margin: 24px 0 8px; }
.lede { color: var(--muted); font-size: 1.1rem; max-width: 70ch; margin: 0 0 24px; }
.crumbs { font-size: 14px; color: var(--muted); margin-top: 16px; }
.crumbs a { color: var(--muted); }
.prose { max-width: 75ch; }
.prose p, .prose li { color: var(--text); }
.note { font-size: 14px; color: var(--muted); }

/* Calculator layout */
.calc { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 24px; align-items: start; }
@media (max-width: 820px) { .calc { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; font-size: 1.1rem; }
.results { position: sticky; top: 16px; }
@media (max-width: 820px) { .results { position: static; } }
fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; padding: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 14px; font-weight: 500; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input { position: relative; }
.input .unit { position: absolute; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 15px; }
.input .unit.pre { left: 12px; }
.input .unit.post { right: 12px; }
input[type="number"], select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-height: 44px;
}
.input.has-pre input { padding-left: 26px; }
.input.has-post input { padding-right: 30px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; margin-bottom: 10px; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); }
details.more { margin-top: 4px; }
details.more summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--accent); padding: 6px 0; }

/* Results */
.big { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat { background: var(--bg); border-radius: 10px; padding: 12px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.primary { background: var(--accent-soft); }
.stat.primary .v { color: var(--accent); }
.v.neg { color: var(--neg) !important; }
table.breakdown { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.breakdown td { padding: 6px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
table.breakdown td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; }
table.breakdown tr.total td { font-weight: 700; border-bottom: 0; }
table.breakdown tr.zero { color: var(--muted); }
.reverse { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.reverse .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.reverse .row .input { width: 120px; }
.reverse output { font-weight: 700; font-size: 1.1rem; }

/* Content tables */
.table-wrap { overflow-x: auto; }
table.rates { border-collapse: collapse; width: 100%; font-size: 15px; background: var(--surface); }
table.rates th, table.rates td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.rates th { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.verified { display: inline-block; font-size: 13px; background: var(--accent-soft); color: var(--accent); padding: 4px 10px; border-radius: 8px; margin-bottom: 16px; }

/* Hub */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 24px 0; padding: 0; list-style: none; }
.tile { display: block; height: 100%; text-decoration: none; color: var(--text); }
a.tile:hover .card { border-color: var(--accent); }
.tile .card { height: 100%; }
.tile h3 { margin: 0 0 6px; }
.tile p { margin: 0; color: var(--muted); font-size: 15px; }
.tile.soon { opacity: .6; }
.badge { font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 99px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; font-weight: 500; }

/* FAQ */
.faq details { border-bottom: 1px solid var(--border); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; }

/* Reserved ad slot (prevents layout shift once AdSense is enabled) */
.ad-slot { min-height: 0; }

/* Markup / margin calculators */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.segmented label { text-align: center; font-size: 14px; padding: 8px 4px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:checked + span { color: var(--text); font-weight: 600; }
.segmented label:has(input:checked) { background: var(--surface); box-shadow: var(--shadow); outline: 1px solid var(--border); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.field.solved input { background: var(--accent-soft); color: var(--accent); font-weight: 700; border-color: transparent; }
.field.solved label::after { content: " (calculated)"; font-weight: 400; color: var(--muted); }
.error { color: var(--neg); font-size: 14px; min-height: 0; margin: 0; }
.error:not(:empty) { margin: 0 0 12px; }

/* Related calculators */
.related { margin-top: 40px; }
.related .tiles { margin-top: 12px; }
