/* Kool Home · estilos. Tokens por rol; el lima de Koolbrand significa «encendido / activo». */
:root{
  --bg:#F3F2EE; --surface:#FFFFFF; --surface-2:#ECEBE6; --surface-3:#E1E0DA;
  --ink:#111111; --ink-2:#2B2B29; --muted:#64635D; --line:rgb(17 17 17 / .08);
  --accent:#CCE673; --on-accent:#111111; --accent-soft:#EDF5CC; --accent-glow:rgb(196 226 92 / .55);
  --heat:#E0703D; --heat-soft:#FBE5D9; --cool:#5B8DEF;
  --alert:#C8372D; --alert-soft:#F7DEDA;
  --glass:rgb(255 255 255 / .72); --scrim:rgb(17 17 17 / .28);
  --shadow:0 1px 1px rgb(17 17 17 / .04),0 2px 6px rgb(17 17 17 / .04),0 10px 24px -8px rgb(17 17 17 / .08);
  --shadow-lift:0 1px 1px rgb(17 17 17 / .04),0 6px 14px rgb(17 17 17 / .06),0 22px 40px -12px rgb(17 17 17 / .16);
  --f-display:"Inter Tight",ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  --f-mono:"JetBrains Mono",ui-monospace,SFMono-Regular,Menlo,monospace;
  --r-card:24px; --r-tile:20px; --r-ctl:14px; --pad-card:18px;
  --ease:cubic-bezier(.2,0,0,1); --spring:cubic-bezier(.32,.72,0,1);
  color-scheme:light;
}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
  --bg:#0E0E0D; --surface:#181816; --surface-2:#232320; --surface-3:#2E2E2A;
  --ink:#F3F2EE; --ink-2:#D9D8D2; --muted:#9C9B94; --line:rgb(255 255 255 / .07);
  --accent-soft:#283112; --accent-glow:rgb(204 230 115 / .30);
  --heat:#F08A5D; --heat-soft:#3A2318; --cool:#7EA6F5;
  --alert:#F0675C; --alert-soft:#3D1D1A;
  --glass:rgb(28 28 26 / .72); --scrim:rgb(0 0 0 / .5);
  --shadow:0 1px 0 rgb(255 255 255 / .03) inset,0 1px 2px rgb(0 0 0 / .5);
  --shadow-lift:0 1px 0 rgb(255 255 255 / .04) inset,0 18px 40px -12px rgb(0 0 0 / .7);
  color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#0E0E0D; --surface:#181816; --surface-2:#232320; --surface-3:#2E2E2A;
  --ink:#F3F2EE; --ink-2:#D9D8D2; --muted:#9C9B94; --line:rgb(255 255 255 / .07);
  --accent-soft:#283112; --accent-glow:rgb(204 230 115 / .30);
  --heat:#F08A5D; --heat-soft:#3A2318; --cool:#7EA6F5;
  --alert:#F0675C; --alert-soft:#3D1D1A;
  --glass:rgb(28 28 26 / .72); --scrim:rgb(0 0 0 / .5);
  --shadow:0 1px 0 rgb(255 255 255 / .03) inset,0 1px 2px rgb(0 0 0 / .5);
  --shadow-lift:0 1px 0 rgb(255 255 255 / .04) inset,0 18px 40px -12px rgb(0 0 0 / .7);
  color-scheme:dark}

*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--f-display);font-size:15px;line-height:1.45;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer;padding:0;touch-action:manipulation}
button:focus-visible,input:focus-visible,a:focus-visible{outline:2px solid var(--ink);outline-offset:3px}
h1,h2,h3{margin:0;font-weight:600;text-wrap:balance}
p{margin:0}
.mono{font-family:var(--f-mono);font-size:11px;font-weight:500;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}
.num{font-variant-numeric:tabular-nums}
.muted{color:var(--muted)} .small{font-size:13px}
svg.i{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;flex:none;overflow:visible}
svg.i .glass{transition-property:fill,fill-opacity;transition-duration:.3s}

