/* =========================================================
   Maison d'Hourtin : sable, pins et océan
   ========================================================= */
:root {
  --bg: #F3EEE6;
  --surface: #FFFFFF;
  --surface-2: #F7F2EA;
  --ink: #1D2A2F;
  --ink-2: #5E6C71;
  --line: #E5DCCF;
  --pine: #2F6B57;
  --ocean: #2A6F97;
  --sun: #E07B45;
  --gold: #E3A93B;
  --clay: #B5654A;
  --night: #36456B;
  --danger: #C2493A;
  --ok: #2F8A5F;
  --accent: var(--ocean);
  --on-accent: #FFFFFF;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(29, 42, 47, .05), 0 10px 30px -12px rgba(29, 42, 47, .18);
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Fraunces', Georgia, serif;
  --nav-h: 68px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0E171B;
  --surface: #152328;
  --surface-2: #1B2C32;
  --ink: #E8EEF0;
  --ink-2: #93A5AB;
  --line: #243940;
  --pine: #62B695;
  --ocean: #62AEDB;
  --sun: #F0975F;
  --gold: #F0C062;
  --clay: #DA8A6E;
  --night: #8E9BE0;
  --danger: #EE7B6A;
  --ok: #5CC28F;
  --on-accent: #0E171B;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -14px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2 { margin: 0; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font: 600 19px/1 var(--display); letter-spacing: .01em; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status[data-state="demo"] { color: var(--sun); }
.status[data-state="live"] { color: var(--ok); }
.status[data-state="connecting"], .status[data-state="offline"] { color: var(--gold); }
.status[data-state="error"] { color: var(--danger); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); box-shadow: var(--shadow);
}

/* ---------- Navigation ---------- */
.tabs {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  width: min(520px, calc(100% - 20px));
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px; gap: 2px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 14px 40px -12px rgba(0, 0, 0, .3);
}
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px 6px; border-radius: 18px;
  color: var(--ink-2); font-size: 11px; font-weight: 600;
  transition: background .2s, color .2s;
}
.tab.is-active { background: var(--accent); color: var(--on-accent); }
.tab em {
  position: absolute; top: 4px; right: calc(50% - 22px);
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--gold); color: #1D2A2F; font: 700 10px/17px var(--font); font-style: normal;
}

/* ---------- Mise en page ---------- */
.main { max-width: 1180px; margin: 0 auto; padding: 4px 16px 0; outline: none; }
.grid { display: grid; gap: 14px; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card__title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin-bottom: 12px; }
.card__head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card__head > div { flex: 1; min-width: 0; }
.card__head h2 { font-size: 17px; }
.card__icon {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--accent);
}
.card__icon--heat { color: var(--sun); background: color-mix(in srgb, var(--sun) 14%, transparent); }
.card__icon--cool { color: var(--ocean); background: color-mix(in srgb, var(--ocean) 14%, transparent); }
.card__icon--water { color: var(--ocean); background: color-mix(in srgb, var(--ocean) 14%, transparent); }
.card__icon--off { color: var(--ink-2); }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 10px 2px 16px;
}
.page-head h1 { font: 600 30px/1.1 var(--display); }
.page-head p { margin-top: 4px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px; border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow);
  font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn .i { width: 18px; height: 18px; }
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }

.pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); }
.pill--ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.pill--warn { color: var(--sun); background: color-mix(in srgb, var(--sun) 14%, transparent); }

.empty { text-align: center; padding: 40px 24px; max-width: 520px; margin: 0 auto; }
.empty__icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--surface-2); color: var(--accent); margin-bottom: 14px; }
.empty__icon .i { width: 30px; height: 30px; }
.empty h2 { font: 600 22px/1.2 var(--display); margin-bottom: 8px; }

