/* ==========================================================================
   Espaces partagés + composants communs des cartes (cards.js) + éditeur
   ========================================================================== */

/* ---------------------------------------------------------------- Icônes Lucide (trait) */

/* Les règles « svg { fill: currentColor } » des composants ne doivent pas remplir les icônes au trait */
svg.icon {
  fill: none !important;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav__icon, [data-icon] { display: inline-grid; place-items: center; }

/* ---------------------------------------------------------------- Fonds (glows) */

[data-bg] { --glow1: transparent; --glow2: transparent; --glow3: transparent; }
[data-bg="aurora"]   { --glow1: rgb(124 58 237 / .38); --glow2: rgb(6 182 212 / .34);  --glow3: rgb(34 197 94 / .22); }
[data-bg="sunset"]   { --glow1: rgb(249 115 22 / .40); --glow2: rgb(236 72 153 / .34); --glow3: rgb(250 204 21 / .24); }
[data-bg="ocean"]    { --glow1: rgb(14 165 233 / .40); --glow2: rgb(37 99 235 / .34);  --glow3: rgb(20 184 166 / .24); }
[data-bg="forest"]   { --glow1: rgb(22 163 74 / .36);  --glow2: rgb(101 163 13 / .28); --glow3: rgb(13 148 136 / .24); }
[data-bg="lavender"] { --glow1: rgb(168 85 247 / .36); --glow2: rgb(236 72 153 / .26); --glow3: rgb(99 102 241 / .28); }
[data-bg="ember"]    { --glow1: rgb(239 68 68 / .36);  --glow2: rgb(249 115 22 / .34); --glow3: rgb(180 83 9 / .26); }
[data-bg="graphite"] { --glow1: rgb(100 116 139 / .30); --glow2: rgb(51 65 85 / .30); --glow3: rgb(148 163 184 / .18); }
[data-bg="accent"]   {
  --glow1: color-mix(in srgb, var(--accent) 42%, transparent);
  --glow2: color-mix(in srgb, var(--accent) 24%, transparent);
  --glow3: color-mix(in srgb, var(--accent) 16%, transparent);
}

/* ---------------------------------------------------------------- Thème d'un espace */

.space {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: rgb(15 23 42 / .05);
  --border: rgb(15 23 42 / .08);
  --border-strong: rgb(15 23 42 / .16);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #6366f1;
  --accent-text: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent);
  --on: #f59e0b;
  --on-soft: rgb(245 158 11 / .16);
  --error: #dc2626;
  --error-soft: rgb(220 38 38 / .12);
  --ok: #059669;
  --ok-soft: rgb(5 150 105 / .12);
  --shadow: 0 1px 2px rgb(15 23 42 / .04), 0 8px 24px rgb(15 23 42 / .06);
  --radius: 20px;
  --radius-sm: 13px;
  --gap: 14px;
  --pad: 16px;
  --font: "Albert Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  position: relative;
  color: var(--text);
  font-family: var(--font);
  --glows:
    radial-gradient(60rem 38rem at 8% -12%, var(--glow1), transparent 62%),
    radial-gradient(52rem 36rem at 96% -4%, var(--glow2), transparent 60%),
    radial-gradient(64rem 40rem at 50% 115%, var(--glow3), transparent 62%);
  background-color: var(--bg);
  background-image: var(--glows);
  color-scheme: light;
}

.space[data-appearance="dark"],
:root[data-theme="dark"] .space[data-appearance="auto"] {
  --bg: #080b15;
  --surface: #131829;
  --surface-2: rgb(255 255 255 / .06);
  --border: rgb(255 255 255 / .08);
  --border-strong: rgb(255 255 255 / .18);
  --text: #eef1f8;
  --muted: #8f99b5;
  --on: #fbbf24;
  --on-soft: rgb(251 191 36 / .16);
  --error: #f87171;
  --error-soft: rgb(248 113 113 / .15);
  --ok: #34d399;
  --ok-soft: rgb(52 211 153 / .14);
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .space[data-appearance="auto"] {
    --bg: #080b15;
    --surface: #131829;
    --surface-2: rgb(255 255 255 / .06);
    --border: rgb(255 255 255 / .08);
    --border-strong: rgb(255 255 255 / .18);
    --text: #eef1f8;
    --muted: #8f99b5;
    --on: #fbbf24;
    --on-soft: rgb(251 191 36 / .16);
    --error: #f87171;
    --error-soft: rgb(248 113 113 / .15);
    --ok: #34d399;
    --ok-soft: rgb(52 211 153 / .14);
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

.space[data-radius="sharp"] { --radius: 8px; --radius-sm: 6px; }
.space[data-radius="round"] { --radius: 30px; --radius-sm: 18px; }
.space[data-density="compact"] { --gap: 10px; --pad: 12px; }
.space[data-font="rounded"] { --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, sans-serif; }
.space[data-font="serif"] { --font: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif; }
.space[data-font="mono"] { --font: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace; }

/* Style des cartes */
.space .card { border-radius: var(--radius); padding: var(--pad); gap: calc(var(--pad) * .8); }
.space[data-cards="glass"] .card {
  background: color-mix(in srgb, var(--surface) 64%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 7%, transparent);
  box-shadow: var(--shadow);
  /* Derrière les cartes, seulement les dégradés du fond, déjà flous : un flou n'y changerait rien et coûte cher
     à chaque défilement ; la saturation suffit à l'effet « verre » */
  -webkit-backdrop-filter: saturate(170%);
  backdrop-filter: saturate(170%);
}
.space[data-cards="solid"] .card { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.space[data-cards="outline"] .card { background: transparent; border: 1.5px solid var(--border-strong); box-shadow: none; }
.space .card__icon { border-radius: calc(var(--radius-sm) - 1px); }

/* ---------------------------------------------------------------- Page espace */

body.is-immersive { background: #080b15; }
/* overflow-x: clip (et non hidden) : rien ne peut élargir la page, sans casser l'en-tête collant (position: sticky).
   Sur mobile, un contenu trop large fait sinon dézoomer la page, avec une bande vide à droite */
body.is-immersive > .space { min-height: 100vh; isolation: isolate; background: none; overflow-x: clip; }
/* Fond fixe sur son propre calque : peint une fois, au lieu d'être redessiné à chaque défilement (background-attachment: fixed) */
body.is-immersive > .space::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-color: var(--bg); background-image: var(--glows);
}

/* Menu du bas (templates/_space_nav.php) : barre flottante, onglets, menus Espaces et Compte */
.space-nav {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom)); width: min(calc(100% - 24px), 520px);
  --nav-ink: color-mix(in srgb, var(--accent) 60%, var(--text)); /* accent lisible sur fond clair comme sombre */
}
/* Voile derrière un menu ouvert : un clic dessus le ferme (shell.js, [data-dropdown]) */
.space-nav:has(details[open])::before {
  content: ""; position: fixed; inset: -100vh -100vw; z-index: -1;
  background: rgb(3 7 18 / .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.space-nav__bar {
  position: relative; display: flex; gap: 4px; padding: 6px; border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 72%, transparent); border: 1px solid var(--border);
  box-shadow: 0 18px 40px rgb(0 0 0 / .35);
  -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
}
.space-nav__bar > * { flex: 1 1 0; min-width: 0; }
.space-nav__tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px;
  padding: 4px 0; border-radius: 18px; color: var(--muted); text-decoration: none; list-style: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.space-nav__tab::-webkit-details-marker { display: none; }
.space-nav__tab:hover { text-decoration: none; color: var(--text); }
.space-nav__tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.space-nav__pill {
  display: grid; place-items: center; width: 54px; height: 30px; border-radius: 999px; transition: background .2s, color .2s;
}
.space-nav__pill svg { width: 22px; height: 22px; }
.space-nav__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .7rem; font-weight: 650; letter-spacing: .01em; }
.space-nav__tab.is-active, .space-nav__menu[open] > .space-nav__tab { color: var(--text); }
.space-nav__tab.is-active .space-nav__pill, .space-nav__menu[open] > .space-nav__tab .space-nav__pill { background: var(--accent-soft); color: var(--nav-ink); }
/* Un menu ouvert prend la place de l'onglet actif */
.space-nav:has(details[open]) .space-nav__tab.is-active { color: var(--muted); }
.space-nav:has(details[open]) .space-nav__tab.is-active .space-nav__pill { background: none; color: inherit; }
.space-nav__avatar {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: .68rem; font-weight: 700; letter-spacing: .02em;
}
.space-nav__avatar--lg { width: 44px; height: 44px; font-size: .92rem; flex: none; }

/* Panneaux des menus : au-dessus de la barre, sur toute sa largeur */
.space-nav__panel {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 10px);
  display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 22px;
  max-height: calc(100vh - 140px - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 24px 60px rgb(0 0 0 / .45);
  animation: space-nav-in .18s ease;
}
@keyframes space-nav-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .space-nav__panel { animation: none; } }
.space-nav__head { display: flex; align-items: center; gap: 12px; padding: 6px 6px 14px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.space-nav__who { display: flex; flex-direction: column; min-width: 0; }
.space-nav__who strong, .space-nav__who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-nav__who strong { font-size: 1rem; font-weight: 650; }
.space-nav__who span { font-size: .82rem; color: var(--muted); }
.space-nav__section { font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 10px 8px 4px; }
.space-nav__item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 8px; border: 0; border-radius: 12px;
  font: inherit; font-size: .95rem; font-weight: 600; color: var(--text); background: none; cursor: pointer; text-align: left; text-decoration: none;
}
.space-nav__item:hover { background: var(--surface-2); text-decoration: none; }
.space-nav__item [data-icon] { display: grid; place-items: center; color: var(--muted); flex: none; }
.space-nav__item svg { width: 19px; height: 19px; }
.space-nav__item.is-active { background: var(--accent-soft); color: var(--nav-ink); }
.space-nav__item.is-active [data-icon] { color: inherit; }
.space-nav__item--danger, .space-nav__item--danger [data-icon] { color: var(--error); }
.space-nav__item--danger:hover { background: var(--error-soft); }
.space-nav__panel form { margin: 0; }
.space-nav__sep { height: 1px; margin: 6px 0; background: var(--border); }
/* Thème : Auto / Clair / Sombre (shell.js, [data-theme-set]) */
.space-nav__themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; margin: 0 6px 8px; border-radius: 14px; background: var(--surface-2); }
.space-nav__theme {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border: 0; border-radius: 11px;
  font: inherit; font-size: .88rem; font-weight: 650; color: var(--muted); background: none; cursor: pointer;
}
.space-nav__theme svg { width: 17px; height: 17px; }
.space-nav__theme[aria-pressed="true"] { background: var(--accent-soft); color: var(--nav-ink); }

/* Home Assistant injoignable : bandeau en haut de la page */
.space-status {
  display: inline-block; margin-bottom: 14px; font-size: .8rem; font-weight: 600; padding: 5px 12px; border-radius: 999px;
  background: var(--error-soft); color: var(--error);
}

/* En haut : sous la barre d'état du téléphone (PWA plein écran) ; en bas : place pour le menu */
.space-main { max-width: none; margin: 0; padding: calc(22px + env(safe-area-inset-top)) 16px calc(104px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .space-main { padding: calc(36px + env(safe-area-inset-top)) 36px calc(112px + env(safe-area-inset-bottom)); } }

.space-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.space-hero__greeting { margin: 0 0 4px; font-weight: 600; color: var(--accent); letter-spacing: .01em; }
.space-hero__title { margin: 0; font-size: clamp(1.9rem, 4.5vw, 3rem); font-weight: 750; letter-spacing: -.035em; line-height: 1.05; }
.space-hero__desc { margin: 8px 0 0; color: var(--muted); max-width: 60ch; }
.space-hero__side { display: flex; align-items: center; gap: 14px; }

.space-clock { display: flex; flex-direction: column; align-items: flex-end; }
.space-clock__time { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.space-clock__date { font-size: .85rem; color: var(--muted); }
.space-clock__date::first-letter { text-transform: uppercase; }
@media (max-width: 640px) {
  .space-hero__side { width: 100%; justify-content: space-between; }
  .space-clock { align-items: flex-start; }
}

.space-weather {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 60%, transparent); border: 1px solid var(--border);
}
.space-weather svg { width: 24px; height: 24px; fill: var(--accent); }
.space-weather__temp { font-weight: 700; font-size: 1.1rem; }
.space-weather__label { color: var(--muted); font-size: .85rem; }

.space-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; scrollbar-width: none; }
.space-tab {
  flex: none; font: inherit; font-weight: 600; font-size: .9rem; padding: 9px 16px; border-radius: 999px; cursor: pointer;
  color: var(--text); background: color-mix(in srgb, var(--surface) 55%, transparent); border: 1px solid var(--border);
}
.space-tab.is-active { background: var(--accent); color: var(--accent-text); border-color: transparent; }

.space-section { margin-bottom: 30px; }
.space-section__title { font-size: 1.05rem; font-weight: 650; margin: 0 0 12px; letter-spacing: -.01em; }

.space-empty {
  padding: 48px 20px; text-align: center; color: var(--muted); border-radius: var(--radius);
  border: 1.5px dashed var(--border-strong);
}
.space-empty--small { padding: 18px; grid-column: 1 / -1; }

/* Grille : 2 / 4 / 6 / 8 colonnes, tailles s m l w */
.space-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: dense; align-items: start; gap: var(--gap); }
.space-grid > *, .space-carousel > * { min-width: 0; }
.space-grid > .card--s { grid-column: span 1; }
.space-grid > .card--m, .space-grid > .card--l { grid-column: span 2; }
.space-grid > .card--w { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .space-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .space-grid > .card--l { grid-column: span 3; }
}
@media (min-width: 1040px) { .space-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (min-width: 1440px) {
  .space-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .space-grid > .card--l { grid-column: span 4; }
}
.editor__preview .space-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.editor__preview .space-grid > .card--l { grid-column: span 3; }

.space-carousel {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 290px); gap: var(--gap);
  overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; scrollbar-width: thin;
}
.space-carousel > * { scroll-snap-align: start; }

/* ---------------------------------------------------------------- Cartes : tailles et états */