/* ---------- Armazón ---------- */
.app{display:grid;grid-template-columns:232px minmax(0,1fr);min-height:100%}
.rail{position:sticky;top:0;height:100vh;display:flex;flex-direction:column;gap:32px;padding-block:28px;padding-inline:max(18px,env(safe-area-inset-left,0px)) 18px}
.brand{display:flex;align-items:center;gap:10px;font-weight:700;font-size:18px;letter-spacing:-.02em}
.logo svg{width:30px;height:30px;display:block}
.logo rect{fill:var(--ink)} .logo path{fill:none;stroke:var(--bg);stroke-width:2;stroke-linejoin:round} .logo circle{fill:var(--accent)}
.nav{position:relative;display:flex;flex-direction:column;gap:2px}
.nav button{position:relative;z-index:1;display:flex;align-items:center;gap:12px;padding:11px 12px;border-radius:var(--r-ctl);color:var(--muted);font-weight:500;transition-property:color;transition-duration:.15s}
.nav button:hover{color:var(--ink)}
.nav button[aria-current="page"]{color:var(--ink)}
.nav .ind{position:absolute;left:0;right:0;top:0;height:44px;border-radius:var(--r-ctl);background:var(--surface);box-shadow:var(--shadow);translate:0 calc(var(--idx,0) * 46px);transition:translate .4s var(--spring)}
.rail-top{display:flex;flex-direction:column;gap:14px}
.rail-top .places{width:100%}
.brand .places{margin-left:2px}
.mobile-top .brand{min-width:0}
.rail-foot{margin-top:auto;display:flex;flex-direction:column;gap:12px}
.sticker{align-self:flex-start;rotate:-3deg;background:var(--accent);color:var(--on-accent);font-family:var(--f-mono);font-size:10.5px;letter-spacing:.06em;text-transform:uppercase;padding:5px 9px;border-radius:6px;font-weight:500}
.live{display:inline-flex;align-items:center;gap:8px;font-family:var(--f-mono);font-size:11px;letter-spacing:.05em;text-transform:uppercase;color:var(--muted)}
.live i{position:relative;width:8px;height:8px;border-radius:50%;background:var(--accent)}
.live i::after{content:"";position:absolute;inset:0;border-radius:50%;background:var(--accent);animation:ping 2.4s var(--ease) infinite}
.live.off i,.live.off i::after{background:var(--heat)}

main{min-width:0;padding-block:28px 120px;padding-inline:clamp(16px,3vw,44px) max(16px,env(safe-area-inset-right,0px))}
.view{max-width:1180px;margin-inline:auto;display:flex;flex-direction:column;gap:32px}

/* ---------- Cabecera ---------- */
.mobile-top{display:none;align-items:center;justify-content:space-between;gap:12px}
.hero{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:20px}
.hero h1{font-size:clamp(32px,4.6vw,48px);line-height:1;letter-spacing:-.035em;font-weight:700}
.hero p{margin-top:10px;color:var(--muted);max-width:56ch;font-size:15.5px}
.hero .kicker{display:flex;align-items:center;gap:10px;margin-bottom:10px}

