/* Thème sombre (défaut). « Auto » suit le système ; un choix explicite pose data-theme sur <html>. */
:root {
  color-scheme: dark;
  --bg: #121417;
  --surface: #1b1f24;
  --surface-2: #232830;
  --track: #2a3038;
  --text: #f1f3f5;
  --muted: #9aa3ad;
  --accent: #f5b74f;
  --accent-text: #f5b74f;
  --on-accent: #1a1307;
  --ok: #5fd3b3;
  --on-ok: #0d2a22;
  --danger: #ff8a7a;
  --sky: #26303c;
  --tempo-blue: #5b8def;
  --tempo-red: #ff6b6b;
  --radius: 18px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #f5efe6;
    --surface: #fffaf2;
    --surface-2: #ece3d6;
    --track: #d9d0c3;
    --text: #231f1a;
    --muted: #6a6155;
    --accent: #b8472f;
    --accent-text: #9c3a25;
    --on-accent: #ffffff;
    --ok: #1f7a58;
    --on-ok: #ffffff;
    --danger: #b3261e;
    --sky: #bcd3e6;
  --tempo-blue: #2e6bd6;
  --tempo-red: #c9302c;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5efe6;
  --surface: #fffaf2;
  --surface-2: #ece3d6;
  --track: #d9d0c3;
  --text: #231f1a;
  --muted: #6a6155;
  --accent: #b8472f;
  --accent-text: #9c3a25;
  --on-accent: #ffffff;
  --ok: #1f7a58;
  --on-ok: #ffffff;
  --danger: #b3261e;
  --sky: #bcd3e6;
  --tempo-blue: #2e6bd6;
  --tempo-red: #c9302c;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main {
  max-width: 760px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(40px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 24px;
}
@media (min-width: 900px) { main { max-width: 1120px; } }

h1 { margin: 2px 0 0; font-size: 30px; letter-spacing: -0.5px; }
h2 { margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.svg { display: inline-grid; place-items: center; line-height: 0; }

/* En-tête */
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.date { font-size: 14px; color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.dot.ko { background: var(--danger); }

/* Présence */
.persons { display: grid; gap: 12px; }
.person {
  display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 16px;
  border-radius: var(--radius); background: var(--surface);
}
.person:hover { background: var(--surface-2); }
.person > .grow { flex: 1; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ok); color: var(--on-ok); font-weight: 700;
}
.pn { font-weight: 500; }
.ps { margin-top: 2px; font-size: 13px; color: var(--muted); }
.ps .home { color: var(--ok); }
.ps .away { color: var(--text); }

/* Sections et tuiles */
.sec h2 {
  margin-bottom: 10px; font-size: 13px; font-weight: 500; letter-spacing: 0.4px;
  text-transform: uppercase; color: var(--muted);
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.cell { position: relative; }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  width: 100%; min-height: 118px; padding: 14px; border: 0; border-radius: var(--radius);
  background: var(--surface); text-align: left; cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.tile:hover { background: var(--surface-2); }
.tile.offline { opacity: 0.6; }
.ico {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--track); color: var(--muted);
}
.ico.on { background: var(--accent); color: var(--on-accent); }
.tl { display: flex; flex-direction: column; gap: 2px; }
.name { font-size: 15px; font-weight: 500; }
.st { font-size: 13px; color: var(--muted); }
.bar { display: block; height: 4px; margin-top: 6px; border-radius: 2px; background: var(--track); overflow: hidden; }
.bar::after { content: ""; display: block; height: 100%; width: var(--p, 0%); background: var(--accent); }
.empty { padding: 24px; border-radius: var(--radius); background: var(--surface); color: var(--muted); }

/* Pages de détail */
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--muted); font-size: 15px; }
.detail { display: flex; flex-direction: column; gap: 18px; max-width: 520px; width: 100%; margin: 0 auto; }
.sub { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 14px; color: var(--muted); }
.big { font-size: 56px; font-weight: 700; letter-spacing: -1px; line-height: 1; text-align: center; }
.center { text-align: center; }
.row { display: flex; gap: 10px; }
.btn {
  flex: 1; min-height: 56px; padding: 0 16px; border: 0; border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-2); color: var(--text); font-weight: 500; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary, .btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn.sm { min-height: 44px; padding: 0 8px; border-radius: 12px; background: var(--surface); white-space: nowrap; }
