/* Maison : la vue d'ensemble arrangée comme un écran d'accueil (homescreen.js) */
.home-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:13px;align-items:stretch}
@media(min-width:1700px){.home-grid{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media(max-width:1200px){.home-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
.home-tile{position:relative;display:flex;flex-direction:column;min-width:0}
.home-tile>*{flex:1}
.home-tile.wide{grid-column:1/-1}
.home-tile>.overview-stats{margin:0}
/* A room's heading between the elements, as in the classic list */
.home-tile.heading{margin-top:14px}
.home-tile.heading:first-child{margin-top:0}
.home-tile>.home-heading{margin:0;padding:2px 0}
.home-grid.editing .home-tile.heading{padding:6px 10px 6px 26px;border:1px dashed rgba(255,255,255,.14);border-radius:14px}

/* Météo et énergie en éléments de l'accueil */
.home-widget{display:flex;border:1px solid var(--line);border-radius:22px;background:linear-gradient(180deg,rgba(255,255,255,.05),rgba(255,255,255,.02));overflow:hidden}
.home-widget .weather-chip{display:grid;grid-template-columns:auto minmax(0,1fr);align-content:center;column-gap:16px;row-gap:6px;width:100%;min-height:150px;margin:0;padding:22px 24px;border:0;border-radius:0;background:none;backdrop-filter:none;box-shadow:none;color:var(--text);font:inherit;text-align:left}
.home-widget .chip-emoji{grid-row:1/3;align-self:center;font-size:44px;line-height:1}
.home-widget .weather-chip strong{align-self:end;font-size:30px;line-height:1}
.home-widget .weather-chip>span:not(.chip-emoji){align-self:start;font-size:13px;line-height:1.4;color:var(--muted);white-space:normal}
.home-widget .energy-chip:hover{background:rgba(255,255,255,.03)}

/* Mode modification : les éléments tremblent, « − » les cache, on les fait glisser */
.home-edit-bar{position:sticky;top:12px;z-index:30;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px 18px;margin:0 0 18px;padding:14px 16px 14px 20px;border:1px solid rgba(81,184,212,.35);border-radius:18px;background:#0f1619;box-shadow:0 14px 30px rgba(0,0,0,.35)}
.home-edit-text strong{display:block;font-size:14px}
.home-edit-text span{font-size:12px;color:var(--muted)}
.home-edit-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
@keyframes home-wiggle{0%,100%{transform:rotate(-.45deg)}50%{transform:rotate(.45deg)}}
@keyframes home-wiggle-wide{0%,100%{transform:rotate(-.12deg)}50%{transform:rotate(.12deg)}}
.home-grid.editing .home-tile{animation:home-wiggle .34s ease-in-out infinite;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.home-grid.editing .home-tile:nth-child(2n){animation-duration:.38s;animation-delay:-.2s}
.home-grid.editing .home-tile.wide{animation-name:home-wiggle-wide}
.home-shield{position:absolute;inset:0;z-index:5;border-radius:22px;cursor:grab;touch-action:pan-y}
.home-hide{position:absolute;top:-9px;left:-9px;z-index:6;display:grid;place-items:center;width:28px;height:28px;padding:0 0 2px;border:1px solid rgba(255,255,255,.28);border-radius:50%;background:#4a5559;color:#fff;font-size:20px;font-weight:600;line-height:1;cursor:pointer;box-shadow:0 4px 10px rgba(0,0,0,.4)}
.home-hide:hover{background:#c8604a}
.home-tile.home-holder{animation:none!important}
.home-tile.home-holder>*{visibility:hidden}
.home-tile.home-holder::after{content:"";position:absolute;inset:0;border:2px dashed rgba(81,184,212,.55);border-radius:22px;background:rgba(81,184,212,.06)}
.home-ghost{position:fixed!important;left:0;top:0;z-index:1000;margin:0;border-radius:22px;background:#11181b;pointer-events:none;animation:none!important;filter:drop-shadow(0 22px 40px rgba(0,0,0,.5))}
/* While editing, the bar's « Terminé » is the one: no second one in the header */
.home-mode [data-home-edit][aria-pressed="true"]{display:none}
.home-ghost .home-hide{display:none}
body.home-dragging,body.home-dragging *{cursor:grabbing!important;-webkit-user-select:none;user-select:none}
@keyframes home-new{0%{box-shadow:0 0 0 0 rgba(81,184,212,.7)}100%{box-shadow:0 0 0 18px rgba(81,184,212,0)}}
.home-tile.home-new>*{animation:home-new 1.4s ease}
@media(prefers-reduced-motion:reduce){.home-grid.editing .home-tile{animation:none}}

/* Fenêtre « Ajouter à l'accueil » */
.home-add-list{display:grid;gap:8px;max-height:60vh;overflow-y:auto}
.home-add-item{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;width:100%;padding:12px 14px;border:1px solid var(--line);border-radius:14px;background:rgba(255,255,255,.04);color:var(--text);font:inherit;text-align:left;cursor:pointer}
.home-add-item:hover{border-color:rgba(81,184,212,.5);background:rgba(81,184,212,.08)}
.home-add-item svg{width:18px;height:18px}
.home-add-icon{display:grid;place-items:center;width:34px;height:34px;border-radius:10px;background:rgba(255,255,255,.07);color:var(--muted)}

@media (max-width:760px){
  /* Sur le téléphone, façon « Maison » d'Apple : deux petites tuiles par rangée ; un intitulé de pièce, la porte, un
     appareil qui porte un bouton (caméra, serrure…) prennent toute la largeur */
  .home-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;align-items:stretch}
  .home-tile.wide,.home-tile:has(>.door-panel),.home-tile:has(>.compact-device>.device-bottom>.button),.home-tile:has(>.compact-device>.device-bottom>.text-button){grid-column:1/-1}
  .home-tile.heading{margin-top:16px}
  .home-tile.heading:first-child{margin-top:0}
  .home-tile>.home-heading{margin:0;padding:0 2px}
  .home-grid:not(.editing) .home-heading h2{cursor:pointer}
  /* Une seule ligne sur le téléphone : l'explication est un message au début de la modification */
  .home-edit-bar{top:calc(var(--appbar) + 6px);margin-bottom:14px;padding:8px;border:0;border-radius:16px;background:rgba(44,44,48,.97);box-shadow:0 16px 34px rgba(0,0,0,.5)}
  .home-edit-text{display:none}
  .home-edit-actions{flex:1 1 100%;flex-wrap:nowrap;gap:6px}
  .home-edit-actions .button{flex:1;min-height:42px;padding:0 10px}
  .home-edit-actions .text-button{flex:none;min-height:42px;padding:0 6px;font-size:13px}
  .home-ghost{border-radius:var(--m-radius);background:rgba(44,44,48,.97)}
  .home-hide{top:-8px;left:-6px;width:28px;height:28px;border:0;background:rgba(99,99,102,.97);font-size:21px}
  .home-hide:hover{background:rgba(99,99,102,.97)}
  .home-shield{border-radius:var(--m-radius)}
  .home-grid.editing .home-tile.heading{padding:6px 10px 6px 26px;border:1px dashed rgba(255,255,255,.22);border-radius:14px}
  .home-tile.home-holder::after{border-color:rgba(255,255,255,.35);border-radius:var(--m-radius);background:rgba(255,255,255,.05)}
  @keyframes home-new{0%{box-shadow:0 0 0 0 rgba(255,159,10,.7)}100%{box-shadow:0 0 0 18px rgba(255,159,10,0)}}
  /* « Ajouter à l'accueil » : une liste à la façon des réglages de l'iPhone */
  .home-add-list{gap:0;overflow:hidden;border-radius:12px;background:#2c2c2e}
  .home-add-item{min-height:52px;padding:0 14px;border:0;border-top:.5px solid rgba(84,84,88,.5);border-radius:0;background:none;color:#fff;font-size:16px}
  .home-add-item:first-child{border-top:0}
  .home-add-item:hover{border-color:rgba(84,84,88,.5);background:none}
  .home-add-item:active{background:rgba(255,255,255,.08)}
  .home-add-item>svg{color:#30d158}
  .home-add-icon{width:30px;height:30px;border-radius:8px;background:#8e8e93;color:#fff}
}
