/* Дом · живой план квартиры.
   Днём — светлый камень и графитовые линии чертежа, ночью — тёмный план, на котором светятся включённые лампы.
   Цвет несут только состояния: тёплый свет, обогрев, охлаждение, тревога. Главная кнопка — графит.
   Движение: отклик начинается на касании; анимируем только transform и opacity; две кривые —
   перемещение (0.45, 0, 0.1, 1) и прибытие (0.22, 1, 0.36, 1); цвет меняется за 200 мс. */
@property --fill { syntax: '<percentage>'; inherits: true; initial-value: 0%; }

:root {
  color-scheme: light dark;
  --bg: #eeefec;
  --surface: #ffffff;
  --surface-2: #f4f4f2;
  --surface-3: #e9eae7;
  --ink: #141516;
  --ink-2: #3c3f43;
  --mut: #73777c;
  --line: #e3e4e0;
  --room: #e2e3df;
  --room-lit: #fbecc9;
  --wall: #2b2d30;
  --furn: rgba(255, 255, 255, 0.72);
  --furn-line: #6a6e73;
  --floor-line: rgba(20, 21, 22, 0.08);
  --glass: #8fb9de;
  --lamp: #ffab17;
  --lamp-ink: #3d2a00;
  --lamp-soft: #fff1d4;
  --lamp-fill: #ffd27a;
  --lamp-glow: #ffb02e;
  --lamp-off: #ffffff;
  --lamp-ring: #8f9398;
  --mark-ring: rgba(20, 21, 22, 0.14);
  --iso-glow: #ffae2e;
  --iso-unlit: rgba(24, 30, 44, 0.07);
  --iso-veil: rgba(255, 255, 255, 0.6);
  --iso-blend: multiply;
  --heat: #ec7429;
  --heat-soft: #fde8da;
  --cool: #2b84d8;
  --cool-soft: #dcebf9;
  --ok: #17a457;
  --alarm: #d6301f;
  --alarm-soft: #fbe3e0;
  --primary: #141516;
  --primary-ink: #ffffff;
  --shadow: 0 1px 2px rgba(20, 21, 22, 0.05), 0 6px 20px rgba(20, 21, 22, 0.05);
  --font: 'Onest', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --travel: cubic-bezier(0.45, 0, 0.1, 1);
  --arrive: cubic-bezier(0.22, 1, 0.36, 1);
  --sheet: cubic-bezier(0.32, 0.72, 0, 1);
  --press: cubic-bezier(0.3, 1.4, 0.6, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0d0e;
    --surface: #161719;
    --surface-2: #1e2022;
    --surface-3: #26282b;
    --ink: #eeeff0;
    --ink-2: #c6c9cd;
    --mut: #8a9096;
    --line: #26292c;
    --room: #1c1e21;
    --room-lit: #3b2f17;
    --wall: #4a4e53;
    --furn: rgba(44, 47, 52, 0.75);
    --furn-line: #8b9197;
    --floor-line: rgba(255, 255, 255, 0.05);
    --glass: #3c6f9c;
    --lamp: #ffb52e;
    --lamp-ink: #2a1c00;
    --lamp-soft: #2f2615;
    --lamp-fill: #6b4a12;
    --lamp-glow: #ffae1a;
    --lamp-off: #26292d;
    --lamp-ring: #6c7177;
    --mark-ring: rgba(255, 255, 255, 0.16);
    --iso-glow: #ffb43a;
    --iso-unlit: rgba(0, 0, 0, 0.32);
    --iso-veil: rgba(22, 23, 25, 0.62);
    --iso-blend: screen;
    --heat: #ff8a45;
    --heat-soft: #3a2316;
    --cool: #4ea1ee;
    --cool-soft: #13283d;
    --alarm: #ff5a47;
    --alarm-soft: #3a1714;
    --primary: #eeeff0;
    --primary-ink: #0c0d0e;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 400 16px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
:focus-visible { outline: 2px solid var(--cool); outline-offset: 2px; }

/* отклик на нажатие: быстро вниз, пружина назад */
.press { transition: transform 280ms var(--press); }
.press:active { transform: scale(0.96); transition: transform 90ms ease-out; }

.app {
  max-width: 600px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 40px) max(16px, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.screen { display: flex; flex-direction: column; gap: 16px; }
.left { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.zones { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.zone { padding: 14px 12px; border: 0; text-align: left; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.zone .room-name { font-size: 13px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zone .t { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.zone .sp { font-size: 12px; color: var(--mut); }

/* ---------- шапка ---------- */
.top { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.top .titles { flex: 1; min-width: 0; }
.top h1 { margin: 0; font-size: 26px; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
.top .sub { margin: 3px 0 0; font-size: 14px; color: var(--mut); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.top-wrap { display: flex; flex-direction: column; gap: 14px; }
.top .eyebrow { font-size: 13px; font-weight: 500; line-height: 1.2; color: var(--mut); margin: 0 0 4px; }
.top.home { align-items: flex-end; }
.top.home h1 { font-size: 31px; font-weight: 650; letter-spacing: -0.028em; }
.round.avatar { position: relative; width: 46px; height: 46px; font-size: 18px; }
.av-dot { position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2.5px var(--bg); transition: background 200ms ease; }
.av-dot.off { background: var(--alarm); }

/* сводка под заголовком: чипы листаются вбок и уходят под край экрана, а не переносятся */
/* запас под тень чипов: полоса с прокруткой вбок обрезает всё, что за её краем, — отступ внутри, отрицательное поле снаружи */
.hstat { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: -10px -16px -14px; padding: 10px 16px 20px; scroll-padding: 0 16px; }
.hstat::-webkit-scrollbar { display: none; }
.hchip {
  flex: none; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px 0 11px;
  border: 0; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow);
  font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; transition: transform 280ms var(--press), background 200ms ease, color 200ms ease;
}
.hchip svg { flex: none; color: var(--mut); transition: color 200ms ease; }
.hchip.lamp svg { color: var(--lamp); }
.hchip.warn { background: var(--heat-soft); color: var(--heat); }
.hchip.warn svg { color: currentColor; }
.hchip.alarm { background: var(--alarm-soft); color: var(--alarm); padding-left: 13px; }

/* компактная полоса при прокрутке: матовое стекло, название по центру */
.topbar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 60;
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px);
  box-shadow: 0 0.5px 0 var(--line);
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity 200ms ease, transform 360ms var(--arrive);
}
.topbar.on { opacity: 1; transform: none; pointer-events: auto; }
.topbar-in {
  max-width: 600px; margin: 0 auto; height: 50px; display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; gap: 8px;
  padding: 0 max(14px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px));
}
.tb-title { text-align: center; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-side { display: flex; }
.tb-side.end { justify-content: flex-end; }
.tb-btn { width: 36px; height: 36px; flex: none; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow); font-size: 15px; font-weight: 600; }
.round { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; font-weight: 600; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status-dot.off { background: var(--alarm); }

/* ---------- сегменты с переезжающей подсветкой ---------- */
.seg { position: relative; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); padding: 4px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.seg.inset { background: var(--surface-2); box-shadow: none; border-radius: 14px; padding: 3px; }
.seg-thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / var(--n)); border-radius: 12px;
  background: var(--primary); transform: translateX(calc(var(--i) * 100%)); transition: transform 380ms var(--arrive);
}
.seg.inset .seg-thumb { top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / var(--n)); border-radius: 11px; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg button {
  position: relative; z-index: 1; height: 48px; border: 0; background: transparent; color: var(--mut);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 500;
  transition: color 200ms ease;
}
.seg.inset button { height: 40px; font-size: 14px; flex-direction: row; }
.seg button[aria-pressed='true'] { color: var(--primary-ink); }
.seg.inset button[aria-pressed='true'] { color: var(--ink); }
.seg button:disabled { opacity: 0.4; }

/* ---------- план ---------- */
.plan-card { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow); padding: 6px; }
.plan-clip { overflow: hidden; border-radius: 22px; }
.plan { display: block; width: 100%; height: auto; transform-origin: 0 0; touch-action: manipulation; user-select: none; -webkit-user-select: none; will-change: transform; }
.plan .room { fill: var(--room); stroke: none; transition: fill 260ms ease, opacity 300ms ease; cursor: pointer; }
.plan .room.lit { fill: var(--room-lit); }
.plan .room.dim { opacity: 0.45; }
.plan .tint { pointer-events: none; transition: fill-opacity 400ms ease; }
.plan .walls { fill: var(--wall); fill-rule: evenodd; pointer-events: none; }
.plan .floor { fill: none; stroke: var(--floor-line); stroke-width: 0.6px; vector-effect: non-scaling-stroke; pointer-events: none; }
.plan .furniture { fill: var(--furn); fill-rule: evenodd; pointer-events: none; transition: fill 260ms ease; }
.plan .lines { fill: none; stroke: var(--furn-line); stroke-width: 0.7px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.plan .glass { stroke: var(--glass); stroke-width: 2.5px; vector-effect: non-scaling-stroke; stroke-linecap: round; fill: none; pointer-events: none; }
.plan .door { display: none; }
.plan .halo { pointer-events: none; transform-box: fill-box; transform-origin: center; transition: opacity 320ms ease, transform 420ms var(--arrive); }
.plan .halo.off { opacity: 0; transform: scale(0.4); }
.plan .layer { transition: opacity 240ms ease 60ms; }
.zooming .plan .layer { opacity: 0; transition: opacity 90ms ease; }
.plan .label { fill: var(--ink-2); font-weight: 600; pointer-events: none; paint-order: stroke; stroke: var(--room); stroke-width: 3px; stroke-linejoin: round; }
.plan .label.big { fill: var(--ink); font-weight: 600; letter-spacing: -0.02em; }
.plan .label.mut { fill: var(--mut); font-weight: 400; }
.plan .label.heat { fill: var(--heat); }
.plan .label.cool { fill: var(--cool); }
.plan.iso .room { fill: transparent; transition: fill 420ms ease; }
.plan.iso .room.lit { fill: transparent; }
.plan.iso .room.unlit { fill: var(--iso-unlit); }
.plan.iso .room.dim { opacity: 1; fill: var(--iso-veil); }
.plan.iso .halo { mix-blend-mode: var(--iso-blend); }
.plan.iso .tint { mix-blend-mode: var(--iso-blend); }
.plan .iso-base { pointer-events: none; }
.plan .iso-tile { pointer-events: none; opacity: 0; transition: opacity 320ms ease; }
.plan .iso-tile.ready { opacity: 1; }
.plan.iso .label { stroke: var(--surface); stroke-width: 4px; }
.plan .mark { cursor: pointer; }
.plan .mark .dot { fill: var(--lamp-off); stroke: var(--mark-ring); transition: fill 200ms ease, stroke 200ms ease; }
.plan .mark .shade { fill: #000; opacity: 0.16; pointer-events: none; }
.plan .mark.on .dot { fill: var(--lamp); stroke: var(--lamp); }
.plan .mark .glyph { fill: none; stroke: var(--ink-2); stroke-linecap: round; stroke-linejoin: round; pointer-events: none; transition: stroke 200ms ease; }
.plan .mark.on .glyph { stroke: var(--lamp-ink); }
.plan .mark.k-heat.on .dot { fill: var(--heat); stroke: var(--heat); }
.plan .mark.k-cool.on .dot { fill: var(--cool); stroke: var(--cool); }
.plan .mark.k-heat.on .glyph, .plan .mark.k-cool.on .glyph { stroke: #fff; }
.plan .mark.k-ink.on .dot { fill: var(--ink); stroke: var(--ink); }
.plan .mark.k-ink.on .glyph { stroke: var(--bg); }
.plan .rlabel { pointer-events: none; }
/* подложка подписи — свой класс: общий .pill (кнопки-пилюли, height: 26px) в SVG перебивает высоту прямоугольника,
   и в Safari белая плашка съезжает вверх от текста */
.plan .pill-bg { fill: var(--surface); fill-opacity: 0.95; stroke: var(--mark-ring); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.plan .pill-shade { fill: #000; opacity: 0.08; }
.plan .pill-ico { fill: none; stroke: var(--ink-2); stroke-linecap: round; stroke-linejoin: round; }
.plan .pill-txt { fill: var(--ink); font-weight: 600; letter-spacing: -0.01em; }
.plan .pill-sub { fill: var(--mut); font-weight: 500; }
.plan .pill-badge { fill: var(--lamp); }
.plan .pill-n { fill: var(--lamp-ink); font-weight: 700; }
.plan .mark .pulse { fill: none; stroke: var(--lamp); opacity: 0; transform-box: fill-box; transform-origin: center; }
.plan .mark.tapped .pulse { animation: ring 520ms var(--arrive); }
.plan .mark .hit { fill: transparent; }
@keyframes ring { from { opacity: 0.7; transform: scale(0.6); } to { opacity: 0; transform: scale(1.8); } }

/* ---------- фото комнаты ---------- */
.photos { display: grid; grid-auto-flow: column; grid-auto-columns: 100%; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; border-radius: var(--r-xl); }
.photos::-webkit-scrollbar { display: none; }
.photo { position: relative; aspect-ratio: 3 / 2; border-radius: var(--r-xl); overflow: hidden; scroll-snap-align: start; border: 0; padding: 0; background: var(--surface-3); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 600ms var(--arrive), opacity 400ms ease; opacity: 0; }
.photo img.ready { opacity: 1; }
.photo:active img { transform: scale(1.02); }
.photo::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.45)); pointer-events: none; }
.photo .cap { position: absolute; left: 16px; bottom: 14px; z-index: 1; color: #fff; font-weight: 500; font-size: 15px; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.3); }
.photo .p360 { position: absolute; right: 12px; bottom: 12px; z-index: 1; height: 34px; padding: 0 12px; border-radius: 999px; display: flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, 0.86); color: #141516; font-size: 13px; font-weight: 600; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: -6px; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--line); transition: width 300ms var(--arrive), background 200ms ease; }
.dots i.on { width: 18px; background: var(--ink-2); }

/* ---------- 360° ---------- */
.pano { position: fixed; inset: 0; z-index: 70; background: #000; animation: fade 260ms ease; touch-action: none; }
.pano canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.pano canvas:active { cursor: grabbing; }
.pano .bar { position: absolute; left: 0; right: 0; top: 0; padding: calc(env(safe-area-inset-top, 0px) + 12px) max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); display: flex; align-items: center; gap: 12px; color: #fff; background: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent); }
.pano .bar b { flex: 1; font-weight: 600; font-size: 17px; }
.pano .glass-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; color: #fff; background: rgba(255, 255, 255, 0.18); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.pano .chips { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); display: flex; justify-content: center; gap: 8px; padding: 0 16px; flex-wrap: wrap; }
.pano .chips button { height: 36px; padding: 0 14px; border-radius: 999px; border: 0; color: #fff; background: rgba(255, 255, 255, 0.16); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); font-size: 14px; transition: background 200ms ease, color 200ms ease; }
.pano .chips button[aria-pressed='true'] { background: #fff; color: #141516; }
.pano .spot { position: absolute; left: 0; top: 0; z-index: 2; margin: -22px 0 0 -22px; padding: 0; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 44px; will-change: transform; transition: opacity 180ms ease; }
.pano .spot-dot { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(18, 18, 20, 0.42); border: 1.5px solid rgba(255, 255, 255, 0.75); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: background 220ms ease, color 200ms ease, box-shadow 320ms ease, border-color 200ms ease, transform 280ms var(--press); }
.pano .spot.on .spot-dot { background: var(--lamp); color: var(--lamp-ink); border-color: rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 6px rgba(255, 176, 40, 0.25), 0 0 30px 10px rgba(255, 176, 40, 0.45); }
.pano .spot:active .spot-dot { transform: scale(0.88); transition: transform 90ms ease-out; }
.pano .spot-name { font-size: 12px; font-weight: 500; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7); white-space: nowrap; }
.pano .hint { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 76px); transform: translateX(-50%); padding: 10px 16px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); white-space: nowrap; color: #fff; font-size: 14px; pointer-events: none; transition: opacity 600ms ease; }
.pano .hint.gone { opacity: 0; }

/* ---------- панели ---------- */
.panel { display: flex; flex-direction: column; gap: 12px; }
.panel h2 { margin: 8px 4px 0; font-size: 13px; font-weight: 500; color: var(--mut); letter-spacing: 0.02em; }
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.list > * + * { border-top: 1px solid var(--line); }
.summary { padding: 16px 16px 16px 20px; display: flex; align-items: center; gap: 14px; }
.summary .big { font-size: 40px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; min-width: 1.2ch; }
.summary .txt { flex: 1; min-width: 0; color: var(--mut); font-size: 14px; line-height: 1.3; }
.summary .txt b { display: block; color: var(--ink); font-weight: 500; font-size: 15px; }
.chip-btn { height: 40px; padding: 0 16px; border-radius: 999px; border: 0; background: var(--surface-2); font-weight: 600; font-size: 14px; white-space: nowrap; }
.chip-btn.dark { background: var(--primary); color: var(--primary-ink); }
.chip-btn:disabled { opacity: 0.45; }

.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 64px; width: 100%; border: 0; background: transparent; text-align: left; }
button.row { transition: background 160ms ease; }
button.row:active { background: var(--surface-2); }
.row .ico { width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--mut); }
.row .label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row .label b { font-weight: 500; font-size: 15px; line-height: 1.25; }
.row .label small { color: var(--mut); font-size: 13px; }
.thumb { width: 48px; height: 48px; flex: none; border-radius: 14px; overflow: hidden; position: relative; background: var(--surface-3); box-shadow: 0 0 0 0 var(--lamp); transition: box-shadow 260ms var(--arrive); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.lit { box-shadow: 0 0 0 2.5px var(--lamp); }

/* ---------- плитки ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile {
  -webkit-user-select: none; user-select: none;
  --fill: 0%;
  position: relative; overflow: hidden; min-height: 108px; padding: 14px; border: 0; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow); text-align: left; display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  touch-action: pan-y; transition: transform 280ms var(--press), --fill 260ms var(--arrive);
}
.tile.dragging { transition: transform 280ms var(--press); }
.tile:active { transform: scale(0.97); transition: transform 90ms ease-out, --fill 260ms var(--arrive); }
.tile.dragging:active { transform: scale(1); }
.tile::before { content: ''; position: absolute; inset: 0; background: var(--lamp-soft); opacity: 0; transition: opacity 220ms ease; }
.tile::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, var(--lamp-fill) var(--fill), transparent var(--fill)); opacity: 0; transition: opacity 220ms ease; }
.tile.on::before { opacity: 1; }
.tile.on.dimmable::after { opacity: 0.55; }
.tile.on.k-heat::before { background: var(--heat-soft); }
.tile.on.k-cool::before { background: var(--cool-soft); }
.tile.on.k-ink::before { background: var(--surface-3); }
.tile > * { position: relative; z-index: 1; }
.tile .t-ico { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--mut); transition: background 200ms ease, color 200ms ease, transform 360ms var(--press); }
.tile.on .t-ico { background: var(--lamp); color: var(--lamp-ink); transform: scale(1.06); }
.tile.on.k-heat .t-ico { background: var(--heat); color: #fff; }
.tile.on.k-cool .t-ico { background: var(--cool); color: #fff; }
.tile.on.k-ink .t-ico { background: var(--ink); color: var(--bg); }
.tile .t-name { font-size: 15px; font-weight: 500; line-height: 1.22; }
.tile .t-state { font-size: 13px; color: var(--mut); margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.tile.on .t-state { color: var(--ink-2); }
.tile.shake { animation: shake 380ms ease; }
@keyframes shake { 20% { transform: translateX(-5px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } }
.tile .t-hint { position: absolute; right: 12px; top: 14px; z-index: 1; font-size: 11px; color: var(--mut); opacity: 0; transition: opacity 200ms ease; }
.tile.dimmable.on .t-hint { opacity: 0.8; }

/* шторы */
.curtain-tile { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; padding: 10px 10px 10px 14px; }
.curtain-tile:active { transform: none; }
.curtain-tile .t-text { flex: 1; min-width: 0; }
.curtain-tile { container: ct / inline-size; }
.curtain-tile .pair .pl { display: none; }
@container ct (min-width: 400px) { .curtain-tile .pair button { display: inline-flex; align-items: center; gap: 6px; } .curtain-tile .pair .pl { display: inline; font-size: 13.5px; font-weight: 500; } }
.pair { display: flex; gap: 4px; padding: 3px; border-radius: 14px; background: var(--surface-2); }
.pair button { height: 40px; min-width: 52px; padding: 0 12px; border: 0; border-radius: 11px; background: transparent; display: grid; place-items: center; color: var(--ink-2); transition: background 200ms ease, transform 280ms var(--press); }
.pair button:active { transform: scale(0.92); background: var(--surface); transition: transform 90ms ease-out; }
.pair button.sent { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.moving { display: inline-flex; gap: 2px; }
.moving i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; animation: blink 1s infinite; }
.moving i:nth-child(2) { animation-delay: 0.15s; }
.moving i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

/* переключатель */
.switch { position: relative; width: 52px; height: 32px; flex: none; border-radius: 999px; border: 0; padding: 0; background: var(--surface-3); transition: background 220ms ease; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 0 0 0.5px rgba(0, 0, 0, 0.04); transition: transform 320ms var(--arrive), width 160ms ease; }
.switch:active::after { width: 32px; }
.switch[aria-checked='true'] { background: var(--ok); }
.switch[aria-checked='true']::after { transform: translateX(20px); }
.switch[aria-checked='true']:active::after { transform: translateX(14px); }

/* ---------- климат ---------- */
.thermo { padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.thermo-head { display: flex; align-items: center; gap: 10px; }
.thermo-head b { flex: 1; font-weight: 600; font-size: 16px; }
.thermo-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.lbl { font-size: 12px; color: var(--mut); }
.now { font-size: 52px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; margin-top: 4px; }
.now.na { font-size: 15px; font-weight: 400; color: var(--mut); letter-spacing: 0; line-height: 1.35; max-width: 16ch; }
.target { text-align: right; }
.target .v { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; margin-top: 6px; display: inline-flex; align-items: baseline; gap: 2px; }
.target .v.heat { color: var(--heat); }
.target .v.cool { color: var(--cool); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--mut); white-space: nowrap; transition: background 200ms ease, color 200ms ease; }
.pill.heat { background: var(--heat-soft); color: var(--heat); }
.pill.cool { background: var(--cool-soft); color: var(--cool); }
.pill.alarm { background: var(--alarm-soft); color: var(--alarm); }
.pill.ok::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.hint { font-size: 13px; color: var(--mut); line-height: 1.4; }
.hint.warn { color: var(--heat); }

/* линейка уставки */
.ruler { -webkit-user-select: none; user-select: none; position: relative; height: 64px; border-radius: 16px; background: var(--surface-2); overflow: hidden; touch-action: pan-y; cursor: ew-resize; -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); }
.ruler.disabled { opacity: 0.4; pointer-events: none; }
.ruler-strip { position: absolute; top: 0; bottom: 0; left: 0; will-change: transform; }
.ruler-strip i { position: absolute; bottom: 14px; width: 1.5px; height: 10px; margin-left: -0.75px; border-radius: 1px; background: var(--mut); opacity: 0.5; }
.ruler-strip i.major { height: 18px; opacity: 0.9; }
.ruler-strip b { position: absolute; top: 8px; transform: translateX(-50%); font-size: 12px; font-weight: 500; color: var(--mut); }
.ruler-needle { position: absolute; left: 50%; top: 10px; bottom: 10px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--ink); }
.ruler-needle.heat { background: var(--heat); }
.ruler-needle.cool { background: var(--cool); }

.steppers { display: flex; align-items: center; gap: 8px; }
.step { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); display: grid; place-items: center; }
.step:disabled { opacity: 0.3; }

/* ---------- дверь: сдвиньте, чтобы открыть ---------- */
.slide { position: relative; height: 60px; border-radius: 999px; background: var(--surface-2); overflow: hidden; touch-action: pan-y; }
.slide-fill { position: absolute; inset: 0; background: var(--ok); transform-origin: left; transform: scaleX(0); transition: transform 320ms var(--arrive); }
.slide.done .slide-fill { transform: scaleX(1); }
.slide-label { position: absolute; inset: 0; display: grid; place-items: center; padding-left: 40px; font-size: 15px; font-weight: 500; color: var(--mut); transition: opacity 160ms ease, color 200ms ease; }
.slide.done .slide-label { color: #fff; }
.slide-label span { background: linear-gradient(90deg, var(--mut) 40%, var(--ink) 50%, var(--mut) 60%); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shine 2.6s linear infinite; }
.slide.done .slide-label span { animation: none; background: none; color: #fff; }
@keyframes shine { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.slide-knob { position: absolute; top: 5px; left: 5px; width: 50px; height: 50px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); display: grid; place-items: center; color: var(--ink); will-change: transform; cursor: grab; }
.slide-knob.back { transition: transform 420ms var(--arrive); }

/* ---------- лист ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0); transition: background 300ms ease; }
.sheet-wrap.open { background: rgba(0, 0, 0, 0.4); }
.sheet {
  width: 100%; max-width: 600px; background: var(--surface); border-radius: 28px 28px 0 0;
  padding: 10px max(18px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 18px) max(18px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px; transform: translateY(105%); transition: transform 460ms var(--sheet);
}
.sheet-wrap.open .sheet { transform: none; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--line); align-self: center; margin-bottom: 6px; }
.sheet h3 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
.sheet p { margin: 0; color: var(--mut); }
.sheet .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.btn { height: 52px; padding: 0 18px; border-radius: 999px; border: 0; background: var(--surface-2); font-weight: 600; font-size: 15px; white-space: nowrap; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.danger { background: var(--alarm); color: #fff; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; }

/* ---------- сообщения ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 10px); z-index: 80; max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: 16px; background: var(--primary); color: var(--primary-ink); font-size: 14px; font-weight: 500;
  transform: translate(-50%, -140%); transition: transform 420ms var(--arrive); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.toast.show { transform: translate(-50%, 0); }
.toast.err { background: var(--alarm); color: #fff; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); background: var(--alarm-soft); color: var(--alarm); }
.alert b { display: block; color: var(--ink); font-weight: 600; }
.offline { padding: 12px 16px; border-radius: var(--r-md); background: var(--surface); color: var(--mut); font-size: 14px; }

/* ---------- числа, которые перекатываются ---------- */
.count { display: inline-flex; align-items: baseline; white-space: nowrap; }
.count .d { display: inline-block; height: 1em; overflow: hidden; line-height: 1; vertical-align: baseline; -webkit-mask-image: linear-gradient(to bottom, transparent, #000 10%, #000 90%, transparent); mask-image: linear-gradient(to bottom, transparent, #000 10%, #000 90%, transparent); }
.count .s { display: flex; flex-direction: column; will-change: transform; transition: transform 640ms cubic-bezier(0.3, 0.75, 0.1, 1); }
.count .s > span { display: block; height: 1em; line-height: 1; }
.count.snap .s { transition: none; }
.count .u { margin-left: 0.04em; }

/* ---------- вход ---------- */
.login { min-height: 100dvh; max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: 32px max(20px, env(safe-area-inset-right, 0px)) 40px max(20px, env(safe-area-inset-left, 0px)); }
.wordmark { font-size: 15px; font-weight: 600; color: var(--mut); }
.login h1 { margin: 0; font-size: 44px; line-height: 1.04; font-weight: 600; letter-spacing: -0.035em; }
.login p { margin: 8px 0 0; color: var(--mut); }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; color: var(--mut); }
.field input, .field select { height: 54px; width: 100%; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); padding: 0 16px; font-size: 16px; transition: border-color 160ms ease; }
.field input:focus { border-color: var(--ink); outline: none; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.check input { width: 20px; height: 20px; }
.error { margin: 0; color: var(--alarm); font-size: 14px; }

.entry { padding: 12px 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
.entry b { font-weight: 500; font-size: 15px; }
.entry time, .entry small { color: var(--mut); font-size: 13px; }
.entry.fail b { color: var(--alarm); }
.user-row { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.user-row .who { display: flex; align-items: center; gap: 10px; }
.user-row .who b { flex: 1; min-width: 0; font-weight: 500; }
.user-row .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--mut); }
.empty { padding: 24px 16px; color: var(--mut); text-align: center; font-size: 14px; }

/* экран появляется с небольшим подъёмом */
/* backwards, а не both: после появления на экране не остаётся transform — иначе фиксированная полоса шапки
   привязывается к экрану, а не к окну */
.enter { animation: enter 420ms var(--arrive) backwards; }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }

@media (min-width: 760px) {
  .app { max-width: 1120px; }
  .screen { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; gap: 16px 24px; }
  .screen > .top, .screen > .seg, .screen > .alert, .screen > .offline { grid-column: 1 / -1; }
  .screen > .left { grid-column: 1; position: sticky; top: 16px; }
  .screen > .card, .screen > .btn, .screen > .form, .screen > p { grid-column: 1 / -1; max-width: 640px; }
}
/* ---------- настенная панель (iPad): один экран, без прокрутки ---------- */
html.is-wall, html.is-wall body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.is-wall body { min-height: 0; touch-action: manipulation; }
.wall {
  position: fixed; inset: 0; display: grid; gap: 14px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) calc(env(safe-area-inset-right, 0px) + 18px) calc(env(safe-area-inset-bottom, 0px) + 14px) calc(env(safe-area-inset-left, 0px) + 18px);
  -webkit-user-select: none; user-select: none;
}
.wall.land { grid-template-columns: minmax(0, 1fr) 440px; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: 'top top' 'stage rail' 'chips rail'; }
.wall.port { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto 476px; grid-template-areas: 'top' 'stage' 'chips' 'rail'; }

.w-top { grid-area: top; display: flex; align-items: center; gap: 14px; min-height: 56px; }
.w-top .titles { flex: 1; min-width: 0; }
.w-top h1 { margin: 0; font-size: 28px; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-top .sub { margin-top: 3px; font-size: 15px; color: var(--mut); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
/* главный экран панели: дата над названием и сводка-чипы, как на телефоне; в альбомной — в строку с названием */
.w-top .eyebrow { font-size: 14px; font-weight: 500; line-height: 1.2; color: var(--mut); margin: 0 0 3px; }
.w-top.home .titles { flex: none; }
.w-top.home h1 { font-size: 31px; font-weight: 650; letter-spacing: -0.028em; }
.w-sum { flex: 1; min-width: 0; display: flex; }
.w-sum .hstat { flex: 1; min-width: 0; margin: -10px 0 -14px; padding: 10px 4px 20px; scroll-padding: 0; }
.w-top .hchip { height: 44px; padding: 0 18px 0 14px; gap: 8px; font-size: 16px; }
.wall.port .w-top.home { flex-wrap: wrap; row-gap: 8px; }
.wall.port .w-sum { order: 10; flex-basis: 100%; }
.w-top.home .w-clock { margin-left: auto; } /* в портретной чипы ушли на вторую строку — часы и кнопки остаются у правого края */
.w-clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; padding-right: 4px; }
.w-clock b { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; }
.w-clock small { font-size: 13px; color: var(--mut); }
.chip-btn.w-kiosk { display: inline-flex; align-items: center; gap: 6px; height: 44px; background: var(--surface); box-shadow: var(--shadow); }
.round.w-kiosk.on { position: relative; color: var(--ok); }
.round.w-kiosk.on::after { content: ''; position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px var(--surface); }
.w-360 { display: inline-flex; align-items: center; gap: 6px; height: 44px; background: var(--surface); box-shadow: var(--shadow); }

.w-stage { grid-area: stage; position: relative; min-height: 0; min-width: 0; }
.wall .plan-card { position: absolute; inset: 0; padding: 6px; }
.wall .plan-clip { width: 100%; height: 100%; border-radius: 22px; }
.wall .plan { width: 100%; height: 100%; }
.w-alerts { position: absolute; left: 14px; right: 14px; top: 14px; z-index: 3; display: flex; flex-direction: column; gap: 8px; }
.w-alerts .alert { box-shadow: var(--shadow); align-items: center; }

.w-chips { grid-area: chips; display: flex; gap: 6px; }
.w-chip { flex: 1 1 0; min-width: 0; height: 66px; padding: 6px 4px 7px; border: 0; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; font-size: 13px; font-weight: 500; color: var(--ink-2); transition: background 220ms ease, color 220ms ease, transform 280ms var(--press); }
.w-chip .w-ci { width: 36px; height: 30px; flex: none; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); transition: background 220ms ease, color 220ms ease, box-shadow 220ms ease; }
.w-chip .w-cn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.15; }
.w-chip.lit .w-ci { background: var(--lamp); color: var(--lamp-ink); box-shadow: 0 0 0 3px var(--lamp-soft), 0 2px 10px -2px var(--lamp-glow); }
.w-chip.cur { background: var(--primary); color: var(--primary-ink); }
.w-chip.cur .w-ci { background: color-mix(in srgb, var(--primary-ink) 16%, transparent); color: var(--primary-ink); }
.w-chip.cur.lit .w-ci { background: var(--lamp); color: var(--lamp-ink); box-shadow: none; }

.w-rail { grid-area: rail; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.wall .seg button { height: 54px; font-size: 12.5px; }
.w-fit { flex: 1; min-height: 0; overflow: hidden; }
.w-fit.d2 { overflow-y: auto; } /* страховка: если и в плотном виде не влезло */
.w-stack { display: flex; flex-direction: column; gap: 12px; }

/* общие мелочи пульта */
.wall .t-ico { flex: none; }
.vcard .t-ico, .w-lock .t-ico, .hrow .t-ico, .w-sensor .t-ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--mut); transition: background 220ms ease, color 220ms ease; }
.wall .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--surface); box-shadow: var(--shadow); }
.wall .summary { padding: 14px 14px 14px 18px; }
.wall .tile { min-height: 92px; padding: 12px; gap: 6px; }
.wall .tile .t-ico { width: 34px; height: 34px; }
.wall .tile .t-name { font-size: 14.5px; overflow-wrap: break-word; }
.wall .tile:not(.on) .t-ico { color: var(--ink-2); }
.wall .tile .t-hint { display: none; }
.wall .curtain-tile { grid-column: auto; min-height: 60px; padding: 8px 8px 8px 12px; }
.wall .step { width: 42px; height: 42px; }

/* свет: комнаты карточками */
.w-rooms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.wall.land .w-rooms > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.wall.port .w-rooms { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.w-room { display: flex; align-items: center; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; transition: box-shadow 260ms ease; }
.w-room-go { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px; border: 0; background: transparent; text-align: left; }
.w-room-txt { display: flex; flex-direction: column; min-width: 0; }
.w-room-txt b { font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-room-txt small { color: var(--mut); font-size: 13px; white-space: nowrap; }
.w-off { width: 42px; height: 42px; margin-right: 10px; flex: none; border: 0; border-radius: 50%; background: var(--lamp); color: var(--lamp-ink); display: grid; place-items: center; }
.wall.port .w-room { position: relative; }
.wall.port .w-room-go { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
.wall.port .w-room .thumb { width: 100%; height: 76px; border-radius: 14px; }
.wall.port .w-off { position: absolute; right: 8px; top: 8px; margin: 0; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); }

/* климат */
.w-zones { display: flex; flex-direction: column; gap: 10px; }
.wall.port .w-zones { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.w-tiles3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.w-tiles3 .tile { min-height: 80px; }
.zcard { padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; container: zc / inline-size; }
@container zc (max-width: 290px) { .zcard .z-head .z-ico { display: none; } }
.z-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.z-ico { width: 30px; height: 30px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); margin-right: -2px; }
.zcard.heat .z-ico { background: var(--heat-soft); color: var(--heat); }
.zcard.cool .z-ico { background: var(--cool-soft); color: var(--cool); }
.z-title { flex: 1; min-width: 0; display: flex; flex-direction: column; font-weight: 600; font-size: 16px; text-align: left; border: 0; background: none; padding: 0; color: var(--ink); white-space: nowrap; }
.z-title small { font-weight: 400; font-size: 13px; color: var(--mut); }
button.z-title { flex-direction: row; align-items: center; gap: 2px; min-height: 36px; }
.z-main { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.z-now { display: flex; flex-direction: column; }
.z-now .v { font-size: 40px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.z-set { display: flex; align-items: center; gap: 6px; }
.z-sp { display: flex; flex-direction: column; align-items: center; min-width: 62px; }
.z-sp .v { font-size: 24px; font-weight: 600; line-height: 1.1; }
.z-sp .v.heat { color: var(--heat); }
.z-sp .v.cool { color: var(--cool); }
.zcard .seg.inset button { height: 38px; font-size: 13px; }
.zcard.heat { box-shadow: var(--shadow), inset 3px 0 0 var(--heat); }
.zcard.cool { box-shadow: var(--shadow), inset 3px 0 0 var(--cool); }

.hrow { padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.hrow { container: hr / inline-size; }
@container hr (max-width: 320px) { .hrow .t-ico { display: none; } }
.hrow .t-ico.run { background: var(--cool); color: #fff; }
.h-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.h-txt b { font-weight: 500; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-txt small { color: var(--mut); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hrow .steppers { gap: 4px; }
.hrow .step { width: 36px; height: 36px; }
.hrow .v { min-width: 46px; text-align: center; font-weight: 600; }

/* шторы */
.w-pair2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.w-curt { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.wall.port .w-curt { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* вентиляция */
.w-vents { display: flex; flex-direction: column; gap: 10px; }
.wall.port .w-vent { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.vcard { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.vcard.on .t-ico { background: var(--cool); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: no-preference) { .vcard .t-ico.spin svg { animation: spin 1.8s linear infinite; } }
.vcard .seg.inset button { height: 40px; font-size: 13px; }
.v-speed { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; }
.w-fans { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.w-cap { font-size: 13px; color: var(--mut); }
.w-fan { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 10px; }
.w-fan b { font-weight: 500; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.w-fan b svg { color: var(--mut); flex: none; }
.w-fan .seg.inset button { height: 36px; }

/* охрана */
.w-lock { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.w-sensors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.wall.port .w-sensors { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.w-sensor { padding: 10px 12px; display: flex; align-items: center; gap: 10px; min-width: 0; }
.w-s-txt { display: flex; flex-direction: column; min-width: 0; }
.w-s-txt b { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-s-txt small { color: var(--ok); font-size: 12.5px; }
.w-sensor.alarm { background: var(--alarm-soft); }
.w-sensor.alarm small, .w-sensor.alarm .t-ico { color: var(--alarm); }
.w-sensor.info small { color: var(--cool); }

/* комната */
.w-roomgrid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); align-content: start; }
.b-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.w-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.wall.port .w-roomgrid.has-side { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); grid-template-areas: 'tiles side'; }
.wall.port .b-side .w-curt { grid-template-columns: minmax(0, 1fr); }
.wall.port .w-roomgrid.has-side .b-tiles { grid-area: tiles; }
.wall.port .w-roomgrid.has-side .b-side { grid-area: side; }
.wall.port .w-roomgrid.has-side .b-curt { grid-area: curt; }
.wall.port .w-roomgrid:not(.has-side) .w-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.wall.port .b-curt .w-curt { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* плотнее, если не влезает */
.w-fit.d1 .w-stack, .w-fit.d1 .w-roomgrid, .w-fit.d1 .b-side { gap: 8px; }
.w-fit.d1 .tile { min-height: 76px; padding: 10px; }
.w-fit.d1 .zcard { padding: 10px 12px; gap: 8px; }
.w-fit.d1 .z-now .v { font-size: 32px; }
.w-fit.d1 .curtain-tile { min-height: 52px; padding: 5px 6px 5px 12px; }
.w-fit.d1 .pair button { height: 36px; }
.w-fit.d1 .hrow { padding: 6px 10px; }
.w-fit.d2 .tile { min-height: 62px; padding: 8px 10px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; }
.w-fit.d2 .tile .t-ico { width: 28px; height: 28px; }
.w-fit.d2 .tile .t-ico svg { width: 17px; height: 17px; }
.w-fit.d2 .tile .t-name { font-size: 13px; line-height: 1.2; }
.w-fit.d2 .tile:not(.curtain-tile) .t-state { display: none; }
.w-fit.d2 .zcard .seg.inset button, .w-fit.d2 .vcard .seg.inset button { height: 32px; }
.w-fit.d2 .z-now .v { font-size: 28px; }

/* Заставка настенной панели — OLED, горит круглосуточно.
   Фон — чистый чёрный (пиксели выключены); светятся только тонкие штрихи цифр и значков, всё приглушено.
   Цвета свои, не из темы: в светлой и тёмной системной теме заставка одинаковая.
   Выгорание: всё плывёт по двум осям с разными периодами (±--amb-ax / ±--amb-ay),
   а раз в 8 минут — другая компоновка (v0…v3), часы переходят на другую сторону экрана.
   Ночью — тусклая красная гамма, как ночной режим Apple. */
.ambient {
  --amb-hi: #c9cacc;      /* часы, температура */
  --amb-mid: #898b8f;     /* дата, подписи */
  --amb-lo: #55575b;      /* второстепенное */
  --amb-faint: #2a2b2e;   /* погасшие значки */
  --amb-line: #18191b;    /* волоски */
  --amb-lamp: #e7a445;    /* горит свет */
  --amb-glow: rgba(231, 164, 69, 0.3);
  --amb-heat: #ec8a50;
  --amb-cool: #63a6e6;
  --amb-warn: #e7a445;
  --amb-alarm: #ff5d4f;
  --amb-alarm-glow: rgba(255, 93, 79, 0.55);
  --amb-ax: 26px;
  --amb-ay: 20px;
  position: fixed; inset: 0; z-index: 90; overflow: hidden;
  background: #000; color: var(--amb-mid); color-scheme: dark;
  font-family: var(--font); cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: none;
  animation: fade 900ms ease; transition: opacity 360ms ease;
}
.ambient.night {
  --amb-hi: #862c20;
  --amb-mid: #6a2419;
  --amb-lo: #4a1911;
  --amb-faint: #260c08;
  --amb-line: #160604;
  --amb-lamp: #a8521b;
  --amb-glow: rgba(168, 82, 27, 0.25);
  --amb-heat: #a8521b;
  --amb-cool: #8a3f63;
  --amb-warn: #a8521b;
  --amb-alarm: #ff4b3a;
  --amb-alarm-glow: rgba(255, 75, 58, 0.5);
}
.ambient.leaving { opacity: 0; }

/* медленный дрейф: два слоя, периоды ≈5 и ≈3,5 минуты, туда-обратно, фаза — случайная при каждом показе */
@keyframes amb-dx { from { transform: translateX(calc(var(--amb-ax) * -1)); } to { transform: translateX(var(--amb-ax)); } }
@keyframes amb-dy { from { transform: translateY(calc(var(--amb-ay) * -1)); } to { transform: translateY(var(--amb-ay)); } }
.amb-dx, .amb-dy { position: absolute; inset: 0; }
.amb-dx { animation: amb-dx 307s var(--amb-px, 0s) ease-in-out infinite alternate; }
.amb-dy { animation: amb-dy 211s var(--amb-py, 0s) ease-in-out infinite alternate; }

.amb-grid { position: absolute; inset: 0; display: grid; transition: opacity 1.4s ease; }
.ambient.fading .amb-grid { opacity: 0; }

/* часы: лёгкое начертание Onest (вариативный шрифт), цифры одной ширины; под ними — дорожка минуты */
.amb-clock { grid-area: clock; display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.amb-time {
  display: flex; align-items: baseline; white-space: nowrap;
  font-weight: 200; font-feature-settings: 'tnum' 1;
  letter-spacing: -0.035em; line-height: 0.8; color: var(--amb-hi); margin-left: -0.05em;
}
.amb-colon { position: relative; top: -0.08em; margin: 0 0.01em; color: var(--amb-lo); }
.amb-sec { align-self: stretch; position: relative; height: 2px; border-radius: 2px; background: var(--amb-line); overflow: hidden; }
.amb-sec i { position: absolute; inset: 0; background: var(--amb-lo); transform-origin: left center; transform: scaleX(0); animation: amb-sec 60s var(--amb-ps, 0s) linear infinite; }
@keyframes amb-sec { to { transform: scaleX(1); } }
.amb-date { font-size: 28px; line-height: 1.2; color: var(--amb-mid); white-space: nowrap; }

/* климат: значок и комната, температура, режим и влажность */
.amb-zones { grid-area: zones; display: flex; min-width: 0; }
.amb-zone { display: flex; flex-direction: column; min-width: 0; }
.amb-zn { display: flex; align-items: center; gap: 10px; font-size: 18px; color: var(--amb-mid); white-space: nowrap; }
.amb-zn svg { color: var(--amb-lo); flex: none; }
.amb-zt { display: flex; margin: 14px 0 12px; font-size: 76px; line-height: 0.9; font-weight: 200; letter-spacing: -0.02em; color: var(--amb-hi); white-space: nowrap; }
.amb-zt .count { align-items: flex-start; }
.amb-zt .u { font-size: 0.4em; line-height: 1; margin: 0.1em 0 0 0.02em; color: var(--amb-lo); }
.amb-none { color: var(--amb-lo); }
.amb-zone.heat .amb-zt .u { color: var(--amb-heat); }
.amb-zone.cool .amb-zt .u { color: var(--amb-cool); }
.amb-zone.off .amb-zt { color: var(--amb-lo); }
.amb-zs { display: flex; flex-direction: column; gap: 6px; font-size: 17px; line-height: 1.2; color: var(--amb-lo); white-space: nowrap; }
.amb-mode { display: inline-flex; align-items: center; gap: 8px; }
.amb-mode i { width: 6px; height: 6px; border-radius: 50%; background: var(--amb-faint); flex: none; }
.amb-zone.heat .amb-mode { color: var(--amb-heat); }
.amb-zone.heat .amb-mode i { background: var(--amb-heat); box-shadow: 0 0 8px var(--amb-heat); }
.amb-zone.cool .amb-mode { color: var(--amb-cool); }
.amb-zone.cool .amb-mode i { background: var(--amb-cool); box-shadow: 0 0 8px var(--amb-cool); }
.amb-hum { display: inline-flex; align-items: center; gap: 6px; }
.amb-hum svg { margin-left: -1px; }

/* тревоги — отдельной строкой; ниже ряд «значки над подписью»: свет | дверь */
.amb-status { grid-area: status; display: flex; flex-direction: column; align-items: flex-start; gap: 26px; min-width: 0; }
.amb-alarms { display: flex; flex-wrap: wrap; gap: 12px 32px; }
.amb-al { display: flex; align-items: center; gap: 12px; font-size: 21px; line-height: 1.2; color: var(--amb-mid); white-space: nowrap; }
.amb-al svg { color: var(--amb-alarm); opacity: 0.55; flex: none; }
.amb-al small { font-size: 17px; color: var(--amb-lo); }
.amb-al.fresh { color: var(--amb-alarm); }
.amb-al.fresh small { color: var(--amb-alarm); opacity: 0.7; }
.amb-al.fresh svg { opacity: 1; filter: drop-shadow(0 0 10px var(--amb-alarm-glow)); animation: amb-pulse 2.6s ease-in-out infinite; }
@keyframes amb-pulse { 50% { opacity: 0.45; } }
.amb-row { display: flex; align-items: flex-end; min-width: 0; }
.amb-w { display: flex; flex-direction: column; gap: 14px; min-width: 0; color: var(--amb-mid); }
.amb-w + .amb-w { margin-left: 36px; padding-left: 36px; border-left: 1px solid var(--amb-line); }
.amb-wi { display: flex; gap: 16px; color: var(--amb-lo); }
.amb-wc { font-size: 19px; line-height: 1.2; white-space: nowrap; }
.amb-room { display: grid; place-items: center; color: var(--amb-faint); }
.amb-room.lit { color: var(--amb-lamp); filter: drop-shadow(0 0 9px var(--amb-glow)); }
.amb-w.warn, .amb-w.warn .amb-wi { color: var(--amb-warn); }

/* альбом: часы и строка состояния — в широкой колонке, климат — столбиком в узкой.
   v0: часы слева сверху; v1: справа снизу; v2: слева снизу; v3: справа сверху */
@media (orientation: landscape) {
  .amb-grid { padding: 66px 80px; grid-template-columns: minmax(0, 1fr) 270px; grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: 'clock zones' 'status zones'; column-gap: 64px; }
  .amb-time { font-size: min(244px, 20vw, 29vh); }
  .amb-sec { margin: 32px 0 22px; }
  .amb-clock { justify-self: start; align-self: start; }
  .amb-status { align-self: end; }
  .amb-zones { align-self: center; flex-direction: column; }
  .amb-zone + .amb-zone { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--amb-line); }
  .ambient.v1 .amb-grid, .ambient.v3 .amb-grid { grid-template-columns: 270px minmax(0, 1fr); }
  .ambient.v1 .amb-grid { grid-template-rows: auto minmax(0, 1fr); grid-template-areas: 'zones status' 'zones clock'; }
  .ambient.v2 .amb-grid { grid-template-rows: auto minmax(0, 1fr); grid-template-areas: 'status zones' 'clock zones'; }
  .ambient.v3 .amb-grid { grid-template-areas: 'zones clock' 'zones status'; }
  .ambient.v1 .amb-clock, .ambient.v2 .amb-clock { align-self: end; }
  .ambient.v1 .amb-status, .ambient.v2 .amb-status { align-self: start; }
  .ambient.v1 .amb-clock, .ambient.v3 .amb-clock { justify-self: end; align-items: flex-end; }
  .ambient.v1 .amb-time, .ambient.v3 .amb-time { margin: 0 -0.03em 0 0; }
  .ambient.v1 .amb-status, .ambient.v3 .amb-status { align-items: flex-end; }
}
/* портрет: всё по центру, часы в две строки; v0/v2 — часы сверху, v1/v3 — снизу */
@media (orientation: portrait) {
  .amb-grid { padding: 76px 60px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; grid-template-areas: 'clock' '.' 'zones' 'status'; row-gap: 44px; }
  .amb-clock { justify-self: center; align-items: center; }
  .amb-time { flex-direction: column; align-items: center; font-size: min(326px, 39vw, 27vh); line-height: 0.8; margin: 0; }
  .ambient.crowd .amb-time { font-size: min(296px, 35vw, 24.5vh); } /* есть тревоги — на строку больше, часы чуть меньше */
  .amb-colon { display: none; }
  .amb-sec { margin: 34px 0 22px; }
  .amb-zones { justify-content: space-around; padding-top: 40px; border-top: 1px solid var(--amb-line); }
  .amb-zone { flex: 0 1 220px; align-items: center; text-align: center; }
  .amb-zs { align-items: center; }
  .amb-status { align-items: center; }
  .amb-alarms { justify-content: center; }
  .amb-w { align-items: center; }
  .ambient.v1 .amb-grid, .ambient.v3 .amb-grid { grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: 'status' 'zones' '.' 'clock'; }
  .ambient.v1 .amb-zones, .ambient.v3 .amb-zones { padding: 0 0 40px; border-top: 0; border-bottom: 1px solid var(--amb-line); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  /* заставка: без анимаций, кроме очень медленного дрейфа (защита OLED) */
  .ambient .amb-dx { animation: amb-dx 307s var(--amb-px, 0s) ease-in-out infinite alternate !important; }
  .ambient .amb-dy { animation: amb-dy 211s var(--amb-py, 0s) ease-in-out infinite alternate !important; }
  .ambient .amb-sec { visibility: hidden; }
}

/* ---------- RGBW-ленты ---------- */
.tile.rgb { position: relative; }
.tile.on.rgb::before { background: color-mix(in srgb, var(--lc, var(--lamp)) 16%, var(--surface)); }
.tile.on.rgb .t-ico { background: var(--lc, var(--lamp)); color: var(--lc-ink, var(--lamp-ink)); box-shadow: 0 0 14px -3px var(--lc, var(--lamp)); }
.t-pal { position: absolute; z-index: 2; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: conic-gradient(#f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); box-shadow: 0 0 0 2px var(--surface), 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 200ms var(--press); }
.t-pal::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.t-pal:active { transform: scale(0.9); }
.t-pal:focus-visible { outline: 2px solid var(--cool); outline-offset: 3px; }
.w-fit.d2 .tile.rgb { padding-right: 46px; }
.w-fit.d2 .t-pal { top: 50%; margin-top: -15px; }

.range { position: relative; height: 34px; border-radius: 17px; background: var(--track); cursor: pointer; touch-action: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.range-thumb { position: absolute; top: 3px; left: calc(3px + var(--v) * (100% - 34px)); width: 28px; height: 28px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.06); pointer-events: none; }
.range.disabled { opacity: 0.45; cursor: default; }
.range:focus-visible { outline: 2px solid var(--cool); outline-offset: 3px; }

.color-sheet { gap: 16px; max-height: 92vh; overflow-y: auto; }
.cs-head { display: flex; align-items: center; gap: 12px; }
.cs-swatch { width: 50px; height: 50px; flex: none; border-radius: 15px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2);
  transition: background 260ms ease, box-shadow 260ms ease; }
.cs-swatch.on { box-shadow: 0 0 22px -6px currentColor; }
.cs-title { flex: 1; min-width: 0; }
.cs-title h3 { font-size: 19px; }
.cs-title small { color: var(--mut); font-size: 13px; }
.cs-presets { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px 4px; }
.cs-chip { border: 0; background: none; padding: 2px 0; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; color: var(--mut); font-size: clamp(9.5px, 2.65vw, 11px); letter-spacing: -0.01em; line-height: 1.15; }
.cs-chip i { width: 42px; height: 42px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); transition: box-shadow 200ms ease, transform 200ms var(--press); }
.cs-chip:active i { transform: scale(0.9); }
.cs-chip.cur i { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }
.cs-chip.cur { color: var(--ink); font-weight: 500; }
.cs-chip span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-sliders { display: grid; gap: 12px; }
.cs-row { display: grid; gap: 6px; }
.cs-lbl { font-size: 13px; font-weight: 500; color: var(--mut); }
.cs-wsw { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.cs-wsw small { color: var(--mut); font-size: 12.5px; }
.sheet .cs-note { font-size: 12.5px; }
@media (min-width: 700px) { .sheet-wrap:has(.color-sheet) { align-items: center; } .color-sheet { border-radius: 28px; max-width: 520px; } .sheet-wrap.open .color-sheet { transform: none; } }