/* Chips de resumen (como la franja de estado de Apple Home) */
.chips{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:10px}
.chip{display:flex;align-items:center;gap:12px;padding:12px 14px 12px 12px;background:var(--surface);border-radius:var(--r-tile);box-shadow:var(--shadow);text-align:start;min-width:0;transition-property:scale,box-shadow;transition-duration:.2s;transition-timing-function:var(--ease)}
button.chip:hover{box-shadow:var(--shadow-lift)}
.chip .b{width:40px;height:40px;border-radius:50%;display:grid;place-items:center;background:var(--surface-2);flex:none;transition-property:background-color,color;transition-duration:.3s}
.chip .b svg{width:20px;height:20px}
.chip .t{display:flex;flex-direction:column;min-width:0}
.chip .t span{font-size:12.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chip .t b{font-size:17px;font-weight:600;letter-spacing:-.015em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chip.lit .b{background:var(--accent);color:var(--on-accent);box-shadow:0 0 0 4px var(--accent-soft)}
.chip.heat .b{background:var(--heat-soft);color:var(--heat)}
.chip.warn .b{background:var(--alert-soft);color:var(--alert)}

/* Control maestro */
.master{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:16px;padding:16px 16px 16px 20px;background:var(--surface);border-radius:var(--r-card);box-shadow:var(--shadow)}
.master .lbl{display:flex;align-items:center;gap:14px}
.master .lbl .b{width:44px;height:44px;border-radius:14px;display:grid;place-items:center;background:var(--ink);color:var(--accent)}
.master h2{font-size:16px;letter-spacing:-.01em}

/* Segmentado con pastilla que se desliza */
.seg{--n:3;--idx:0;position:relative;display:inline-grid;grid-auto-flow:column;grid-auto-columns:1fr;padding:4px;background:var(--surface-2);border-radius:var(--r-ctl);isolation:isolate}
.seg>.thumb{position:absolute;z-index:-1;top:4px;bottom:4px;left:4px;width:calc((100% - 8px) / var(--n));border-radius:10px;background:var(--surface);box-shadow:var(--shadow);translate:calc(var(--idx) * 100%) 0;transition:translate .42s var(--spring),opacity .2s}
.seg.none>.thumb{opacity:0}
.seg.accent>.thumb{background:var(--accent);box-shadow:0 2px 10px -2px var(--accent-glow)}
.seg>button,.seg>span{padding:9px 14px;border-radius:10px;font-weight:500;font-size:14px;color:var(--muted);text-align:center;white-space:nowrap;transition-property:color,scale;transition-duration:.2s}
.seg>button:hover{color:var(--ink)}
.seg>[aria-pressed="true"],.seg>[aria-current="true"]{color:var(--ink)}
.seg.accent>[aria-pressed="true"],.seg.accent>[aria-current="true"]{color:var(--on-accent)}
.seg.sm>button,.seg.sm>span{padding:7px 10px;font-size:13px}
.seg.ro{cursor:default}
.seg.wrap{display:grid;grid-auto-flow:row;grid-template-columns:repeat(3,1fr)}
.seg.wrap>.thumb{display:none}
.seg.wrap>[aria-pressed="true"],.seg.wrap>[aria-current="true"]{background:var(--surface);box-shadow:var(--shadow)}
.seg.wrap.accent>[aria-pressed="true"],.seg.wrap.accent>[aria-current="true"]{background:var(--accent);color:var(--on-accent)}
.seg button:disabled{opacity:.45;cursor:default}

button:active:not(:disabled),.room:has(.open:active){scale:.96}
.seg>button:active{scale:.96}

/* ---------- Salas ---------- */
.section{display:flex;flex-direction:column;gap:14px}
.section-h{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
.section-h h2{font-size:20px;letter-spacing:-.02em}
.rooms{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:14px}
.room{--glow:0;--glow-c:var(--accent);position:relative;isolation:isolate;overflow:hidden;background:var(--surface);border-radius:var(--r-card);padding:var(--pad-card);box-shadow:var(--shadow);display:flex;flex-direction:column;gap:18px;min-width:0;min-height:196px;transition-property:scale,box-shadow;transition-duration:.25s;transition-timing-function:var(--ease)}
.room::before{content:"";position:absolute;z-index:-1;inset:-55% -45% auto auto;width:90%;aspect-ratio:1;border-radius:50%;background:radial-gradient(closest-side,var(--glow-c),transparent 75%);opacity:calc(var(--glow) * .42);transition:opacity .8s var(--ease),background .8s}
.room:hover{box-shadow:var(--shadow-lift)}
.room .open{position:absolute;inset:0;border-radius:inherit;z-index:1}
.room-top{display:flex;justify-content:space-between;align-items:flex-start;gap:10px}
.r-ico{width:44px;height:44px;border-radius:14px;display:grid;place-items:center;background:var(--surface-2);transition-property:background-color,color;transition-duration:.4s}
.r-ico svg{width:22px;height:22px}
.room.lit .r-ico{background:var(--ink);color:var(--accent)}
.power{position:relative;z-index:2;width:38px;height:38px;border-radius:50%;display:grid;place-items:center;background:var(--surface-2);color:var(--muted);transition-property:background-color,color,box-shadow,scale;transition-duration:.3s}
.power svg{width:18px;height:18px}
.power[aria-pressed="true"]{background:var(--accent);color:var(--on-accent);box-shadow:0 0 0 5px var(--accent-soft),0 4px 16px -2px var(--accent-glow)}
.power:hover{color:var(--ink)}
.room h3{font-size:18px;letter-spacing:-.02em;line-height:1.15}
.room .id{display:block;margin-bottom:4px}
.room-mid{margin-top:auto;display:flex;align-items:flex-end;justify-content:space-between;gap:10px}
.temp{font-size:34px;font-weight:600;letter-spacing:-.045em;line-height:.9}
.temp small{font-size:15px;color:var(--muted);font-weight:500;letter-spacing:0;margin-left:2px}
.room-foot{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;color:var(--muted);font-size:13px}
.blinds-sum{display:inline-flex;align-items:center;gap:8px;font-size:13.5px;font-weight:500;color:var(--ink-2)}
.blinds-sum svg{width:22px;height:22px;color:var(--muted)}
.pips{display:flex;gap:4px}
.pips i{width:7px;height:16px;border-radius:4px;background:var(--surface-3);transition:background-color .4s,box-shadow .4s}
.pips i.on{background:var(--accent);box-shadow:0 0 8px var(--accent-glow)}
.pips i.c{box-shadow:0 0 8px var(--c)}
.badge{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;font-weight:600;padding:4px 10px 4px 8px;border-radius:999px;background:var(--surface-2);color:var(--ink-2);white-space:nowrap}
.badge svg{width:14px;height:14px}
.badge.presence{background:var(--accent-soft);color:var(--ink)}
.badge.presence .dot{position:relative;width:7px;height:7px;border-radius:50%;background:var(--accent);box-shadow:0 0 0 1px rgb(17 17 17 / .2)}
.badge.presence .dot::after{content:"";position:absolute;inset:0;border-radius:50%;background:var(--accent);animation:ping 1.8s var(--ease) infinite}
.badge.warn{background:var(--heat-soft);color:var(--ink)}
.badge.heat{background:var(--heat-soft);color:var(--ink)} .badge.heat svg{color:var(--heat)}
.badge.alert{background:var(--alert-soft);color:var(--ink)} .badge.alert svg{color:var(--alert)}
.badge.ok{background:var(--accent-soft);color:var(--ink)}
.meta{display:flex;flex-wrap:wrap;gap:6px}

/* ---------- Hoja de sala ---------- */
.sheet-wrap{position:fixed;inset:0;z-index:40;display:flex;justify-content:flex-end;background:var(--scrim);-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px);opacity:0;pointer-events:none;transition:opacity .3s var(--ease)}
.sheet-wrap.open{opacity:1;pointer-events:auto}
.sheet{position:relative;width:min(580px,100%);height:100%;overflow:auto;overscroll-behavior:contain;background:var(--bg);padding-block:calc(24px + env(safe-area-inset-top,0px)) calc(40px + env(safe-area-inset-bottom,0px));padding-inline:24px max(24px,env(safe-area-inset-right,0px));display:flex;flex-direction:column;gap:26px;translate:40px 0;transition:translate .5s var(--spring);box-shadow:-30px 0 60px -30px rgb(0 0 0 / .3)}
.sheet-wrap.open .sheet{translate:0 0}
.grab{display:none}
.sheet-head{display:flex;justify-content:space-between;align-items:center;gap:12px}
.sheet-head .who{display:flex;align-items:center;gap:14px;min-width:0}
.sheet-head .r-ico{width:52px;height:52px;border-radius:16px}
.sheet-head h2{font-size:28px;letter-spacing:-.035em;line-height:1.05}
.icon-btn{width:40px;height:40px;border-radius:50%;display:grid;place-items:center;background:var(--surface);box-shadow:var(--shadow);flex:none}
.icon-btn svg{width:18px;height:18px}
.stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(118px,1fr));gap:10px}
.stat{background:var(--surface);border-radius:var(--r-tile);padding:14px;box-shadow:var(--shadow);display:flex;flex-direction:column;gap:8px;min-width:0}
.stat .h{display:flex;align-items:center;gap:6px;color:var(--muted);font-size:12.5px}
.stat .h svg{width:15px;height:15px}
.stat b{font-size:21px;font-weight:600;letter-spacing:-.025em}
.scene-row{display:flex;flex-direction:column;gap:10px}
.scene-row .seg{width:100%}

