:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e3e2dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7974;
  --accent: #2a78d6;
  --accent-soft: #e7f1fb;
  --price: #2a78d6;
  --carbon: #52514e;
  --carbon-fill: rgba(82, 81, 78, 0.12);
  --good: #0ca30c;
  --good-soft: #e5f4e4;
  --good-ink: #006300;
  --warn: #fab219;
  --warn-soft: #f9eeda;
  --warn-ink: #8a5a00;
  --bad: #d03b3b;
  --bad-soft: #fbebeb;
  --bad-ink: #a12a2a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2f2f2c;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #908f86;
    --accent: #3987e5;
    --accent-soft: #17283d;
    --price: #3987e5;
    --carbon: #c3c2b7;
    --carbon-fill: rgba(195, 194, 183, 0.12);
    --good-soft: #15291a;
    --good-ink: #5fd35f;
    --warn-soft: #2e2512;
    --warn-ink: #fab219;
    --bad-soft: #321a1a;
    --bad-ink: #ef8a8a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2f2f2c;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #908f86; --accent: #3987e5; --accent-soft: #17283d;
  --price: #3987e5; --carbon: #c3c2b7; --carbon-fill: rgba(195,194,183,.12);
  --good-soft: #15291a; --good-ink: #5fd35f; --warn-soft: #2e2512; --warn-ink: #fab219;
  --bad-soft: #321a1a; --bad-ink: #ef8a8a; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* Header */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.top .wrap { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand svg { flex: none; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--text-3); letter-spacing: 0; }
.controls { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ctl {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 4px 8px; font-size: 13px; color: var(--text-2);
}
.ctl select, .ctl input[type="time"] { border: 0; background: transparent; font-weight: 600; color: var(--text); padding: 2px 0; }
.ctl label { white-space: nowrap; }
.ctl input[type="checkbox"] { accent-color: var(--accent); }

main { padding: 20px 0 48px; }
section.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px;
}
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 19px; letter-spacing: -0.01em; margin: 0 0 4px; }
.sub { color: var(--text-2); margin: 0 0 14px; }
.muted { color: var(--text-3); font-size: 13px; }

/* Hero */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }
.light {
  width: 92px; padding: 10px; border-radius: 22px; background: #1b1b1a;
  display: grid; gap: 8px; box-shadow: inset 0 0 0 1px #000;
}
.light span { display: block; width: 72px; height: 72px; border-radius: 50%; background: #333; opacity: .28; transition: all .3s; }
.light span.on { opacity: 1; box-shadow: 0 0 22px 2px currentColor; }
.light .r { background: var(--bad); color: var(--bad); }
.light .a { background: var(--warn); color: var(--warn); }
.light .g { background: var(--good); color: var(--good); }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12px;
  letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px;
}
.st-green { background: var(--good-soft); color: var(--good-ink); }
.st-amber { background: var(--warn-soft); color: var(--warn-ink); }
.st-red { background: var(--bad-soft); color: var(--bad-ink); }
.hero h1 { margin-top: 8px; }
.kpis { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; min-width: 132px; }
.kpi b { display: block; font-size: 20px; letter-spacing: -0.01em; }
.kpi span { font-size: 12px; color: var(--text-3); }
.live-badge { font-size: 12px; color: var(--text-3); margin-top: 8px; }

/* Day strip + charts */
.strip { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin: 6px 0 2px; }
.strip div { height: 28px; border-radius: 4px; position: relative; cursor: default; }
.strip .g { background: var(--good); } .strip .a { background: var(--warn); } .strip .r { background: var(--bad); }
.strip div.now::after {
  content: ""; position: absolute; inset: -4px -2px; border: 2px solid var(--text); border-radius: 6px;
}
.strip-labels { display: grid; grid-template-columns: repeat(24, minmax(0,1fr)); font-size: 11px; color: var(--text-3); overflow: hidden; }
.strip-labels span { white-space: nowrap; }
.strip-labels span:nth-child(3n+2), .strip-labels span:nth-child(3n) { visibility: hidden; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin: 10px 0 4px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 16px 0 2px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { font-size: 11px; fill: var(--text-3); }
.chart .grid line { stroke: var(--border); stroke-width: 1; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--surface);
  font-size: 12px; line-height: 1.4; padding: 7px 9px; border-radius: 8px; white-space: nowrap;
  transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s; z-index: 5;
}
.tooltip.show { opacity: 1; }

.insight {
  border-left: 4px solid var(--warn); background: var(--warn-soft); border-radius: 8px;
  padding: 12px 14px; margin-top: 16px; color: var(--text);
}
.insight b { color: var(--text); }

/* Weight slider */
.prio { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); margin: 4px 0 14px; flex-wrap: wrap; }
.prio input[type="range"] { flex: 1; min-width: 160px; accent-color: var(--accent); }