.btn.sm[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
input[type="range"] { width: 100%; height: 44px; margin: 0; accent-color: var(--accent); background: transparent; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.card { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 14px; background: var(--surface); }
.card .k { font-size: 12px; color: var(--muted); }
.card .v { margin-top: 2px; font-size: 16px; font-weight: 500; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; }

/* Volet dessiné */
.window {
  position: relative; width: 220px; height: 300px; margin: 0 auto; overflow: hidden;
  border: 6px solid var(--track); border-radius: 14px; background: var(--sky);
}
.window .sun { position: absolute; right: 30px; bottom: 34px; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); }
.window .blind {
  position: absolute; inset: 0 0 auto 0; height: calc(100% - var(--open, 0) * 1%);
  background: repeating-linear-gradient(#d3d6db 0 10px, #b9bdc4 10px 12px); transition: height 0.4s;
}
.window .hem {
  position: absolute; left: 0; right: 0; height: 8px; top: calc(100% - var(--open, 0) * 1% - 8px);
  background: #8b9099; transition: top 0.4s;
}
@media (prefers-reduced-motion: reduce) { .window .blind, .window .hem { transition: none; } }

/* Zone de présence */
.ring { position: relative; width: 300px; height: 300px; margin: 0 auto; }
.ring .r { position: absolute; left: 50%; top: 50%; border-radius: 50%; transform: translate(-50%, -50%); }
.ring .out { width: 270px; height: 270px; border: 2px dashed var(--muted); }
.ring .in {
  width: var(--d, 180px); height: var(--d, 180px); border: 2px solid var(--ok);
  background: color-mix(in srgb, var(--ok) 15%, transparent);
}
.ring .home { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.ring .lbl { position: absolute; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); }
.ring .lbl.o { top: 38px; }
.ring .lbl.i { top: calc(50% - var(--d, 180px) / 2 + 8px); color: var(--ok); }
.ring .who {
  position: absolute; left: var(--x); top: var(--y); width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: var(--on-ok);
  font-size: 13px; font-weight: 700;
}

/* Réglages */
.settings { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; border-top: 1px solid var(--track); }
.settings h2 { font-size: 13px; font-weight: 500; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); }

/* Connexion */
.login { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
input[type="password"], input[type="text"], input[type="number"], input[type="date"], input[type="time"], select {
  min-height: 52px; padding: 0 16px; border: 1px solid var(--track); border-radius: 14px;
  background: var(--surface); color: var(--text); font: inherit;
}
.err { min-height: 1.4em; color: var(--danger); }

/* Vue invité : plus grand, plus simple */
.guest { max-width: 520px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.pill {
  display: inline-block; padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 500;
  color: var(--accent-text); background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.gcard { display: flex; flex-direction: column; gap: 16px; padding: 22px; border-radius: 22px; background: var(--surface); }
.gcard .name { font-size: 22px; font-weight: 700; }
.gcard .st { margin-top: 4px; font-size: 18px; }
.gcard .btn { min-height: 64px; border-radius: 18px; font-size: 20px; font-weight: 700; }
.guest .note { font-size: 16px; line-height: 1.5; color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 10;
  max-width: 90vw; padding: 12px 18px; border-radius: 14px; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
#toast:empty { display: none; }

/* Compte, réglages, pièces */
.top .side { display: flex; align-items: center; gap: 10px; }
.avatar-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--text); font-weight: 700;
}
.avatar-btn:hover { background: var(--surface-2); }
.panel { display: flex; flex-direction: column; gap: 10px; }
.panel h2 { font-size: 13px; font-weight: 500; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); }
.listrow {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px;
  border-radius: 14px; background: var(--surface);
}
a.listrow:hover { background: var(--surface-2); }
.grow { flex: 1; min-width: 0; }
.meta { display: block; font-size: 13px; color: var(--muted); }
.addform { display: flex; gap: 10px; }
.addform input { flex: 1; min-width: 0; }
.addform .btn { flex: 0 0 auto; padding: 0 20px; }
label.check {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 16px;
  border-radius: 14px; background: var(--surface); cursor: pointer;
}
label.check:hover { background: var(--surface-2); }
label.check input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
label.check .ico { width: 32px; height: 32px; flex: none; }
.btn.danger { background: var(--surface); color: var(--danger); }
.btn.danger.confirm { background: var(--danger); color: var(--on-accent); font-weight: 700; }
.detail .note { font-size: 14px; }

/* Énergie */
.energy-card {
  display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: var(--radius); background: var(--surface);
}
.energy-card:hover { background: var(--surface-2); }
.energy-card .watts { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; line-height: 1; }
.energy-card .end { text-align: right; }
.lab { margin-top: 4px; font-size: 13px; color: var(--muted); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 13px;
}
.swatch { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; }
.c-blue { background: var(--tempo-blue); }
.c-red { background: var(--tempo-red); }
.c-white { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.c-none { background: var(--track); }
.chartcard { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--radius); background: var(--surface); }
.chartcard h2 { font-size: 13px; font-weight: 500; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); }
.row.wrap { flex-wrap: wrap; justify-content: center; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { padding: 14px; border-radius: 14px; background: var(--surface); }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { margin: 2px 0; font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.readout { min-height: 4.4em; font-size: 14px; }
.readout .sub2 { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 150px; border-bottom: 1px solid var(--track); }
.bar-col {
  flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; border-radius: 4px 4px 0 0;
  display: flex; align-items: flex-end; background: transparent; cursor: pointer;
}
.bar-col[aria-pressed="true"] { background: color-mix(in srgb, var(--text) 10%, transparent); }
.bar-col .fill { display: block; width: 100%; height: calc(var(--h, 0) * 1%); min-height: 2px; border-radius: 4px 4px 0 0; }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
details summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; color: var(--muted); font-size: 14px; }
table.days { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.days th, table.days td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--track); font-weight: 400; }
table.days th:first-child, table.days td:first-child { text-align: left; }
table.days thead th { color: var(--muted); }
.split-row { display: grid; gap: 6px; padding: 12px 16px; border-radius: 14px; background: var(--surface); }
.split-row .line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.meter { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.meter::after { content: ""; display: block; height: 100%; width: calc(var(--p, 0) * 1%); background: var(--accent); }

/* Navigation latérale (masquée sur smartphone) */
.shell { display: block; }
#nav { display: none; }

/* Ordinateur : barre latérale, grilles plus larges, page Énergie sur deux colonnes */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
  #nav {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px;
    padding: 28px 16px 20px; background: var(--surface); border-right: 1px solid var(--track);
  }
  #nav:empty { display: none; }
  .shell:has(#nav:empty) { grid-template-columns: minmax(0, 1fr); }
  #nav .brand { padding: 0 12px; font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
  .navlinks { display: flex; flex-direction: column; gap: 4px; flex: 1; }
  .navlink {
    display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px;
    color: var(--muted); font-size: 15px;
  }
  .navlink:hover { background: var(--surface-2); color: var(--text); }
  .navlink[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
  .navlink[aria-current="page"] .svg { color: var(--accent-text); }
  .navlink.account { min-height: 56px; }
  .avatar-mini {
    width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center;
    background: var(--ok); color: var(--on-ok); font-weight: 700; font-size: 14px;
  }
  .who2 { display: flex; flex-direction: column; line-height: 1.25; }
  .who2 .name { color: var(--text); font-size: 14px; }

  main { max-width: 1240px; margin: 0; padding: 36px 44px 56px; gap: 28px; }
  .avatar-btn { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
  .tile { min-height: 132px; padding: 16px; }
  .summary-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; align-items: stretch; }
  .summary-row .persons, .summary-row .energy-card { height: 100%; }
  .summary-row .persons { align-content: start; }
  .detail { max-width: 640px; margin: 0; }
  .login { margin: 8vh auto 0; }
  .guest { margin: 4vh auto; }

  .detail.wide {
    max-width: none; display: grid; gap: 18px; align-items: start;
    grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
    grid-template-areas: "back back" "title title" "side chart" "devices devices";
  }
  .detail.wide > .back { grid-area: back; justify-self: start; }
  .detail.wide > h1 { grid-area: title; }
  .g-side { grid-area: side; display: flex; flex-direction: column; gap: 18px; }
  .g-chart { grid-area: chart; align-self: stretch; }
  .g-chart .bars { height: 240px; }
  .g-devices { grid-area: devices; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
  .g-devices > h2, .g-devices > .empty { grid-column: 1 / -1; }
}
@media (min-width: 1500px) {
  main { max-width: 1400px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
}

.summary-row { display: grid; gap: 12px; }
@media (min-width: 900px) { .summary-row { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; } }

/* Formulaires de réglages */
.field { display: flex; flex-direction: column; gap: 6px; }
.field .flabel { font-size: 14px; }
select { appearance: auto; width: 100%; }
.pricegrid { display: grid; grid-template-columns: auto 1fr 1fr; gap: 10px; align-items: center; }
.pricegrid .rowlabel { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.pricegrid input { min-width: 0; width: 100%; }
a.btn { text-decoration: none; }
@media (min-width: 900px) { .g-link { grid-area: link; } .detail.wide { grid-template-areas: "back back" "title title" "side chart" "trail trail" "tips tips" "devices devices" "link link"; } .g-trail { grid-area: trail; } .g-tips { grid-area: tips; } }
.note.warn { color: var(--warn, #e0a030); }
pre.code { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--card-2, rgba(127,127,127,.12)); font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-x: auto; user-select: all; }
ol.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--muted); }

/* Lecteurs multimédia */
.nowplaying { text-align: center; padding: 8px 0; }
.np-title { font-size: 22px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.np-sub { margin-top: 4px; }
.mediabtns { display: flex; gap: 14px; justify-content: center; align-items: center; }
.btn.round { flex: none; width: 56px; min-width: 56px; height: 56px; min-height: 56px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.btn.round.main { width: 72px; min-width: 72px; height: 72px; min-height: 72px; }
.dpad { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 56px); gap: 8px; justify-content: center; margin-top: 8px; }
.dkey { padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.dkey.up { grid-area: 1 / 2; }
.dkey.left { grid-area: 2 / 1; }
.dkey.select { grid-area: 2 / 2; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.dkey.right { grid-area: 2 / 3; }
.dkey.down { grid-area: 3 / 2; }
.row > .btn { flex: 1; }

/* Automatismes, modes, alertes */
.modes { display: flex; gap: 8px; flex-wrap: wrap; }
.mode { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 0; background: var(--surface); color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.mode[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.mode:disabled { cursor: default; opacity: 0.85; }
.alerts { display: flex; gap: 8px; flex-wrap: wrap; }
.alert { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--surface); color: var(--danger); font-size: 14px; }
.alert:hover { background: var(--surface-2); }
.tile[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.autorow { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; background: var(--surface); }
.autorow.off .name, .autorow.off .meta { opacity: 0.55; }
.autorow .grow { color: inherit; }
.autorow .btn.sm { flex: none; padding: 0 14px; }
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.template { text-align: left; border: 0; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 14px; background: var(--surface); cursor: pointer; }
.template:hover { background: var(--surface-2); }
.steprow { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: 14px; background: var(--surface); }
.steprow .stack { display: flex; flex-direction: column; gap: 8px; }
.steprow select, .steprow input { width: 100%; }
.steprow .row > * { flex: 1; min-width: 0; }
.stepno { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--track); font-size: 13px; }
.stepbtns { display: flex; flex-direction: column; gap: 6px; }
.stepbtns .btn.sm, .steprow > .btn.sm { min-width: 44px; }
.daypick { display: flex; gap: 6px; }
.btn.sm.day { flex: 1; padding: 0; }
.sep { align-self: center; flex: none !important; color: var(--muted); }
.autosum { padding: 12px 16px; border-radius: 14px; background: var(--surface); }
.detail input[type="text"], .detail input[type="number"] { width: 100%; }
.steprow > .btn.sm { flex: none; }

/* Courbe 24 h et conseils */
.trailbox { position: relative; }
.trail { width: 100%; height: 180px; display: block; touch-action: pan-y; }
.trail .hc { fill: var(--track); opacity: 0.35; }
.trail .grid { stroke: var(--track); stroke-width: 1; vector-effect: non-scaling-stroke; }
.trail .area { fill: var(--accent); opacity: 0.2; }
.trail .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.trail .cursor { stroke: var(--text); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: 0.6; }
.ymax { position: absolute; top: 2px; left: 4px; font-size: 11px; color: var(--muted); pointer-events: none; }
.hcsw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--track); opacity: 0.6; vertical-align: -1px; margin-right: 6px; }
.tips { gap: 8px; }
.tip { display: flex; gap: 12px; padding: 12px 16px 12px 12px; border-radius: 14px; background: var(--surface); }
.tipbar { flex: none; width: 4px; border-radius: 2px; background: var(--muted); }
.tip.ok .tipbar { background: var(--ok); }
.tip.warn .tipbar { background: var(--danger); }
.tip.info .tipbar { background: var(--accent); }

/* Accueil : résumé et pièces */
.glance { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.sumcard { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 72px; border-radius: var(--radius); background: var(--surface); }
.sumcard.on { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.sumico { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--track); }
.sumcard.on .sumico { background: var(--accent); color: var(--on-accent); }
.sumv { font-weight: 600; }
.sumk { font-size: 13px; color: var(--muted); }
.sumcard .btn.sm { flex: none; min-height: 40px; padding: 0 14px; }
.roomcard { padding: 16px; border-radius: calc(var(--radius) + 6px); background: var(--surface); }
.roomcard .tile { background: var(--surface-2); }
.roomcard .tile[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); }
.rh { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.rh h2 { margin: 0; }
.rs { font-size: 13px; color: var(--muted); }

/* Réglage de l'intensité directement sur la tuile d'une lumière */
.cell.dim .tile { padding-bottom: 52px; }
.dimbar { position: absolute; left: 10px; bottom: 6px; width: calc(100% - 20px); max-width: calc(100% - 20px); box-sizing: border-box; height: 40px; margin: 0; touch-action: pan-y; }
textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line, rgba(128,128,128,.3)); background: var(--card); color: inherit; font: inherit; resize: vertical; }
.bar.wide { height: 8px; border-radius: 4px; margin: 4px 0 12px; }

.colorpanel { gap: 6px; margin-top: 8px; }
.colorhead { display: flex; align-items: center; justify-content: space-between; }
.colorswatch { width: 34px; height: 34px; border-radius: 50%; background: var(--sw); border: 2px solid var(--surface); box-shadow: 0 0 0 1px rgba(128,128,128,.35); }
.small { font-size: 12px; }
input[type="range"].huebar, input[type="range"].satbar, input[type="range"].tempbar { appearance: none; -webkit-appearance: none; height: 22px; border-radius: 11px; margin: 6px 0 12px; }
input[type="range"].huebar { background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
input[type="range"].satbar { background: linear-gradient(90deg, #fff, var(--sw, #f90)); }
input[type="range"].tempbar { background: linear-gradient(90deg, #ffa43a, #ffe9c9, #cfe3ff); }
input[type="range"].huebar::-webkit-slider-thumb, input[type="range"].satbar::-webkit-slider-thumb, input[type="range"].tempbar::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid rgba(0,0,0,.35); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
input[type="range"].huebar::-moz-range-thumb, input[type="range"].satbar::-moz-range-thumb, input[type="range"].tempbar::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid rgba(0,0,0,.35); }
.presets { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.preset { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px rgba(128,128,128,.4); background: var(--sw); cursor: pointer; padding: 0; }


/* Familles de couleurs des thèmes futuristes (valeurs RGB pour les transparences) */
:root {
  --a-rgb: 77, 240, 255; --b-rgb: 155, 140, 255; --lit-rgb: 255, 211, 107; --e-rgb: 110, 190, 255; --deep-rgb: 10, 16, 30;
  --g1: #4df0ff; --g1b: #8de9ff; --g3: #9b8cff; --on-lit: #1a1200;
}
/* ===== Thème « Futur » : cockpit sombre, verre, filets cyan, lueurs ===== */
:root[data-theme="futur"] {
  color-scheme: dark;
  --bg: #04060c;
  --surface: rgba(16, 24, 42, 0.72);
  --surface-2: rgba(28, 42, 70, 0.78);
  --track: rgba(110, 160, 230, 0.2);
  --text: #e8f1ff;
  --muted: #93a6c6;
  --accent: #4df0ff;
  --accent-text: #4df0ff;
  --on-accent: #04060c;
  --ok: #7cffb2;
  --on-ok: #04200f;
  --danger: #ff9393;
  --warn: #ffb84d;
  --sky: #0d1a30;
  --tempo-blue: #2f7bff;
  --tempo-red: #ff6b6b;
  --radius: 20px;
  --edge: rgba(110, 190, 255, 0.18);
  --glow: rgba(77, 240, 255, 0.35);
  --lit: #ffd36b;
  --on-lit: #1a1200;
}
[data-fx] body {
  background-color: #04060c;
  background-image:
    radial-gradient(900px 620px at 50% 30%, rgba(var(--a-rgb), 0.1), transparent 62%),
    radial-gradient(700px 520px at 100% 0%, rgba(var(--b-rgb), 0.14), transparent 60%),
    radial-gradient(600px 400px at 0% 100%, rgba(var(--a-rgb), 0.07), transparent 60%),
    linear-gradient(rgba(120, 170, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 170, 255, 0.045) 1px, transparent 1px);
  background-size: auto, auto, auto, 56px 56px, 56px 56px;
  background-attachment: fixed;
}
[data-fx] h1 { font-weight: 500; letter-spacing: -0.025em; }
/* Surfaces en verre */
[data-fx] :is(.tile, .sumcard, .roomcard, .energy-card, .chartcard, .person, .listrow, .card, .kpi, .split-row, .autorow, .template, .steprow, .autosum, .tip, .gcard, .empty, .orbcard, label.check, .btn.sm, .mode, .alert, .chip, .avatar-btn, .badge, input[type="password"], input[type="text"], input[type="number"], input[type="date"], input[type="time"], select, textarea) {
  border: 1px solid var(--edge);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
[data-fx] :is(.tile, .sumcard, .roomcard, .chartcard, .orbcard, .gcard) { box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4); }
[data-fx] :is(.tile, .person, a.listrow, .template, .alert, label.check, .energy-card, .orbcard):hover { border-color: rgba(var(--a-rgb), 0.45); background: var(--surface-2); }
[data-fx] .roomcard .tile { background: rgba(var(--deep-rgb), 0.55); }
/* Éléments actifs : lueur ambre pour ce qui est allumé, cyan pour l'interface */
[data-fx] .tile[aria-pressed="true"],
[data-fx] .roomcard .tile[aria-pressed="true"],
[data-fx] .sumcard.on {
  background: linear-gradient(160deg, rgba(var(--lit-rgb), 0.16), rgba(var(--deep-rgb), 0.78));
  border-color: rgba(var(--lit-rgb), 0.5);
  box-shadow: 0 0 34px rgba(var(--lit-rgb), 0.12);
}
[data-fx] .ico.on, [data-fx] .sumcard.on .sumico { background: var(--lit); color: var(--on-lit); box-shadow: 0 0 18px rgba(var(--lit-rgb), 0.6); }
[data-fx] .ico, [data-fx] .sumico { background: rgba(var(--e-rgb), 0.1); }
[data-fx] :is(.btn.primary, .btn[aria-pressed="true"], .btn.sm[aria-pressed="true"], .mode[aria-pressed="true"], .dkey.select) {
  background: linear-gradient(135deg, var(--g1), var(--g1b)); color: var(--on-accent); border-color: transparent; box-shadow: 0 0 22px rgba(var(--a-rgb), 0.45);
}
[data-fx] .btn { border: 1px solid var(--edge); background: rgba(var(--deep-rgb), 0.7); }
[data-fx] .btn.danger { color: var(--danger); }
[data-fx] .btn.danger.confirm { background: var(--danger); color: #1a0505; }
[data-fx] .bar::after, [data-fx] .meter::after { background: linear-gradient(90deg, var(--g1), var(--g3)); box-shadow: 0 0 8px rgba(var(--a-rgb), 0.6); }
[data-fx] .dot { box-shadow: 0 0 10px var(--ok); }
/* Étiquettes techniques */
[data-fx] :is(.sec h2, .panel h2, .chartcard h2, .settings h2, .card .k, .kpi .k, .rs, .date) {
  font: 500 11px/1.4 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
[data-fx] :is(.big, .watts, .kpi .v, .np-title) { text-shadow: 0 0 28px rgba(var(--a-rgb), 0.35); }
/* Navigation latérale */
[data-fx] #nav { background: rgba(var(--deep-rgb), 0.6); border-right-color: var(--edge); backdrop-filter: blur(14px); }
[data-fx] #nav .brand { background: linear-gradient(135deg, var(--g1), var(--g3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-fx] .navlink[aria-current="page"] { background: rgba(var(--a-rgb), 0.1); box-shadow: inset 0 0 0 1px rgba(var(--a-rgb), 0.4), 0 0 22px rgba(var(--a-rgb), 0.2); }
[data-fx] .navlink[aria-current="page"] .svg { color: var(--accent); }
[data-fx] .avatar, [data-fx] .avatar-mini { background: rgba(var(--b-rgb), 0.2); color: var(--text); box-shadow: 0 0 0 1px rgba(var(--b-rgb), 0.55); }
[data-fx] .ring .in { background: rgba(124, 255, 178, 0.1); box-shadow: 0 0 30px rgba(124, 255, 178, 0.2); }
[data-fx] #toast { background: rgba(var(--deep-rgb), 0.92); border: 1px solid var(--edge); }
/* Courbe, graphiques */
[data-fx] .trail .line { stroke: var(--g1); filter: drop-shadow(0 0 5px rgba(var(--a-rgb), 0.8)); }
[data-fx] .trail .area { fill: var(--g1); opacity: 0.16; }
[data-fx] .bar-col .fill { box-shadow: 0 0 10px rgba(47, 123, 255, 0.35); }

/* Noyau d'énergie (accueil) */
.orbcard { display: none; }
[data-fx] .orbcard { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 18px 16px 16px; border-radius: var(--radius); position: relative; overflow: hidden; }
[data-fx] .summary-row .orbcard { height: 100%; justify-content: center; }
.orbwrap { position: relative; width: 260px; max-width: 100%; aspect-ratio: 1 / 1; }
.orbsvg { position: absolute; inset: 0; display: block; }
.orbsvg svg { width: 100%; height: 100%; display: block; }
.orbspin { transform-origin: 130px 130px; animation: orbspin 90s linear infinite; }
@keyframes orbspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .orbspin { animation: none; } }
.orbcore { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; }
.orbk { font: 500 10px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); }
.orbw { font-size: 46px; font-weight: 500; letter-spacing: -0.04em; line-height: 1.05; text-shadow: 0 0 30px rgba(var(--a-rgb), 0.45); }
.orbt .badge { font-size: 12px; padding: 4px 10px; background: rgba(var(--deep-rgb), 0.85); }
.orbfoot { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; font-size: 14px; color: var(--muted); }
.orbp { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

/* Roue de teinte (fiche d'une lumière) */
.wheel {
  position: relative; width: min(240px, 100%); aspect-ratio: 1 / 1; margin: 6px auto 12px; border-radius: 50%; cursor: pointer; touch-action: none;
  background: conic-gradient(from 0deg, #ff3b3b, #ffb02e, #f6ff4a, #3dff8a, #2ef4ff, #3b6bff, #b04dff, #ff4dc1, #ff3b3b);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 0 40px rgba(var(--a-rgb), 0.12);
}
.wheel:focus-visible { outline-offset: 6px; }
.wheel-in { position: absolute; inset: 18%; border-radius: 50%; background: radial-gradient(circle, var(--sw, #4df0ff) 0%, #050914 78%); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); pointer-events: none; }
.wheel-handle { position: absolute; left: var(--hx, 50%); top: var(--hy, 9%); width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 3px solid #fff; background: transparent; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4), 0 0 18px rgba(255, 255, 255, 0.6); pointer-events: none; }

/* Éléments SVG du noyau d'énergie : couleurs issues du thème */
.orbsvg .s1 { stop-color: var(--g1); }
.orbsvg .s3 { stop-color: var(--g3); }
.orbring { stroke: rgba(var(--a-rgb), 0.16); }
.orbtrack { stroke: rgba(var(--e-rgb), 0.14); }

/* ===== Thème « Néon » : cyberpunk, magenta et cyan, angles vifs ===== */
:root[data-theme="neon"] {
  color-scheme: dark;
  --bg: #07030f; --surface: rgba(24, 8, 40, 0.78); --surface-2: rgba(44, 14, 66, 0.82); --track: rgba(255, 60, 214, 0.22);
  --text: #fbeaff; --muted: #b497c9; --accent: #ff2bd6; --accent-text: #ff6be6; --on-accent: #1a0314;
  --ok: #3dfff0; --on-ok: #02201d; --danger: #ff6b8a; --warn: #ffd23d; --sky: #1a0830;
  --tempo-blue: #19c6ff; --tempo-red: #ff4d6d; --radius: 6px;
  --edge: rgba(255, 60, 214, 0.38); --glow: rgba(255, 43, 214, 0.45); --lit: #fff35c; --on-lit: #1a1700;
  --a-rgb: 255, 43, 214; --b-rgb: 25, 230, 255; --lit-rgb: 255, 243, 92; --e-rgb: 255, 80, 220; --deep-rgb: 14, 4, 26;
  --g1: #ff2bd6; --g1b: #ff7ae8; --g3: #19e6ff;
}
[data-theme="neon"] body {
  background-color: #07030f;
  background-image:
    radial-gradient(800px 560px at 12% 0%, rgba(255, 43, 214, 0.2), transparent 60%),
    radial-gradient(760px 560px at 100% 100%, rgba(25, 230, 255, 0.16), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 4px);
  background-size: auto, auto, auto;
  background-attachment: fixed;
}
[data-theme="neon"] h1 { text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; text-shadow: 0 0 22px rgba(255, 43, 214, 0.55); }
[data-theme="neon"] :is(.tile, .sumcard, .roomcard, .chartcard, .orbcard, .gcard, .panel, .card, .person) {
  box-shadow: 0 0 0 1px rgba(255, 43, 214, 0.12), 0 0 26px rgba(255, 43, 214, 0.14), inset 0 0 26px rgba(255, 43, 214, 0.05);
}
[data-theme="neon"] :is(.tile, .person, a.listrow, .template, .alert, label.check, .energy-card, .orbcard):hover { border-color: #19e6ff; box-shadow: 0 0 22px rgba(25, 230, 255, 0.35); }
[data-theme="neon"] :is(.btn.primary, .btn[aria-pressed="true"], .btn.sm[aria-pressed="true"], .mode[aria-pressed="true"], .dkey.select) { text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; box-shadow: 0 0 24px rgba(255, 43, 214, 0.6); }
[data-theme="neon"] .tile[aria-pressed="true"], [data-theme="neon"] .roomcard .tile[aria-pressed="true"], [data-theme="neon"] .sumcard.on {
  background: linear-gradient(160deg, rgba(255, 243, 92, 0.2), rgba(14, 4, 26, 0.8)); border-color: #fff35c; box-shadow: 0 0 28px rgba(255, 243, 92, 0.3);
}
[data-theme="neon"] :is(.big, .watts, .kpi .v, .np-title, .orbw) { text-shadow: 0 0 24px rgba(255, 43, 214, 0.7); }
[data-theme="neon"] .navlink[aria-current="page"] { background: rgba(255, 43, 214, 0.14); box-shadow: inset 0 0 0 1px #ff2bd6, 0 0 22px rgba(255, 43, 214, 0.4); }
[data-theme="neon"] .trail .line { filter: drop-shadow(0 0 6px #ff2bd6); }

/* ===== Thème « Aurore » : verre givré, aurore boréale, grands arrondis ===== */
:root[data-theme="aurore"] {
  color-scheme: dark;
  --bg: #040b10; --surface: rgba(20, 44, 52, 0.5); --surface-2: rgba(30, 64, 74, 0.58); --track: rgba(140, 255, 214, 0.18);
  --text: #eafff7; --muted: #9bbfb6; --accent: #7affc8; --accent-text: #7affc8; --on-accent: #03140e;
  --ok: #7affc8; --on-ok: #03140e; --danger: #ff9bb0; --warn: #ffd58a; --sky: #0a2230;
  --tempo-blue: #5aa8ff; --tempo-red: #ff7a8a; --radius: 30px;
  --edge: rgba(190, 255, 235, 0.2); --glow: rgba(122, 255, 200, 0.35); --lit: #ffe08a; --on-lit: #241a00;
  --a-rgb: 122, 255, 200; --b-rgb: 176, 140, 255; --lit-rgb: 255, 224, 138; --e-rgb: 170, 255, 230; --deep-rgb: 6, 22, 28;
  --g1: #7affc8; --g1b: #b6ffe2; --g3: #b08cff;
}
[data-theme="aurore"] body {
  background-color: #040b10;
  background-image:
    radial-gradient(900px 520px at 20% -5%, rgba(80, 255, 190, 0.28), transparent 62%),
    radial-gradient(800px 560px at 85% 10%, rgba(176, 140, 255, 0.26), transparent 60%),
    radial-gradient(900px 520px at 50% 105%, rgba(60, 170, 255, 0.18), transparent 60%);
  background-attachment: fixed;
}
[data-theme="aurore"] h1 { font-weight: 300; letter-spacing: -0.03em; font-size: 1.15em; }
[data-theme="aurore"] :is(.tile, .sumcard, .roomcard, .chartcard, .orbcard, .gcard, .panel, .card, .person, .listrow, .alert, .energy-card) { backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3); border-radius: 30px; }
[data-theme="aurore"] .tile { border-radius: 24px; }
[data-theme="aurore"] :is(.btn, .btn.sm, .mode, .chip, .badge) { border-radius: 999px; }
[data-theme="aurore"] :is(.sec h2, .panel h2, .chartcard h2, .settings h2, .card .k, .kpi .k, .rs, .date) { font-family: inherit; letter-spacing: 0.08em; text-transform: none; font-size: 13px; }
[data-theme="aurore"] .tile[aria-pressed="true"], [data-theme="aurore"] .roomcard .tile[aria-pressed="true"], [data-theme="aurore"] .sumcard.on {
  background: linear-gradient(160deg, rgba(255, 224, 138, 0.26), rgba(255, 170, 200, 0.1)); border-color: rgba(255, 224, 138, 0.55); box-shadow: 0 0 40px rgba(255, 224, 138, 0.16);
}
[data-theme="aurore"] :is(.btn.primary, .btn[aria-pressed="true"], .btn.sm[aria-pressed="true"], .mode[aria-pressed="true"], .dkey.select) { background: linear-gradient(135deg, #7affc8, #b08cff); box-shadow: 0 8px 34px rgba(122, 255, 200, 0.35); }
[data-theme="aurore"] #nav .brand { background: linear-gradient(135deg, #7affc8, #b08cff); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-theme="aurore"] .trail .line { stroke: #7affc8; }

/* ===== Thème « HUD » : affichage tête haute, phosphore vert, traits fins ===== */
:root[data-theme="hud"] {
  color-scheme: dark;
  --bg: #020805; --surface: rgba(4, 22, 14, 0.72); --surface-2: rgba(8, 40, 26, 0.8); --track: rgba(61, 255, 160, 0.2);
  --text: #d6ffe9; --muted: #6fb892; --accent: #3dffa0; --accent-text: #3dffa0; --on-accent: #00140a;
  --ok: #3dffa0; --on-ok: #00140a; --danger: #ff7b6b; --warn: #ffc83d; --sky: #05241a;
  --tempo-blue: #3d9bff; --tempo-red: #ff6b5a; --radius: 2px;
  --edge: rgba(61, 255, 160, 0.34); --glow: rgba(61, 255, 160, 0.4); --lit: #ffc83d; --on-lit: #1a1200;
  --a-rgb: 61, 255, 160; --b-rgb: 255, 200, 61; --lit-rgb: 255, 200, 61; --e-rgb: 61, 255, 160; --deep-rgb: 2, 14, 8;
  --g1: #3dffa0; --g1b: #9bffd0; --g3: #ffc83d;
}
[data-theme="hud"] body {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background-color: #020805;
  background-image:
    radial-gradient(900px 600px at 50% 40%, rgba(61, 255, 160, 0.08), transparent 62%),
    linear-gradient(rgba(61, 255, 160, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(61, 255, 160, 0.06) 1px, transparent 1px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  background-size: auto, 28px 28px, 28px 28px, auto;
  background-attachment: fixed;
}
[data-theme="hud"] :is(h1, .name, .big, .watts, .kpi .v, .orbw) { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
[data-theme="hud"] h1 { text-transform: uppercase; letter-spacing: 0.12em; font-weight: 500; font-size: 0.95em; }
[data-theme="hud"] :is(.tile, .sumcard, .roomcard, .chartcard, .orbcard, .gcard, .panel, .card, .person, .listrow, .alert, .energy-card) { backdrop-filter: none; -webkit-backdrop-filter: none; border-style: solid; box-shadow: inset 0 0 0 1px rgba(61, 255, 160, 0.06), 0 0 18px rgba(61, 255, 160, 0.06); }
[data-theme="hud"] .roomcard { border-left: 3px solid var(--accent); }
[data-theme="hud"] :is(.btn, .btn.sm, .mode, .chip, .badge, input, select, textarea) { border-radius: 2px; }
[data-theme="hud"] :is(.btn.primary, .btn[aria-pressed="true"], .btn.sm[aria-pressed="true"], .mode[aria-pressed="true"], .dkey.select) { background: var(--accent); text-transform: uppercase; letter-spacing: 0.1em; box-shadow: 0 0 18px rgba(61, 255, 160, 0.5); }
[data-theme="hud"] .tile[aria-pressed="true"], [data-theme="hud"] .roomcard .tile[aria-pressed="true"], [data-theme="hud"] .sumcard.on {
  background: linear-gradient(160deg, rgba(255, 200, 61, 0.16), rgba(2, 14, 8, 0.8)); border-color: #ffc83d; box-shadow: 0 0 22px rgba(255, 200, 61, 0.2);
}
[data-theme="hud"] .navlink[aria-current="page"] { background: rgba(61, 255, 160, 0.1); box-shadow: inset 3px 0 0 var(--accent); }
[data-theme="hud"] .trail .line { filter: none; }
[data-theme="hud"] .ico, [data-theme="hud"] .sumico { border-radius: 2px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== Plan de la maison ===== */
.planstage { margin: 6px 0 18px; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.planmain { container-type: inline-size; min-width: 0; }
@media (min-width: 1100px) { .planstage { grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; } .planpanel { position: sticky; top: 20px; } }
.planpanel .btn.sm { align-self: flex-start; margin: 4px 0 10px; }
.planscene {
  --pw: min(88cqw, 640px);
  position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden;
  height: calc(var(--pw) * 0.8); border-radius: var(--radius);
}
.planplane {
  position: relative; width: var(--pw); aspect-ratio: var(--ar, 1.35);
  transform: rotateX(58deg) rotateZ(-38deg); transform-style: preserve-3d;
}
.planplane::before {
  content: ""; position: absolute; inset: -14px; border-radius: 12px; transform: translateZ(-16px);
  background: rgba(var(--a-rgb), 0.05); border: 1px solid rgba(var(--a-rgb), 0.35);
  box-shadow: 0 0 60px rgba(var(--a-rgb), 0.14);
}
.planimg {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; user-select: none;
  filter: invert(1) hue-rotate(180deg) brightness(1.15) contrast(1.1) drop-shadow(0 0 5px rgba(var(--a-rgb), 0.6));
  mix-blend-mode: screen; opacity: 0.95;
}
.planglow {
  position: absolute; left: calc(var(--x) * 100%); top: calc(var(--y) * 100%); width: 40%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(var(--a-rgb), 0.3) 0%, transparent 68%); opacity: 0.7;
}
.planglow.lit { width: 62%; background: radial-gradient(circle, rgba(var(--lit-rgb), 0.75) 0%, rgba(var(--lit-rgb), 0.2) 45%, transparent 70%); opacity: 1; }
.planglow.sel { box-shadow: 0 0 0 2px rgba(var(--a-rgb), 0.8); }
.planlabels { position: absolute; inset: 0; pointer-events: none; }
.planlabel {
  position: absolute; left: 50%; top: 50%; pointer-events: auto;
  transform: translate(-50%, -50%) translate(calc(var(--sx) * var(--pw)), calc(var(--sy) * var(--pw)));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; white-space: nowrap;
  min-height: 40px; min-width: 44px; padding: 3px 12px; border-radius: 999px; cursor: pointer;
  color: var(--text); font: inherit; font-size: 12px; background: rgba(var(--deep-rgb), 0.86); border: 1px solid var(--edge);
}
.planlabel .pn { font-weight: 600; }
.planlabel .ps { font: 500 9px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.planlabel.lit { border-color: rgba(var(--lit-rgb), 0.85); box-shadow: 0 0 22px rgba(var(--lit-rgb), 0.35); }
.planlabel.lit .ps { color: var(--lit); }
.planlabel[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 22px rgba(var(--a-rgb), 0.5); }
.planpanel { margin-top: 0; }

/* Éditeur du plan (réglages) */
.planflat { position: relative; width: 100%; line-height: 0; cursor: crosshair; border-radius: 12px; overflow: hidden; background: #fff; touch-action: manipulation; }
.planflat img { width: 100%; height: auto; display: block; user-select: none; -webkit-user-drag: none; }
.flatpin {
  position: absolute; left: calc(var(--x) * 100%); top: calc(var(--y) * 100%); transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 0 10px 0 4px; border-radius: 999px; cursor: pointer;
  font: 600 12px/1 system-ui, sans-serif; color: #04121a; background: rgba(255, 255, 255, 0.92); border: 2px solid #1c6fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.flatpin .fn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: #1c6fff; color: #fff; }
.flatpin.sel { border-color: #ff7a1c; box-shadow: 0 0 0 3px rgba(255, 122, 28, 0.35); }
.flatpin.sel .fn { background: #ff7a1c; }
.flatghost { position: absolute; left: calc(var(--x) * 100%); top: calc(var(--y) * 100%); width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 3px solid #ff7a1c; background: rgba(255, 122, 28, 0.25); pointer-events: none; }

/* ---------- Caméras ---------- */
.camgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.camtile { position: relative; display: block; border-radius: 16px; overflow: hidden; background: var(--surface-2, #0b1220); color: inherit; text-decoration: none; border: 1px solid var(--line, rgba(255,255,255,.1)); }
.camtile.offline { opacity: .55; }
.camframe { position: relative; aspect-ratio: 16 / 9; display: grid; place-items: center; background: #0b1220; color: rgba(255,255,255,.35); overflow: hidden; }
.camframe.big { border-radius: 16px; }
.camframe .camimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
.camframe .camimg.ready { opacity: 1; }
.camcap { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; gap: 8px; padding: 22px 12px 10px; background: linear-gradient(transparent, rgba(0,0,0,.7)); color: #fff; font-size: 14px; }
.camcap .name { font-weight: 600; }
.camcap .st { opacity: .85; }
.cambadges { position: absolute; top: 10px; left: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.camhero { position: relative; }
.cambadge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--accent, #3b82f6); color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.18); }
.cambadge.ring { background: #f59e0b; }
.camlive { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; gap: 10px; padding: 12px; background: rgba(0,0,0,.94); color: #fff; }
.camlive .livebar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.camlive .livevideo { flex: 1; min-height: 0; width: 100%; background: #000; border-radius: 12px; object-fit: contain; }
.camlive .livestatus { position: absolute; left: 0; right: 0; top: 50%; text-align: center; margin: 0; }
.camlive .livestatus.warn { color: #fbbf24; }

#app, .camframe { overflow-anchor: none; }
.camframe { min-height: 120px; }

/* ---------- Réseau ---------- */
.detail.netpage { max-width: 1100px; }
@media (min-width: 900px) { .detail.netpage { max-width: none; } }
.netsummary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.netsummary .warnv { color: #fbbf24; }
.netgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.netcard { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 16px; background: var(--surface, rgba(255,255,255,.04)); border: 1px solid var(--line, rgba(255,255,255,.1)); }
.netcard.offline { opacity: .75; border-color: rgba(251,191,36,.5); }
.netcard .nhead { display: flex; align-items: center; gap: 10px; }
.srcbadge { padding: 2px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line, rgba(255,255,255,.2)); opacity: .85; white-space: nowrap; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.facts dt { opacity: .65; }
.facts dd { margin: 0; text-align: right; }
.nmeter { display: grid; grid-template-columns: 84px 1fr 44px; align-items: center; gap: 8px; font-size: 12px; }
.nmeter .nmbar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.12); position: relative; overflow: hidden; }
.nmeter .nmbar::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--p); background: var(--accent, #3b82f6); border-radius: 3px; }
.nmeter .nmbar.warm::after { background: #f59e0b; }
.nmeter .nmbar.hot::after { background: #ef4444; }
.nmeter .nmv { text-align: right; }
.ports { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.port { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; font-size: 11px; background: rgba(255,255,255,.08); opacity: .6; }
.port.up { background: var(--accent, #22c55e); color: #04110a; opacity: 1; font-weight: 600; }
.clients { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.client { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--surface, rgba(255,255,255,.04)); }
.client .cico { opacity: .7; display: grid; }
.client .name { font-size: 14px; }
.nmeter, .nhead, .facts, .ports { flex-shrink: 0; }
input[type="search"] { width: 100%; min-height: 48px; padding: 0 16px; border: 1px solid var(--track); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; }

/* Plusieurs maisons */
.housebar { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--edge, rgba(128,128,128,.25)); width: fit-content; max-width: 100%; }
.housebar select { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; min-width: 0; max-width: 60vw; }
.housebar.remote { border-color: #f5a524; box-shadow: 0 0 0 2px rgba(245,165,36,.25); }
.housebar .housenote { font-size: 12px; color: #f5a524; font-weight: 600; white-space: nowrap; }

/* Mises à jour */
.fwrow { align-items: center; gap: 12px; }
.fwnew { color: #f5a524; font-weight: 600; font-size: 14px; margin-top: 2px; }
.fwok { color: var(--muted, #8a94a6); font-size: 13px; margin-top: 2px; }

.siteorg { margin: 8px 0 14px; }
.sitepick { display: flex; align-items: center; gap: 10px; padding: 8px 2px; }
.sitepick input { width: 20px; height: 20px; flex: 0 0 auto; }