.card { position: relative; }
.card__head.is-clickable, .card.is-clickable { cursor: pointer; }
.card__titles { min-width: 0; }

.card--s { min-height: 128px; justify-content: space-between; }
.card--s .card__head { flex-direction: column; align-items: flex-start; gap: 12px; height: 100%; }
.card--s .card__name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .93rem; }
.card--s .card__body { display: none; }
.card--s .toggle { position: absolute; top: var(--pad, 14px); right: var(--pad, 14px); }
.card--s .card__fav { position: absolute; bottom: 8px; right: 8px; }

.card--l .metric__value, .card--detail .metric__value { font-size: 2.6rem; }

/* Petites tuiles capteur / thermostat : la valeur en grand, sans graphique ni commandes */
.card--s.card--sensor .card__body, .card--s.card--climate .card__body { display: flex; }
.card--s .gauge, .card--s .card__graph, .card--s .card__controls, .card--s .metric__target,
.card--s .metric .badge, .card--s .metric__unit + .metric__unit { display: none; }
.card--s .gauge-wrap .metric { margin-top: 0; }
.card--s .metric__value { font-size: 1.7rem; }
.card--s.card--sensor .card__head, .card--s.card--climate .card__head { height: auto; }

/* Grand chiffre */
.metric--big { justify-content: center; padding: 10px 0; }
.metric--big .metric__value { font-size: clamp(2.6rem, 6vw, 3.6rem); letter-spacing: -.04em; }
.metric__target { font-size: .85rem; color: var(--muted); font-weight: 600; }

/* Météo détaillée */
.weather-details { display: flex; gap: 14px; color: var(--muted); font-size: .85rem; }
.weather-details span { display: inline-flex; align-items: center; gap: 4px; }
.weather-details svg { width: 15px; height: 15px; fill: currentColor; }

