:root {
  --bg: #0b1020;
  --surface: #141a2e;
  --surface-2: #1c2440;
  --text: #eef1f8;
  --muted: #9aa3c0;
  --faint: #6b7497;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --accent: #22c55e;
  --accent-text: #22c55e;
  --accent-bg: color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-dim: color-mix(in srgb, var(--accent) 9%, transparent);
  --warn: #f59e0b;
  --hot: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 920px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fb; --surface: #ffffff; --surface-2: #eef1f8;
    --text: #16203a; --muted: #5a6488; --faint: #8b93ad;
    --border: rgba(20,30,60,.10); --border-strong: rgba(20,30,60,.18);
    --accent: #16a34a; --accent-text: #15803d;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
svg { width: 1em; height: 1em; }

.site-header { max-width: var(--maxw); margin: 0 auto; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; } .brand-icon { color: var(--accent); font-size: 1.3rem; }
.rate-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 5px 11px; border-radius: 999px; cursor: pointer; }
.rate-pill b { color: var(--accent-text); font-weight: 600; }
.rate-pill:hover { border-color: var(--border-strong); }

#main { max-width: var(--maxw); margin: 0 auto; padding: 4px 18px 40px; }
.intro h1 { font-size: 1.6rem; margin: 8px 0 4px; }
.intro .subtitle { color: var(--muted); margin: 0 0 18px; font-size: .95rem; }

/* mode toggle */
.modes { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; margin-bottom: 16px; gap: 2px; }
.modes button { font: inherit; font-size: .85rem; font-weight: 500; border: none; background: transparent; color: var(--muted); border-radius: 999px; padding: 7px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.modes button[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent-text); }

/* control card */
.controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.ctl { display: flex; flex-direction: column; gap: 5px; } .ctl.grow { flex: 1; min-width: 220px; }
.ctl label { font-size: .74rem; color: var(--muted); }
input, select { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); padding: 9px 11px; font: inherit; font-size: .88rem; max-width: 100%; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
.ctl .with-unit { display: flex; align-items: center; gap: 0; }
.ctl .with-unit input { border-top-right-radius: 0; border-bottom-right-radius: 0; width: 120px; }
.ctl .with-unit .unit { font-size: .8rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-left: none; border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); padding: 9px 11px; }
.hint { font-size: .72rem; color: var(--faint); }
.hint a { color: var(--faint); text-decoration: underline; }

/* range row */
.rangerow { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 220px; }
.rangerow .rl { display: flex; justify-content: space-between; font-size: .74rem; color: var(--muted); }
.rangerow .rl b { color: var(--text); font-weight: 600; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 6px; background: var(--surface-2); border-radius: 999px; padding: 0; border: 1px solid var(--border); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); cursor: pointer; border: none; }