/* Mosaicos de dispositivo */
.tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px}
.tile{position:relative;overflow:hidden;isolation:isolate;text-align:start;background:var(--surface);border-radius:var(--r-tile);padding:14px;min-height:124px;display:flex;flex-direction:column;justify-content:space-between;gap:14px;box-shadow:var(--shadow);transition-property:background-color,color,scale,box-shadow;transition-duration:.3s;transition-timing-function:var(--ease);min-width:0}
.tile .t-ico{width:40px;height:40px;border-radius:50%;display:grid;place-items:center;background:var(--surface-2);transition-property:background-color,color,box-shadow;transition-duration:.3s}
.tile .t-ico svg{width:21px;height:21px}
.tile .t-name{display:block;font-weight:600;font-size:14.5px;line-height:1.25}
.tile .t-state{display:block;color:var(--muted);font-size:13px;margin-top:2px;transition:color .3s}
.tile.on{background:var(--accent);color:var(--on-accent);box-shadow:0 10px 28px -12px var(--accent-glow),var(--shadow)}
.tile.on .t-ico{background:rgb(255 255 255 / .6);box-shadow:0 0 18px 2px rgb(255 255 255 / .7)}
.tile.on .t-state{color:rgb(17 17 17 / .66)}
.tile.on .glass{fill:currentColor;fill-opacity:.22}
.tile.on .spin{animation:spin 1.4s linear infinite;transform-origin:12px 12px}
.tile.busy::after{content:"";position:absolute;inset:0;z-index:-1;background:linear-gradient(100deg,transparent 30%,rgb(255 255 255 / .35) 50%,transparent 70%);background-size:220% 100%;animation:shimmer 1.1s linear infinite}
.tile.wide{grid-column:1/-1;min-height:0;cursor:default;gap:14px}
.tile.wide .row{display:flex;align-items:center;gap:12px;justify-content:space-between;flex-wrap:wrap}
.tile .who{display:flex;align-items:center;gap:12px;min-width:0;text-align:start}
.tile.led.on{background:color-mix(in oklab,var(--led,var(--accent)) 30%,var(--surface));color:var(--ink);box-shadow:0 10px 30px -10px color-mix(in oklab,var(--led,var(--accent)) 70%,transparent),var(--shadow)}
.tile.led.on .t-state{color:var(--muted)}
.tile.led.on .t-ico{background:var(--led,var(--accent));color:#111;box-shadow:0 0 20px 2px color-mix(in oklab,var(--led,var(--accent)) 70%,transparent)}
.swatches{display:flex;flex-wrap:wrap;gap:8px}
.sw{width:28px;height:28px;border-radius:50%;box-shadow:inset 0 0 0 1px rgb(17 17 17 / .14);transition-property:box-shadow,scale;transition-duration:.2s}
.sw:hover{scale:1.08}
.sw[aria-pressed="true"]{box-shadow:0 0 0 2px var(--surface),0 0 0 4px var(--ink)}

/* Regulador tipo píldora (se envía al soltar, en pasos válidos) */
.dim{--v:0%;-webkit-appearance:none;appearance:none;width:100%;height:46px;margin:0;border-radius:var(--r-ctl);background:linear-gradient(90deg,var(--fill,var(--ink)) 0 var(--v),var(--trk,var(--surface-2)) var(--v) 100%);cursor:pointer;touch-action:pan-y}
/* En la tarjeta encendida (lima) el fondo de la barra es lima oscurecido, no gris: así la parte negra se distingue (23-nov-2026) */
.tile.on .dim{--fill:#111;--trk:rgb(17 17 17 / .16);--thumb:#fff}
.dim[data-kind="blind"]{--fill:var(--accent)}
.tile.led.on .dim{--fill:var(--led,var(--accent))}
.dim::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:6px;height:26px;border-radius:3px;background:var(--thumb,var(--surface));box-shadow:0 0 0 1px rgb(17 17 17 / .2),0 2px 6px rgb(0 0 0 / .2)}
.dim::-moz-range-thumb{width:6px;height:26px;border:0;border-radius:3px;background:var(--thumb,var(--surface));box-shadow:0 0 0 1px rgb(17 17 17 / .2)}
.dim:disabled{cursor:default}
.meter{height:8px;border-radius:4px;background:var(--surface-2);overflow:hidden;flex:1;min-width:120px}
.meter span{display:block;height:100%;background:var(--ink);border-radius:inherit;transition:width .5s var(--ease)}
.tile.on .meter{background:rgb(255 255 255 / .5)} .tile.on .meter span{background:#111}

/* Estor: el icono baja y sube con la posición */
.blind-ico rect.cloth{fill:currentColor;fill-opacity:.18;transition:height .6s var(--spring)}
.row-ctl{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:11px 18px;border-radius:var(--r-ctl);background:var(--ink);color:var(--bg);font-weight:600;transition-property:scale,opacity;transition-duration:.15s}
.btn.ghost{background:var(--surface-2);color:var(--ink)}
.btn.sm{padding:8px 12px;font-size:13px}
.btn svg{width:16px;height:16px}
.note{display:flex;gap:10px;align-items:flex-start;color:var(--muted);font-size:13px}
.note svg{width:16px;height:16px;flex:none;margin-top:2px}

/* ---------- Clima ---------- */
.zones{display:grid;grid-template-columns:repeat(auto-fit,minmax(340px,1fr));gap:14px}
.zone{background:var(--surface);border-radius:var(--r-card);padding:20px;box-shadow:var(--shadow);display:flex;flex-direction:column;gap:18px;min-width:0}
.zone h3{font-size:19px;letter-spacing:-.02em}
.circuit{display:grid;grid-template-columns:64px minmax(0,1fr);align-items:center;column-gap:14px;row-gap:12px;padding-block:14px;border-top:1px solid var(--line)}
.circuit .stepper{grid-column:1/-1;justify-self:stretch;justify-content:space-between}
.circuit .badge{grid-column:2}
.dial{position:relative;width:64px;height:64px}
.dial svg{width:64px;height:64px;rotate:135deg}
.dial .trk{fill:none;stroke:var(--surface-2);stroke-width:6;stroke-linecap:round}
.dial .val{fill:none;stroke:var(--ink);stroke-width:6;stroke-linecap:round;transition:stroke-dashoffset .7s var(--spring),stroke .4s}
.dial.hot .val{stroke:var(--heat)}
.dial b{position:absolute;inset:0;display:grid;place-items:center;font-size:15px;font-weight:600;letter-spacing:-.02em}
.dial .fl{position:absolute;right:-4px;bottom:-2px;width:24px;height:24px;border-radius:50%;display:grid;place-items:center;background:var(--heat);color:#fff;box-shadow:0 0 0 3px var(--surface)}
.dial .fl svg{width:14px;height:14px;animation:flicker 1.6s ease-in-out infinite;transform-origin:50% 90%}
.circuit .nm{font-weight:600;line-height:1.25}
.stepper{display:inline-flex;align-items:center;gap:2px;background:var(--surface-2);border-radius:var(--r-ctl);padding:4px}
.stepper button{width:36px;height:36px;border-radius:10px;font-size:19px;font-weight:500;display:grid;place-items:center;transition-property:background-color,scale;transition-duration:.15s}
.stepper button:hover:not(:disabled){background:var(--surface)}
.stepper button:disabled{opacity:.35;cursor:default}
.stepper output{min-width:76px;text-align:center;font-weight:600;font-size:14px}
.temps{display:flex;flex-direction:column;background:var(--surface);border-radius:var(--r-card);box-shadow:var(--shadow);padding:6px 20px}
.trow{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(0,2fr) auto;align-items:center;gap:16px;padding-block:12px;border-top:1px solid var(--line)}
.trow:first-child{border-top:0}
.trow .nm{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.scale{position:relative;height:8px;border-radius:4px;background:linear-gradient(90deg in oklab,var(--cool),#9BC9B0,var(--accent),var(--heat));opacity:.9}
.scale i{position:absolute;top:50%;width:16px;height:16px;border-radius:50%;background:var(--surface);box-shadow:0 0 0 2px var(--ink),0 2px 6px rgb(0 0 0 / .25);translate:-50% -50%;transition:left .7s var(--spring)}
.trow b{font-size:17px;letter-spacing:-.02em;min-width:66px;text-align:right}

/* ---------- Seguridad ---------- */
.guard{position:relative;overflow:hidden;isolation:isolate;display:flex;align-items:center;gap:22px;padding:26px;border-radius:var(--r-card);background:var(--ink);color:var(--bg)}
.guard .ring{position:relative;width:72px;height:72px;border-radius:50%;display:grid;place-items:center;background:var(--accent);color:var(--on-accent);flex:none}
.guard .ring::before,.guard .ring::after{content:"";position:absolute;inset:0;border-radius:50%;border:2px solid var(--accent);animation:ripple 2.8s var(--ease) infinite}
.guard .ring::after{animation-delay:1.4s}
.guard.off .ring{background:var(--heat);color:#111}
.guard.off .ring::before,.guard.off .ring::after{border-color:var(--heat)}
.guard .ring svg{width:34px;height:34px}
.guard h2{font-size:clamp(24px,3vw,32px);letter-spacing:-.03em;line-height:1.05}
.guard p{opacity:.7;margin-top:6px}
.guard .mono{color:inherit;opacity:.6}
.guard .guard-btn{margin-top:14px}
.guard .btn.ghost{background:color-mix(in oklab,var(--bg) 16%,transparent);color:inherit}
.list{background:var(--surface);border-radius:var(--r-card);box-shadow:var(--shadow);padding:4px 18px}
.li{display:flex;align-items:center;gap:14px;padding-block:14px;border-top:1px solid var(--line)}
.li:first-child{border-top:0}
.li .b{width:40px;height:40px;border-radius:12px;display:grid;place-items:center;background:var(--surface-2)}
.li .b svg{width:20px;height:20px}
.li .tx{flex:1;min-width:0}
.li .tx b{display:block;font-weight:600}
.li .tx span{color:var(--muted);font-size:13px}
.cams{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:12px}
.cam{position:relative;overflow:hidden;border-radius:var(--r-tile);background:#151514;color:#F3F2EE;aspect-ratio:16/10;box-shadow:var(--shadow)}
.cam::before{content:"";position:absolute;inset:0;background:radial-gradient(120% 90% at 30% 20%,rgb(255 255 255 / .08),transparent 60%),repeating-linear-gradient(0deg,rgb(255 255 255 / .025) 0 1px,transparent 1px 3px)}
.cam .cap{position:absolute;inset:auto 0 0 0;display:flex;justify-content:space-between;align-items:center;gap:8px;padding:10px 12px;font-size:13px;font-weight:500;background:linear-gradient(transparent,rgb(0 0 0 / .55))}
.cam .tag{position:absolute;top:10px;left:10px;display:inline-flex;align-items:center;gap:6px;font-family:var(--f-mono);font-size:10px;letter-spacing:.06em;text-transform:uppercase;padding:4px 8px;border-radius:6px;background:rgb(255 255 255 / .1);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}
.cam{display:block;width:100%;padding:0;text-align:start;cursor:pointer;transition-property:scale,box-shadow;transition-duration:.25s}
.cam:hover{box-shadow:var(--shadow-lift)}
.cam img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;outline:1px solid rgb(255 255 255 / .08);outline-offset:-1px;animation:fadein .4s var(--ease)}
.cam.onair::before{z-index:1;background:linear-gradient(rgb(0 0 0 / .25),transparent 35%)}
.cam .tag,.cam .cap{z-index:2}
.cam .ph{position:absolute;inset:0;display:grid;place-content:center;justify-items:center;gap:8px;opacity:.45}
.cam .ph svg{width:28px;height:28px}
.cam .cap .mono{white-space:nowrap;font-size:10px}
.cam.err .ph{opacity:.6;color:var(--heat)}
.rec{width:6px;height:6px;border-radius:50%;background:#FF4D4D;box-shadow:0 0 6px #FF4D4D;animation:blink 1.6s ease-in-out infinite}
.zoom{position:fixed;inset:0;z-index:50;display:grid;place-items:center;padding:calc(16px + env(safe-area-inset-top,0px)) 16px calc(16px + env(safe-area-inset-bottom,0px));background:rgb(10 10 10 / .82);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);opacity:0;pointer-events:none;transition:opacity .3s var(--ease)}
.zoom.open{opacity:1;pointer-events:auto}
.zoom-in{width:min(1100px,100%);display:flex;flex-direction:column;gap:14px;color:#F3F2EE;scale:.96;transition:scale .45s var(--spring)}
.zoom.open .zoom-in{scale:1}
.zoom-top{display:flex;justify-content:space-between;align-items:flex-end;gap:12px}
.zoom-top h2{font-size:clamp(20px,3vw,28px);letter-spacing:-.02em}
.zoom img,.zoom .ph{width:100%;aspect-ratio:4/3;max-height:calc(100dvh - 140px);object-fit:contain;border-radius:var(--r-tile);background:#151514;outline:1px solid rgb(255 255 255 / .1);outline-offset:-1px}
.zoom .ph{display:grid;place-items:center;opacity:.4}
.zoom .icon-btn{background:rgb(255 255 255 / .12);color:#fff;box-shadow:none}

/* ---------- Avisos, carga, acceso ---------- */
.banner{display:flex;gap:10px;align-items:center;padding:12px 16px;border-radius:var(--r-tile);font-size:14px;background:var(--heat-soft)}
.banner svg{width:18px;height:18px;color:var(--heat);flex:none}
.toast{position:fixed;left:50%;bottom:calc(28px + env(safe-area-inset-bottom,0px));z-index:60;display:flex;align-items:center;gap:10px;background:var(--ink);color:var(--bg);padding:11px 18px 11px 12px;border-radius:999px;font-size:14px;font-weight:500;max-width:calc(100% - 32px);box-shadow:0 12px 30px -8px rgb(0 0 0 / .35);translate:-50% 20px;scale:.94;opacity:0;transition:opacity .25s var(--ease),translate .45s var(--spring),scale .45s var(--spring);pointer-events:none}
.toast.show{opacity:1;translate:-50% 0;scale:1}
.toast .b{width:24px;height:24px;border-radius:50%;display:grid;place-items:center;background:var(--accent);color:#111;flex:none}
.toast.err .b{background:var(--alert);color:#fff}
.toast .b svg{width:14px;height:14px;stroke-width:2.2}
.sk{border-radius:var(--r-tile);background:linear-gradient(100deg,var(--surface) 30%,var(--surface-2) 50%,var(--surface) 70%);background-size:220% 100%;animation:shimmer 1.4s linear infinite}
.keyview{max-width:520px;padding-top:12vh;margin-inline:auto;display:flex;flex-direction:column;gap:28px}
.card{background:var(--surface);box-shadow:var(--shadow)}
.login{display:flex;flex-direction:column;gap:14px;padding:20px;border-radius:var(--r-card)}
.login label{display:flex;flex-direction:column;gap:6px;font-size:13px;font-weight:600;color:var(--ink-2)}
.login input{font:inherit;font-size:16px;padding:13px 14px;border-radius:var(--r-ctl);border:1px solid transparent;background:var(--surface-2);color:var(--ink);transition:border-color .15s}
.login input:focus{outline:none;border-color:var(--ink)}
.btn.big{padding:14px 18px;font-size:15.5px;margin-top:4px}
.login-err{display:flex;gap:8px;align-items:center;color:var(--alert);font-size:13.5px}
.login-err svg{width:16px;height:16px;flex:none}
.linkish{align-self:flex-start;color:var(--muted);font-size:13.5px;text-decoration:underline;text-underline-offset:3px}
.linkish:hover{color:var(--ink)}
.session-foot{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;padding:14px 16px;border-radius:var(--r-tile);background:var(--surface);box-shadow:var(--shadow);font-size:13.5px;color:var(--muted)}
.session-foot span{display:inline-flex;align-items:center;gap:8px}
.session-foot svg{width:16px;height:16px;color:var(--ink)}
.session-foot b{color:var(--ink);font-weight:600}
.keyform{display:flex;gap:8px;padding:8px;background:var(--surface);border-radius:var(--r-card);box-shadow:var(--shadow)}
.keyform input{flex:1;min-width:0;font:inherit;font-size:16px;padding:12px 14px;border-radius:var(--r-ctl);border:0;background:var(--surface-2);color:var(--ink)}
body.nokey .tabbar{display:none!important}
body.nokey .app{grid-template-columns:minmax(0,1fr)} body.nokey .rail{display:none}

/* Entrada escalonada: solo al cambiar de vista, nunca en las lecturas periódicas */
.enter .st{animation:rise .55s var(--ease) both;animation-delay:calc(var(--i,0) * 55ms)}

.btn.door{background:var(--accent);color:var(--on-accent)}
.btn:disabled{opacity:.6;cursor:default}
.li .b.open,.tile.lock.on .t-ico{background:var(--heat);color:#fff}
.tile.lock{grid-column:1/-1;flex-direction:row;align-items:center;min-height:0;gap:12px}
.tile.lock>div{flex:1;min-width:0}
.tile.lock.on{background:var(--heat-soft);color:var(--ink)}
.tile.lock.on .t-state{color:var(--ink)}
.ask{position:fixed;inset:0;z-index:55;display:grid;place-items:center;padding:16px;background:var(--scrim);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);opacity:0;pointer-events:none;transition:opacity .25s var(--ease)}
.ask.open{opacity:1;pointer-events:auto}
.ask-in{width:min(400px,100%);display:flex;flex-direction:column;align-items:center;text-align:center;gap:12px;padding:28px 22px 22px;background:var(--surface);border-radius:28px;box-shadow:var(--shadow-lift);scale:.94;transition:scale .4s var(--spring)}
.ask.open .ask-in{scale:1}
.ask-ico{width:60px;height:60px;border-radius:50%;display:grid;place-items:center;background:var(--accent);color:var(--on-accent);margin-bottom:4px}
.ask-ico svg{width:28px;height:28px}
.ask-in h2{font-size:21px;letter-spacing:-.02em}
.ask-in p{color:var(--muted);font-size:14px}
.ask-btns{display:grid;grid-template-columns:1fr 1fr;gap:8px;width:100%;margin-top:10px}
.ask-btns .btn{padding:13px 12px}
@keyframes fadein{from{opacity:.6}to{opacity:1}}
@keyframes blink{50%{opacity:.25}}
@keyframes rise{from{opacity:0;translate:0 10px;filter:blur(4px)}to{opacity:1;translate:0 0;filter:blur(0)}}
@keyframes ping{0%{scale:1;opacity:.7}70%,100%{scale:2.6;opacity:0}}
@keyframes ripple{0%{scale:1;opacity:.7}100%{scale:1.7;opacity:0}}
@keyframes spin{to{rotate:360deg}}
@keyframes shimmer{from{background-position:120% 0}to{background-position:-120% 0}}
@keyframes flicker{0%,100%{scale:1 1}30%{scale:.92 1.06}60%{scale:1.05 .95}}

/* ---------- Móvil ---------- */
.tabbar{display:none}

@media (max-width:760px){
  .app{grid-template-columns:minmax(0,1fr)}
  .rail{display:none}
  main{padding-block:calc(14px + env(safe-area-inset-top,0px)) 130px;padding-inline:max(16px,env(safe-area-inset-left,0px)) max(16px,env(safe-area-inset-right,0px))}
  .view{gap:24px}
  .mobile-top{display:flex}
  .chips{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;margin-inline:-16px;padding:2px 16px 10px;scrollbar-width:none}
  .chips::-webkit-scrollbar{display:none}
  .chip{flex:none;scroll-snap-align:start;padding-right:18px}
  .master{padding:14px}
  .master .seg{width:100%}
  .rooms{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .room{--pad-card:14px;min-height:178px;gap:12px;border-radius:22px}
  .room h3{font-size:16px}
  .temp{font-size:26px}
  .room .r-ico{width:38px;height:38px;border-radius:12px}
  .room .meta{display:none}
  .room-foot .lbl,.room .badge .lbl{display:none}
  .room .badge.presence{padding:6px}
  .master .seg>button,.master .seg>span{padding:9px 4px;font-size:13.5px}
  .tabbar{display:flex;position:fixed;left:50%;bottom:calc(12px + env(safe-area-inset-bottom,0px));translate:-50% 0;z-index:30;gap:2px;padding:6px;border-radius:999px;background:var(--glass);-webkit-backdrop-filter:blur(20px) saturate(1.6);backdrop-filter:blur(20px) saturate(1.6);box-shadow:0 0 0 1px var(--line),0 12px 32px -8px rgb(0 0 0 / .25)}
  .tabbar .ind{position:absolute;top:6px;bottom:6px;left:6px;width:96px;border-radius:999px;background:var(--ink);translate:calc(var(--idx,0) * 98px) 0;transition:translate .45s var(--spring)}
  .tabbar button{position:relative;z-index:1;width:96px;display:flex;flex-direction:column;align-items:center;gap:2px;padding:7px 0 6px;font-size:11px;font-weight:600;color:var(--muted);border-radius:999px;transition:color .25s}
  .tabbar button svg{width:22px;height:22px}
  .tabbar button[aria-current="page"]{color:var(--bg)}
  .tabbar button[aria-current="page"] svg{color:var(--accent)}
  .zones{grid-template-columns:minmax(0,1fr)}
  .circuit{grid-template-columns:56px minmax(0,1fr)}
  .dial,.dial svg{width:56px;height:56px}
  .trow{grid-template-columns:minmax(0,1fr) auto;row-gap:8px}
  .trow .scale{grid-column:1/-1;grid-row:2}
  .guard{padding:20px;gap:16px}
  .guard .ring{width:60px;height:60px}
  .cams{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  /* La hoja sube desde abajo */
  .sheet-wrap{align-items:flex-end}
  .sheet{width:100%;height:auto;max-height:calc(100dvh - 40px - env(safe-area-inset-top,0px));border-radius:28px 28px 0 0;padding-top:10px;padding-inline:max(16px,env(safe-area-inset-left,0px)) max(16px,env(safe-area-inset-right,0px));translate:0 100%;gap:22px;box-shadow:0 -20px 60px -20px rgb(0 0 0 / .4)}
  .grab{display:block;align-self:center;width:40px;height:5px;border-radius:3px;background:var(--surface-3);flex:none}
  .sheet-head h2{font-size:24px}
  .tiles{grid-template-columns:repeat(2,minmax(0,1fr))}
  .seg.wrap{grid-template-columns:repeat(2,1fr)}
}
@media (max-width:380px){.tabbar .ind{width:84px;translate:calc(var(--idx,0) * 86px) 0}.tabbar button{width:84px}}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation:none!important;transition-duration:0s!important}
}
