:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-alt: #f4f2ed;
  --ink: #1a1a17;
  --ink-soft: #5d5c56;
  --ink-faint: #8b8981;
  --line: #e3e1da;
  --line-strong: #cdcac1;
  --accent: #1f5e4a;
  --accent-ink: #ffffff;
  --accent-soft: #e7f0ec;
  --warn-bg: #fdf6e6;
  --warn-line: #e8d8ae;
  --radius: 10px;
  --radius-lg: 14px;
  --max: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14150f;
    --surface: #1c1d17;
    --surface-alt: #22231c;
    --ink: #f2f1ec;
    --ink-soft: #a9a79e;
    --ink-faint: #7c7a72;
    --line: #303128;
    --line-strong: #45463a;
    --accent: #6cc4a2;
    --accent-ink: #10251d;
    --accent-soft: #1e2f27;
    --warn-bg: #2a2418;
    --warn-line: #4a3f22;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.site-head {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-head .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 60px;
}
.brand {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
}
.nav { margin-left: auto; display: flex; gap: 18px; font-size: 14px; }
.nav a { color: var(--ink-soft); }
.nav a:hover { color: var(--accent); text-decoration: none; }
@media (max-width: 620px) { .nav { gap: 12px; font-size: 13px; } }

/* ---------- breadcrumb ---------- */
.crumb {
  font-size: 13px;
  color: var(--ink-faint);
  padding: 18px 0 0;
}
.crumb a { color: var(--ink-faint); }
.crumb span { margin: 0 6px; opacity: 0.6; }

/* ---------- typography ---------- */
h1 {
  font-size: 32px;
  line-height: 1.22;
  letter-spacing: -0.022em;
  margin: 12px 0 10px;
  font-weight: 600;
}
h2 {
  font-size: 21px;
  line-height: 1.3;
  letter-spacing: -0.014em;
  margin: 40px 0 12px;
  font-weight: 600;
}
h3 { font-size: 16px; margin: 22px 0 6px; font-weight: 600; }
p { margin: 0 0 14px; }
.lede { font-size: 17px; color: var(--ink-soft); margin: 0 0 24px; max-width: 66ch; }
.muted { color: var(--ink-soft); }
.small { font-size: 14px; }

/* ---------- ad slot ---------- */
.ad {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-alt);
  min-height: 96px;
  display: grid;
  place-items: center;
  margin: 28px 0;
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  overflow: hidden;
}
.ad--tall { min-height: 250px; }

/* ---------- calculator ---------- */
.calc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 24px 0;
}
.calc-grid { display: grid; grid-template-columns: 1fr 320px; }
@media (max-width: 860px) { .calc-grid { grid-template-columns: 1fr; } }

.calc-form { padding: 24px; }
.calc-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 560px) { .calc-fields { grid-template-columns: 1fr; } }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.input-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-row input,
.input-row select {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  font-size: 15px;
  color: var(--ink);
  font-family: inherit;
  outline: none;
  appearance: none;
}
.input-row input::-webkit-outer-spin-button,
.input-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-unit {
  flex: none;
  padding: 9px 10px 9px 0;
  font-size: 13px;
  color: var(--ink-faint);
  white-space: nowrap;
}
.select-row { position: relative; }
.select-row select { cursor: pointer; padding-right: 24px; }
.select-row::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--ink-faint);
  border-bottom: 1.5px solid var(--ink-faint);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.form-hint {
  font-size: 12.5px;
  color: var(--ink-faint);
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  line-height: 1.5;
}

/* ---------- results ---------- */
.calc-result {
  background: var(--accent-soft);
  border-left: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
}
@media (max-width: 860px) {
  .calc-result { border-left: 0; border-top: 1px solid var(--line); }
}
.result-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin-bottom: 2px;
}
.result-primary {
  font-size: 38px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}
.result-unit { font-size: 15px; font-weight: 500; color: var(--ink-soft); margin-left: 4px; }
.result-rows { margin: 16px 0 0; border-top: 1px solid var(--accent); opacity: 0.98; }
.result-rows dl { margin: 0; padding: 0; }
.result-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.result-row dt { color: var(--ink-soft); margin: 0; }
.result-row dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }
.result-note {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* ---------- content blocks ---------- */
.prose { max-width: 68ch; }
.prose h2 { margin-top: 34px; }
.faq { margin: 8px 0 0; }
.faq details {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.faq summary {
  cursor: pointer;
  font-weight: 500;
  list-style: none;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: "+";
  color: var(--accent);
  font-weight: 600;
  flex: none;
  width: 14px;
}
.faq details[open] summary::before { content: "\2013"; }
.faq details p { margin: 10px 0 0 24px; color: var(--ink-soft); font-size: 15px; }

.callout {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--ink-soft);
  margin: 24px 0;
}
.callout strong { color: var(--ink); }

/* ---------- tool cards ---------- */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
  margin: 18px 0 8px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  color: var(--ink);
  transition: border-color 0.14s, transform 0.14s;
}
.tool-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-1px);
}
.tool-card strong { display: block; font-size: 15px; font-weight: 500; margin-bottom: 2px; }
.tool-card span { font-size: 13px; color: var(--ink-soft); line-height: 1.45; display: block; }

/* ---------- hero ---------- */
.hero { padding: 44px 0 8px; }
.hero h1 { font-size: 38px; max-width: 20ch; }
@media (max-width: 620px) { .hero h1 { font-size: 30px; } h1 { font-size: 27px; } }