/* Batterie */
.card__line { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.battery {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px 1px 5px; border-radius: 999px;
  font-size: .7rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ok, #059669);
  background: color-mix(in srgb, currentColor 12%, transparent); white-space: nowrap;
}
.battery svg { width: 20px; height: 11px; }
.battery__shell { fill: none; stroke: currentColor; stroke-width: 1.6; }
.battery__tip, .battery__fill { fill: currentColor; }
.battery.is-mid { color: #d97706; }
.battery.is-low { color: var(--error, #dc2626); }

.card.is-on .card__icon { background: var(--on-soft); color: var(--on); }
.card--cover.is-on .card__icon, .card--climate.is-on .card__icon, .card--script.is-on .card__icon { background: var(--accent-soft); color: var(--accent); }
.card.has-color.is-on .card__icon { background: color-mix(in srgb, var(--light-color) 24%, transparent); color: var(--light-color); }
.card.has-color.is-on { box-shadow: 0 10px 34px -12px color-mix(in srgb, var(--light-color) 55%, transparent); }
.card.is-alert { border-color: var(--error) !important; }
.card.is-alert .card__icon { background: var(--error-soft); color: var(--error); }
.card.is-alert .card__state { color: var(--error); font-weight: 600; }

.card__controls { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.card--detail { gap: 18px; }

/* Volets : fenêtre (ciel jour / nuit), volet à lames, caisson, repère de la position visée */
.cover-layout { display: flex; gap: 16px; align-items: stretch; flex: 1; min-width: 0; }
.cover-layout .card__controls { min-width: 0; }
.cover-visual { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cover-pos { font-size: .78rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.shutter {
  --frame: color-mix(in srgb, var(--text) 24%, var(--surface));
  --slat: color-mix(in srgb, var(--text) 42%, var(--surface));
  --slat-gap: color-mix(in srgb, var(--text) 62%, var(--surface));
  position: relative; width: 64px; height: 92px; min-height: 0; border-radius: 10px; overflow: hidden; flex: none;
  border: 3px solid var(--frame); background: var(--surface); user-select: none;
}
.card--l .shutter, .card--w .shutter { width: 76px; height: 108px; }
.card--detail .shutter { width: 116px; height: 164px; border-width: 4px; border-radius: 14px; }
.card--detail .shutter__motion { width: 40px; height: 52px; }
.card--detail .shutter__motion svg { width: 26px; height: 26px; margin: -8px 0; }
.shutter__sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 72% 28%, rgb(255 241 180 / .95) 0 9%, rgb(255 236 170 / .35) 16%, transparent 32%),
    linear-gradient(180deg, #6db8f5 0%, #b7defc 62%, #e6f4ff 100%);
  transition: filter .6s;
}
.shutter.is-night .shutter__sky {
  background:
    radial-gradient(circle at 70% 26%, #f1f5f9 0 7%, transparent 8%),
    radial-gradient(circle at 22% 20%, rgb(255 255 255 / .9) 0 1.5%, transparent 2.5%),
    radial-gradient(circle at 40% 48%, rgb(255 255 255 / .7) 0 1.2%, transparent 2.2%),
    radial-gradient(circle at 84% 62%, rgb(255 255 255 / .7) 0 1.2%, transparent 2.2%),
    linear-gradient(180deg, #0b1533 0%, #1c2a57 100%);
}
/* Croisillons de la fenêtre */
.shutter__frame {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, transparent calc(50% - 1.5px), var(--frame) calc(50% - 1.5px) calc(50% + 1.5px), transparent calc(50% + 1.5px)),
    linear-gradient(180deg, transparent calc(56% - 1.5px), var(--frame) calc(56% - 1.5px) calc(56% + 1.5px), transparent calc(56% + 1.5px));
}
.shutter__blind {
  position: absolute; inset: 0 0 auto 0; height: 0; box-shadow: 0 3px 6px rgb(0 0 0 / .22);
  background: repeating-linear-gradient(180deg, var(--slat) 0 6px, var(--slat-gap) 6px 7.5px);
  transition-property: height; transition-duration: .8s; transition-timing-function: cubic-bezier(.3, .7, .2, 1);
}
.shutter__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--slat-gap); }
.shutter__box { position: absolute; left: 0; right: 0; top: 0; height: 7px; background: var(--frame); box-shadow: 0 1px 2px rgb(0 0 0 / .2); }
/* Lames qui défilent pendant le mouvement */
.shutter.is-opening .shutter__blind { animation: shutter-up .5s linear infinite; }
.shutter.is-closing .shutter__blind { animation: shutter-down .5s linear infinite; }
@keyframes shutter-up { to { background-position: 0 -7.5px; } }
@keyframes shutter-down { to { background-position: 0 7.5px; } }
/* Position visée */
.shutter__target {
  position: absolute; left: 4px; right: 4px; height: 0; border-top: 2px dashed var(--accent); z-index: 2;
  filter: drop-shadow(0 0 2px rgb(0 0 0 / .5)); transition: top .3s ease; pointer-events: none;
}
.shutter__target::after {
  content: ""; position: absolute; right: -4px; top: -5px; border: 4px solid transparent; border-right-color: var(--accent);
}
/* Sens du mouvement */
.shutter__motion {
  position: absolute; left: 50%; top: 50%; z-index: 3; width: 30px; height: 38px; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden;
  border-radius: 999px; color: #fff; background: rgb(15 23 42 / .45); backdrop-filter: blur(2px); pointer-events: none;
}
.shutter__motion.is-up { transform: translate(-50%, -50%) rotate(180deg); }
.shutter__motion svg { width: 20px; height: 20px; margin: -6px 0; stroke-width: 3; animation: shutter-chevron 1s ease-in-out infinite; }
.shutter__motion svg + svg { animation-delay: .18s; }
@keyframes shutter-chevron { 0% { opacity: 0; transform: translateY(-5px); } 45% { opacity: 1; } 100% { opacity: 0; transform: translateY(6px); } }
/* Arrivée : rebond du volet et coche */
.shutter__check { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; opacity: 0; pointer-events: none; }
.shutter__check svg {
  width: 28px; height: 28px; padding: 4px; border-radius: 50%; background: var(--ok); fill: none; stroke: #fff;
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; box-shadow: 0 2px 8px rgb(0 0 0 / .3);
}
.shutter.is-arrived .shutter__check { animation: shutter-check 1.3s ease; }
.shutter.is-arrived .shutter__blind { animation: shutter-bounce .45s ease; }
@keyframes shutter-check { 0% { opacity: 0; transform: scale(.6); } 20% { opacity: 1; transform: scale(1.08); } 35% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes shutter-bounce { 30% { transform: translateY(3px); } 65% { transform: translateY(-1px); } 100% { transform: none; } }
/* Glisser le volet sur la fenêtre */
.shutter.is-draggable { cursor: ns-resize; touch-action: none; transition: border-color .2s; }
.shutter.is-draggable:hover, .shutter.is-grabbed { border-color: var(--accent); }

/* Commandes : le sens en cours s'allume, Stop devient l'action principale */
.cover-buttons .btn--control.is-running { background: var(--accent-soft); color: var(--accent); animation: cover-pulse 1.4s ease-in-out infinite; }
.cover-buttons .btn--control.is-primary { background: var(--accent); color: var(--accent-text); }
@keyframes cover-pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); } }

/* Curseur d'ouverture */
.cover-range { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cover-range__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cover-range__value { font-size: .85rem; font-variant-numeric: tabular-nums; }
.cover-range__ends { display: flex; justify-content: space-between; gap: 8px; font-size: .72rem; color: var(--muted); }
.cover-range__ends span { display: inline-flex; align-items: center; gap: 4px; }
.cover-range__ends svg { width: 13px; height: 13px; }
.cover-range__ticks { position: relative; height: 20px; margin: 0 9px; }
.cover-range__tick {
  position: absolute; top: 2px; transform: translateX(-50%); padding: 1px 6px; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: .68rem; font-weight: 600; color: var(--muted); background: var(--surface-2);
}
.cover-range__tick::before { content: ""; position: absolute; left: 50%; top: -4px; width: 1.5px; height: 4px; background: var(--border-strong); }
.cover-range__tick:hover { color: var(--accent); background: var(--accent-soft); }

/* Petite tuile : mini-fenêtre en haut à droite */
.card--s.card--cover .card__body { display: block; position: absolute; top: var(--pad, 14px); right: var(--pad, 14px); }
.card--s.card--cover .card__controls, .card--s.card--cover .cover-pos { display: none; }
.card--s.card--cover .shutter { width: 34px; height: 46px; border-width: 2px; border-radius: 7px; }
.card--s.card--cover .shutter__box { height: 4px; }
.card--s.card--cover .shutter__motion { width: 18px; height: 24px; }
.card--s.card--cover .shutter__motion svg { width: 13px; height: 13px; margin: -4px 0; }
.card--s.card--cover .shutter__check svg { width: 18px; height: 18px; padding: 2px; }

@media (prefers-reduced-motion: reduce) {
  .shutter.is-opening .shutter__blind, .shutter.is-closing .shutter__blind, .shutter__motion svg,
  .shutter.is-arrived .shutter__blind, .cover-buttons .btn--control.is-running { animation: none; }
}

/* Icônes dans les boutons (ex. « + Ajouter une section ») ; les variantes ci-dessous peuvent les redimensionner */
.btn > svg { width: 18px; height: 18px; fill: currentColor; flex: none; }

/* Boutons de commande */
.btn-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.btn--control { background: var(--surface-2); color: var(--text); border-radius: var(--radius-sm); }
.btn--control:hover { background: var(--accent-soft); border-color: transparent; }
.btn--round { width: 46px; height: 46px; padding: 0; border-radius: 50%; background: var(--surface-2); color: var(--text); flex: none; }
.btn--round svg { width: 22px; height: 22px; fill: currentColor; }
.btn--round span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.card--s.is-action { cursor: pointer; transition: transform .15s; }
.card--s.is-action:active { transform: scale(.97); }
.card--s.is-action .card__icon { background: var(--accent-soft); color: var(--accent); }
.btn--round:hover { background: var(--accent-soft); }
.btn--scene { width: 100%; padding: 12px; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-text); }
.btn--scene svg { width: 18px; height: 18px; fill: currentColor; }
.btn--scene:active { transform: scale(.98); }

.chips--small { margin: 0; padding: 0; gap: 6px; flex-wrap: wrap; overflow: visible; }
.chips--small .chip { padding: 5px 11px; font-size: .78rem; background: var(--surface-2); border-color: transparent; }
.chips--small .chip.is-active { background: var(--accent); color: var(--accent-text); }

/* Curseurs */
.range--kelvin { background: linear-gradient(90deg, #ffae5e, #ffe7c7 45%, #eef4ff 70%, #bcd6ff) !important; }
.range-wrap { min-width: 0; }

/* Couleurs */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; padding: 0; cursor: pointer; flex: none;
  background: var(--swatch, #fff); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong);
  transition: transform .15s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-active { box-shadow: 0 0 0 2px var(--accent); }
.swatch--custom {
  -webkit-appearance: none; appearance: none; background: conic-gradient(#f44, #fd4, #4f8, #4df, #84f, #f4d, #f44);
  padding: 3px; border: 0;
}
.swatch--custom::-webkit-color-swatch-wrapper { padding: 0; }
.swatch--custom::-webkit-color-swatch { border: 2px solid var(--surface); border-radius: 50%; }
.swatch--custom::-moz-color-swatch { border: 2px solid var(--surface); border-radius: 50%; }

/* Thermostat */
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px; border-radius: var(--radius-sm); background: var(--surface-2); }
.stepper__center { display: flex; flex-direction: column; align-items: center; }
.stepper__label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stepper__value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric .badge { margin-left: auto; align-self: center; }

/* Jauge & graphique */
.gauge-wrap { position: relative; display: flex; flex-direction: column; align-items: center; }
.gauge { width: 100%; max-width: 190px; }
.gauge__track, .gauge__value { fill: none; stroke-width: 9; stroke-linecap: round; }
.gauge__track { stroke: var(--surface-2); }
.gauge__value { stroke: var(--accent); transition: stroke-dasharray .6s ease; }
.gauge-wrap .metric { margin-top: -30px; }

.card__graph { min-height: 70px; }
.spark__svg { display: block; width: 100%; height: 70px; overflow: visible; }
.card--detail .spark__svg { height: 150px; }
.spark__line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark__stop { stop-color: var(--accent); }
.spark__scale { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); margin-top: 4px; }
.spark__empty { display: block; font-size: .8rem; color: var(--muted); padding: 20px 0; text-align: center; }

/* ---------------------------------------------------------------- Fiche détaillée & confirmation */

.sheet, .modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet__backdrop, .modal__backdrop { position: absolute; inset: 0; background: rgb(3 7 18 / .5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet__panel {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); color: var(--text); border-radius: 26px 26px 0 0;
  padding: 26px 22px calc(26px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgb(0 0 0 / .3);
  transform: translateY(24px); opacity: 0; transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .2s;
}
.sheet.is-open .sheet__panel { transform: none; opacity: 1; }
.sheet .card { background: transparent !important; border: 0 !important; box-shadow: none !important; padding: 0; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
.sheet .card__head { padding-right: 40px; }
.sheet .card__icon { width: 52px; height: 52px; }
.sheet .card__name { font-size: 1.25rem; white-space: normal; }
.sheet__close {
  position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text); z-index: 1;
}
.sheet__close svg { width: 18px; height: 18px; fill: currentColor; }
@media (min-width: 700px) {
  .sheet, .modal { align-items: center; }
  .sheet__panel { border-radius: 26px; padding-bottom: 26px; }
}

.modal { align-items: center; padding: 16px; }
.modal__box {
  position: relative; width: 100%; max-width: 380px; background: var(--surface); color: var(--text);
  border-radius: 20px; padding: 22px; box-shadow: 0 20px 50px rgb(0 0 0 / .35);
}
.modal__text { margin: 0 0 18px; font-weight: 600; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast { transition: opacity .35s, transform .35s; }
.toast.is-leaving { opacity: 0; transform: translateY(8px); }
body.is-immersive .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); } /* au-dessus du menu du bas */
.toast--success { background: var(--ok, #059669); color: #fff; }

/* ---------------------------------------------------------------- Liste des espaces */

.space-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.space-tile {
  --accent: #6366f1;
  position: relative; overflow: hidden; isolation: isolate; display: flex; align-items: flex-start; gap: 16px;
  min-height: 150px; padding: 22px; border-radius: 22px; color: var(--text); text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
a.space-tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 14px 36px -12px rgb(0 0 0 / .25); }
.space-tile__glow {
  position: absolute; inset: 0; z-index: -1;
  background-image:
    radial-gradient(22rem 14rem at 0% 0%, var(--glow1), transparent 70%),
    radial-gradient(20rem 14rem at 100% 0%, var(--glow2), transparent 70%),
    radial-gradient(22rem 12rem at 50% 120%, var(--glow3), transparent 70%);
}
.space-tile__icon {
  flex: none; display: grid; place-items: center; width: 50px; height: 50px; border-radius: 15px;
  background: var(--accent); color: #fff; box-shadow: 0 8px 20px -8px var(--accent);
}
.space-tile__icon svg { width: 26px; height: 26px; fill: currentColor; }
.space-tile__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.space-tile__name { font-size: 1.15rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.space-tile__desc { color: var(--muted); font-size: .9rem; }
.space-tile__meta { color: var(--muted); font-size: .8rem; margin-top: auto; padding-top: 8px; }
.space-tile__arrow { font-size: 1.3rem; color: var(--muted); align-self: center; }
.space-tile__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.space-tile__actions form { margin: 0; }

/* ---------------------------------------------------------------- Administration : composants */

.segmented {
  display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 20px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.segmented__item {
  font: inherit; font-size: .85rem; font-weight: 600; padding: 7px 14px; border-radius: 9px; border: 0; cursor: pointer;
  color: var(--muted); background: transparent; text-decoration: none; white-space: nowrap;
}
.segmented__item:hover { color: var(--text); text-decoration: none; }
.segmented__item.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.segmented--inline { margin: 0; }
.segmented--wrap { flex-wrap: wrap; }

.member-list { display: flex; flex-direction: column; gap: 8px; }
.member { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; flex-wrap: wrap; }
.member__name { display: flex; flex-direction: column; flex: 1; min-width: 140px; }
.choice { display: inline-flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 10px; }
.choice__item { position: relative; }
.choice__item input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice__item span { display: block; padding: 6px 12px; font-size: .82rem; font-weight: 600; border-radius: 8px; color: var(--muted); }
.choice__item input:checked + span { background: var(--accent); color: var(--accent-text); }
.choice__item input:focus-visible + span { outline: 2px solid var(--accent); }

.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.icon-grid__item {
  position: relative; display: grid; place-items: center; height: 42px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); padding: 0; font: inherit; font-size: .7rem; font-weight: 700;
}
.icon-grid__item svg, .icon-grid__item span svg { width: 22px; height: 22px; fill: currentColor; }
.icon-grid__item input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.icon-grid__item:has(input:checked), .icon-grid__item.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.icon-grid--compact { grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); }
.icon-grid--compact .icon-grid__item { height: 36px; }

.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plain-list li { display: flex; align-items: center; gap: 8px; }
.panel--danger { border-color: color-mix(in srgb, var(--error) 35%, var(--border)); }
fieldset.field { border: 0; padding: 0; margin: 0; }
fieldset.field legend { padding: 0; margin-bottom: 6px; }

/* ---------------------------------------------------------------- Éditeur d'espace (plein écran, templates/admin/space.php) */

.studio { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); }
.studio--editor { height: 100vh; height: 100dvh; overflow: hidden; }
.studio__bar {
  position: sticky; top: 0; z-index: 40; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.studio__back { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px; color: var(--text); background: var(--surface-2); }
.studio__back svg { width: 18px; height: 18px; }
.studio__title { display: flex; flex-direction: column; min-width: 0; margin-right: 6px; }
.studio__title strong { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
.studio__title > span { display: flex; align-items: center; gap: 6px; }
.studio__status { font-size: .78rem; color: var(--muted); }
.studio__status.is-dirty { color: var(--on); font-weight: 600; }
.studio__tabs { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); overflow-x: auto; scrollbar-width: none; }
.studio__tab { padding: 7px 14px; border-radius: 9px; font-size: .88rem; font-weight: 650; color: var(--muted); white-space: nowrap; }
.studio__tab:hover { color: var(--text); text-decoration: none; }
.studio__tab.is-active { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.studio__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.studio__group { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.studio__tool { display: grid; place-items: center; width: 34px; height: 32px; border: 0; border-radius: 9px; color: var(--text); background: none; cursor: pointer; }
.studio__tool svg { width: 17px; height: 17px; }
.studio__tool:disabled { opacity: .35; cursor: default; }
.studio__tool[aria-pressed="true"] { color: var(--accent); background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.studio__flash { margin: 12px 16px 0; }
.studio__page { display: flex; flex-direction: column; gap: 18px; width: 100%; max-width: 860px; margin: 0 auto; padding: 24px 16px 60px; box-sizing: border-box; }

.studio__editor { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.studio__body { display: grid; grid-template-columns: 330px minmax(0, 1fr) 350px; flex: 1; min-height: 0; }
.studio__side, .studio__inspector {
  display: flex; flex-direction: column; gap: 14px; min-height: 0; padding: 16px; overflow-y: auto; overscroll-behavior: contain;
  background: color-mix(in srgb, var(--surface) 55%, var(--bg));
}
.studio__side { border-right: 1px solid var(--border); }
.studio__inspector { border-left: 1px solid var(--border); }
.studio__stage { display: flex; justify-content: center; align-items: flex-start; min-width: 0; padding: 24px; overflow: auto; }
.studio__frame { width: 100%; }
.studio__frame--phone { width: 390px; max-width: 100%; }
.studio__frame .editor__preview { max-height: none; min-height: 600px; }
.studio__frame--phone .editor__preview { border-radius: 34px; }
.studio__frame--phone .editor__preview .space-main { padding: 26px 16px 40px; }
/* Aperçu téléphone : grilles en 2 colonnes, comme sur un vrai téléphone (les media queries suivent la fenêtre) */
.studio__frame--phone .editor__preview .space-grid:not(.space-grid--custom) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.studio__frame--phone .editor__preview .space-grid:not(.space-grid--custom) > .card--m,
.studio__frame--phone .editor__preview .space-grid:not(.space-grid--custom) > .card--l { grid-column: span 2; }
.studio__frame--phone .space-widgets, .studio__frame--phone .space-rooms { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.studio__frame--phone .widget--w { grid-column: 1 / -1; }
.studio__frame--phone .space-hero__side { width: 100%; justify-content: space-between; }
.studio__rooms { margin-bottom: 18px; }
.studio__rooms .space-room { min-height: 84px; font: inherit; text-align: left; cursor: pointer; }
.studio__rooms .space-room.is-active { outline: 2px solid var(--accent); outline-offset: 2px; }
.studio__hint .muted { margin: 0; }
.tree__heading { flex: 1; font-size: .9rem; }
/* Colonne étroite : le titre de la section sur sa ligne, disposition et boutons dessous */
.studio__side .tree__section-head { flex-wrap: wrap; }
.studio__side .tree__title { flex: 1 1 160px; }
.studio__frame--phone .space-clock { align-items: flex-start; }
.tree__empty--action { width: 100%; border: 0; background: none; font: inherit; font-size: .8rem; color: var(--accent); cursor: pointer; }
.studio__lib-tabs { align-self: flex-start; }
.studio__backdrop, .studio__dock { display: none; }

/* Petits écrans : aperçu plein écran ; bibliothèque / style et réglages dans des panneaux qui montent du bas */
@media (max-width: 999px) {
  .studio--editor { height: auto; overflow: visible; }
  .studio__title strong { max-width: 40vw; }
  .studio__tabs { order: 3; width: 100%; }
  .studio__tab { flex: 1; padding: 7px 6px; text-align: center; }
  .studio__view, .studio__devices { display: none; }
  .studio__body { display: block; }
  .studio__stage { padding: 12px 10px calc(100px + env(safe-area-inset-bottom)); }
  .studio__frame--phone, .studio__frame--desktop { width: 100%; }
  .studio__frame .editor__preview { border-radius: 24px; min-height: 0; }
  .studio__side, .studio__inspector {
    position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; max-height: 78vh; padding: 18px 14px calc(96px + env(safe-area-inset-bottom));
    border: 0; border-radius: 24px 24px 0 0; background: var(--surface); box-shadow: 0 -12px 40px rgb(0 0 0 / .3);
    transform: translateY(105%); visibility: hidden; transition: transform .26s cubic-bezier(.2, .8, .2, 1), visibility 0s .26s;
  }
  .studio__editor.is-sheet-side .studio__side, .studio__editor.is-sheet-inspector .studio__inspector { transform: none; visibility: visible; transition: transform .26s cubic-bezier(.2, .8, .2, 1); }
  .studio__backdrop {
    display: block; position: fixed; z-index: 55; inset: 0; border: 0; padding: 0; background: rgb(3 7 18 / .45);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .studio__editor.is-sheet-side .studio__backdrop, .studio__editor.is-sheet-inspector .studio__backdrop { opacity: 1; pointer-events: auto; }
  .studio__dock {
    display: flex; position: fixed; z-index: 65; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom));
    gap: 6px; padding: 6px; border-radius: 22px; border: 1px solid var(--border); box-shadow: 0 18px 40px rgb(0 0 0 / .35);
    background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  }
  .studio__dock-btn {
    display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 0; border-radius: 16px;
    font: inherit; font-size: .95rem; font-weight: 650; color: var(--text); background: none; cursor: pointer;
  }
  .studio__dock-btn svg { width: 18px; height: 18px; }
  .studio__dock-btn[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }
  .studio__dock-btn:disabled { opacity: .4; cursor: default; }
}
@media (prefers-reduced-motion: reduce) {
  .studio__side, .studio__inspector, .studio__backdrop { transition: none !important; }
}

.editor__preview {
  border-radius: 20px; border: 1px solid var(--border); overflow: auto; min-height: 520px;
  box-shadow: 0 20px 50px -20px rgb(0 0 0 / .35);
}
.editor__preview .space-main { padding: 26px 22px 36px; }
.editor__preview .space-hero__title { font-size: 2rem; }
.card.is-preview { cursor: pointer; }
.card.is-preview .card__controls, .card.is-preview .toggle, .card.is-preview .btn--scene, .card.is-preview .card__fav { pointer-events: none; }
.card.is-selected { outline: 3px solid var(--accent); outline-offset: 3px; }

.editor-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.editor-panel__title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.editor-panel--inspector { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor-panel__head { display: flex; align-items: center; gap: 10px; }
.editor-panel__head .tree__label { flex: 1; }

.efield { display: flex; flex-direction: column; gap: 6px; }
.efield__label { font-size: .8rem; font-weight: 600; }
.efield__hint { display: block; margin: 0; font-weight: 400; }
.efield-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.editor-panel .check { align-items: flex-start; }
.editor-panel .check input { margin-top: 2px; flex: none; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.checks .check { font-weight: 500; font-size: .85rem; }

.tree { display: flex; flex-direction: column; gap: 12px; }
.tree__section { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.tree__section-head { display: flex; align-items: center; gap: 6px; padding: 8px; background: var(--surface-2); }
.tree__section-head.is-drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.tree__title { flex: 1; min-width: 0; font-weight: 600 !important; padding: 6px 8px !important; }
.tree__select { width: auto !important; padding: 6px !important; font-size: .8rem !important; }
.tree__grip { display: grid; place-items: center; color: var(--muted); cursor: grab; flex: none; }
.tree__grip svg { width: 18px; height: 18px; fill: currentColor; }
.tree__items { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-height: 40px; }
.tree__items.is-drop-target { background: var(--accent-soft); }
.tree__item {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent; background: var(--surface);
}
.tree__item:hover { border-color: var(--border); }
.tree__item.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.tree__item.is-warning .tree__meta { color: var(--error); }
.tree__item.is-dragging { opacity: .4; }
.tree__item.is-drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.tree__item.is-drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.tree__icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); color: var(--muted); flex: none; }
.tree__icon svg { width: 18px; height: 18px; fill: currentColor; }
.tree__label { display: flex; flex-direction: column; min-width: 0; flex: 1; font-size: .88rem; }
.tree__label > span:first-child, .tree__label > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree__meta { font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree__empty { padding: 10px; font-size: .8rem; color: var(--muted); text-align: center; }

.icon-btn {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; border: 0; flex: none;
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn svg { width: 17px; height: 17px; fill: currentColor; }

.catalog__filters { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.catalog__filters select { width: auto; }
.catalog { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow-y: auto; }
.catalog__row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 9px; }
.catalog__row:hover { background: var(--surface-2); }
.catalog__row.is-used .tree__label > span:first-child { color: var(--muted); }
.catalog__group { padding: 10px 8px 2px; font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.catalog__count { margin: 0; }
.studio__side .catalog { max-height: none; overflow: visible; } /* la colonne défile déjà */
.catalog__row .icon-btn { background: var(--accent-soft); color: var(--accent); }

.swatch-edit { position: relative; }
.swatch__remove {
  position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%; border: 0; padding: 0;
  font-size: 11px; line-height: 16px; background: var(--text); color: var(--bg); cursor: pointer;
}

.bg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bg-grid__item { display: flex; flex-direction: column; gap: 4px; padding: 4px; border-radius: 12px; border: 2px solid transparent; background: none; cursor: pointer; font: inherit; color: var(--text); }
.bg-grid__item.is-active { border-color: var(--accent); }
.bg-grid__swatch { display: block; height: 48px; border-radius: 9px; border: 1px solid var(--border); }
.bg-grid__label { font-size: .74rem; font-weight: 600; }

.nav__icon svg { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- Graphique détaillé (fiche) */

.spark--axis { display: flex; flex-direction: column; gap: 6px; }
.spark__plot { position: relative; touch-action: pan-y; cursor: crosshair; }
.spark__grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.spark__axis { position: relative; height: 16px; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.spark__tick { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.spark__tick.is-first { transform: none; }
.spark__tick.is-last { transform: translateX(-100%); }
.spark__periods { margin-bottom: 2px; }
.spark__cursor {
  position: absolute; top: 0; bottom: 0; width: 1px; transform: translateX(-.5px);
  background: color-mix(in srgb, var(--accent) 55%, transparent); pointer-events: none;
}
.spark__dot {
  position: absolute; width: 10px; height: 10px; border-radius: 50%; transform: translate(-50%, -50%);
  background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); pointer-events: none;
}
.spark__tip {
  position: absolute; top: -8px; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; padding: 5px 9px; border-radius: 9px;
  background: var(--text); color: var(--bg); font-size: .75rem; line-height: 1.25; box-shadow: 0 6px 18px rgb(0 0 0 / .25);
}
.spark__tip strong { font-size: .85rem; }
.sheet .spark--axis { margin-top: 18px; }

/* Graphique à deux sens (import / export, décharge / charge) de part et d'autre de zéro */
.spark--split { --pos: var(--accent); }
.spark__line--pos { stroke: var(--pos); }
.spark__line--neg { stroke: var(--neg, var(--muted)); }
.spark__stop--pos { stop-color: var(--pos); }
.spark__stop--neg { stop-color: var(--neg, var(--muted)); }
.spark__zero { stroke: var(--muted); stroke-width: 1; opacity: .55; vector-effect: non-scaling-stroke; }
.spark__side {
  position: absolute; left: 6px; display: inline-flex; align-items: center; gap: 3px; pointer-events: none;
  padding: 2px 8px 2px 5px; border-radius: 999px; font-size: .7rem; font-weight: 700;
}
.spark__side svg { width: 12px; height: 12px; }
.spark__side--pos { top: 4px; color: var(--pos); background: color-mix(in srgb, var(--pos) 13%, var(--surface)); }
.spark__side--neg { bottom: 4px; color: var(--neg); background: color-mix(in srgb, var(--neg) 13%, var(--surface)); }
.spark__dot.is-neg { background: var(--neg); box-shadow: 0 0 0 1px var(--neg); }

/* ---------------------------------------------------------------- Favoris (en haut de l'espace) */

.space-favorites { margin-bottom: 26px; }
.space-favorites__title {
  display: flex; align-items: center; gap: 6px; margin: 0 0 10px;
  font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.space-favorites__title svg { width: 14px; height: 14px; color: var(--on); }
.space-favorites__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }

.space .card--xs, .card--xs {
  flex-direction: row; align-items: center; min-height: 0;
  padding: 9px 12px; gap: 10px; border-radius: var(--radius-sm);
}
.card--xs .card__head { flex: 1; gap: 10px; min-width: 0; }
.card--xs .card__icon { width: 34px; height: 34px; }
.card--xs .card__icon svg { width: 18px; height: 18px; }
.card--xs .card__name { font-size: .86rem; }
.card--xs .card__state { font-size: .76rem; margin: 0; }
.card--xs .card__body, .card--xs .card__fav, .card--xs .battery { display: none; }
.card--xs .toggle { width: 42px; height: 26px; }
.card--xs .toggle__thumb { width: 20px; height: 20px; }
.card--xs .toggle[aria-checked="true"] .toggle__thumb { transform: translateX(16px); }
.card--xs.is-action, .card--xs.is-clickable { cursor: pointer; }

/* Étoile sur les cartes des espaces */
.space .card__fav { color: color-mix(in srgb, var(--text) 22%, transparent); }
.space .card__fav:hover { color: var(--muted); }
.space .card__fav.is-active { color: var(--on); }
.space .card__fav.is-active svg { fill: currentColor !important; }

/* ---------------------------------------------------------------- Grille libre */

.space-grid--custom { --row: 44px; }
@media (min-width: 1040px) {
  .space-grid--custom {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-auto-rows: var(--row);
    grid-auto-flow: row;
    align-items: stretch;
  }
  .space-grid--custom > .card.is-placed {
    grid-column: var(--gx) / span var(--gw);
    grid-row: var(--gy) / span var(--gh);
    min-height: 0;
    overflow: hidden;
  }
}
/* L'aperçu de l'éditeur montre toujours la disposition « grand écran » */
.editor__preview .space-grid--custom {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-auto-rows: var(--row);
  grid-auto-flow: row;
  align-items: stretch;
}
.editor__preview .space-grid--custom > .card.is-placed {
  grid-column: var(--gx) / span var(--gw);
  grid-row: var(--gy) / span var(--gh);
  min-height: 0;
  overflow: hidden;
}
.grid-cell {
  border-radius: var(--radius-sm);
  border: 1px dashed color-mix(in srgb, var(--text) 13%, transparent);
  pointer-events: none;
}
.card.is-draggable { cursor: grab; touch-action: none; }
.card.is-dragging { cursor: grabbing; z-index: 5; opacity: .9; outline: 2px dashed var(--accent); outline-offset: 2px; }
.grid-resize {
  position: absolute; right: 4px; bottom: 4px; width: 18px; height: 18px; border-radius: 5px; cursor: nwse-resize; z-index: 2;
  background:
    linear-gradient(135deg, transparent 45%, var(--muted) 45% 52%, transparent 52% 62%, var(--muted) 62% 69%, transparent 69%);
  opacity: .7;
}
.grid-resize:hover { opacity: 1; background-color: var(--surface-2); }

/* ---------------------------------------------------------------- Thème & installation */

.theme-toggle, .install-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; min-width: 32px; padding: 0 8px; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: .8rem; font-weight: 600; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
}
.theme-toggle svg, .install-btn svg { width: 17px; height: 17px; }
.theme-toggle:hover, .install-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav__tools { display: flex; gap: 6px; width: 100%; }
.nav__tools .install-btn { flex: 1; }
@media (max-width: 899px) { .nav__tools { display: none; } }

/* « Grand chiffre » dans une petite tuile : même taille que la valeur standard */
.card--s .metric--big { justify-content: flex-start; padding: 0; }
.card--s .metric--big .metric__value { font-size: 1.7rem; }

/* ---------------------------------------------------------------- Flux d'énergie (capteur, affichage « energy ») */

@property --p1 { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@property --p2 { syntax: '<percentage>'; inherits: false; initial-value: 0%; }

.card--energy .card__body { flex: 1; min-height: 0; }
.card--s.card--energy .card__body { display: flex; }
.card--s.card--energy .card__head { height: auto; }
.energy {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; flex: 1; min-height: 0; align-self: stretch;
  container-name: energy; container-type: inline-size;
}

/* Zone 4:3 : les pôles (HTML) sont placés en % par-dessus le tracé SVG (repère 400 × 300) */
.energy-flow {
  position: relative; width: min(100%, 460px); aspect-ratio: 4 / 3; margin: 0 auto; flex: none;
  container-type: inline-size;
}
/* Grille libre (grand écran et aperçu) : la zone s'adapte aussi à la hauteur de la carte */
@media (min-width: 1040px) {
  .space-grid--custom > .card--energy.is-placed .energy { container-type: size; }
  .space-grid--custom > .card--energy.is-placed .energy-flow { width: min(100%, 460px, calc((100cqh - 34px) * 4 / 3)); }
  .space-grid--custom > .card--energy.is-placed .energy-flow--flat { width: min(100%, 460px, calc((100cqh - 34px) * 400 / 170)); }
}
.editor__preview .space-grid--custom > .card--energy.is-placed .energy { container-type: size; }
.editor__preview .space-grid--custom > .card--energy.is-placed .energy-flow { width: min(100%, 460px, calc((100cqh - 34px) * 4 / 3)); }
.editor__preview .space-grid--custom > .card--energy.is-placed .energy-flow--flat { width: min(100%, 460px, calc((100cqh - 34px) * 400 / 170)); }

.energy-flow--flat { aspect-ratio: 400 / 170; }
.energy-flow__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
/* Liaisons : discrètes au repos, teintées de la couleur de la source quand l'énergie y circule */
.energy-line {
  fill: none; stroke: color-mix(in srgb, var(--border-strong) 55%, transparent); stroke-width: 2; stroke-linecap: round;
  transition: stroke .5s, stroke-width .5s;
}
.energy-line.is-active { stroke: color-mix(in srgb, var(--c) 32%, transparent); stroke-width: 3; }
/* Points animés : redessinés à chaque image, donc sans filtre (lueur coûteuse) et dans un calque à part */
.energy-dots {
  fill: none; stroke: var(--c); stroke-width: var(--w, 6); stroke-linecap: round;
  stroke-dasharray: 0 18; opacity: 0; transition: opacity .4s, stroke-width .6s;
}
.energy-dots.is-flowing { opacity: 1; animation: energy-flow var(--dur, 1s) linear infinite; }
.energy-dots.is-reverse { animation-direction: reverse; }
@keyframes energy-flow { to { stroke-dashoffset: -18; } }
/* Calque des éléments animés : couche à part, l'illustration en dessous n'est pas redessinée */
.energy-motion { pointer-events: none; will-change: transform; }
/* Carte hors de l'écran : animations en pause */
.is-offscreen *, .is-offscreen *::before, .is-offscreen *::after { animation-play-state: paused !important; }

/* Puissance d'un trajet, posée sur sa liaison */
.energy-link {
  position: absolute; z-index: 1; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap;
  padding: .35cqw 1.4cqw; border-radius: 999px; font-size: clamp(.56rem, 2.5cqw, .74rem); font-weight: 700;
  font-variant-numeric: tabular-nums; color: color-mix(in srgb, var(--c) 70%, var(--text));
  background: color-mix(in srgb, var(--c) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  box-shadow: 0 2px 8px rgb(0 0 0 / .08);
  animation: energy-link-in .35s ease;
}
@keyframes energy-link-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.85); } }
@container (max-width: 300px) { .energy-link { display: none; } }

.energy-node {
  position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%);
  width: 23cqw; display: flex; flex-direction: column; align-items: center;
}
.energy-node__disc {
  --ring: var(--c);
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 50%; padding: 1cqw;
  background: var(--ring);
  transition: box-shadow .4s, opacity .4s;
}
.energy-node__inner {
  position: relative; height: 100%; border-radius: 50%; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2cqw;
  background: color-mix(in srgb, var(--c) 10%, var(--surface));
  text-align: center; line-height: 1.1;
}
.energy-node__inner svg { width: 6.5cqw; height: 6.5cqw; color: var(--c); position: relative; }
.energy-node__value { position: relative; font-size: clamp(.68rem, 4.1cqw, 1.15rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; white-space: nowrap; }
.energy-node__sub { position: relative; font-size: clamp(.58rem, 2.8cqw, .8rem); font-weight: 600; color: var(--muted); white-space: nowrap; }
.energy-node__sub[data-dir="import"] { color: var(--c-grid, var(--c)); }
.energy-node__sub[data-dir="export"] { color: var(--c-export); }
.energy-node__label {
  position: absolute; top: 100%; margin-top: 1.2cqw; font-size: clamp(.62rem, 3cqw, .85rem); font-weight: 600; color: var(--muted);
  white-space: nowrap;
}
/* Pôles du haut et du bas : libellé à droite du disque (le tracé passe dessous / dessus) */
.energy-node--solar .energy-node__label, .energy-node--battery .energy-node__label {
  top: 50%; left: 100%; margin: 0 0 0 1.6cqw; transform: translateY(-50%);
}

.energy-node.is-unknown .energy-node__disc { opacity: .55; }
/* Onde autour d'un pôle actif : anneau agrandi et estompé (transform / opacity, sans redessin) */
.energy-node__disc::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 50%; pointer-events: none;
  background: color-mix(in srgb, var(--c) 45%, transparent); opacity: 0;
}
.energy-node.is-active .energy-node__disc::after { animation: energy-pulse 2.6s ease-out infinite; }
@keyframes energy-pulse {
  0%   { opacity: 1; transform: scale(1); }
  70%  { opacity: 0; transform: scale(1.28); }
  100% { opacity: 0; transform: scale(1.28); }
}

/* Maison : anneau réparti entre solaire, batterie et réseau */
.energy-node--home .energy-node__disc.has-mix {
  --ring: conic-gradient(
    var(--c-solar, var(--c)) 0 var(--p1),
    var(--c-battery, var(--c)) var(--p1) var(--p2),
    var(--c-grid, var(--border-strong)) var(--p2) 100%
  );
  transition: --p1 .8s ease, --p2 .8s ease, box-shadow .4s;
}

/* Batterie : niveau de charge en fond du disque */
.energy-node--battery.has-soc .energy-node__inner::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--soc, 0%);
  background: color-mix(in srgb, var(--c) 24%, transparent);
  transition: height .8s ease;
}
.energy-node--battery.is-charging.has-soc .energy-node__inner::before {
  background: linear-gradient(0deg, color-mix(in srgb, var(--c) 30%, transparent), color-mix(in srgb, var(--c) 14%, transparent));
  animation: energy-charge 2.4s ease-in-out infinite;
}
@keyframes energy-charge { 50% { opacity: .55; } }

.energy-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.energy-stat {
  display: inline-flex; align-items: baseline; gap: 5px; padding: 4px 10px; border-radius: 999px;
  font-size: .76rem; color: var(--muted); background: var(--surface-2);
}
.energy-stat strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* Petite tuile : liste compacte des pôles */
.energy-list { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.energy-row { display: flex; align-items: center; gap: 8px; font-size: .8rem; min-width: 0; }
.energy-row__icon {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; flex: none;
  color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent);
}
.energy-row__icon svg { width: 13px; height: 13px; }
.energy-row__label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.energy-row .energy-node__sub { font-size: .7rem; }
.energy-row .energy-node__value { font-size: .82rem; }
.energy-row.is-active .energy-row__icon { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 35%, transparent); }

@media (prefers-reduced-motion: reduce) {
  .energy-dots.is-flowing { animation: none; }
  .energy-node.is-active .energy-node__disc::after,
  .energy-node--battery.is-charging.has-soc .energy-node__inner::before { animation: none; }
}

/* Éditeur : réglages des pôles du flux d'énergie */
.energy-edit { border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; }
.energy-edit[open] { padding-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.energy-edit__head { display: flex; align-items: center; gap: 8px; padding: 10px 0; cursor: pointer; list-style: none; }
.energy-edit__head::-webkit-details-marker { display: none; }
.energy-edit__head .tree__meta { margin-left: auto; }
.energy-edit__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }

/* Flux d'énergie : statuts (charge de la batterie, connexion au réseau) */
.energy-node__label { display: flex; flex-direction: column; align-items: center; line-height: 1.25; }
.energy-node--solar .energy-node__label, .energy-node--battery .energy-node__label { align-items: flex-start; }
/* Statut d'un pôle (en décharge, connecté…) : pastille teintée de sa couleur */
.energy-node__status {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; padding: 2px 8px 2px 7px; border-radius: 999px;
  font-size: clamp(.58rem, 2.6cqw, .75rem); font-weight: 700; line-height: 1.3; white-space: nowrap; color: var(--c);
  background: color-mix(in srgb, currentColor 14%, transparent); border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
}
.energy-node__status[hidden] { display: none; }
.energy-node__status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.energy-node__status[data-state="connected"] { color: var(--ok); }
.energy-node__status[data-state="disconnected"] { color: var(--error); }
.energy-node__status[data-state="charging"]::before { animation: energy-blink 1.4s ease-in-out infinite; }
@keyframes energy-blink { 50% { opacity: .25; } }

.energy-node__badge {
  position: absolute; top: 2%; right: 2%; width: 30%; aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; background: var(--c); color: #fff; box-shadow: 0 0 0 .8cqw var(--surface);
}
.energy-node__badge svg { width: 62%; height: 62%; }
.energy-node.is-offline { --c: var(--error) !important; } /* prime sur la couleur du pôle (style en ligne) */
.energy-node.is-offline .energy-node__badge { background: var(--error); }
.energy-line.is-offline { stroke: var(--error); stroke-dasharray: 6 7; opacity: .7; }

.energy-node.is-clickable, .energy-row.is-clickable { cursor: pointer; }
.energy-node.is-clickable .energy-node__disc { transition: transform .18s ease, box-shadow .4s, opacity .4s; }
.energy-node.is-clickable:hover .energy-node__disc { transform: scale(1.05); }
.energy-node.is-clickable:focus-visible { outline: none; }
.energy-node.is-clickable:focus-visible .energy-node__disc { outline: 2px solid var(--c); outline-offset: 3px; }
.energy-row.is-clickable { border-radius: 8px; margin: -2px -4px; padding: 2px 4px; }
.energy-row.is-clickable:hover { background: var(--surface-2); }
.energy-row.is-offline .energy-node__sub { color: var(--error); font-weight: 700; }

/* Fiche d'un pôle */
.energy-sheet .card__icon { background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.energy-sheet .metric { align-items: center; }
.energy-status {
  display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 4px 11px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
}
.energy-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.energy-status[data-state="connected"] { color: var(--ok); background: var(--ok-soft); }
.energy-status[data-state="disconnected"] { color: var(--error); background: var(--error-soft); }
.energy-graphs { display: flex; flex-direction: column; gap: 20px; }

/* Totaux de la période sous un graphique */
.energy-totals { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; font-size: .78rem; }
.energy-total {
  --t: var(--pos, var(--accent));
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  color: var(--muted); background: color-mix(in srgb, var(--t) 10%, var(--surface));
}
.energy-total::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--t); }
.energy-total strong { color: var(--text); font-variant-numeric: tabular-nums; }
.energy-total--neg { --t: var(--neg); }
.energy-totals__period { margin-left: auto; color: var(--muted); font-size: .72rem; }

/* Répartition en direct dans la fiche d'un pôle */
.energy-split { display: flex; flex-direction: column; gap: 14px; margin: 4px 0 16px; }
.energy-split[hidden] { display: none; }
.energy-split__group { display: flex; flex-direction: column; gap: 7px; }
.energy-split__head { display: flex; justify-content: space-between; align-items: baseline; font-size: .82rem; }
.energy-split__head span { color: var(--muted); font-variant-numeric: tabular-nums; }
.energy-split__row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 30% auto; align-items: center; gap: 10px; font-size: .8rem; }
.energy-split__icon {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
}
.energy-split__icon svg { width: 14px; height: 14px; }
.energy-split__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.energy-split__bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.energy-split__bar span { display: block; height: 100%; border-radius: inherit; background: var(--c); transition: width .6s ease; }
.energy-split__value { min-width: 4.5em; text-align: right; font-variant-numeric: tabular-nums; }
.energy-split__row.is-idle { opacity: .45; }
.energy-graph__title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 10px; margin-bottom: 6px; font-size: .85rem; }
.energy-graph__title span { font-size: .74rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .energy-node__status[data-state="charging"]::before { animation: none; }
}
.energy-row__label { min-width: 3.5em; }
.energy-row .energy-node__sub { max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- Flux d'énergie : disposition, maison, statistiques */

/* Illustration (et pastilles) à gauche ; panneau de statistiques à droite quand la carte est assez large,
   sinon bouton « Statistiques » (fiche). Dans une fiche, le panneau s'empile sous l'illustration. */
.energy__layout { display: flex; flex-direction: column; align-items: stretch; gap: 14px; width: 100%; flex: 1; min-height: 0; }
.energy__scene { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; flex: 1; min-width: 0; min-height: 0; }
.energy__layout > .energy-panel { display: none; }
.energy__more { align-self: center; display: inline-flex; align-items: center; gap: 6px; }
.energy__more svg { width: 15px; height: 15px; }
@container energy (min-width: 760px) {
  .energy__layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 1.1fr); align-items: center; gap: 24px; }
  .energy__layout > .energy-panel { display: flex; }
  .energy__more { display: none; }
}
.energy--stack .energy__layout > .energy-panel { display: flex; }
.energy--stack .energy__more { display: none; }

/* Grille libre (grand écran et aperçu) : l'illustration suit la hauteur de la carte, le panneau défile */
@media (min-width: 1040px) {
  .space-grid--custom > .card--energy.is-placed .ehouse { width: min(100%, 560px, calc((100cqh - 74px) * 480 / 340)); }
  .space-grid--custom > .card--energy.is-placed .energy__layout { height: 100%; }
  .space-grid--custom > .card--energy.is-placed .energy-panel { align-self: stretch; max-height: 100cqh; overflow-y: auto; scrollbar-width: thin; }
}
.editor__preview .space-grid--custom > .card--energy.is-placed .ehouse { width: min(100%, 560px, calc((100cqh - 74px) * 480 / 340)); }
.editor__preview .space-grid--custom > .card--energy.is-placed .energy__layout { height: 100%; }
.editor__preview .space-grid--custom > .card--energy.is-placed .energy-panel { align-self: stretch; max-height: 100cqh; overflow-y: auto; }

/* --- Maison isométrique (repère 480 × 340, étiquettes HTML placées en %) */
/* Style sobre : gris neutres tirés du thème, toit sombre couvert de panneaux, fenêtres éclairées.
   Décor fixe (dégradés SVG, sans filtre) : seuls les éclats des câbles bougent. */
.ehouse {
  --h-wall1: color-mix(in srgb, var(--text) 14%, var(--surface));
  --h-wall1-hi: color-mix(in srgb, var(--h-wall1) 90%, #fff);
  --h-wall2: color-mix(in srgb, var(--h-wall1) 82%, #000);
  --h-wall2-hi: color-mix(in srgb, var(--h-wall2) 92%, #fff);
  --h-edge: color-mix(in srgb, var(--text) 24%, var(--surface));
  --h-edge-hi: color-mix(in srgb, var(--text) 12%, transparent);
  --h-roof: color-mix(in srgb, var(--h-wall1) 38%, #000);
  --h-fascia: color-mix(in srgb, var(--h-wall1) 48%, #000);
  --h-glass: color-mix(in srgb, var(--h-wall1) 60%, #000);
  --h-light: #f6e7c6;
  --h-panel: #10131b;
  --h-panel-hi: #1c2232;
  --h-bat1: #f2f3f5;
  --h-bat2: #c4c7cd;
  --h-hub: color-mix(in srgb, var(--text) 32%, var(--surface));
  --h-shadow: rgb(0 0 0 / .45);
  position: relative; width: min(100%, 560px); aspect-ratio: 480 / 340; margin: 0 auto; flex: none;
  container-type: inline-size;
}
.ehouse__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
.ehouse__wall, .ehouse__roof, .ehouse__door { stroke: var(--h-edge); stroke-width: .6; stroke-linejoin: round; }
.ehouse__corner, .ehouse__ridge { stroke: var(--h-edge-hi); stroke-width: 1; stroke-linecap: round; fill: none; }
.ehouse__glass { fill: var(--h-glass); }
.ehouse__lit { fill: var(--h-light); opacity: calc(.12 + var(--lit, 0) * .7); transition: opacity 1s; }
.ehouse.is-night .ehouse__lit { opacity: calc(.2 + var(--lit, 0) * .8); }
.ehouse__mullion { stroke: var(--h-wall1); stroke-width: 1.1; fill: none; }
.ehouse__door { fill: var(--h-fascia); }
.ehouse__roof { fill: var(--h-roof); }
.ehouse__fascia { fill: var(--h-fascia); stroke: var(--h-edge); stroke-width: .5; }
.ehouse__barge { fill: none; stroke: var(--h-fascia); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.ehouse__panel-glow { fill: var(--c-solar); opacity: calc(var(--sun, 0) * .14); transition: opacity 1s; }
.ehouse__cells { fill: none; stroke: rgb(255 255 255 / .06); stroke-width: .6; }
.ehouse__panel-frame { fill: none; stroke: rgb(255 255 255 / .16); stroke-width: .9; stroke-linejoin: round; }
.ehouse__leader { fill: none; stroke: color-mix(in srgb, var(--text) 28%, transparent); stroke-width: 1; stroke-dasharray: 2 3; }
.ehouse__bat { stroke: rgb(0 0 0 / .18); stroke-width: .5; stroke-linejoin: round; }
.ehouse__bat--side { fill: var(--h-bat2); }
.ehouse__hub { fill: var(--h-hub); stroke: rgb(0 0 0 / .25); stroke-width: .5; stroke-linejoin: round; }
.ehouse__hub--side { fill: color-mix(in srgb, var(--h-hub) 82%, #000); }
.ehouse__soc-track { fill: rgb(0 0 0 / .1); }
.ehouse__soc { fill: var(--c-battery); }
.ehouse__soc.is-low { fill: var(--error); }
.ehouse__soc.is-charging { animation: energy-charge 2.4s ease-in-out infinite; }
.ehouse__screen { fill: color-mix(in srgb, var(--text) 40%, var(--surface)); transition: fill .5s; }
.ehouse__screen.is-on { fill: var(--ok); }
.ehouse__led { fill: var(--muted); }
.ehouse__led.is-on { fill: var(--ok); animation: energy-blink 1.6s ease-in-out infinite; }
.ehouse__pole path { fill: none; stroke: var(--h-edge); stroke-width: 1.6; stroke-linecap: round; }
.ehouse__pole .ehouse__mast { stroke-width: 3; }
.ehouse__pole .ehouse__wire { stroke-width: .6; opacity: .7; }
.ehouse__pole.is-offline path { stroke: var(--error); }

/* Câbles le long des murs : gaine discrète au repos ; allumés, un cœur net dans un halo de traits larges (sans filtre) */
.ehouse__cable path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ehouse__cable-groove { stroke: color-mix(in srgb, var(--text) 9%, transparent); stroke-width: 3; }
.ehouse__cable-halo, .ehouse__cable-glow, .ehouse__cable-core { stroke: var(--c); opacity: 0; transition: opacity .7s, stroke .7s; }
.ehouse__cable-halo { stroke-width: 11; }
.ehouse__cable-glow { stroke-width: 6; }
.ehouse__cable-core { stroke-width: 2.4; }
.ehouse__cable.is-active .ehouse__cable-halo { opacity: .1; }
.ehouse__cable.is-active .ehouse__cable-glow { opacity: .22; }
.ehouse__cable.is-active .ehouse__cable-core { opacity: 1; }
.ehouse__cable.is-offline .ehouse__cable-groove { stroke: color-mix(in srgb, var(--error) 45%, transparent); }

/* Éclats : chaîne de points superposés qui suit le câble, dessinée dans un seul canvas (energyHouse, cards.js)
   au repère 480 × 340 mis à l'échelle : un calque unique, quel que soit le nombre de points */
.ehouse__fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* Ciel : soleil (plus vif en production), lune la nuit */
.ehouse__sun { fill: #fbbf24; opacity: .45; transition: opacity .6s; }
.ehouse__rays { stroke: #fbbf24; stroke-width: 2; stroke-linecap: round; opacity: .45; transform-box: fill-box; transform-origin: center; transition: opacity .6s; }
.ehouse.is-producing .ehouse__sun, .ehouse.is-producing .ehouse__rays { opacity: 1; }
.ehouse.is-producing .ehouse__rays { animation: ehouse-spin 24s linear infinite; }
.ehouse__moon { fill: #cbd5e1; opacity: 0; transition: opacity .6s; }
.ehouse.is-night .ehouse__sun, .ehouse.is-night .ehouse__rays { opacity: 0; }
.ehouse.is-night .ehouse__moon { opacity: .9; }
@keyframes ehouse-spin { to { transform: rotate(360deg); } }

.ehouse__tag {
  position: absolute; z-index: 1; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.15; white-space: nowrap;
  padding: .5cqw 1.6cqw; border-radius: 12px; transition: background .2s;
}
.ehouse__tag .energy-node__value { font-size: clamp(.82rem, 5cqw, 1.55rem); font-weight: 650; letter-spacing: -.02em; }
.ehouse__name { display: inline-flex; align-items: center; gap: .4em; font-size: clamp(.64rem, 3cqw, .92rem); font-weight: 600; color: var(--muted); }
.ehouse__name::before { content: ""; width: .55em; height: .55em; border-radius: 50%; background: var(--c); }
.ehouse__tag .energy-node__sub { font-size: clamp(.58rem, 2.6cqw, .8rem); }
.ehouse__tag .energy-node__status { font-size: clamp(.56rem, 2.5cqw, .76rem); }
.ehouse__tag.is-unknown .energy-node__value { color: var(--muted); }
.ehouse__tag.is-offline .energy-node__value, .ehouse__tag.is-offline .ehouse__name { color: var(--error); }
.ehouse__tag.is-clickable { cursor: pointer; }
.ehouse__tag.is-clickable:hover { background: color-mix(in srgb, var(--c) 12%, transparent); }
.ehouse__tag.is-clickable:focus-visible { outline: 2px solid var(--c); outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) {
  .ehouse.is-producing .ehouse__rays, .ehouse__led.is-on, .ehouse__soc.is-charging { animation: none; }
}

/* --- Panneau de statistiques */
.energy-panel { display: flex; flex-direction: column; gap: 14px; width: 100%; min-width: 0; font-size: .85rem; }
.epanel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.epanel__head > strong { font-size: .95rem; }
.epanel__head .spark__periods { margin: 0; }
/* Période personnalisée */
.epanel__range { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: -4px; }
.epanel__range label { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.epanel__date {
  font: inherit; font-size: .8rem; padding: 5px 9px; border-radius: 9px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); color-scheme: inherit;
}
.epanel__date:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Onglets Bilan / Batterie */
.epanel__tabs { margin-right: auto; padding: 3px; border-radius: 10px; }
.epanel__tabs .segmented__item { padding: 4px 12px; font-size: .8rem; border-radius: 7px; }
/* En direct : batterie et abonnement côte à côte quand la place le permet */
.epanel__live { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.epanel__live > * { flex: 1 1 200px; min-width: 0; }
.epanel__live > .epanel__line--battery { flex: 1.8 1 300px; }
.epanel__live:not(:has(.epanel__meter + .epanel__meter)) .epanel__meter { flex-basis: 100%; }
.epanel__meter { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.epanel__meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.epanel__meter-head strong { color: var(--text); font-size: .88rem; font-variant-numeric: tabular-nums; }
.epanel__bar { height: 7px; border-radius: 999px; background: color-mix(in srgb, var(--text) 9%, transparent); overflow: hidden; }
.epanel__bar span { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent)); transition: width .6s ease; }
.epanel__meter.is-warn .epanel__bar span { background: var(--on); }
.epanel__meter.is-alert .epanel__bar span { background: var(--error); }
.epanel__meter.is-alert .epanel__meter-head strong { color: var(--error); }
.epanel__meter-foot { font-size: .74rem; color: var(--muted); }
.epanel__body { display: flex; flex-direction: column; gap: 14px; }
.epanel__note { margin: 0; padding: 8px 0; font-size: .8rem; color: var(--muted); }

/* Tuiles de la période : toute la largeur, à parts égales sur chaque ligne */
.energy-panel { container: epanel / inline-size; }
.etiles { --per: var(--n, 4); display: flex; flex-wrap: wrap; gap: 8px; }
.etiles > .etile { flex: 1 1 calc((100% - (var(--per) - 1) * 8px) / var(--per)); }
@container epanel (max-width: 600px) { .etiles { --per: var(--half, 2); } }
@container epanel (max-width: 330px) { .etiles { --per: 2; } }
.etile {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "icon label" "value value" "sub sub";
  align-items: center; gap: 2px 7px; min-width: 0; padding: 9px 11px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--c) 8%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--c) 18%, transparent);
}
.etile__icon { grid-area: icon; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }
.etile__icon svg { width: 12px; height: 12px; }
.etile__label { grid-area: label; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .74rem; font-weight: 600; color: var(--muted); }
.etile__value { grid-area: value; margin-top: 4px; font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.etile__sub { grid-area: sub; font-size: .7rem; color: var(--muted); }

.epanel__row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.erings { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.ering { display: flex; align-items: center; gap: 8px; }
.ering__chart { position: relative; display: grid; place-items: center; width: 50px; height: 50px; }
.ering__chart svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ering__chart strong { position: relative; font-size: .72rem; font-variant-numeric: tabular-nums; }
.ering__track { fill: none; stroke: color-mix(in srgb, var(--text) 9%, transparent); stroke-width: 4; }
.ering__value { fill: none; stroke: var(--c); stroke-width: 4; stroke-linecap: round; transition: stroke-dasharray .8s ease; }
.ering__label { font-size: .76rem; font-weight: 600; color: var(--muted); }
.ecosts { flex: 1 1 300px; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); align-items: center; gap: 6px; }
.ecosts .etempo { justify-self: start; white-space: nowrap; }
.ecost { display: flex; flex-direction: column; min-width: 86px; padding: 6px 11px; border-radius: 10px; background: var(--surface-2); }
.ecost span { font-size: .7rem; color: var(--muted); }
.ecost strong { font-variant-numeric: tabular-nums; }
.ecost--saved strong { color: var(--ok); }
.ecost--sold strong { color: #f97316; }
.etempo { padding: 4px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.etempo--blue { color: #2563eb; background: rgb(37 99 235 / .14); }
.etempo--white { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-strong); }
.etempo--red { color: var(--error); background: var(--error-soft); }

.epanel__chart { display: flex; flex-direction: column; gap: 6px; }
.epanel__chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.elegend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .72rem; font-weight: 500; }
.elegend span { display: inline-flex; align-items: center; gap: 5px; }
.elegend span::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--t); }
.ebars__plot { position: relative; height: 130px; touch-action: pan-y; cursor: crosshair; }
.ebars__svg { display: block; width: 100%; height: 100%; }
.ebars__now { fill: color-mix(in srgb, var(--text) 6%, transparent); }
.ebars__cursor { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: color-mix(in srgb, var(--text) 9%, transparent); pointer-events: none; }
.ebars__tip { top: 2px; transform: translateX(-50%); z-index: 2; align-items: stretch; gap: 2px; }
.ebars__row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 6px; font-size: .72rem; }
.ebars__row i { width: 8px; height: 8px; border-radius: 2px; background: var(--t, transparent); }
.ebars__row b { font-variant-numeric: tabular-nums; }
.ebars .spark__axis { margin-top: 3px; }

.efacts { display: flex; flex-direction: column; gap: 5px; margin: 0; padding: 0; list-style: none; font-size: .76rem; color: var(--muted); }
.efacts li { display: flex; align-items: center; gap: 7px; }
.efacts svg { flex: none; width: 13px; height: 13px; }

/* Fiche « Statistiques » (cartes étroites) */
.energy-sheet--stats .card__icon { background: var(--accent-soft); color: var(--accent); }
.energy-edit__dot--tariff { --c: var(--accent); }
.energy-edit__plane { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-top: 1px dashed var(--border-strong); }
.energy-edit__plane > .btn { align-self: flex-start; }

/* Batterie et abonnement : simple ligne avec une barre fine (jauge complète seulement en cas de risque) */
.epanel__line {
  position: relative; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px;
  padding: 0 2px 7px; font-size: .76rem; color: var(--muted); cursor: default;
}
.epanel__line strong { color: var(--text); font-variant-numeric: tabular-nums; }
.epanel__line-info { margin-left: auto; font-size: .72rem; text-align: right; }
.epanel__line-bar { position: absolute; left: 2px; right: 2px; bottom: 0; height: 3px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); overflow: hidden; }
.epanel__line-bar span { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent)); transition: width .6s ease; }
.epanel__line.is-warn strong, .epanel__line.is-warn .epanel__line-info { color: var(--on); }
.epanel__line.is-warn .epanel__line-bar span { background: var(--on); }
.epanel__more {
  padding: 0; border: 0; background: none; font: inherit; font-size: .72rem; font-weight: 700; cursor: pointer;
  color: color-mix(in srgb, var(--c, var(--accent)) 70%, var(--text));
}
.epanel__more:hover { text-decoration: underline; }
/* Panneau étroit : « Détails » à droite du niveau, prévision en dessous sur toute la largeur */
@container epanel (max-width: 600px) {
  .epanel__line--battery .epanel__more { margin-left: auto; }
  .epanel__line--battery .epanel__line-info { order: 1; flex-basis: 100%; margin-left: 0; text-align: left; }
  .epanel__line--battery .epanel__line-bar { order: 2; }
}

/* Courbe du niveau de la batterie sur le graphique horaire */
.ebars__level { fill: none; stroke: color-mix(in srgb, var(--lvl) 75%, var(--text)); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ebars__level.is-forecast { stroke-dasharray: 4 4; }
.ebars__band { fill: color-mix(in srgb, var(--lvl) 14%, transparent); }
.ebars__reserve { stroke: #f97316; stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; vector-effect: non-scaling-stroke; }
.elegend span.is-line::before { width: 12px; height: 3px; border-radius: 2px; }

/* Onglet Batterie : prévision en direct */
.ebatt { display: flex; flex-direction: column; gap: 12px; }
.ebatt__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.ebatt__head .ering__label { display: none; }
.ebatt__state { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ebatt__pill {
  align-self: flex-start; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700;
  color: color-mix(in srgb, var(--c) 65%, var(--text)); background: color-mix(in srgb, var(--c) 16%, transparent);
}
.ebatt__pill.is-idle { color: var(--muted); background: var(--surface-2); }
.ebatt__pill.is-warn { color: color-mix(in srgb, var(--on) 75%, var(--text)); background: color-mix(in srgb, var(--on) 16%, transparent); }
.ebatt__stored { font-size: .76rem; color: var(--muted); }
.ebatt__rel { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; color: var(--muted); }
.ebatt__rel::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.ebatt__rel.is-fair::before { background: var(--on); }
.ebatt__rel.is-low::before { background: var(--error); }
.ebatt__cells { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.ebatt__cell { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.ebatt__cell span, .ebatt__cell small { font-size: .72rem; color: var(--muted); }
.ebatt__cell strong { font-size: .98rem; font-variant-numeric: tabular-nums; }
.ebatt__cell.is-key { background: color-mix(in srgb, #f97316 10%, var(--surface-2)); box-shadow: inset 0 0 0 1px color-mix(in srgb, #f97316 30%, transparent); }
.ebatt__cell.is-key span { font-weight: 650; color: color-mix(in srgb, #f97316 70%, var(--text)); }
.ebatt__chart { display: flex; flex-direction: column; gap: 4px; }
.ebatt__plot { position: relative; height: 130px; }
.ebatt__svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ebatt__night { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.ebatt__grid { fill: rgb(59 130 246 / .2); }
.ebatt__reserve { stroke: #f97316; stroke-width: 1.2; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.ebatt__band { fill: color-mix(in srgb, var(--c) 18%, transparent); }
.ebatt__line { fill: none; stroke: var(--c); stroke-width: 2.2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ebatt__dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--surface); }
.ebatt__dot.is-cross { background: #f97316; }
.ebatt__tag { position: absolute; right: 0; transform: translateY(-125%); font-size: .68rem; color: color-mix(in srgb, #f97316 70%, var(--text)); pointer-events: none; }
.ebatt__today { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ebatt__today > strong { margin-right: 4px; font-size: .76rem; font-weight: 600; color: var(--muted); }
.ebatt__how summary { width: fit-content; cursor: pointer; font-size: .76rem; font-weight: 700; color: var(--accent); }
.ebatt__how ul { display: flex; flex-direction: column; gap: 3px; margin: 6px 0 0; padding-left: 18px; font-size: .76rem; color: var(--muted); }
.ecost--total { background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.ehouse__brand path { fill: color-mix(in srgb, var(--text) 62%, var(--surface)); }

/* ---------------------------------------------------------------- Page « Production solaire » (solar.js) */

.energy__solar { align-self: center; display: inline-flex; align-items: center; gap: 6px; }
.energy__solar svg { width: 15px; height: 15px; }

.solar-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); align-items: start; }
.solar-grid > * { min-width: 0; }
@media (min-width: 1100px) {
  .solar-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .solar-grid > .solar-now, .solar-grid > .card--energy, .solar-grid > .solar-setup,
  .solar-grid > .solar-week, .solar-grid > .solar-accuracy, .solar-grid > .solar-habits,
  .solar-grid > .solar-goals, .solar-grid > .solar-report, .solar-grid > .solar-battery { grid-column: 1 / -1; }
  .solar-grid > .solar-hours { grid-column: span 2; }
  .solar-grid > .solar-tips { align-self: stretch; }
}

.solar-block__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; }
.solar-block__title { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 1rem; font-weight: 650; letter-spacing: -.01em; }
.solar-block__title svg { width: 18px; height: 18px; color: var(--c, var(--accent)); }
.solar-block__tools { min-width: 0; max-width: 100%; }
.solar-block__tools .spark__periods { margin: 0; padding-bottom: 2px; }
.solar-block__body { display: flex; flex-direction: column; gap: 10px; min-width: 0; font-size: .85rem; }
.solar-note { margin: 0; color: var(--muted); font-size: .84rem; }
.solar-note--legend { display: flex; align-items: center; gap: 8px; font-size: .74rem; }
.solar-setup .btn { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; }
.solar-setup .btn svg { width: 15px; height: 15px; }
.solar-credit { margin: 0; font-size: .7rem; color: var(--muted); }
.solar-credit a { color: inherit; text-decoration: underline; }

/* --- En direct */
.solar-now { gap: 18px; }
.solar-now__top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 14px 24px; }
.solar-now__main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.solar-now__label { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.solar-now__label svg { width: 16px; height: 16px; color: var(--c); }
.solar-now__value { font-size: clamp(2.4rem, 7vw, 3.6rem); font-weight: 750; letter-spacing: -.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.solar-now__line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: .8rem; color: var(--muted); }
.solar-badge {
  padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text); background: var(--surface-2);
}
.solar-badge.is-up { color: var(--ok); background: var(--ok-soft); }
.solar-badge.is-down { color: var(--on); background: var(--on-soft); }
.solar-now__sky { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 999px; background: var(--surface-2); }
.solar-now__sky-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); }
.solar-now__sky-icon svg { width: 22px; height: 22px; }
.solar-now__sky div { display: flex; flex-direction: column; line-height: 1.25; }
.solar-now__sky strong { font-size: .88rem; }
.solar-now__sky span { font-size: .74rem; color: var(--muted); }

.solar-progress { display: flex; flex-direction: column; gap: 7px; }
.solar-progress__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: .82rem; color: var(--muted); }
.solar-progress__head strong { color: var(--text); font-size: 1rem; font-variant-numeric: tabular-nums; }
.solar-progress__bar { position: relative; height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--c) 16%, transparent); }
.solar-progress__fill { display: block; height: 100%; border-radius: inherit; background: var(--c); transition: width .8s ease; }
.solar-progress__mark { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 2px; background: var(--text); opacity: .7; }
.solar-progress__foot { font-size: .76rem; color: var(--muted); }
.solar-progress__foot::first-letter { text-transform: uppercase; }

/* --- Graphiques prévu / mesuré */
.solar-chart__plot { height: 160px; }
.solar-chart__fc { fill: color-mix(in srgb, var(--c) 26%, transparent); }
.solar-chart__real { fill: var(--c); }
.solar-legend--fc::before { background: color-mix(in srgb, var(--c) 30%, transparent) !important; }
.solar-legend--real::before { background: var(--c) !important; }
.solar-sky { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); margin-top: -2px; }
.solar-sky__cell { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; font-size: .66rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.solar-sky__cell svg { width: 16px; height: 16px; color: var(--text); opacity: .75; }
.solar-facts { flex-direction: row; flex-wrap: wrap; gap: 6px 16px; }
/* Historique heure par heure : choix de la journée passée */
.solar-past { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.solar-past__name { margin-left: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.solar-past__name::first-letter { text-transform: uppercase; }

/* --- Prochains jours */
.solar-days { display: grid; grid-template-columns: repeat(7, minmax(118px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.solar-day {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name icon" "date icon" "sky sky" "value value" "bar bar" "meta meta";
  gap: 1px 8px; padding: 10px 12px; min-width: 0; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  border-radius: var(--radius-sm); border: 1.5px solid transparent; background: var(--surface-2);
}
.solar-day:hover { border-color: var(--border-strong); }
.solar-day.is-active { border-color: var(--c); background: color-mix(in srgb, var(--c) 9%, var(--surface-2)); }
.solar-day__name { grid-area: name; font-size: .8rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.solar-day__date { grid-area: date; font-size: .7rem; color: var(--muted); }
.solar-day__icon { grid-area: icon; align-self: center; color: var(--c); }
.solar-day__icon svg { width: 26px; height: 26px; }
.solar-day__value { grid-area: value; margin-top: 6px; font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.solar-day__bar { grid-area: bar; position: relative; height: 6px; margin: 5px 0 4px; border-radius: 999px; background: color-mix(in srgb, var(--text) 9%, transparent); }
.solar-day__fill { display: block; height: 100%; border-radius: inherit; background: var(--c); }
.solar-day__usual { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 2px; background: var(--c-home, var(--text)); }
.solar-day__usual--key { position: static; display: inline-block; height: 12px; margin: 0; }
.solar-day__sky { grid-area: sky; margin-top: 4px; font-size: .74rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.solar-day__meta { grid-area: meta; display: flex; flex-direction: column; gap: 2px; font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.solar-day__meta span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.solar-day__meta svg { flex: none; width: 11px; height: 11px; }

/* --- Conseils */
.solar-tips__list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.solar-tip { display: flex; align-items: flex-start; gap: 10px; }
.solar-tip__icon { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--muted); background: var(--surface-2); }
.solar-tip__icon svg { width: 16px; height: 16px; }
.solar-tip.is-good .solar-tip__icon { color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); }
.solar-tip.is-warn .solar-tip__icon { color: var(--error); background: var(--error-soft); }

/* --- Habitudes */
.solar-habits__hero {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px; padding: 16px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface-2)), color-mix(in srgb, var(--c-solar, var(--on)) 12%, var(--surface-2)));
}
.solar-habits__intro { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.solar-habits__kicker { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--accent-ink, var(--accent)); }
.solar-habits__words { display: flex; flex-wrap: wrap; gap: 6px; }
.solar-habits__word { padding: 4px 12px; border-radius: 999px; font-size: clamp(1.05rem, 3.6vw, 1.35rem); font-weight: 800; letter-spacing: -.01em; background: var(--surface); }
.solar-habits__word:nth-child(2) { color: color-mix(in srgb, var(--c-solar, var(--on)) 70%, var(--text)); }
.solar-habits__word:nth-child(3) { color: color-mix(in srgb, var(--c-grid, var(--accent)) 70%, var(--text)); }
.solar-habits__since { margin: 0; font-size: .8rem; color: var(--muted); }
.solar-habits__score { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 16px; border-radius: var(--radius-sm); background: var(--surface); text-align: center; max-width: 150px; }
.solar-habits__score strong { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; color: color-mix(in srgb, var(--c-solar, var(--on)) 70%, var(--text)); font-variant-numeric: tabular-nums; }
.solar-habits__score span { font-size: .72rem; color: var(--muted); line-height: 1.3; }
.solar-habits__change { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.solar-habits__change.is-good { border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); }
.solar-habits__change p { margin: 0; font-size: .84rem; line-height: 1.45; }
.solar-habits__badge { flex: none; padding: 3px 8px; border-radius: 999px; font-size: .64rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--surface); background: var(--muted); }
.solar-habits__change.is-good .solar-habits__badge { background: var(--ok); }
.solar-habits__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 10px; }
.solar-habit { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.solar-habit--production { grid-column: 1 / -1; }
.solar-habit__head { display: flex; align-items: center; gap: 10px; }
.solar-habit__icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); }
.solar-habit__icon svg { width: 18px; height: 18px; }
.solar-habit__title { display: flex; flex-direction: column; min-width: 0; }
.solar-habit__title strong { font-size: .92rem; }
.solar-habit__title span { font-size: .74rem; color: var(--muted); }
.solar-habit__stats { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.solar-habit__stat { display: flex; flex-direction: column; }
.solar-habit__stat strong { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.solar-habit__stat.is-muted strong { color: var(--muted); }
.solar-habit__stat span { font-size: .72rem; color: var(--muted); }
.solar-habit__text { margin: 0; font-size: .8rem; line-height: 1.45; color: var(--muted); }
.solar-habit__viz, .solar-habit__chart { display: flex; flex-direction: column; gap: 6px; }
.solar-habit__bars { display: flex; align-items: flex-end; gap: 2px; height: 54px; }
.solar-habit__bar { flex: 1; min-width: 0; border-radius: 3px 3px 0 0; background: color-mix(in srgb, var(--text) 16%, transparent); }
.solar-habit__bar.is-sun { background: var(--c-solar, var(--on)); }
.solar-habit__bar.is-peak { background: var(--c); }
.solar-habit__bar.is-low { background: color-mix(in srgb, var(--c) 40%, transparent); }
.solar-habit--weekday .solar-habit__bars { gap: 6px; }
.solar-habit__ticks { display: flex; justify-content: space-between; font-size: .66rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.solar-habit--weekday .solar-habit__ticks span { flex: 1; text-align: center; }
.solar-habit__key { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; }
.solar-habit__key.is-sun, .solar-habit__key.is-solar { background: var(--c-solar, var(--on)); }
.solar-habit__key.is-battery { background: var(--c-battery, var(--ok)); }
.solar-habit__key.is-grid { background: var(--c-grid, var(--muted)); }
.solar-habit__gauge { height: 8px; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--text) 9%, transparent); }
.solar-habit__gauge span { display: block; height: 100%; border-radius: inherit; background: var(--c); }
.solar-habit__rows { display: flex; flex-direction: column; gap: 8px; }
.solar-habit__row { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: .74rem; color: var(--muted); }
.solar-habit__row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.solar-habit__track { height: 12px; border-radius: 4px; background: color-mix(in srgb, var(--text) 7%, transparent); overflow: hidden; }
.solar-habit__fill { display: block; height: 100%; border-radius: inherit; background: color-mix(in srgb, var(--c) 45%, transparent); }
.solar-habit__fill.is-strong { background: var(--c); }
.solar-habit__curve { width: 100%; height: 60px; overflow: visible; }
.solar-habit__line { fill: none; stroke: var(--c); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.solar-habit__reserve { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; vector-effect: non-scaling-stroke; }
.solar-habit__split { display: flex; height: 16px; border-radius: 999px; overflow: hidden; gap: 2px; }
.solar-habit__split .is-solar { background: var(--c-solar, var(--on)); }
.solar-habit__split .is-battery { background: var(--c-battery, var(--ok)); }
.solar-habit__split .is-grid { background: var(--c-grid, var(--muted)); }
.solar-habit__legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .76rem; color: var(--muted); }
.solar-habit__legend > span { display: inline-flex; align-items: center; gap: 6px; }
.solar-habit--months, .solar-habit--tariff, .solar-habit--tempo { grid-column: 1 / -1; }
.solar-habit__days { margin: auto 0 0; font-size: .7rem; color: var(--muted); }
.solar-habit__box { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.solar-habit__box strong { font-size: .86rem; }
.solar-habit__box span { font-size: .76rem; color: var(--muted); line-height: 1.45; }
.solar-habit__link {
  align-self: flex-start; min-height: 32px; padding: 0; border: 0; background: none; font: inherit; font-size: .8rem; font-weight: 650;
  color: var(--accent-ink, var(--accent)); cursor: pointer;
}
.solar-habit__link:hover { text-decoration: underline; }
.solar-habit__bar { position: relative; }
.solar-habit__bar i { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); padding-bottom: 2px; font-style: normal; font-size: .62rem; color: var(--muted); white-space: nowrap; }
.solar-habit__bars:has(i) { margin-top: 14px; }
.solar-habit__key.is-hp, .solar-habit__split .is-hp { background: color-mix(in srgb, var(--error) 75%, var(--surface)); }
.solar-habit__key.is-hc, .solar-habit__split .is-hc { background: var(--accent); }
.solar-habit__key.is-white, .solar-habit__split .is-white { background: color-mix(in srgb, var(--muted) 70%, var(--surface)); }
.solar-habit__key.is-red, .solar-habit__split .is-red { background: #dc2626; }
.solar-habit__fill.is-blue { background: #2563eb; }
.solar-habit__fill.is-white { background: color-mix(in srgb, var(--muted) 70%, var(--surface)); }
.solar-habit__fill.is-red { background: #dc2626; }
.solar-habits__away { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.solar-habits__away .solar-habit__icon { --c: var(--accent); }
.solar-habits__away p { flex: 1 1 260px; margin: 0; font-size: .82rem; line-height: 1.45; }

/* --- Objectifs et défis */
.solar-sub { margin: 6px 0 0; font-size: .92rem; font-weight: 700; }
.solar-goal { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; }
.solar-ring { flex: none; }
.solar-ring__track { fill: none; stroke: color-mix(in srgb, var(--c-solar, var(--on)) 18%, transparent); stroke-width: 12; }
.solar-ring__value { fill: none; stroke: var(--c-solar, var(--on)); stroke-width: 12; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.solar-ring__goal { stroke: var(--text); stroke-width: 3; stroke-linecap: round; }
.solar-ring__text { fill: var(--text); font-size: 24px; font-weight: 800; }
.solar-ring__sub { fill: var(--muted); font-size: 10px; }
.solar-goal__text { flex: 1 1 280px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.solar-goal__kicker { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: color-mix(in srgb, var(--c-solar, var(--on)) 70%, var(--text)); }
.solar-goal__title { margin: 0; font-size: 1.12rem; font-weight: 700; line-height: 1.3; }
.solar-goal__desc { margin: 0; font-size: .84rem; color: var(--muted); line-height: 1.5; }
.solar-goal__months { display: flex; flex-wrap: wrap; gap: 6px; }
.solar-chip { padding: 4px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--surface-2); }
.solar-chip.is-ok { color: var(--ok); background: var(--ok-soft); }
.solar-cal__head-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; font-size: .8rem; color: var(--muted); }
.solar-cal__head-row > strong, .solar-cal__head-row > .solar-sub { color: var(--text); font-size: .9rem; }
.solar-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.solar-cal__head { font-size: .68rem; color: var(--muted); text-align: center; }
.solar-cal__day {
  display: grid; place-items: center; height: 36px; border-radius: 9px; font-size: .78rem; font-weight: 650; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--muted);
}
.solar-cal__day.is-ok, .solar-cal__key.is-ok { background: var(--c-solar, var(--on)); color: #1c1405; }
.solar-cal__day.is-near, .solar-cal__key.is-near { background: color-mix(in srgb, var(--c-solar, var(--on)) 35%, var(--surface)); color: var(--text); }
.solar-cal__day.is-no, .solar-cal__key.is-no { background: var(--surface-2); color: var(--text); }
.solar-cal__day.is-away, .solar-cal__key.is-away { background: repeating-linear-gradient(135deg, var(--surface-2) 0 4px, transparent 4px 8px); color: var(--muted); }
.solar-cal__day.is-today { outline: 2px solid var(--text); outline-offset: -2px; background: transparent; color: var(--text); }
.solar-cal__day.is-future, .solar-cal__day.is-none { background: transparent; border: 1px dashed var(--border-strong); }
.solar-cal__key { border: 1px solid var(--border); }
.solar-challenges { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 10px; }
.solar-challenge { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); --c: var(--c-solar, var(--on)); }
.solar-challenge.is-done { --c: var(--ok); }
.solar-challenge.is-missed { --c: var(--muted); }
.solar-challenge__head { display: flex; align-items: center; gap: 8px; }
.solar-challenge__head strong { flex: 1; font-size: .88rem; }
.solar-challenge__status { padding: 2px 8px; border-radius: 999px; font-size: .68rem; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); }
.solar-challenge__progress { margin: 0; font-size: .76rem; font-weight: 600; }
.solar-trophies { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr)); gap: 12px; }
.solar-trophy { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; opacity: .55; }
.solar-trophy.is-unlocked { opacity: 1; }
.solar-trophy__badge { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; color: var(--muted); background: var(--surface-2); border: 3px solid var(--border-strong); }
.solar-trophy.is-unlocked .solar-trophy__badge { color: var(--accent-ink, var(--accent)); background: var(--accent-soft); border-color: var(--accent); }
.solar-trophy__badge svg { width: 24px; height: 24px; }
.solar-trophy strong { font-size: .8rem; }
.solar-trophy span:last-child { font-size: .7rem; color: var(--muted); line-height: 1.35; }

/* --- Bilan du mois et batterie */
.solar-report__hero {
  display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: var(--radius-sm); color: #fff;
  background: linear-gradient(135deg, #1e1b4b, #78350f);
}
.solar-report__kicker { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #fcd34d; }
.solar-report__title { margin: 0; font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 800; letter-spacing: -.02em; }
.solar-report__lead { margin: 0; font-size: .92rem; line-height: 1.5; color: #e0e7ff; }
.solar-report__lead::first-letter { text-transform: uppercase; }
.solar-report__stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 10px; }
.solar-report__stat { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.solar-report__stat > span:first-child { font-size: .74rem; color: var(--muted); }
.solar-report__stat strong { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.solar-report__stat > span:last-child:not(:first-child) { font-size: .74rem; color: var(--muted); }
.solar-report__stat .is-ok, .solar-report__stat.is-ok strong { color: var(--ok); }
.solar-report__cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 14px 20px; }
.solar-report__col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.solar-report__figures { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: .8rem; }
.solar-report__figures dt { color: var(--muted); }
.solar-report__figures dd { margin: 0; }
.solar-report__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.solar-report__share { display: inline-flex; align-items: center; gap: 6px; }
.solar-report__share svg { width: 15px; height: 15px; }
.solar-report .solar-habit__bar.is-sun { background: var(--c-solar, var(--on)); }
.solar-report .solar-habit__bar.is-peak { background: color-mix(in srgb, var(--c-solar, var(--on)) 70%, var(--text)); }
.solar-report .solar-habit__bar.is-low { background: color-mix(in srgb, var(--text) 25%, transparent); }
.solar-battery .solar-habit__bar { background: color-mix(in srgb, var(--c-battery, var(--ok)) 40%, transparent); }
.solar-battery .solar-habit__bar.is-peak { background: var(--c-battery, var(--ok)); }
.solar-battery .solar-habit__gauge span { background: var(--c-battery, var(--ok)); }
.solar-amort__box { gap: 8px; }
.solar-amort { height: 14px; }

/* --- Alerte : panne du jour, baisse de rendement */
.solar-grid > .solar-alert { grid-column: 1 / -1; }
.space .solar-alert { gap: 12px; border-color: color-mix(in srgb, var(--error) 45%, transparent); background: color-mix(in srgb, var(--error) 7%, var(--surface)); }
.solar-alert__item { display: flex; align-items: flex-start; gap: 12px; }
.solar-alert__icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--error); background: var(--error-soft); }
.solar-alert__icon svg { width: 18px; height: 18px; }
.solar-alert__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.solar-alert__text strong { color: var(--error); font-size: .92rem; }
.solar-alert__text span { font-size: .82rem; color: var(--text); }
.solar-tip__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.solar-tip__text strong { font-size: .86rem; }
.solar-tip__text span { font-size: .78rem; color: var(--muted); }

/* ---------------------------------------------------------------- Widgets d'accueil (widgets.js) */

.space { --accent-ink: color-mix(in srgb, var(--accent) 60%, var(--text)); } /* accent lisible sur fond clair comme sombre */
.space-widgets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; margin-bottom: 26px; }
.space-widgets > * { min-width: 0; }
.widget--w { grid-column: 1 / -1; }
@media (min-width: 700px) {
  .space-widgets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .widget--w { grid-column: span 2; }
}
@media (min-width: 1200px) { .space-widgets { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.space .widget { display: flex; flex-direction: column; gap: 12px; }
.widget__title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0;
  font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
}
.widget__link { font-size: .82rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--accent-ink); }
.widget__body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.widget__note { margin: 0; font-size: .85rem; color: var(--muted); }
.widget.is-preview { cursor: pointer; }
.widget.is-selected { outline: 3px solid var(--accent); outline-offset: 3px; }
.widget__action {
  align-self: flex-start; margin-top: 4px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border);
  font: inherit; font-size: .76rem; font-weight: 650; color: var(--text); background: var(--surface); cursor: pointer;
}
.widget__action:hover { border-color: var(--accent); color: var(--accent-ink); }
.widget.is-preview .widget__action, .widget.is-preview .wshort__btn { pointer-events: none; }

/* Météo */
.wx__now { display: flex; align-items: center; gap: 12px; }
.wx__icon { display: grid; place-items: center; width: 52px; height: 52px; flex: none; border-radius: 16px; color: #f59e0b; background: rgb(245 158 11 / .14); }
.wx__icon svg { width: 30px; height: 30px; }
.wx__main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.wx__temp { font-size: 2.2rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.wx__label { font-size: .82rem; color: var(--muted); }
.wx__side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.widget--m .wx__side { display: none; }
.wx__tip { display: flex; align-items: center; gap: 8px; margin: 0; padding: 9px 12px; border-radius: 12px; font-size: .82rem; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); }
.wx__tip svg { width: 17px; height: 17px; flex: none; }
.wx__hours { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; text-align: center; font-size: .74rem; color: var(--muted); }
.wx__hour { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.wx__hour svg { width: 18px; height: 18px; color: var(--text); opacity: .8; }
.wx__hour strong { font-size: .82rem; color: var(--text); font-variant-numeric: tabular-nums; }
.wx__rain { font-weight: 600; color: #0ea5e9; }
.wx__days { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.wx__day { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: 12px; font-size: .74rem; background: var(--surface-2); }
.wx__day svg { width: 18px; height: 18px; }
.wx__day-name { font-weight: 650; }
.wx__day-range { font-variant-numeric: tabular-nums; color: var(--muted); }

/* En ce moment */
.wsum { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.widget--m .wsum { grid-template-columns: minmax(0, 1fr); }
.wsum__tile { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.wsum__icon svg { width: 20px; height: 20px; }
.wsum__tile--on .wsum__icon { color: var(--on); }
.wsum__tile--accent .wsum__icon { color: var(--accent-ink); }
.wsum__tile--warm .wsum__icon { color: #fb923c; }
.wsum__tile--sun .wsum__icon { color: #f59e0b; }
.wsum__value { font-size: 1.05rem; font-weight: 700; }
.wsum__detail { font-size: .74rem; color: var(--muted); }

/* Alertes */
.walert { display: flex; align-items: center; gap: 12px; }
.walert + .walert { padding-top: 10px; border-top: 1px solid var(--border); }
.walert__icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 11px; }
.walert__icon svg { width: 18px; height: 18px; }
.walert--warn .walert__icon { color: var(--on); background: var(--on-soft); }
.walert--alert .walert__icon { color: var(--error); background: var(--error-soft); }
.walert--ok .walert__icon { color: var(--ok); background: var(--ok-soft); }
.walert__text { display: flex; flex-direction: column; min-width: 0; }
.walert__text strong { font-size: .88rem; }
.walert__text span { font-size: .76rem; color: var(--muted); }

/* Raccourcis */
.wshort { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.widget--m .wshort { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wshort__btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; padding: 12px 4px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer;
}
.wshort__btn:hover:not(:disabled) { border-color: var(--accent); }
.wshort__btn:disabled { opacity: .5; cursor: default; }
.wshort__btn.is-busy { opacity: .6; }
.wshort__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; color: var(--accent-ink); background: var(--accent-soft); }
.wshort__icon svg { width: 20px; height: 20px; }
.wshort__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .74rem; font-weight: 650; }

/* Énergie du jour */
.wenergy__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.wenergy__stat span { display: block; font-size: .74rem; color: var(--muted); }
.wenergy__stat strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.wenergy__stat .is-ok { color: var(--ok); }
.wenergy__bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.wenergy__legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .74rem; color: var(--muted); }
.wenergy__legend span { display: inline-flex; align-items: center; gap: 6px; }
.wenergy__legend i { width: 8px; height: 8px; border-radius: 50%; }

/* Objectifs solaires */
.wsolar__goal-row { display: flex; align-items: center; gap: 14px; }
.wsolar__ring { flex: none; width: 76px; height: 76px; }
.wsolar__track { fill: none; stroke: color-mix(in srgb, var(--on) 18%, transparent); stroke-width: 14; }
.wsolar__value { fill: none; stroke: var(--on); stroke-width: 14; stroke-linecap: round; }
.wsolar__goal { stroke: var(--text); stroke-width: 3; stroke-linecap: round; }
.wsolar__pct { fill: var(--text); font-size: 26px; font-weight: 800; }
.wsolar__goal-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wsolar__goal-text strong { font-size: .95rem; }
.wsolar__goal-text span { font-size: .76rem; color: var(--muted); }
.wsolar__challenge { display: flex; flex-direction: column; gap: 6px; }
.wsolar__line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: .84rem; }
.wsolar__icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: var(--on); background: var(--on-soft); }
.wsolar__icon svg { width: 15px; height: 15px; }
.wsolar__status { margin-left: auto; padding: 2px 8px; border-radius: 999px; font-size: .68rem; font-weight: 700; color: var(--on); background: var(--on-soft); }
.wsolar__bar { height: 7px; border-radius: 999px; background: color-mix(in srgb, var(--text) 9%, transparent); overflow: hidden; }
.wsolar__bar span { display: block; height: 100%; border-radius: inherit; background: var(--on); }
.wsolar__house { display: flex; flex-direction: column; gap: 6px; }
.wsolar__words { display: flex; flex-wrap: wrap; gap: 6px; }
.wsolar__words span { padding: 3px 10px; border-radius: 999px; font-size: .95rem; font-weight: 800; background: var(--surface-2); }
.wsolar__report .widget__link { margin-left: auto; }

/* ---------------------------------------------------------------- Dispositions « Par pièce » et « Tableau » */

.space-rooms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
@media (min-width: 700px) { .space-rooms { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.space .space-room { display: flex; flex-direction: column; justify-content: flex-start; gap: 4px; min-height: 120px; color: var(--text); text-decoration: none; }
.space .space-room:hover { text-decoration: none; border-color: var(--accent); }
.space-room__title { font-size: 1.05rem; font-weight: 700; }
.space-room__meta { font-size: .8rem; color: var(--muted); }
.space-room__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.space-room__chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--surface-2); }
.space-room__chip svg { width: 13px; height: 13px; }
.space-room__chip.is-on { color: var(--on); }
.space-room-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.space-room-head__back { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; color: var(--text); background: var(--surface-2); }
.space-room-head__back svg { width: 20px; height: 20px; }
.space-room-head__title { margin: 0; font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; }
.space--board .space-hero { margin-bottom: 18px; }
.space--board .space-hero__title { font-size: clamp(1.5rem, 3vw, 2.2rem); }

/* ---------------------------------------------------------------- Climat de plusieurs pièces (capteur en affichage « climate ») */

.climate__summary { display: flex; flex-direction: column; gap: 2px; }
.climate__avg { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; }
.climate__avg .metric__value { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.climate__hum { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: .95rem; font-weight: 650; color: #0ea5e9; }
.climate__hum svg { width: 16px; height: 16px; }
.climate__range { font-size: .78rem; color: var(--muted); }
.climate__rows { display: flex; flex-direction: column; gap: 6px; }
.climate__row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "label temp hum" "chip temp hum";
  align-items: center; gap: 2px 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: var(--radius-sm);
  font: inherit; color: var(--text); text-align: left; background: var(--surface-2);
}
button.climate__row { cursor: pointer; }
button.climate__row:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.climate__label { grid-area: label; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; font-weight: 600; }
.climate__chip { grid-area: chip; justify-self: start; font-size: .7rem; font-weight: 650; color: var(--muted); }
.climate__chip[data-tone="ok"] { color: var(--ok); }
.climate__chip[data-tone="warn"] { color: var(--on); }
.climate__chip[data-tone="alert"] { color: var(--error); }
.climate__temp { grid-area: temp; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.climate__row-hum { grid-area: hum; min-width: 3.2em; text-align: right; font-size: .85rem; font-weight: 600; color: #0ea5e9; font-variant-numeric: tabular-nums; }
.climate__empty { margin: 0; font-size: .85rem; color: var(--muted); }
.climate__graphs { display: flex; flex-direction: column; gap: 18px; }
.climate__graph { display: flex; flex-direction: column; gap: 6px; }
.climate__graph-title { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 650; color: var(--muted); }
.climate__graph-title svg { width: 15px; height: 15px; }
/* Éditeur : une pièce par bloc */
.climate-edit { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 12px; border: 1px solid var(--border); }
.climate-edit__head { display: flex; align-items: center; gap: 4px; }
.climate-edit__head input { flex: 1; min-width: 0; }