.banner {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0 0; padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--sun) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--sun) 30%, transparent);
  font-size: 13.5px;
}
.banner > span { color: var(--sun); }
.banner p { flex: 1; }
.banner--warn { background: color-mix(in srgb, var(--danger) 9%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.banner--warn > span { color: var(--danger); }

/* ---------- Accueil : bandeau paysage ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 28px;
  min-height: 260px;
  margin-top: 4px;
  color: #fff;
  --sky1: #6FB3DC; --sky2: #CFE6EE; --orb: #FFE7A3; --far: #6E9C83; --lake: #4D93BC; --near: #2D5A45; --pine: #1F3F31;
  background: linear-gradient(180deg, var(--sky1), var(--sky2));
  box-shadow: var(--shadow);
}
.hero--dusk { --sky1: #4B5F96; --sky2: #F3A673; --orb: #FFC27A; --far: #5B5E7A; --lake: #7C7FA6; --near: #2D3550; --pine: #1B2036; }
.hero--night { --sky1: #0B1630; --sky2: #24375E; --orb: #EDEFF7; --far: #1D2B47; --lake: #2A3D63; --near: #121D33; --pine: #0A1222; }
.hero__art { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero__stars { fill: #fff; opacity: .8; }
.hero__orb { fill: var(--orb); filter: drop-shadow(0 0 18px var(--orb)); }
.hero__far { fill: var(--far); }
.hero__lake { fill: var(--lake); }
.hero__shine { stroke: rgba(255, 255, 255, .45); stroke-width: 1.2; stroke-linecap: round; }
.hero__near { fill: var(--near); }
.hero__pines { fill: var(--pine); }
.hero__content { position: relative; padding: 22px 22px 26px; text-shadow: 0 1px 12px rgba(0, 0, 0, .25); }
.hero--day .hero__content { color: #12303F; text-shadow: 0 1px 10px rgba(255, 255, 255, .5); }
.hero__date { font-size: 13px; font-weight: 600; text-transform: capitalize; opacity: .85; }
.hero__title { font: 600 32px/1.1 var(--display); margin: 4px 0 14px; }
.hero__weather { display: flex; align-items: center; gap: 10px; }
.hero__weather .i { width: 34px; height: 34px; }
.hero__temp { font: 600 38px/1 var(--display); }
.hero__wtext { font-size: 14px; line-height: 1.3; }
.hero__wtext small { opacity: .85; }
.forecast {
  list-style: none; margin: 16px 0 0; padding: 0;
  display: flex; gap: 6px; max-width: 420px;
}
.forecast li {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: 14px;
  background: rgba(255, 255, 255, .22); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 12px; text-transform: capitalize;
}
.hero--night .forecast li, .hero--dusk .forecast li { background: rgba(10, 18, 34, .35); }
.forecast .i { width: 20px; height: 20px; }
.forecast small { opacity: .75; }

/* ---------- Accueil : grille ---------- */
.grid--home { margin-top: 14px; grid-template-columns: 1fr; }

.card--gate.is-open .card__icon { color: var(--sun); }
.slide {
  --x: 0px; --f: 0;
  position: relative; height: 62px; border-radius: 999px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden; user-select: none; -webkit-user-select: none;
}
.slide__fill {
  position: absolute; inset: 0; width: calc(var(--x) + 58px);
  background: linear-gradient(90deg, color-mix(in srgb, var(--pine) 20%, transparent), color-mix(in srgb, var(--pine) 40%, transparent));
  border-radius: inherit;
}
.slide__label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; letter-spacing: .02em; color: var(--ink-2);
  padding-left: 40px; opacity: calc(1 - var(--f) * 1.4);
}
.slide__knob {
  position: absolute; left: 4px; top: 4px; width: 54px; height: 54px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--pine); color: #fff;
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--pine) 70%, transparent);
  transform: translateX(var(--x));
  touch-action: none;
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.2);
}
.slide.is-dragging .slide__knob { transition: none; }
.slide.is-dragging .slide__fill { transition: none; }
.slide__fill { transition: width .35s cubic-bezier(.2, .9, .3, 1.2); }
.slide.is-hint .slide__knob { animation: nudge .7s ease; }
.slide.is-busy .slide__knob { background: var(--ink-2); }
.slide.is-busy .slide__label { opacity: 1; }
@keyframes nudge { 30% { transform: translateX(26px); } 60% { transform: translateX(-4px); } }