/* Appliances */
.apps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.app {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; background: var(--surface);
  text-align: left; transition: border-color .15s, background .15s;
}
.app:hover { border-color: var(--accent); }
.app.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.app b { display: block; font-size: 14px; }
.app span { font-size: 12px; color: var(--text-3); }
.app svg { margin-bottom: 6px; color: var(--text-2); }
.compare { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.opt { border-radius: 12px; padding: 14px; background: var(--surface-2); }
.opt.best { background: var(--good-soft); box-shadow: inset 0 0 0 2px var(--good); }
.opt .when { font-size: 13px; color: var(--text-2); font-weight: 600; }
.opt .big { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.opt .co2 { font-size: 14px; color: var(--text-2); }
.saving { margin-top: 12px; font-size: 15px; }
.edit-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--text-2); }
.edit-row input { width: 70px; border: 1px solid var(--border); border-radius: 8px; padding: 3px 6px; background: var(--surface); }

/* Bill X-ray */
.xray-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 10px;
  cursor: pointer; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.drop {
  border: 2px dashed var(--border); border-radius: 12px; padding: 16px; text-align: center; color: var(--text-2);
  margin-top: 12px; transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.tile { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.tile b { display: block; font-size: 22px; letter-spacing: -0.02em; }
.tile span { font-size: 12px; color: var(--text-3); }
.share { display: flex; height: 30px; border-radius: 8px; overflow: hidden; gap: 2px; margin: 14px 0 6px; }
.share div { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #0b0b0b; min-width: 0; overflow: hidden; white-space: nowrap; }
.share .g { background: var(--good); color: #fff; } .share .a { background: var(--warn); } .share .r { background: var(--bad); color: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 10px; }
th, td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
th { font-size: 12px; color: var(--text-3); font-weight: 600; }
tr.win td { font-weight: 700; }
tr.win td:first-child::after { content: "  best fit"; font-size: 11px; color: var(--good-ink); font-weight: 700; }
.shift-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 14px; font-size: 14px; }
.shift-row input[type="range"] { accent-color: var(--accent); width: 180px; }
.result { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--good-soft); }
.result b { font-size: 18px; }

/* Nudges */
.nudge-grid { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
.phone {
  border: 10px solid #1b1b1a; border-radius: 36px; background: var(--surface-2); padding: 18px 12px 22px;
  min-height: 420px;
}
.phone .bar { text-align: center; font-size: 12px; color: var(--text-3); margin-bottom: 10px; }
.sms { background: var(--surface); border-radius: 16px; padding: 10px 12px; margin-bottom: 10px; font-size: 13.5px; line-height: 1.45; box-shadow: var(--shadow); }
.sms .t { font-size: 11px; color: var(--text-3); display: block; margin-bottom: 2px; }
.how li { margin-bottom: 8px; }

/* Footer */
.method { font-size: 13.5px; color: var(--text-2); }
.method h3 { font-size: 14px; color: var(--text); margin: 14px 0 4px; }
.method ul { padding-left: 18px; margin: 4px 0; }
.realsim { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.realsim > div { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; }
footer { text-align: center; font-size: 12px; color: var(--text-3); padding: 20px 0 40px; }

@media (max-width: 860px) {
  .apps { grid-template-columns: repeat(2, 1fr); }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .nudge-grid { grid-template-columns: 1fr; }
  .phone { max-width: 320px; margin: 0 auto; }
  .realsim { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .hero { grid-template-columns: 1fr; }
  .light { grid-template-columns: repeat(3, 1fr); width: 100%; max-width: 240px; }
  .light span { width: 100%; height: auto; aspect-ratio: 1; }
  .compare { grid-template-columns: 1fr; }
  h1 { font-size: 23px; }
  .controls { margin-left: 0; }
  header.top { position: static; }
  .strip-labels { font-size: 10px; }
  .strip-labels span:nth-child(odd) { visibility: hidden; }
}

.impact { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.impact .tile b { font-size: 20px; }
.impact-in { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; margin-top: 16px; }
.impact-in input { width: 110px; border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; background: var(--surface); }
@media (max-width: 560px) { .impact { grid-template-columns: 1fr; } }

.kpi b, .opt .big, .tile b, .result b { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; letter-spacing: -0.02em; }
h1, h2 { text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.strip .p, .share .p, i.hatch { background: repeating-linear-gradient(135deg, var(--warn) 0 5px, color-mix(in srgb, var(--warn) 55%, var(--surface)) 5px 9px); }
i.hatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.prio select { border: 1px solid var(--border); padding: 3px 6px; }
td:first-child { white-space: nowrap; }
.share div { padding: 0 4px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .phone { border-color: #3a3a37; } }
:root[data-theme="dark"] .phone { border-color: #3a3a37; }
.result.worse { background: var(--bad-soft); }
.shift-row select, .prio select { max-width: 100%; min-width: 0; }
.shift-row { min-width: 0; }
