/* =========================================================
   Casa Demo — tema "Liquid Glass"
   Vetro traslucido, angoli molto arrotondati, bordi luminosi,
   sfondo sfumato. Chiaro/scuro automatici (o forzati dal simulatore).
   ========================================================= */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Helvetica Neue", system-ui, sans-serif;
  --r-card: 24px;
  --r-sheet: 34px;
  --blur: 20px;

  --primary: #007AFF;
  --accent: #FF9F0A;
  --text: #1C1C1E;
  --text2: rgba(60, 60, 67, .65);
  --text3: rgba(60, 60, 67, .3);
  --divider: rgba(60, 60, 67, .12);
  --ok: #34C759;
  --warn: #FF9500;
  --err: #FF3B30;
  --cool: #32ADE6;

  --glass: rgba(255, 255, 255, .45);
  --glass-strong: rgba(255, 255, 255, .72);
  --glass-border: rgba(255, 255, 255, .7);
  --glass-shadow: 0 4px 14px rgba(31, 38, 135, .10), inset 0 1px 0 rgba(255, 255, 255, .6);
  --sheet-bg: rgba(248, 248, 252, .78);
  --sheet-shadow: 0 -4px 20px rgba(31, 38, 135, .18), inset 0 1px 0 rgba(255, 255, 255, .6);
  --scrim: rgba(0, 0, 0, .25);
  --fill-soft: rgba(127, 127, 127, .14);

  --bg: linear-gradient(160deg, #eef3fb 0%, #f7f1fa 100%);
  --blob1: #c9e4ff; --blob2: #ffd9ec; --blob3: #d9f7e8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #0A84FF; --accent: #FFD60A; --text: #F5F5F7;
    --text2: rgba(235, 235, 245, .6); --text3: rgba(235, 235, 245, .3);
    --divider: rgba(255, 255, 255, .10); --ok: #30D158; --warn: #FF9F0A; --err: #FF453A;
    --glass: rgba(44, 44, 50, .42); --glass-strong: rgba(44, 44, 50, .7);
    --glass-border: rgba(255, 255, 255, .14);
    --glass-shadow: 0 4px 14px rgba(0, 0, 0, .30), inset 0 1px 0 rgba(255, 255, 255, .08);
    --sheet-bg: rgba(28, 28, 32, .72);
    --sheet-shadow: 0 -4px 20px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .08);
    --scrim: rgba(0, 0, 0, .5);
    --bg: linear-gradient(160deg, #0b0d14 0%, #12101a 100%);
    --blob1: #1d3a6e; --blob2: #4a1f5c; --blob3: #0f4a43;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #0A84FF; --accent: #FFD60A; --text: #F5F5F7;
  --text2: rgba(235, 235, 245, .6); --text3: rgba(235, 235, 245, .3);
  --divider: rgba(255, 255, 255, .10); --ok: #30D158; --warn: #FF9F0A; --err: #FF453A;
  --glass: rgba(44, 44, 50, .42); --glass-strong: rgba(44, 44, 50, .7);
  --glass-border: rgba(255, 255, 255, .14);
  --glass-shadow: 0 4px 14px rgba(0, 0, 0, .30), inset 0 1px 0 rgba(255, 255, 255, .08);
  --sheet-bg: rgba(28, 28, 32, .72);
  --sheet-shadow: 0 -4px 20px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .08);
  --scrim: rgba(0, 0, 0, .5);
  --bg: linear-gradient(160deg, #0b0d14 0%, #12101a 100%);
  --blob1: #1d3a6e; --blob2: #4a1f5c; --blob3: #0f4a43;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: #eef3fb; }
html[data-theme="dark"] { background: #0b0d14; }
@media (prefers-color-scheme: dark) { html:not([data-theme="light"]) { background: #0b0d14; } }
body {
  margin: 0; min-height: 100dvh; font-family: var(--font); color: var(--text);
  background: var(--bg) fixed; -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
svg.i { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.fill { fill: currentColor; stroke: none; }

/* macchie di colore dietro al vetro: senza di loro la sfocatura non si vede */
.blobs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.blobs i { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(60px); opacity: .75; }
.blobs i:nth-child(1) { background: var(--blob1); left: -15vmax; top: -15vmax; }
.blobs i:nth-child(2) { background: var(--blob2); right: -20vmax; top: 5vmax; }
.blobs i:nth-child(3) { background: var(--blob3); left: 20vmax; bottom: -30vmax; }
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; animation: none !important; } }

/* vetro */
.glass {
  background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4); backdrop-filter: blur(var(--blur)) saturate(1.4);
}

#app { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 14px 16px 120px; }

/* ---------- testata ---------- */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 6px 0 14px; }
.top h1 { margin: 0; font-size: 34px; letter-spacing: -.8px; line-height: 1.1; }
.top .sub { margin: 4px 0 0; color: var(--text2); font-size: 15px; }
.top .btns { display: flex; gap: 10px; }
.rbtn { width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.rbtn:active { transform: scale(.94); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 16px; font-size: 14px; font-weight: 600; }
.chip svg.i { width: 18px; height: 18px; }
.chip.warm svg { color: var(--accent); } .chip.cool svg { color: var(--cool); } .chip.ok svg { color: var(--ok); }

.rooms { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 14px; scrollbar-width: none; margin: 0 -2px; }
.rooms::-webkit-scrollbar { display: none; }
.rooms button { flex: none; padding: 9px 16px; border-radius: 18px; font-weight: 600; font-size: 15px; color: var(--text2); }
.rooms button.on { background: var(--primary); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(0, 122, 255, .35); }

h2.sec { font-size: 21px; letter-spacing: -.3px; margin: 22px 4px 10px; display: flex; align-items: center; gap: 8px; }
h2.sec small { font-size: 13px; font-weight: 500; color: var(--text2); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
@media (max-width: 420px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } .top h1 { font-size: 30px; } }

/* ---------- tessere ---------- */
.tile {
  border-radius: var(--r-card); padding: 14px; min-height: 118px; position: relative; text-align: left;
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px; cursor: pointer;
  transition: transform .15s, background .25s, box-shadow .25s; color: var(--text);
}
.tile:active { transform: scale(.975); }
.tile .row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tile .ic { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--fill-soft); color: var(--text2); transition: all .25s; }
.tile .name { font-weight: 650; font-size: 15px; line-height: 1.2; }
.tile .st { font-size: 13px; color: var(--text2); margin-top: 2px; }
.tile .rm { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; opacity: .85; }
.tile.on { background: var(--glass-strong); }
.tile.on .ic { background: var(--accent); color: #fff; box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 65%, transparent); }
.tile.cool.on .ic { background: var(--cool); box-shadow: 0 0 18px color-mix(in srgb, var(--cool) 65%, transparent); }
.tile.heat.on .ic { background: #FF6A3D; box-shadow: 0 0 18px rgba(255, 106, 61, .6); }
.tile.green.on .ic { background: var(--ok); box-shadow: 0 0 18px color-mix(in srgb, var(--ok) 55%, transparent); }
.tile.blue.on .ic { background: var(--primary); box-shadow: 0 0 18px color-mix(in srgb, var(--primary) 55%, transparent); }
.tile .mini { position: absolute; left: 14px; right: 14px; bottom: 10px; height: 4px; border-radius: 2px; background: var(--fill-soft); overflow: hidden; }
.tile .mini b { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s; }
.tile .sw { width: 44px; height: 26px; border-radius: 13px; background: rgba(127, 127, 127, .35); position: relative; flex: none; transition: background .2s; }
.tile .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.tile.on .sw { background: var(--ok); } .tile.on .sw::after { transform: translateX(18px); }
.tile.wide { grid-column: span 2; }
.tile.add { align-items: center; justify-content: center; color: var(--text2); border-style: dashed; }
.tile.alarm .time { font-size: 30px; font-weight: 300; letter-spacing: -1px; }
.tile.alarm:not(.on) .time, .tile.alarm:not(.on) .name { opacity: .5; }
.tile.cam { padding: 0; overflow: hidden; min-height: 150px; }
.tile.cam canvas { width: 100%; height: 100%; display: block; position: absolute; inset: 0; object-fit: cover; }
.tile.cam .ov { position: relative; z-index: 1; margin-top: auto; padding: 10px 14px; background: linear-gradient(0deg, rgba(0, 0, 0, .55), transparent); color: #fff; }
.tile.cam .ov .st { color: rgba(255, 255, 255, .8); }
.tile.cam .live { position: absolute; top: 10px; left: 12px; z-index: 1; background: rgba(255, 59, 48, .9); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 10px; letter-spacing: .5px; }
.tile.cam .live.alert { background: var(--accent); color: #000; }

/* scene */
.scenes { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; margin: 0 -2px; }
.scenes::-webkit-scrollbar { display: none; }
.scene { flex: none; width: 132px; border-radius: var(--r-card); padding: 14px; display: flex; flex-direction: column; gap: 22px; text-align: left; transition: transform .15s; }
.scene:active { transform: scale(.96); }
.scene .ic { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; }
.scene .n { font-weight: 650; font-size: 15px; line-height: 1.2; }
.scene.on { outline: 2px solid var(--primary); outline-offset: -2px; }
.scene .d { font-size: 12px; color: var(--text2); margin-top: 2px; font-weight: 500; }

/* energia / attività */
.cards2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.card { border-radius: var(--r-card); padding: 16px; }
.card h3 { margin: 0 0 2px; font-size: 15px; color: var(--text2); font-weight: 600; }
.card .big { font-size: 34px; font-weight: 300; letter-spacing: -1px; }
.card .big small { font-size: 16px; color: var(--text2); font-weight: 500; letter-spacing: 0; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 70px; margin-top: 10px; }
.bars i { flex: 1; border-radius: 3px 3px 1px 1px; background: var(--primary); opacity: .35; min-height: 2px; transition: height .4s; }
.bars i.now { opacity: 1; }
.bars-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--text2); margin-top: 4px; }
.log { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.log li { display: flex; gap: 10px; align-items: baseline; }
.log time { color: var(--text2); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; width: 42px; }
.log .empty { color: var(--text2); }

.foot { text-align: center; color: var(--text2); font-size: 12px; margin: 28px 0 0; }

/* ---------- pop-up dal basso ---------- */
.scrim { position: fixed; inset: 0; z-index: 100; display: none; align-items: flex-end; justify-content: center; padding: 0 12px; background: var(--scrim); opacity: 0; transition: opacity .22s; }
.scrim.open { display: flex; } .scrim.show { opacity: 1; }
.dlg {
  width: min(640px, 100%); max-height: calc(100dvh - 48px); display: flex; flex-direction: column; position: relative; overflow: hidden;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0; background: var(--sheet-bg); border: 1px solid var(--glass-border); border-bottom: 0;
  box-shadow: var(--sheet-shadow); transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4); backdrop-filter: blur(var(--blur)) saturate(1.4);
}
.scrim.show .dlg { transform: none; }
.grab { position: absolute; top: 7px; left: 50%; transform: translateX(-50%); width: 36px; height: 5px; border-radius: 3px; background: rgba(127, 127, 127, .5); }
.hdr { display: flex; align-items: center; gap: 12px; padding: 18px 12px 10px 20px; flex: none; }
.hdr .tt { flex: 1; min-width: 0; line-height: 1.15; }
.hdr .tt small { display: block; font-size: 13px; color: var(--text2); }
.hdr .tt b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xbtn { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); }
.xbtn:active { transform: scale(.94); }
.body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; }

/* componenti dei pop-up */
.pwr { width: 84px; height: 84px; border-radius: 50%; margin: 2px auto; display: flex; align-items: center; justify-content: center; background: var(--fill-soft); color: var(--text2); transition: all .25s; }
.pwr svg.i { width: 36px; height: 36px; }
.pwr.on { background: var(--accent); color: #fff; box-shadow: 0 0 34px color-mix(in srgb, var(--accent) 70%, transparent); }
.pwr.cool.on { background: var(--cool); box-shadow: 0 0 34px color-mix(in srgb, var(--cool) 70%, transparent); }
.pwr.heat.on { background: #FF6A3D; box-shadow: 0 0 34px rgba(255, 106, 61, .65); }
.pwr.green.on { background: var(--ok); box-shadow: 0 0 34px color-mix(in srgb, var(--ok) 60%, transparent); }
.readout { text-align: center; }
.readout .v { font-size: 56px; font-weight: 200; letter-spacing: -2px; line-height: 1; }
.readout .v small { font-size: 22px; font-weight: 400; color: var(--text2); letter-spacing: 0; }
.readout .l { color: var(--text2); font-size: 14px; margin-top: 4px; }
.lbl { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; margin: 2px 4px -6px; }

.gs { -webkit-appearance: none; appearance: none; width: 100%; height: 64px; border-radius: 32px; outline: none; margin: 0; cursor: pointer;
  background: linear-gradient(90deg, var(--fillc, var(--accent)) var(--v, 0%), var(--fill-soft) var(--v, 0%)); box-shadow: inset 0 0 0 1px var(--glass-border); }
.gs::-webkit-slider-thumb { -webkit-appearance: none; width: 6px; height: 30px; border-radius: 3px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); margin-right: 14px; }
.gs::-moz-range-thumb { width: 6px; height: 30px; border-radius: 3px; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.gs.ct { background: linear-gradient(90deg, #ffb35c, #fff3e0 50%, #bfe0ff); }
.gs.slim { height: 44px; border-radius: 22px; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1 1 auto; min-width: 64px; padding: 12px 10px; border-radius: 18px; font-weight: 600; font-size: 14px; background: var(--glass); border: 1px solid var(--glass-border); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.seg button svg.i { width: 20px; height: 20px; }
.seg button.on { background: var(--primary); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(0, 122, 255, .35); }
.seg.accent button.on { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(255, 159, 10, .4); }

.stepper { display: flex; align-items: center; justify-content: center; gap: 22px; }
.stepper button { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); }
.stepper button:active { transform: scale(.92); }
.stepper button svg.i { width: 28px; height: 28px; }

.btnrow { display: flex; gap: 10px; }
.btn { flex: 1; height: 52px; border-radius: 26px; font-size: 16px; font-weight: 650; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); }
.btn:active { transform: scale(.97); }
.btn.pri { background: var(--accent); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(255, 159, 10, .4); }
.btn.blue { background: var(--primary); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(0, 122, 255, .35); }
.btn.danger { color: var(--err); }
.btn svg.i { width: 20px; height: 20px; }

.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kv > div { padding: 12px 8px; border-radius: 18px; text-align: center; background: var(--glass); border: 1px solid var(--glass-border); }
.kv b { display: block; font-size: 20px; font-weight: 650; }
.kv span { font-size: 12px; color: var(--text2); }
.status-pill { align-self: center; display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 20px; font-weight: 600; font-size: 15px; }
.status-pill i { width: 10px; height: 10px; border-radius: 50%; background: #8E8E93; }
.status-pill.go i { background: var(--ok); animation: pulse 1.4s infinite; }
.status-pill.warn i { background: var(--warn); } .status-pill.err i { background: var(--err); }
@keyframes pulse { 50% { opacity: .35; } }

/* finestra con tapparella */
.win { width: 190px; height: 170px; margin: 0 auto; border-radius: 14px; position: relative; overflow: hidden; border: 6px solid rgba(127, 127, 127, .55);
  background: linear-gradient(#8ec9ff, #dff1ff); box-shadow: var(--glass-shadow); }
.win .slats { position: absolute; left: 0; right: 0; top: 0; height: 100%; transform-origin: top; background: repeating-linear-gradient(180deg, #b8bcc6 0 9px, #9da2ae 9px 11px); transition: none; border-bottom: 5px solid #7d828e; }
.win .cross { position: absolute; inset: 0; background: linear-gradient(90deg, transparent 49%, rgba(127, 127, 127, .55) 49% 51%, transparent 51%); pointer-events: none; }
.win.night { background: linear-gradient(#10183a, #26335f); }

/* tv */
.tvscr { aspect-ratio: 16/9; border-radius: 16px; overflow: hidden; position: relative; background: #05060a; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; box-shadow: var(--glass-shadow); }
.tvscr .pic { position: absolute; inset: 0; opacity: 0; transition: opacity .4s; background-size: 200% 200%; animation: tvmove 8s ease-in-out infinite alternate; }
.tvscr.on .pic { opacity: 1; }
.tvscr .cap { position: relative; z-index: 1; text-shadow: 0 2px 10px rgba(0, 0, 0, .6); font-size: 20px; text-align: center; padding: 0 12px; }
.tvscr .osd { position: absolute; left: 12px; right: 12px; bottom: 10px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .25); z-index: 2; opacity: 0; transition: opacity .3s; }
.tvscr .osd b { display: block; height: 100%; border-radius: 3px; background: #fff; }
.tvscr .osd.show { opacity: 1; }
@keyframes tvmove { to { background-position: 100% 100%; } }
.remote { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; }
.pill { width: 70px; border-radius: 38px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 4px 0; background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); justify-self: center; }
.pill button { width: 100%; height: 54px; display: flex; align-items: center; justify-content: center; border-radius: 27px; }
.pill button:active { background: var(--fill-soft); }
.pill .m { font-size: 12px; font-weight: 700; color: var(--text2); }
.dpad { width: 168px; height: 168px; position: relative; border-radius: 50%; background: var(--glass); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); }
.dpad button { position: absolute; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.dpad button:active { background: var(--fill-soft); }
.dpad .u { top: 4px; left: 58px; } .dpad .d { bottom: 4px; left: 58px; } .dpad .l { left: 4px; top: 58px; } .dpad .r { right: 4px; top: 58px; }
.dpad .ok { left: 50%; top: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: var(--glass-strong); border: 1px solid var(--glass-border); font-weight: 700; font-size: 15px; }

/* telecamera */
.camview { position: relative; border-radius: 20px; overflow: hidden; background: #000; aspect-ratio: 16/10; box-shadow: var(--glass-shadow); }
.camview canvas { width: 100%; height: 100%; display: block; }
.camview .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.camview .flash.go { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }
.togs { display: flex; flex-direction: column; gap: 8px; }
.tog { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 20px; text-align: left; font-weight: 600; font-size: 15px; background: var(--glass); border: 1px solid var(--glass-border); }
.tog .t { flex: 1; } .tog .t small { display: block; font-weight: 400; color: var(--text2); font-size: 12.5px; }
.tog .sw { width: 44px; height: 26px; border-radius: 13px; background: rgba(127, 127, 127, .35); position: relative; flex: none; transition: background .2s; }
.tog .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.tog.on .sw { background: var(--ok); } .tog.on .sw::after { transform: translateX(18px); }

/* robot */
.map { width: 100%; border-radius: 20px; background: var(--glass); border: 1px solid var(--glass-border); }
.map .room { fill: rgba(127, 127, 127, .12); stroke: rgba(127, 127, 127, .45); stroke-width: 2; transition: fill .3s; }
.map .room.sel { fill: color-mix(in srgb, var(--primary) 22%, transparent); }
.map .room.done { fill: color-mix(in srgb, var(--ok) 25%, transparent); }
.map text { fill: var(--text2); font-size: 15px; font-weight: 600; text-anchor: middle; font-family: var(--font); pointer-events: none; }
.map .trail { fill: none; stroke: var(--primary); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: .55; }
.map .dock { fill: var(--ok); }
.map .bot circle.b { fill: var(--glass-strong); stroke: var(--primary); stroke-width: 3; }
.map .bot circle.s { fill: var(--primary); }
.map .bot .ring { fill: none; stroke: var(--accent); stroke-width: 3; opacity: 0; }
.map .bot.loc .ring { animation: ping 1s ease-out infinite; }
@keyframes ping { 0% { r: 14; opacity: .9; } 100% { r: 46; opacity: 0; } }

/* sveglie */
.daysrow { display: flex; gap: 6px; justify-content: space-between; }
.daysrow button { width: 40px; height: 40px; border-radius: 50%; font-size: 15px; font-weight: 600; background: var(--fill-soft); }
.daysrow button.on { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(255, 159, 10, .45); }
.timein { font: inherit; font-size: 56px; font-weight: 200; text-align: center; width: 100%; border: 0; background: transparent; color: var(--text); outline: none; letter-spacing: -2px; font-variant-numeric: tabular-nums; }
.txt { width: 100%; border: 0; border-bottom: 1.5px solid rgba(127, 127, 127, .5); background: transparent; color: inherit; font: inherit; font-size: 17px; padding: 8px 4px; outline: none; }
.txt:focus { border-bottom-color: var(--accent); }

.alarm-ring { position: fixed; inset: 0; z-index: 300; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(0, 0, 0, .45); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.alarm-ring.open { display: flex; }
.alarm-ring .box { width: min(380px, 100%); border-radius: var(--r-sheet); padding: 28px 20px 20px; text-align: center; display: flex; flex-direction: column; gap: 14px; background: var(--sheet-bg); border: 1px solid var(--glass-border); box-shadow: var(--sheet-shadow); }
.alarm-ring .bell { margin: 0 auto; width: 76px; height: 76px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; animation: shake .5s infinite; }
.alarm-ring .bell svg.i { width: 38px; height: 38px; }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }
.alarm-ring .t { font-size: 60px; font-weight: 200; letter-spacing: -2px; line-height: 1; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); z-index: 400; padding: 12px 18px; border-radius: 22px; font-weight: 600; font-size: 15px; opacity: 0; pointer-events: none; transition: all .3s; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* banner demo */
.demo-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--accent); padding: 4px 10px; border-radius: 12px; margin-left: 4px; vertical-align: middle; }

@media (min-width: 900px) {
  .tile { min-height: 128px; }
}
[hidden] { display: none !important; }
.bars-sub { color: var(--text2); font-size: 14px; margin-top: 2px; }
.bars-sub b { color: var(--text); }
.nextal { color: var(--text2); font-size: 13px; margin: 12px 0 0; }
/* strisce scorrevoli a tutto schermo */
.rooms, .scenes { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; scroll-padding: 16px; }

/* mappa dei dispositivi personali (Leaflet + OpenStreetMap) */
.lmap { height: 300px; border-radius: var(--r-card); overflow: hidden; position: relative; z-index: 0; isolation: isolate; font-family: var(--font); }
@media (min-width: 700px) { .lmap { height: 360px; } }
.leaflet-container { font-family: var(--font); background: var(--glass); }
.leaflet-control-zoom { border: 1px solid var(--glass-border) !important; box-shadow: var(--glass-shadow) !important; border-radius: 14px !important; overflow: hidden; }
.leaflet-control-zoom a { background: var(--glass-strong) !important; color: var(--text) !important; border-bottom-color: var(--divider) !important; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.leaflet-control-attribution { background: var(--glass-strong) !important; color: var(--text2) !important; border-radius: 10px 0 0 0; font-size: 10px; }
.leaflet-control-attribution a { color: var(--primary) !important; }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.8); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.8); } }
.fpin { background: none; border: 0; }
.fpin .b { position: relative; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--glass-strong); border: 2.5px solid var(--primary); color: var(--primary); box-shadow: 0 3px 10px rgba(0, 0, 0, .28); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.fpin .b svg.i { width: 20px; height: 20px; stroke-width: 2; }
.fpin.home .b { border-color: var(--ok); color: var(--ok); }
.fpin .n { position: absolute; left: 50%; top: 44px; transform: translateX(-50%); white-space: nowrap; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 9px; background: var(--glass-strong); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.fpin.ring .b::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; border: 3px solid var(--accent); animation: halo 1s ease-out infinite; }
@keyframes halo { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(2.4); opacity: 0; } }
.leaflet-popup-content-wrapper { background: var(--sheet-bg); color: var(--text); border: 1px solid var(--glass-border); border-radius: 18px; box-shadow: var(--glass-shadow); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.leaflet-popup-tip { background: var(--sheet-bg); }
.leaflet-popup-close-button { color: var(--text2) !important; }
.fpop { font-family: var(--font); min-width: 150px; line-height: 1.3; }
.fpop b { display: block; font-size: 15px; }
.fpop span { display: block; font-size: 12.5px; color: var(--text2); }
.fpop button { margin-top: 8px; width: 100%; padding: 8px; border-radius: 14px; font-size: 13px; font-weight: 650; color: #fff; background: var(--primary); }
