:root {
      --ink: #1a2420;
      --muted: #5c6b64;
      --line: rgba(26, 36, 32, 0.12);
      --paper: #f3f0e8;
      --panel: rgba(255, 252, 246, 0.72);
      --accent: #0f7a5f;
      --accent-2: #c45c26;
      --glow: #e8f5ef;
      --warn: #b45309;
      --radius: 18px;
      --shadow: 0 24px 60px rgba(26, 36, 32, 0.08);
    }

    * { box-sizing: border-box; }
    html { scroll-behavior: smooth; }
    body {
      margin: 0;
      min-height: 100vh;
      color: var(--ink);
      font-family: "Outfit", system-ui, sans-serif;
      background:
        radial-gradient(1200px 600px at 12% -10%, #d9efe6 0%, transparent 55%),
        radial-gradient(900px 500px at 100% 0%, #f6e2d4 0%, transparent 50%),
        linear-gradient(180deg, #f7f4ec 0%, #ebe6db 100%);
    }

    .noise {
      pointer-events: none;
      position: fixed;
      inset: 0;
      opacity: 0.035;
      background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
      z-index: 0;
    }

    .wrap {
      position: relative;
      z-index: 1;
      width: min(1180px, calc(100% - 2rem));
      margin: 0 auto;
      padding: 1.5rem 0 4rem;
    }

    header.top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      margin-bottom: 1.75rem;
    }

    .brand {
      display: flex;
      align-items: baseline;
      gap: 0.65rem;
    }
    .brand strong {
      font-family: "Fraunces", Georgia, serif;
      font-size: 1.55rem;
      font-weight: 700;
      letter-spacing: -0.02em;
    }
    .brand span {
      color: var(--muted);
      font-size: 0.85rem;
      font-weight: 400;
    }

    .chip {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
      padding: 0.35rem 0.75rem;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: rgba(255,255,255,0.5);
      color: var(--muted);
      font-size: 0.78rem;
    }
    .chip i {
      width: 7px; height: 7px; border-radius: 50%;
      background: var(--accent);
      box-shadow: 0 0 0 4px rgba(15,122,95,0.15);
    }

    /* Hero composition: résultat + une phrase + contrôles collés */
    .hero {
      display: grid;
      grid-template-columns: 1.05fr 0.95fr;
      gap: 1.5rem;
      align-items: stretch;
      min-height: min(78vh, 720px);
    }

    .result {
      position: relative;
      overflow: hidden;
      border-radius: calc(var(--radius) + 6px);
      padding: 2rem 2rem 1.5rem;
      background:
        linear-gradient(160deg, rgba(15,122,95,0.12), transparent 42%),
        linear-gradient(20deg, rgba(196,92,38,0.08), transparent 35%),
        var(--panel);
      border: 1px solid var(--line);
      box-shadow: var(--shadow);
      backdrop-filter: blur(10px);
      display: flex;
      flex-direction: column;
    }

    .result::before {
      content: "";
      position: absolute;
      right: -80px; top: -80px;
      width: 280px; height: 280px;
      border-radius: 50%;
      background: radial-gradient(circle, rgba(15,122,95,0.18), transparent 70%);
      animation: pulse 6s ease-in-out infinite;
    }

    @keyframes pulse {
      0%, 100% { transform: scale(1); opacity: 0.8; }
      50% { transform: scale(1.12); opacity: 1; }
    }

    .eyebrow {
      position: relative;
      font-size: 0.78rem;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: var(--accent);
      font-weight: 500;
      margin-bottom: 0.85rem;
    }

    .result h1 {
      position: relative;
      margin: 0;
      font-family: "Fraunces", Georgia, serif;
      font-weight: 500;
      font-size: clamp(1.7rem, 3.2vw, 2.35rem);
      line-height: 1.15;
      letter-spacing: -0.03em;
      max-width: 16ch;
    }

    .result p.lead {
      position: relative;
      margin: 0.9rem 0 0;
      color: var(--muted);
      font-size: 1.02rem;
      line-height: 1.45;
      max-width: 34ch;
    }

    .kwh-block {
      position: relative;
      margin-top: auto;
      padding-top: 2rem;
    }

    .kwh-label {
      font-size: 0.82rem;
      color: var(--muted);
      margin-bottom: 0.25rem;
    }

    .kwh {
      display: flex;
      align-items: baseline;
      gap: 0.45rem;
      font-family: "Fraunces", Georgia, serif;
      font-size: clamp(3.4rem, 7vw, 5.2rem);
      font-weight: 700;
      letter-spacing: -0.04em;
      line-height: 1;
      transition: color 0.35s ease;
    }
    .kwh em {
      font-style: normal;
      font-size: 0.32em;
      font-family: "Outfit", sans-serif;
      font-weight: 500;
      color: var(--muted);
      letter-spacing: 0;
    }

    .delta-row {
      display: flex;
      flex-wrap: wrap;
      gap: 0.6rem;
      margin-top: 1.1rem;
    }

    .delta {
      padding: 0.55rem 0.85rem;
      border-radius: 12px;
      background: rgba(255,255,255,0.65);
      border: 1px solid var(--line);
      font-size: 0.88rem;
    }
    .delta b { font-weight: 600; }
    .delta.up b { color: var(--accent-2); }
    .delta.down b { color: var(--accent); }
    .delta.neutral b { color: var(--ink); }

    .chart-wrap {
      position: relative;
      margin-top: 1.4rem;
      padding-top: 0.85rem;
      border-top: 1px solid var(--line);
    }
    .chart-wrap h3 {
      margin: 0 0 0.65rem;
      font-size: 0.8rem;
      font-weight: 500;
      color: var(--muted);
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }
    canvas#dayChart {
      width: 100%;
      height: 110px;
      display: block;
    }

    /* Controls panel */
    .controls {
      border-radius: calc(var(--radius) + 6px);
      background: var(--panel);
      border: 1px solid var(--line);
      box-shadow: var(--shadow);
      backdrop-filter: blur(10px);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .tabs {
      display: grid;
      grid-template-columns: 1fr 1fr;
      border-bottom: 1px solid var(--line);
    }
    .tabs button {
      appearance: none;
      border: 0;
      background: transparent;
      padding: 1rem 1.1rem;
      font: inherit;
      font-weight: 500;
      color: var(--muted);
      cursor: pointer;
      transition: background 0.2s, color 0.2s;
    }
    .tabs button[aria-selected="true"] {
      color: var(--ink);
      background: rgba(15,122,95,0.08);
      box-shadow: inset 0 -2px 0 var(--accent);
    }

    .pane {
      display: none;
      padding: 1.25rem 1.35rem 1.5rem;
      overflow-y: auto;
      flex: 1;
    }
    .pane.active { display: block; }

    .section-title {
      margin: 0 0 1rem;
      font-size: 0.75rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--muted);
    }

    .preset-load {
      margin-bottom: 1.15rem;
      padding: 0.85rem 0.95rem;
      border-radius: 14px;
      border: 1px dashed rgba(15, 122, 95, 0.35);
      background: rgba(15, 122, 95, 0.05);
    }
    .preset-load .field-head { margin-bottom: 0.45rem; }
    .preset-status {
      margin: 0.55rem 0 0;
      font-size: 0.78rem;
      color: var(--muted);
      line-height: 1.35;
    }
    .preset-status strong { color: var(--accent); font-weight: 600; }

    .field {
      margin-bottom: 1.15rem;
    }
    .field:last-child { margin-bottom: 0; }

    .field-head {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      gap: 0.75rem;
      margin-bottom: 0.45rem;
    }
    .field-head label {
      font-size: 0.92rem;
      font-weight: 500;
    }
    .field-head output {
      font-variant-numeric: tabular-nums;
      font-size: 0.9rem;
      color: var(--accent);
      font-weight: 600;
    }

    input[type="range"] {
      -webkit-appearance: none;
      appearance: none;
      width: 100%;
      height: 6px;
      border-radius: 999px;
      background: linear-gradient(90deg, var(--accent), #7bbfa9);
      outline: none;
    }
    input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 20px; height: 20px;
      border-radius: 50%;
      background: #fff;
      border: 2px solid var(--accent);
      box-shadow: 0 4px 12px rgba(15,122,95,0.25);
      cursor: grab;
      transition: transform 0.15s ease;
    }
    input[type="range"]::-webkit-slider-thumb:active {
      transform: scale(1.12);
      cursor: grabbing;
    }

    .range-ends {
      display: flex;
      justify-content: space-between;
      margin-top: 0.25rem;
      font-size: 0.72rem;
      color: var(--muted);
    }

    select, input[type="datetime-local"] {
      width: 100%;
      padding: 0.7rem 0.85rem;
      border-radius: 12px;
      border: 1px solid var(--line);
      background: rgba(255,255,255,0.75);
      font: inherit;
      color: var(--ink);
      outline: none;
      transition: border-color 0.2s, box-shadow 0.2s;
    }
    select:focus, input[type="datetime-local"]:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(15,122,95,0.15);
    }

    .row-2 {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 0.85rem;
    }

    .hint {
      margin-top: 1.1rem;
      padding: 0.85rem 0.95rem;
      border-radius: 12px;
      background: rgba(15,122,95,0.07);
      color: var(--muted);
      font-size: 0.82rem;
      line-height: 1.4;
    }
    .hint strong { color: var(--ink); font-weight: 500; }

    .actions {
      display: flex;
      gap: 0.65rem;
      margin-top: 1.2rem;
    }
    .btn {
      appearance: none;
      border: 0;
      border-radius: 999px;
      padding: 0.75rem 1.15rem;
      font: inherit;
      font-weight: 500;
      cursor: pointer;
      transition: transform 0.15s, background 0.2s, color 0.2s;
    }
    .btn:active { transform: scale(0.98); }
    .btn-primary {
      background: var(--ink);
      color: #f7f4ec;
      flex: 1;
    }
    .btn-primary:hover { background: #0f1a16; }
    .btn-ghost {
      background: transparent;
      border: 1px solid var(--line);
      color: var(--muted);
    }
    .btn-ghost:hover { color: var(--ink); background: rgba(255,255,255,0.5); }

    /* Second section: scenario story */
    .story {
      margin-top: 2.5rem;
      display: grid;
      grid-template-columns: 1.2fr 0.8fr;
      gap: 1.25rem;
    }
    .story article {
      padding: 1.5rem 1.6rem;
      border-radius: var(--radius);
      border: 1px solid var(--line);
      background: rgba(255,252,246,0.55);
    }
    .story h2 {
      margin: 0 0 0.5rem;
      font-family: "Fraunces", Georgia, serif;
      font-weight: 500;
      font-size: 1.35rem;
    }
    .story p {
      margin: 0;
      color: var(--muted);
      line-height: 1.5;
      font-size: 0.95rem;
    }
    .presets {
      display: flex;
      flex-direction: column;
      gap: 0.65rem;
    }
    .preset {
      text-align: left;
      padding: 0.95rem 1.05rem;
      border-radius: 14px;
      border: 1px solid var(--line);
      background: rgba(255,255,255,0.55);
      cursor: pointer;
      font: inherit;
      transition: border-color 0.2s, background 0.2s, transform 0.15s;
    }
    .preset:hover {
      border-color: rgba(15,122,95,0.35);
      background: rgba(15,122,95,0.06);
      transform: translateY(-1px);
    }
    .preset strong {
      display: block;
      font-weight: 600;
      margin-bottom: 0.2rem;
    }
    .preset span {
      color: var(--muted);
      font-size: 0.82rem;
    }

    footer.note {
      margin-top: 2rem;
      color: var(--muted);
      font-size: 0.8rem;
      line-height: 1.45;
    }
    footer.note code {
      font-size: 0.78em;
      background: rgba(0,0,0,0.05);
      padding: 0.1em 0.35em;
      border-radius: 4px;
    }

    @media (max-width: 900px) {
      .hero, .story { grid-template-columns: 1fr; min-height: 0; }
      .result { min-height: auto; }
      .kwh-block { margin-top: 2rem; }
      .row-2 { grid-template-columns: 1fr; }
    }
