* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: #fafaf7;
  color: #1d1d1f;
  line-height: 1.5;
  font-size: 16px;
}
header {
  background: #dc2626;
  color: white;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark svg { display: block; height: 34px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.08; }
header h1 { margin: 0; font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; }
.tagline { font-size: 0.78rem; font-weight: 400; opacity: 0.92; }
.tagline em { font-style: italic; }
header button {
  background: rgba(255,255,255,0.15); color: white;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
  font-size: 0.85rem; font-family: inherit;
}
header button:hover { background: rgba(255,255,255,0.25); }
main { max-width: 760px; margin: 0 auto; padding: 24px 20px 80px; }
h2 { font-size: 1.5rem; margin: 0 0 12px; letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; margin: 24px 0 8px; }
p  { margin: 0 0 12px; }
.muted { color: #6b6b70; font-size: 0.9rem; }
.center { text-align: center; }

/* Start screen */
.hero { text-align: center; padding: 32px 0 24px; }
.hero-logo { display: block; width: 190px; max-width: 62%; height: auto; margin: 0 auto 4px; }
.hero-tagline { font-size: 1.2rem; color: #dc2626; font-weight: 600; margin-bottom: 16px; letter-spacing: -0.01em; }
.hero-tagline em { font-style: italic; }
.hero h2 { font-size: 2rem; }
.hero p { max-width: 520px; margin: 0 auto 24px; }
.cta-row { display: flex; flex-direction: column; gap: 12px; max-width: 380px; margin: 24px auto 0; }
.btn {
  display: inline-block; padding: 14px 22px; font-size: 1rem; font-family: inherit;
  border: none; border-radius: 10px; cursor: pointer;
  background: #dc2626; color: white; font-weight: 600; letter-spacing: 0.01em;
  transition: transform 0.1s, background 0.15s;
}
.btn:hover { background: #b91c1c; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #2d2d2d; }
.btn.secondary:hover { background: #1a1a1a; }
.btn.ghost { background: transparent; color: #1d1d1f; border: 1px solid #c5c5cc; }
.btn.ghost:hover { background: #f3f3ef; }

.start-meta {
  margin-top: 40px; padding: 16px 20px; background: #f3f3ef;
  border-radius: 10px; font-size: 0.9rem; color: #4b4b50;
}
.start-meta strong { color: #1d1d1f; }
.honest-note {
  max-width: 520px; margin: 18px auto 0; font-size: 0.85rem; color: #6b6b70;
  border-left: 3px solid #dc2626; padding: 6px 0 6px 14px; text-align: left;
}

/* Form */
.progress-wrap {
  position: sticky; top: 0; background: #fafaf7; padding: 12px 0; z-index: 5;
  border-bottom: 1px solid #e7e7e1; margin-bottom: 16px;
}
.progress-bar { height: 6px; background: #e7e7e1; border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: #dc2626; width: 0%; transition: width 0.3s; }
.progress-text { display: flex; justify-content: space-between; font-size: 0.85rem; color: #6b6b70; margin-top: 6px; }

.cat-section { margin: 20px 0; background: white; border-radius: 12px; overflow: hidden; border: 1px solid #e7e7e1; }
.cat-header {
  padding: 14px 18px; font-weight: 600; font-size: 1rem; letter-spacing: 0.02em;
  text-transform: uppercase; color: #1d1d1f; border-bottom: 1px solid rgba(0,0,0,0.06);
}
.cat-body { padding: 16px 18px; }
.question { margin: 0 0 18px; }
.question:last-child { margin-bottom: 0; }
.question.hidden { display: none; }
.q-label { display: block; font-weight: 500; margin-bottom: 6px; color: #1d1d1f; }
.q-help { display: block; font-size: 0.85rem; color: #6b6b70; margin-bottom: 8px; }
.q-input {
  width: 100%; max-width: 320px; padding: 10px 12px; font-size: 1rem; font-family: inherit;
  border: 1px solid #c5c5cc; border-radius: 8px; background: white;
}
.q-input:focus { outline: 2px solid #dc2626; outline-offset: 1px; border-color: transparent; }
.q-unit { display: inline-block; margin-left: 8px; color: #6b6b70; font-size: 0.9rem; }
.q-options { display: flex; flex-direction: column; gap: 6px; }
.q-option {
  display: flex; align-items: center; padding: 8px 12px; border: 1px solid #d8d8d1;
  border-radius: 8px; cursor: pointer; transition: all 0.1s; background: white;
}
.q-option:hover { border-color: #999; }
.q-option input { margin-right: 10px; }
.q-option.selected { border-color: #dc2626; background: #fef2f2; }

.form-actions { margin-top: 28px; text-align: center; }
.form-actions .btn { min-width: 280px; }

/* Results */
.result-card { background: white; border: 1px solid #e7e7e1; border-radius: 12px; padding: 24px; margin-bottom: 20px; }
.total-block { text-align: center; padding: 8px 0; }
.total-number { font-size: 3rem; font-weight: 700; letter-spacing: -0.02em; color: #1d1d1f; line-height: 1; }
.total-unit { color: #6b6b70; margin-top: 4px; font-size: 1rem; }

/* Planetary frame */
.paris-line { margin-top: 14px; font-size: 1.05rem; }
.paris-mult { font-weight: 700; color: #b91c1c; }
.total-msg {
  margin-top: 14px; padding: 8px 16px; border-radius: 8px; display: inline-block;
  font-weight: 500; font-size: 0.9rem;
}
.total-msg.below_target, .total-msg.well_below_avg { background: #d1fae5; color: #065f46; }
.total-msg.below_avg { background: #ecfccb; color: #3f6212; }
.total-msg.near_avg  { background: #fef3c7; color: #78350f; }
.total-msg.above_avg { background: #fed7aa; color: #9a3412; }
.total-msg.high_emitter { background: #fecaca; color: #991b1b; }

.scale { margin: 26px 0 8px; position: relative; height: 56px; }
.scale-bar { height: 10px; background: linear-gradient(to right, #16a34a 0%, #16a34a 14%, #facc15 40%, #ea580c 70%, #b91c1c 100%); border-radius: 5px; margin: 14px 0 4px; }
.scale-marker { position: absolute; top: 8px; width: 2px; height: 22px; background: #1d1d1f; transition: left 0.6s ease-out; }
.scale-marker.you { background: #dc2626; height: 28px; width: 3px; }
.scale-marker-label { position: absolute; top: 36px; transform: translateX(-50%); font-size: 0.72rem; color: #1d1d1f; white-space: nowrap; transition: left 0.6s ease-out; }
.scale-marker-label.you { color: #dc2626; font-weight: 600; }

/* breakdown */
.breakdown-row {
  display: grid; grid-template-columns: 120px 1fr 74px 64px; gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid #f0f0eb; font-size: 0.95rem;
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-label { font-weight: 500; }
.breakdown-bar-wrap { background: #f0f0eb; border-radius: 4px; height: 14px; overflow: hidden; }
.breakdown-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease-out; }
.breakdown-value { text-align: right; font-variant-numeric: tabular-nums; }
.breakdown-dev { text-align: right; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.dev-pos { color: #b91c1c; } .dev-neg { color: #15803d; } .dev-zero { color: #6b6b70; }

/* ===== WHAT-IF MODE ===== */
.whatif-intro { color: #4b4b50; font-size: 0.92rem; margin-bottom: 18px; }
.whatif-hero { text-align: center; margin: 8px 0 18px; }
.whatif-total { font-size: 2.6rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; transition: color 0.3s; }
.whatif-total.win { color: #15803d; }
.whatif-sub { color: #6b6b70; font-size: 0.95rem; margin-top: 4px; }

.stack { display: flex; height: 30px; border-radius: 6px; overflow: hidden; background: #f0f0eb; margin: 18px 0 6px; }
.stack-seg { height: 100%; transition: width 0.55s ease-out; }
.stack-scaleline { position: relative; height: 34px; margin-bottom: 8px; }
.stack-tick { position: absolute; top: 0; width: 2px; height: 12px; background: #1d1d1f; }
.stack-tick-label { position: absolute; top: 13px; transform: translateX(-50%); font-size: 0.7rem; color: #4b4b50; white-space: nowrap; }

.savings-row { display: flex; gap: 12px; justify-content: center; margin: 14px 0 4px; flex-wrap: wrap; }
.savings-pill { background: #f3f3ef; border-radius: 10px; padding: 10px 16px; text-align: center; min-width: 130px; }
.savings-pill .big { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.savings-pill.co2 .big { color: #15803d; }
.savings-pill.chf .big { color: #1c7ed6; }
.savings-pill .lbl { font-size: 0.78rem; color: #6b6b70; }

.whatif-actions { margin-top: 18px; }
.whatif-cat { margin: 14px 0 6px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: #868e96; }
.toggle {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 11px 14px; margin: 6px 0; border: 1px solid #d8d8d1; border-radius: 10px;
  background: white; cursor: pointer; font-family: inherit; font-size: 0.95rem; transition: all 0.12s;
}
.toggle:hover { border-color: #999; }
.toggle.on { border-color: #15803d; background: #f0fdf4; }
.toggle-check {
  flex: 0 0 22px; height: 22px; border-radius: 6px; border: 2px solid #c5c5cc;
  display: grid; place-items: center; font-size: 14px; color: white; transition: all 0.12s;
}
.toggle.on .toggle-check { background: #15803d; border-color: #15803d; }
.toggle-text { flex: 1; }
.toggle-nums { flex: 0 0 auto; text-align: right; font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.toggle-kg { color: #15803d; font-weight: 600; display: block; }
.toggle-chf { color: #1c7ed6; display: block; font-size: 0.8rem; }
.toggle-chf.none { color: #adb5bd; }

.whatif-foot { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* drivers */
.driver { padding: 14px 0; border-bottom: 1px solid #f0f0eb; }
.driver:last-child { border: none; }
.driver h4 { margin: 0 0 6px; font-size: 1rem; letter-spacing: 0.02em; text-transform: uppercase; }
.driver-bench { color: #b91c1c; font-weight: 500; font-size: 0.9rem; }
.driver-actions { margin: 8px 0 0; padding-left: 0; list-style: none; }
.driver-actions li { padding: 6px 0; display: flex; justify-content: space-between; gap: 12px; }
.driver-actions li::before { content: "→ "; color: #dc2626; font-weight: 600; }
.driver-actions .saving { color: #15803d; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 0.9rem; }

/* handprint */
.handprint-intro { color: #4b4b50; font-size: 0.92rem; margin-bottom: 14px; }
.hand-card { border: 1px solid #e7e7e1; border-left: 4px solid #2f9e44; border-radius: 10px; padding: 14px 16px; margin: 10px 0; background: #fbfdfb; }
.hand-card h4 { margin: 0 0 4px; font-size: 1rem; }
.hand-tag { display: inline-block; font-size: 0.72rem; font-weight: 600; color: #2f9e44; background: #e6f4ea; border-radius: 999px; padding: 2px 9px; margin-bottom: 6px; }
.hand-card p { margin: 0; font-size: 0.9rem; color: #4b4b50; }

.legend { font-size: 0.8rem; color: #6b6b70; margin-top: 12px; text-align: center; }
.footer-actions { display: flex; gap: 10px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
footer { text-align: center; font-size: 0.8rem; color: #6b6b70; padding: 24px 20px; }

@media (max-width: 560px) {
  .total-number { font-size: 2.4rem; }
  .whatif-total { font-size: 2.1rem; }
  .breakdown-row { grid-template-columns: 92px 1fr 60px 52px; font-size: 0.88rem; }
  .cta-row { max-width: 100%; }
}

/* ---------- What-if v2: ghost stack, gauge, delta chips ---------- */
.stack-wrap { position: relative; margin: 18px 0 6px; }
.stack-wrap .stack { margin: 0; }
.stack.ghost { position: absolute; inset: 0; z-index: 0; pointer-events: none; background: transparent; }
.stack.ghost .stack-seg { filter: saturate(0); opacity: 0.22; }
.stack-wrap .stack:not(.ghost) { position: relative; z-index: 1; background: transparent; }

.gauge { margin: 4px auto 14px; max-width: 460px; }
.gauge-label { display: flex; justify-content: space-between; font-size: 0.78rem; color: #6b6b70; margin-bottom: 4px; }
.gauge-label #gauge-pct { font-weight: 700; color: #15803d; font-variant-numeric: tabular-nums; }
.gauge-bar { height: 8px; border-radius: 4px; background: #eceae4; overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #74c69d, #15803d); transition: width 0.55s ease-out; }
.gauge-fill.done { background: linear-gradient(90deg, #15803d, #0b5e2b); animation: gauge-pulse 1.2s ease-in-out 2; }
@keyframes gauge-pulse { 50% { filter: brightness(1.35); } }

.wi-deltas { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 4px; }
.delta-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: #3d3d40;
  border: 1px solid #ddd; border-radius: 999px; padding: 3px 10px; background: #fff;
}
.delta-chip strong { font-variant-numeric: tabular-nums; }
.delta-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }

.whatif-total.win { animation: win-pop 0.5s ease-out; }
@keyframes win-pop { 40% { transform: scale(1.12); } }

/* ---------- Save & share ---------- */
.share-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.share-form input {
  flex: 1 1 200px; padding: 10px 12px; border: 1px solid #d8d8d1; border-radius: 8px;
  font: inherit; font-size: 0.92rem; background: #fff;
}
.share-form input:disabled { background: #f3f3ef; color: #6b6b70; }
.share-result {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px;
  background: #f0fdf4; border: 1px solid #bbe5c8; border-radius: 10px; padding: 10px 14px; font-size: 0.92rem;
}
.share-link { font-weight: 700; color: #15803d; word-break: break-all; }
.share-error { margin-top: 10px; color: #b91c1c; font-size: 0.9rem; }
#share-card code { background: #f3f3ef; border-radius: 4px; padding: 1px 5px; font-size: 0.85em; }

@media print {
  header button, .footer-actions, .progress-wrap, .whatif-actions, .whatif-foot,
  #share-card, .stack.ghost, .gauge { display: none !important; }
  header { background: #dc2626 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .result-card { break-inside: avoid; border-color: #ccc; }
  .breakdown-bar-fill, .scale-bar, .total-msg, .stack-seg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  main { padding-bottom: 0; }
}