/* headline result */
.result { background: linear-gradient(180deg, var(--accent-dim), transparent), var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.result .lead { font-size: .85rem; color: var(--muted); margin: 0 0 6px; }
.result .lead b { color: var(--text); }
.bignum { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.bignum .money { font-size: 2.6rem; font-weight: 700; letter-spacing: -0.02em; color: var(--accent-text); font-variant-numeric: tabular-nums; line-height: 1; }
.bignum .per { font-size: 1rem; color: var(--muted); }
.periods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.period { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; text-align: center; }
.period .pv { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.period .pl { font-size: .7rem; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }
.context { margin-top: 14px; font-size: .85rem; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.context .row { display: flex; align-items: flex-start; gap: 8px; }
.context .row svg { color: var(--accent-text); margin-top: 2px; flex: none; }
.context b { color: var(--text); }

/* savings callout */
.savings { background: var(--accent-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; font-size: .86rem; margin-bottom: 16px; display: flex; gap: 9px; align-items: flex-start; }
.savings svg { color: var(--accent-text); margin-top: 2px; flex: none; } .savings b { color: var(--accent-text); }

/* whole-home */
.home-add { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.itemlist { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); margin-bottom: 16px; }
.itemlist:empty { display: none; }
.item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 12px 14px; }
.item + .item { border-top: 1px solid var(--border); }
.item .nm { font-size: .9rem; font-weight: 500; }
.item .meta { font-size: .73rem; color: var(--muted); margin-top: 2px; }
.item .bar { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 2px; }
.item .bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.item.top .bar > span { background: var(--hot); }
.item .cost { font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; min-width: 92px; }
.item .cost small { display: block; font-size: .68rem; color: var(--muted); font-weight: 400; }
.item .edit { display: flex; gap: 6px; align-items: center; }
.item .edit input { width: 58px; padding: 5px 7px; font-size: .8rem; }
.item .rm { background: none; border: none; color: var(--faint); cursor: pointer; font-size: 1rem; padding: 2px 4px; line-height: 1; }
.item .rm:hover { color: var(--hot); }
.hometotal { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; background: linear-gradient(180deg, var(--accent-dim), transparent), var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.hometotal .tl { font-size: .85rem; color: var(--muted); }
.hometotal .tv { font-size: 2rem; font-weight: 700; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.hometotal .tv small { font-size: .9rem; color: var(--muted); font-weight: 400; }
.empty-home { text-align: center; color: var(--faint); font-size: .88rem; padding: 22px; border: 1px dashed var(--border-strong); border-radius: var(--radius); margin-bottom: 16px; }

/* buttons */
.actions { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: .85rem; font-weight: 500; border: 1px solid var(--border-strong); background: transparent; color: var(--text); border-radius: var(--radius-sm); padding: 9px 13px; cursor: pointer; }
.btn:hover { background: var(--surface-2); } .btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent-bg); border-color: transparent; color: var(--accent-text); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }

/* ---------- ad slot (reserved, no shift) ---------- */
.ad-slot {
  margin: 26px 0;
  min-height: 100px;            /* reserves space → no layout shift when the ad loads */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.ad-slot::before {
  content: "Advertisement";
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.ad-slot .adsbygoogle { display: block; width: 100%; }

/* popular / internal links */
.popular { margin: 26px 0 8px; }
.popular h2 { font-size: 1rem; margin: 0 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: .82rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 7px 13px; }
.chip:hover { border-color: var(--accent); text-decoration: none; color: var(--accent-text); }

.about { margin-top: 26px; } .about h2 { font-size: 1rem; margin: 0 0 8px; } .about p { font-size: .88rem; color: var(--muted); margin: 0 0 10px; }
.faq { margin-top: 22px; } .faq h2 { font-size: 1rem; margin: 0 0 10px; }
.faq details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 14px; margin-bottom: 8px; background: var(--surface); }
.faq summary { cursor: pointer; padding: 12px 0; font-size: .9rem; font-weight: 500; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-size: 1.1rem; }
.faq details[open] summary::after { content: "–"; }
.faq details p { font-size: .86rem; color: var(--muted); margin: 0 0 12px; }

.site-footer { max-width: var(--maxw); margin: 0 auto; padding: 24px 18px 40px; font-size: .76rem; color: var(--faint); text-align: center; }
.site-footer a { color: var(--faint); text-decoration: underline; }
.trio { font-size: .78rem; color: var(--faint); margin-top: 14px; }
.trio b { color: var(--muted); font-weight: 600; } .trio a { color: var(--accent-text); }

/* appliance detail page */
.crumb { font-size: .78rem; color: var(--faint); margin: 4px 0 10px; }
.crumb a { color: var(--muted); }
.specs { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.spec { font-size: .78rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; }
.spec b { color: var(--text); }
.prose { font-size: .92rem; color: var(--muted); }
.prose h2 { font-size: 1.15rem; color: var(--text); margin: 26px 0 8px; }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0 0 12px; padding-left: 18px; }
.prose li { margin-bottom: 6px; }

@media (max-width: 560px) {
  .periods { grid-template-columns: repeat(2, 1fr); }
  .bignum .money { font-size: 2.1rem; }
  .item { grid-template-columns: 1fr auto; }
  .item .edit { grid-column: 1 / -1; }
}