.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.chip {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px;
  text-align: left; padding: 12px; border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.chip .i { grid-row: span 2; align-self: center; color: var(--ink-2); }
.chip strong { font-size: 17px; line-height: 1.1; }
.chip span { font-size: 12px; color: var(--ink-2); line-height: 1.2; }
.chip.is-on .i { color: var(--gold); }

.scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.scene {
  --tone: var(--ocean);
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; padding: 14px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--tone) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--tone) 22%, transparent);
  transition: transform .15s;
}
.scene:active { transform: scale(.97); }
.scene__icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--tone); color: #fff; margin-bottom: 8px; }
.scene strong { font-size: 15px; }
.scene small { font-size: 12px; color: var(--ink-2); line-height: 1.3; }
.scene--sun { --tone: var(--sun); }
.scene--pine { --tone: var(--pine); }
.scene--ocean { --tone: var(--ocean); }
.scene--night { --tone: var(--night); }
.scene--clay { --tone: var(--clay); }

.cams { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.cam { position: relative; display: block; border-radius: var(--radius-sm); overflow: hidden; background: #111; aspect-ratio: 16 / 9; text-align: left; }
.cam img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam__meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; padding: 22px 12px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .7)); color: #fff;
}
.cam__meta strong { font-size: 14px; }
.cam__meta small { font-size: 12px; opacity: .85; }
.cam__meta small.live { color: #FFD66B; opacity: 1; }
.cam__meta small.live::before { content: '● '; }

/* ---------- Lignes (volets, lumières) ---------- */
.grid--rooms { grid-template-columns: 1fr; }
.room { padding: 14px 16px 6px; }
.room__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.room__head h2 { font: 600 19px/1.2 var(--display); }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.room__head + .row, .presets + .row { border-top: 0; }
.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__sub { font-size: 13px; color: var(--ink-2); }

.shutter {
  --p: 100;
  position: relative; flex: none; width: 34px; height: 40px; border-radius: 6px;
  background: linear-gradient(160deg, #BFE0F0, #EAF5FA);
  box-shadow: inset 0 0 0 2px var(--line);
  overflow: hidden;
}
:root[data-theme="dark"] .shutter { background: linear-gradient(160deg, #24506A, #2F6584); }
.shutter span {
  position: absolute; left: 0; right: 0; top: 0;
  height: calc((100 - var(--p)) * 1%);
  background: repeating-linear-gradient(180deg, var(--ink-2) 0 3px, color-mix(in srgb, var(--ink-2) 70%, var(--surface)) 3px 5px);
  transition: height .25s linear;
}
.shutter.is-moving { box-shadow: inset 0 0 0 2px var(--gold); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; flex: none; }
.seg button { width: 40px; height: 38px; border-radius: 9px; display: grid; place-items: center; color: var(--ink); }
.seg button:active, .seg button.is-active { background: var(--surface); box-shadow: var(--shadow); }
.seg--sm button { width: 36px; height: 32px; }
.seg--text { flex-wrap: wrap; }
.seg--text button { width: auto; padding: 0 12px; font-size: 13px; font-weight: 600; }
.seg--text button.is-active { color: var(--accent); }

.range {
  --v: 50%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; margin: 6px 0 0; background: transparent;
}
.range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--v), var(--line) var(--v));
}
.range::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
.range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; margin-top: -8px;
  background: #fff; border: 0; box-shadow: 0 1px 6px rgba(0, 0, 0, .3);
}
.range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 6px rgba(0, 0, 0, .3); }
.range--warm::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--gold) var(--v), var(--line) var(--v)); }
.range--warm::-moz-range-progress { background: var(--gold); }
.range:disabled { opacity: .4; }