.section-head { margin-top: 44px; }
.section-head h2 { margin: 0 0 4px; }
.section-head p { margin: 0; font-size: 14.5px; color: var(--ink-soft); }

/* ---------- footer ---------- */
.site-foot {
  border-top: 1px solid var(--line);
  margin-top: 64px;
  padding: 32px 0 48px;
  font-size: 13px;
  color: var(--ink-faint);
}
.site-foot .foot-links { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 14px; }
.site-foot a { color: var(--ink-soft); }
.site-foot p { max-width: 76ch; margin: 0 0 10px; }

.cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 26px 0;
}
.cta p { margin: 0; font-size: 15px; }
.cta .btn {
  flex: none;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.cta .btn:hover { text-decoration: none; opacity: 0.92; }

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

/* ---------- account + saved estimates ---------- */

.acct { display: flex; align-items: center; gap: 10px; }
.acct-note { font-size: 13px; color: var(--ink-faint); }
.acct-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.acct-btn:hover { opacity: 0.9; }
.acct-btn--quiet {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line-strong);
}
.acct-btn--quiet:hover { color: var(--ink); border-color: var(--ink-faint); opacity: 1; }
.acct-link { font-size: 13px; white-space: nowrap; }

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 9px 18px;
  cursor: pointer;
}
.btn:hover { opacity: 0.92; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--wide { display: block; width: 100%; margin-top: 12px; padding: 11px 18px; }

/* save bar under the calculator */
.calc-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 16px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
}
.btn--save { flex: none; }
.calc-actions-hint {
  font-size: 13px;
  color: var(--ink-faint);
  line-height: 1.5;
  max-width: 52ch;
}

/* sign-in modal */
body.has-modal { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 21, 15, 0.55);
  backdrop-filter: blur(2px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px 24px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}
.modal h2 { margin: 0 0 6px; font-size: 21px; }
.modal-lede { margin: 0 0 18px; font-size: 14.5px; color: var(--ink-soft); }
.modal-x {
  position: absolute;
  top: 10px; right: 12px;
  width: 30px; height: 30px;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-faint);
  background: none;
  border: 0;
  cursor: pointer;
  border-radius: 6px;
}
.modal-x:hover { color: var(--ink); background: var(--surface-alt); }
.modal-step label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.modal-step input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
}
.modal-step input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#auth-code { letter-spacing: 0.28em; font-variant-numeric: tabular-nums; }
.modal-error { margin: 12px 0 0; min-height: 18px; font-size: 13.5px; color: #b3261e; }
@media (prefers-color-scheme: dark) { .modal-error { color: #ff8a80; } }
.modal-foot { margin: 14px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--ink-faint); }
.btn-link {
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  margin-top: 12px;
  cursor: pointer;
  text-decoration: underline;
}
.btn-link--danger { color: #b3261e; }
@media (prefers-color-scheme: dark) { .btn-link--danger { color: #ff8a80; } }
.btn-link:disabled { opacity: 0.5; cursor: default; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  z-index: 95;
  max-width: min(88vw, 420px);
  padding: 11px 18px;
  border-radius: 9px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.toast[data-tone='error'] { background: #8c1d18; color: #fff; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* saved list */
.saved-app { margin: 8px 0 40px; }
.saved-app .lede { margin-bottom: 18px; }
.empty {
  font-size: 14.5px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 22px 20px;
  margin: 0;
}
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.saved-body { min-width: 0; }
.saved-headline { margin: 0; font-size: 16px; font-weight: 600; }
.saved-tool { margin: 3px 0 0; font-size: 13px; color: var(--ink-faint); }
.saved-tool .dot { opacity: 0.5; }
.saved-actions { display: flex; align-items: center; gap: 16px; flex: none; }
.saved-actions .btn-link { margin: 0; white-space: nowrap; }
@media (max-width: 560px) {
  .saved-item { flex-direction: column; align-items: flex-start; gap: 10px; }
  .calc-actions { flex-direction: column; align-items: flex-start; }
  .btn--save { width: 100%; }
}

/* ---------- embed widget ----------
   .embed-box sits at the bottom of every tool page; /embed/ reuses the same
   code block plus a live demo. The iframe itself is styled by embed.css, which
   is a separate file on purpose — the frame must not inherit page rules. */
.embed-box {
  margin: 36px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.embed-box > summary {
  cursor: pointer;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.embed-box > summary:hover { color: var(--accent); }
.embed-body { padding: 2px 18px 18px; }
.embed-body p {
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0 0 12px;
  max-width: 64ch;
}
.embed-code {
  display: block;
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  resize: vertical;
  /* Wrap rather than scroll sideways: the snippet is three long lines, and a
     horizontal scrollbar hides most of it. Wrapping does not change the value
     that gets copied. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
}
.embed-code:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.embed-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}
.embed-foot a { font-size: 13px; color: var(--accent); }
.btn--ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--line-strong);
  padding: 7px 14px;
}
.btn--ghost:hover { border-color: var(--accent); opacity: 1; }

.embed-demo {
  margin: 18px 0 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
}
.embed-demo iframe { display: block; width: 100%; }
.embed-copy { margin: 0 0 34px; }
.embed-copy-label { font-size: 13px; color: var(--ink-faint); margin: 0 0 8px; }
.embed-steps { padding-left: 22px; color: var(--ink-soft); }
.embed-steps li { margin: 9px 0; }
.embed-note { font-size: 13.5px; color: var(--ink-faint); }
.embed-grid { margin: 18px 0 0; }
