:root {
  --bg: #f5f2ec;
  --surface: #ffffff;
  --ink: #152120;
  --muted: #58625f;
  --line: #e2dccf;
  --brand: #0f3d3e;
  --brand-soft: #d9e7e5;
  --accent: #e8a33d;
  --good: #26734a;
  --good-soft: #e1f1e7;
  --warn: #9a5b00;
  --warn-soft: #fbeed5;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  --info: #25598f;
  --info-soft: #e1ebf6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 28, .06), 0 6px 24px rgba(20, 30, 28, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1413;
    --surface: #162120;
    --ink: #e7eceb;
    --muted: #9aa8a5;
    --line: #26322f;
    --brand: #8fd0cc;
    --brand-soft: #1d3634;
    --good: #7bd19f;
    --good-soft: #17301f;
    --warn: #f2bb62;
    --warn-soft: #33270f;
    --bad: #ff8a80;
    --bad-soft: #3a1714;
    --info: #8ab8ec;
    --info-soft: #152538;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--brand); font-weight: 700; text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; }
.langs { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.langs button {
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; cursor: pointer;
}
.langs button[aria-pressed="true"] { background: var(--brand); color: var(--surface); }

.hero { padding: 36px 0 12px; }
h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 12px; }
.lede { color: var(--muted); margin: 0 0 22px; max-width: 60ch; }

.link-form { display: flex; gap: 8px; }
.link-form input {
  flex: 1; min-width: 0; font: inherit; padding: 13px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
}
.link-form input:focus, .grid-form :is(input, select, textarea):focus { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
.btn {
  font: inherit; font-weight: 650; border-radius: 12px; padding: 12px 18px; cursor: pointer;
  border: 1.5px solid transparent; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { background: var(--brand); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: var(--brand); color: var(--brand); }
.form-error { color: var(--bad); margin: 10px 0 0; }

.manual { margin-top: 16px; }
.manual summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.grid-form label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); }
.grid-form :is(input, select, textarea) {
  font: inherit; color: var(--ink); background: var(--surface); padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 10px; width: 100%;
}
.span-2 { grid-column: span 2; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.results { display: grid; gap: 16px; margin: 18px 0 8px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card h2 { font-size: 18px; margin: 0 0 12px; letter-spacing: -.01em; }
.card p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 14px; }

.summary-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.summary-head .facts { color: var(--muted); font-size: 14px; }

.pill { display: inline-block; font-weight: 700; font-size: 15px; padding: 5px 12px; border-radius: 999px; margin-bottom: 8px; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.fair { background: var(--info-soft); color: var(--info); }
.pill.high { background: var(--warn-soft); color: var(--warn); }
.pill.veryHigh, .pill.suspicious { background: var(--bad-soft); color: var(--bad); }

.bar { position: relative; height: 34px; margin: 18px 0 6px; }
.bar-track { position: absolute; left: 0; right: 0; top: 14px; height: 6px; border-radius: 3px; background: var(--line); }
.bar-band { position: absolute; top: 10px; height: 14px; border-radius: 7px; background: var(--brand-soft); border: 1.5px solid var(--brand); }
.bar-marker {
  position: absolute; top: 5px; width: 24px; height: 24px; margin-left: -12px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--ink);
}
.bar-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.costs { width: 100%; border-collapse: collapse; margin: 4px 0 10px; }
.costs td { padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.costs td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; padding-left: 12px; }
.costs tr.total td { border-bottom: 0; font-weight: 750; font-size: 18px; padding-top: 12px; }

.building { display: flex; gap: 12px; align-items: flex-start; margin-top: 10px; }
.eclass {
  flex: none; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 17px;
}
.eclass[data-c="A+"] { background: #0a7a3d; }
.eclass[data-c="A"] { background: #2f9e44; }
.eclass[data-c="B"] { background: #6ba539; }
.eclass[data-c="C"] { background: #a8a820; }
.eclass[data-c="D"] { background: #d99a0b; }
.eclass[data-c="E"] { background: #e0620d; }
.eclass[data-c="F"] { background: #c62828; }
.eclass[data-c="?"] { background: var(--muted); }

.flags { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.flags li { border-left: 4px solid; border-radius: 8px; padding: 10px 12px; }
.flags li.high { border-color: var(--bad); background: var(--bad-soft); }
.flags li.medium { border-color: var(--warn); background: var(--warn-soft); }
.flags li.low, .flags li.info { border-color: var(--info); background: var(--info-soft); }
.flags .lvl { display: block; font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.flags li.high .lvl { color: var(--bad); }
.flags li.medium .lvl { color: var(--warn); }
.flags li.low .lvl, .flags li.info .lvl { color: var(--info); }

.checklist { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.checklist label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.checklist input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.tool { margin: 28px 0 8px; }
.bookmarklet { cursor: grab; }

.foot { border-top: 1px solid var(--line); margin-top: 32px; padding: 20px 0 36px; color: var(--muted); font-size: 13px; }
.foot p { margin: 6px 0; }

/* ---------- how it works ---------- */
.how { margin: 36px 0 8px; }
.how > h2 { font-size: 22px; margin: 0 0 16px; letter-spacing: -.01em; }
.stats-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--brand); color: var(--surface); border-radius: var(--radius);
  padding: 18px 16px; display: flex; flex-direction: column; gap: 4px;
}
.stat-num { font-size: clamp(26px, 5vw, 36px); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-label { font-size: 13px; opacity: .85; line-height: 1.35; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; box-shadow: var(--shadow); }
.step h3 { margin: 10px 0 4px; font-size: 16px; }
.step p { margin: 0; color: var(--muted); font-size: 14px; }
.step-n {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #2a1a00; font-weight: 800; font-size: 14px;
}

/* ---------- motion ---------- */
.skyline { display: block; width: 100%; height: auto; margin-top: 28px; color: var(--brand); opacity: .55; }
.skyline path {
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round;
  stroke-dasharray: 2600; stroke-dashoffset: 2600;
  animation: draw 2.6s cubic-bezier(.45, .05, .25, 1) .4s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.hero > h1, .hero > .lede, .hero > .link-form, .hero > .manual {
  animation: rise .8s cubic-bezier(.2, .8, .2, 1) both;
}
.hero > .lede { animation-delay: .08s; }
.hero > .link-form { animation-delay: .16s; }
.hero > .manual { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

.reveal {
  opacity: 0; transform: translateY(28px) scale(.985);
  transition: opacity .7s ease, transform .8s cubic-bezier(.2, .8, .2, 1);
  transition-delay: var(--d, 0ms);
}
.reveal.in { opacity: 1; transform: none; }

.pill { transform: scale(.7); opacity: 0; transition: transform .5s cubic-bezier(.3, 1.6, .5, 1) .25s, opacity .3s .25s; }
.in .pill { transform: none; opacity: 1; }

.bar-band { transform: scaleX(0); transform-origin: left; transition: transform 1s cubic-bezier(.2, .8, .2, 1) .3s; }
.in .bar-band { transform: none; }
.bar-marker { left: 0; transition: left 1.3s cubic-bezier(.2, .9, .25, 1.12) .45s; }
.in .bar-marker { left: var(--x); }

.eclass { transform: scale(.4) rotate(-14deg); opacity: 0; transition: transform .7s cubic-bezier(.3, 1.7, .5, 1) .35s, opacity .3s .35s; }
.in .eclass { transform: none; opacity: 1; }

.flags li, .checklist li {
  opacity: 0; transform: translateX(-18px);
  transition: opacity .5s ease, transform .6s cubic-bezier(.2, .8, .2, 1);
  transition-delay: calc(var(--i, 0) * 80ms + 200ms);
}
.in .flags li, .in .checklist li { opacity: 1; transform: none; }

.costs tr.total td:last-child { color: var(--brand); }

.progress { display: none; }
@supports (animation-timeline: scroll()) {
  .progress {
    display: block; position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 10;
    background: linear-gradient(90deg, var(--accent), var(--brand));
    transform-origin: left; animation: grow linear both; animation-timeline: scroll(root);
  }
  @keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  /* the skyline drifts up and fades as the page scrolls past it */
  .skyline { animation: drift linear both; animation-timeline: view(); animation-range: exit 0% exit 100%; }
  @keyframes drift { to { transform: translateY(-30px); opacity: .1; } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal, .pill, .eclass, .flags li, .checklist li { opacity: 1; transform: none; }
  .bar-band { transform: none; }
  .bar-marker { left: var(--x); }
  .skyline path { stroke-dashoffset: 0; }
  .progress { display: none; }
}

@media (max-width: 560px) {
  .stats-strip, .steps { grid-template-columns: 1fr; }
  .link-form { flex-direction: column; }
  .grid-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .card { padding: 16px; }
}