.switch {
  position: relative; flex: none; width: 52px; height: 32px; border-radius: 16px;
  background: var(--line); transition: background .2s;
}
.switch span {
  position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  transition: transform .22s cubic-bezier(.3, .8, .4, 1.2);
}
.switch.is-on { background: var(--gold); }
.switch.is-on span { transform: translateX(20px); }

.bulb {
  --c: transparent;
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2);
  transition: background .25s, box-shadow .25s;
}
.row--light.is-on .bulb { background: var(--c); color: #4A3510; box-shadow: 0 0 22px -2px var(--c); }
.room--lit { background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 9%, var(--surface)), var(--surface) 120px); }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 8px; }
.preset {
  padding: 6px 10px 6px 23px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); position: relative;
}
.preset::before {
  content: ''; position: absolute; left: 8px; top: 50%; width: 11px; height: 11px; margin-top: -5.5px;
  border-radius: 50%; background: var(--k); box-shadow: 0 0 0 1px rgba(0, 0, 0, .1);
}

/* ---------- Confort ---------- */
.grid--thermo { grid-template-columns: 1fr; }
.thermo__body { display: flex; align-items: center; justify-content: center; gap: 4px; }
.dial { width: min(220px, 60vw); height: auto; }
.dial__track { fill: none; stroke: var(--surface-2); stroke-width: 14; stroke-linecap: round; }
.dial__value { fill: none; stroke: var(--accent); stroke-width: 14; stroke-linecap: round; transition: d .3s; }
.dial--heat .dial__value { stroke: var(--sun); }
.dial--cool .dial__value { stroke: var(--ocean); }
.dial--water .dial__value { stroke: var(--ocean); }
.dial__big { font: 600 40px var(--display); fill: var(--ink); }
.dial--off .dial__big { font-size: 28px; fill: var(--ink-2); }
.dial__small { font-size: 13px; fill: var(--ink-2); font-weight: 600; }
.btn-round {
  width: 50px; height: 50px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2);
}
.btn-round:active { transform: scale(.94); }
.modes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.mode {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 66px; padding: 9px 8px; border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--ink-2);
}
.mode .i { width: 20px; height: 20px; }
.mode.is-active { background: var(--accent); color: var(--on-accent); }
.mode--heat.is-active { background: var(--sun); color: #fff; }
.mode--off.is-active { background: var(--ink-2); color: var(--surface); }
.fan { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- TV ---------- */
.grid--tv { grid-template-columns: 1fr; }
.remote__top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.btn-round--power { width: 58px; height: 58px; color: var(--danger); }
.btn-round--power.is-on { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.dpad {
  display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 64px);
  justify-content: center; gap: 0; margin: 4px auto 14px;
  width: 196px; padding: 2px; border-radius: 50%;
  background: var(--surface-2);
}
.dpad .key { border-radius: 50%; background: transparent; box-shadow: none; }
.dpad__up { grid-area: 1 / 2; } .dpad__left { grid-area: 2 / 1; } .dpad__right { grid-area: 2 / 3; } .dpad__down { grid-area: 3 / 2; }
.dpad__ok { grid-area: 2 / 2; background: var(--surface) !important; box-shadow: var(--shadow) !important; }
.key {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px;
  background: var(--surface-2); color: var(--ink);
}
.key:active { transform: scale(.93); }
.key.is-active { background: var(--danger); color: #fff; }
.remote__row { display: flex; justify-content: center; gap: 14px; margin-top: 10px; }
.remote__row--split { align-items: center; margin-top: 16px; }
.rocker {
  display: flex; flex-direction: column; align-items: center;
  background: var(--surface-2); border-radius: 22px; padding: 4px;
}
.rocker button { width: 52px; height: 48px; display: grid; place-items: center; border-radius: 18px; }
.rocker button:active { background: var(--surface); }
.rocker span { font-size: 11px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
.vol { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; color: var(--ink-2); }
.vol .range { margin: 0; }
.vol strong { min-width: 28px; text-align: right; color: var(--ink); }
.sources { display: flex; flex-wrap: wrap; gap: 8px; }
.source { padding: 10px 16px; border-radius: 999px; background: var(--surface-2); font-weight: 600; font-size: 14px; }
.source.is-active { background: var(--accent); color: var(--on-accent); }

/* ---------- Feuilles (dialogues) ---------- */
.sheet {
  width: min(520px, 100%); max-height: 92vh; overflow: auto;
  margin: auto auto 0; padding: 0 20px calc(20px + env(safe-area-inset-bottom));
  border: 0; border-radius: 26px 26px 0 0;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25);
}
.sheet--wide { width: min(900px, 100%); }
.sheet::backdrop { background: rgba(10, 18, 22, .45); backdrop-filter: blur(3px); }
.sheet[open] { animation: rise .28s cubic-bezier(.2, .9, .3, 1); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet__head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0 12px; background: var(--surface);
}
.sheet__head h2 { font: 600 22px/1.2 var(--display); }
.sheet__head .icon-btn { box-shadow: none; background: var(--surface-2); }
.sheet__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.settings .field { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.settings .field > span { font-weight: 700; font-size: 13px; }
.settings input:not([type=radio]), .settings textarea, .settings select {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface-2);
}
.settings textarea { font: 12px/1.4 ui-monospace, Menlo, monospace; resize: vertical; }
.settings .field small { line-height: 1.4; }
.settings.is-demo .live-fields { display: none; }
.segmented { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--surface-2); border-radius: 14px; padding: 4px; }
.segmented legend { font-weight: 700; font-size: 13px; padding: 0 0 8px; }
.segmented--3 { grid-template-columns: repeat(3, 1fr); margin-top: 16px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; text-align: center; padding: 10px; border-radius: 11px; font-weight: 700; cursor: pointer; }
.segmented input:checked + span { background: var(--surface); box-shadow: var(--shadow); color: var(--accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.advanced { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.advanced summary { font-weight: 700; cursor: pointer; }
.cam-full { width: 100%; border-radius: 16px; display: block; background: #111; aspect-ratio: 16 / 9; object-fit: cover; margin-bottom: 10px; }
.events { list-style: none; padding: 0; margin: 14px 0 0; }
.events li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.events li.live small { color: var(--sun); font-weight: 700; }

/* ---------- Notifications ---------- */
.toasts {
  position: fixed; z-index: 50; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 22px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: calc(100% - 32px);
}
.toast {
  max-width: 420px; padding: 11px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .4);
  animation: rise .25s ease;
  transition: opacity .35s, transform .35s;
}
.toast--ok::before { content: '✓  '; color: var(--ok); }
.toast--error { background: var(--danger); color: #fff; }
.toast.is-out { opacity: 0; transform: translateY(8px); }

/* ---------- Écrans larges ---------- */
@media (min-width: 720px) {
  .grid--home { grid-template-columns: 1fr 1fr; }
  .card--scenes, .card--cams { grid-column: span 2; }
  .grid--rooms { grid-template-columns: repeat(2, 1fr); align-items: start; }
  .grid--thermo { grid-template-columns: repeat(2, 1fr); align-items: start; }
  .grid--tv { grid-template-columns: minmax(300px, 380px) 1fr; align-items: start; }
  .hero { min-height: 300px; }
  .hero__title { font-size: 40px; }
  .sheet { margin: auto; border-radius: 26px; }
}
@media (min-width: 1080px) {
  body { padding-bottom: 40px; }
  .tabs {
    position: sticky; top: calc(env(safe-area-inset-top) + 66px); bottom: auto; transform: none; left: auto;
    margin: 0 auto 6px; width: 560px;
  }
  .toasts { bottom: 30px; }
  .grid--home { grid-template-columns: 1.1fr 1fr 1fr; }
  .card--gate { grid-column: 1; }
  .card--summary { grid-column: span 2; }
  .card--scenes { grid-column: span 3; }
  .card--cams { grid-column: span 3; }
  .scenes { grid-template-columns: repeat(5, 1fr); }
  .grid--rooms { grid-template-columns: repeat(3, 1fr); }
  .grid--thermo { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
