:root {
  --bg: #0b0c0f;
  --card: #1c1e23;
  --card-2: #26292f;
  --line: rgba(255,255,255,.07);
  --text: #f4f5f7;
  --muted: #8f96a1;
  --accent: #6b7cff;        /* roxo-azulado do app LG */
  --accent-2: #8a97ff;
  --ice: #4fd1e8;
  --radius: 22px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { min-height: 100dvh; display: flex; justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; touch-action: manipulation; }
main, #lock { width: 100%; max-width: 440px; }
main { display: flex; flex-direction: column; gap: 12px; }

/* ---------- PIN ---------- */
#lock { display: flex; flex-direction: column; justify-content: center; gap: clamp(28px, 6vh, 56px); min-height: calc(100dvh - 60px); }
.lock-top { text-align: center; }
.lockicon { width: 76px; height: 76px; border-radius: 19px; box-shadow: 0 10px 40px rgba(79,163,255,.35); }
#lock h1 { font-size: 24px; margin: 18px 0 4px; font-weight: 650; }
#lock p { color: var(--muted); margin: 0 0 26px; transition: color .2s; }
#lock p.bad { color: #ff6b6b; }
.dots { display: flex; justify-content: center; gap: 16px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #555b66; transition: .15s; }
.dots i.on { background: var(--text); border-color: var(--text); transform: scale(1.05); }
.dots.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-10px); } 40%,80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 22px; max-width: 300px; margin: 0 auto 10px; width: 100%; }
.keypad button { height: 74px; border-radius: 50%; aspect-ratio: 1; justify-self: center;
  font-size: 30px; font-weight: 400; background: var(--card); transition: background .1s, transform .1s; }
.keypad button:active { background: #33373f; transform: scale(.95); }
.keypad button[data-k="del"] { background: none; color: var(--muted); }

/* ---------- topo ---------- */
.top { display: flex; align-items: flex-start; justify-content: space-between; padding: 6px 4px 0; }
.top h1 { font-size: 26px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.room { margin: 2px 0 0; color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.sync { width: 7px; height: 7px; border-radius: 50%; background: transparent; transition: background .2s; }
.sync.busy { background: var(--accent-2); animation: pulse 1s infinite; }
.sync.err { background: #ff6b6b; }
@keyframes pulse { 50% { opacity: .3; } }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); background: var(--card); }

/* ---------- hero ---------- */
.hero { position: relative; display: flex; flex-direction: column; align-items: center; padding: 6px 0 2px;
  background: radial-gradient(60% 70% at 50% 35%, rgba(79,163,255,.18), transparent 70%); border-radius: var(--radius); transition: .4s; }
main.off .hero { background: radial-gradient(60% 70% at 50% 35%, rgba(255,255,255,.05), transparent 70%); }
.unit { position: relative; width: 230px; }
.unit-svg { width: 100%; display: block; filter: drop-shadow(0 12px 22px rgba(0,0,0,.5)); }
.unit-svg .air { transition: opacity .5s; }
main.off .unit-svg .air { opacity: 0; }
main:not(.off) .unit-svg .led { fill: #6cc4ff; }
.breeze { position: absolute; left: 0; right: 0; top: 64px; height: 56px; overflow: hidden; pointer-events: none; }
.breeze i { position: absolute; top: 0; width: 2px; height: 22px; border-radius: 2px; opacity: 0;
  background: linear-gradient(#a8dcff, transparent); animation: drop 1.8s linear infinite; }
.breeze i:nth-child(1) { left: 34%; animation-delay: 0s; }
.breeze i:nth-child(2) { left: 50%; animation-delay: .6s; }
.breeze i:nth-child(3) { left: 66%; animation-delay: 1.2s; }
main.off .breeze i { animation: none; opacity: 0; }
@keyframes drop { 0% { transform: translateY(-6px); opacity: 0; } 25% { opacity: .9; } 100% { transform: translateY(46px); opacity: 0; } }
main.swinging .breeze i:nth-child(1) { animation-name: dropL; }
main.swinging .breeze i:nth-child(3) { animation-name: dropR; }
@keyframes dropL { 0% { transform: translate(0,-6px); opacity: 0; } 25% { opacity: .9; } 100% { transform: translate(-26px,46px); opacity: 0; } }
@keyframes dropR { 0% { transform: translate(0,-6px); opacity: 0; } 25% { opacity: .9; } 100% { transform: translate(26px,46px); opacity: 0; } }
.ambient { display: flex; align-items: center; gap: 6px; font-size: 17px; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }

/* ---------- modo + power ---------- */
.controls-row { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 4px; }
.mode-btn { display: flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 600; padding: 6px 4px; }
.mode-btn svg { color: var(--muted); margin-left: 2px; }
#modeIcon { font-size: 22px; }
.power { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: #2a2d33; color: #6d737d; transition: background .25s, color .25s, box-shadow .25s, transform .1s; }
main:not(.off) .power { background: #eef0f6; color: var(--accent); box-shadow: 0 0 0 6px rgba(107,124,255,.12), 0 10px 30px rgba(0,0,0,.4); }
.power:active { transform: scale(.93); }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); }
.card-title { margin: 0; text-align: center; color: #c9ced6; font-size: 16px; }
.temp-card { padding: 18px 20px 14px; transition: opacity .3s; }
.temp-row { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 12px; }
.round { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); color: #c9ced6; transition: transform .1s, background .1s; }
.round:active { transform: scale(.92); background: #33373f; }
.big { font-size: 56px; font-weight: 300; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.big small { font-size: 28px; font-weight: 300; vertical-align: top; margin-left: 2px; color: #c9ced6; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, var(--accent) 0 var(--p, 33%), #3a3e46 var(--p, 33%) 100%); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -10px; border-radius: 50%;
  background: var(--accent-2); border: 4px solid #eef0ff; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
input[type=range]::-moz-range-track { height: 10px; border-radius: 5px; background: #3a3e46; }
input[type=range]::-moz-range-progress { height: 10px; border-radius: 5px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-2); border: 4px solid #eef0ff; }
.scale { display: flex; justify-content: space-between; color: #5d636d; font-size: 12px; padding: 2px 4px 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 18px 10px 14px; min-height: 168px; transition: background .15s, opacity .3s; }
.tile:active { background: #23262c; }
.tile-icon { margin-bottom: 8px; }
main:not(.off) .tile-icon.fan { animation: spin var(--spin, 2.2s) linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
main.swinging .tile-icon.swing { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.tile-title { margin: 0 0 10px; color: #c9ced6; font-size: 15px; }
.stepper { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 4px; }
.stepper button { width: 38px; height: 38px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; color: #c9ced6; }
.stepper button:active { transform: scale(.92); }
#windLabel { color: var(--accent-2); font-size: 20px; font-weight: 500; white-space: nowrap; }
.pill { color: var(--muted); font-size: 18px; font-weight: 500; margin-top: 6px; }
.pill.on { color: var(--accent-2); }

.list { overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 18px; text-align: left; cursor: pointer; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-row:active { background: #23262c; }
.li-icon { font-size: 22px; width: 28px; text-align: center; }
.li-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.li-text b { font-weight: 500; font-size: 17px; }
.li-text small { color: var(--muted); font-size: 14px; }
.li-text small.on { color: var(--accent-2); }
.list-row > svg { color: var(--muted); }

.switch { position: relative; display: inline-block; }
.switch input { display: none; }
.switch span { display: block; width: 52px; height: 32px; border-radius: 16px; background: #3a3e46; position: relative; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { left: 23px; }

main.off .temp-card, main.off .tile, main.off #timerRow { opacity: .4; pointer-events: none; }

.error { color: #ff8a8a; font-size: 14px; margin: 0; text-align: center; }
footer { text-align: center; padding-top: 6px; }
.link { color: #5d636d; font-size: 13px; }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); z-index: 10; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; margin: 0 auto; max-width: 480px;
  background: #1a1c21; border-radius: 26px 26px 0 0; padding: 10px 18px max(22px, env(safe-area-inset-bottom));
  animation: up .25s cubic-bezier(.2,.9,.3,1); }
.sheet.tall { max-height: 86dvh; overflow-y: auto; }
@keyframes up { from { transform: translateY(100%); } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: #3a3e46; margin: 2px auto 14px; }
.sheet h3 { margin: 0 0 12px 4px; font-size: 19px; font-weight: 650; }
.opt { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 14px; border-radius: 16px; margin-bottom: 8px; background: var(--card); border: 1.5px solid transparent; }
.opt.sel { border-color: var(--accent); background: rgba(107,124,255,.12); }
.opt-ic { font-size: 24px; width: 32px; text-align: center; }
.opt b { display: block; font-size: 17px; font-weight: 600; }
.opt small { color: var(--muted); font-size: 14px; }
.timer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.timer-grid button { padding: 16px 0; border-radius: 14px; background: var(--card); font-size: 17px; font-weight: 500; border: 1.5px solid transparent; }
.timer-grid button:active { background: #2a2d33; }
.danger { width: 100%; margin-top: 12px; padding: 15px; border-radius: 14px; background: rgba(255,107,107,.12); color: #ff8a8a; font-weight: 600; }
.help p { margin: 0 0 14px; color: #c9ced6; font-size: 15px; line-height: 1.45; }
.help b { color: var(--text); display: block; margin-bottom: 2px; font-size: 16px; }
.help .muted { color: var(--muted); }
.help code { background: var(--card-2); padding: 1px 6px; border-radius: 6px; font-size: 13px; color: var(--text); }

@media (min-width: 700px) { body { padding-top: 32px; } }

/* ---------- rotinas ---------- */
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h3 { margin-bottom: 6px; }
.sheet-sub { color: var(--muted); font-size: 14px; margin: 0 4px 14px; }
.add-btn { background: var(--accent); color: #fff; font-weight: 600; padding: 8px 14px; border-radius: 20px; font-size: 15px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; line-height: 1.5; }
.rt { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 16px; padding: 14px 16px; margin-bottom: 8px; text-align: left; width: 100%; }
.rt.off { opacity: .45; }
.rt-time { font-size: 26px; font-weight: 300; font-variant-numeric: tabular-nums; min-width: 72px; }
.rt-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rt-main b { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-main small { color: var(--muted); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
.field > span { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.field input { font: inherit; font-size: 17px; color: var(--text); background: var(--card); border: 0; border-radius: 12px; padding: 13px 14px; outline: none; color-scheme: dark; }
input[type=time] { font-size: 28px !important; font-weight: 300; text-align: center; }
.seg { display: flex; gap: 6px; margin-bottom: 16px; }
.field .seg { margin-bottom: 0; }
.seg button { flex: 1; padding: 11px 0; border-radius: 12px; background: var(--card); color: var(--muted); font-size: 15px; font-weight: 500; border: 1.5px solid transparent; }
.seg button.sel { border-color: var(--accent); background: rgba(107,124,255,.14); color: var(--text); }
.days { display: flex; justify-content: space-between; gap: 6px; }
.days button { flex: 1; aspect-ratio: 1; max-width: 46px; border-radius: 50%; background: var(--card); color: var(--muted); font-weight: 600; }
.days button.sel { background: var(--accent); color: #fff; }
.quick { display: flex; gap: 6px; }
.quick button { font-size: 13px; color: var(--accent-2); padding: 4px 8px; border-radius: 8px; background: rgba(107,124,255,.08); }
.mini-step { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-radius: 12px; padding: 6px; }
.mini-step button { width: 44px; height: 44px; border-radius: 10px; background: var(--card-2); font-size: 22px; }
.mini-step b { font-size: 24px; font-weight: 400; }
.primary { width: 100%; padding: 16px; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 600; font-size: 17px; margin-top: 4px; }
.primary:disabled { opacity: .5; }
.danger-link { color: #ff8a8a; font-size: 15px; }

/* ================= Abas (Ar / Luzes) ================= */
main { padding-bottom: 84px; }
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; gap: 6px; padding: 6px; border-radius: 999px; background: rgba(28,30,35,.86);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line);
  box-shadow: 0 10px 40px rgba(0,0,0,.45); z-index: 20; }
.tabbar button { display: flex; align-items: center; gap: 8px; padding: 11px 22px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 15px; transition: .2s; }
.tabbar button span { font-size: 17px; }
.tabbar button.sel { background: var(--accent); color: #fff; box-shadow: 0 6px 20px rgba(107,124,255,.4); }

/* ================= Luzes ================= */
#viewLuzes { display: flex; flex-direction: column; gap: 12px; }
.offline { margin: 0; padding: 12px 14px; border-radius: 16px; background: #2b2417; color: #ffcf7a; font-size: 14px; }
.offline .link { color: #ffe1a6; text-decoration: underline; margin-left: 4px; }
.lamps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lamp { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; min-height: 150px; padding: 16px; }
.lamp .glow { position: absolute; inset: auto -30% -60% -30%; height: 120%; border-radius: 50%; filter: blur(34px); opacity: .0; transition: opacity .4s, background .4s; }
.lamp.on .glow { opacity: .55; }
.lamp-info { position: relative; display: flex; flex-direction: column; gap: 2px; }
.lamp-info b { font-size: 18px; }
.lamp-info small { color: var(--muted); font-size: 13px; }
.lamp.on .lamp-info small { color: #e9ebef; }
.lamp-pow { position: relative; align-self: flex-start; margin-top: 18px; padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 13px; letter-spacing: .06em;
  background: #30343b; color: var(--muted); transition: .2s; }
.lamp.on .lamp-pow { background: #fff; color: #111; }

.scenes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.scenes button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px; border-radius: 16px; background: var(--card-2); font-size: 12.5px; color: #dfe2e7; transition: transform .1s; }
.scenes button span { font-size: 22px; }
.scenes button:active, .fxgrid button:active, .colors button:active { transform: scale(.94); }

.seg { display: flex; background: var(--card-2); border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.seg button { flex: 1; padding: 9px 4px; border-radius: 11px; color: var(--muted); font-weight: 600; font-size: 14px; transition: .15s; }
.seg button.sel { background: #3a3e46; color: #fff; }
.seg.tabs button.sel { background: var(--accent); }
.pane { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.sl label { display: flex; justify-content: space-between; font-size: 14px; color: #cfd3da; margin-bottom: 8px; }
.sl label b { color: var(--accent-2); font-weight: 600; }

.rng { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; border-radius: 999px; outline: none; margin: 0; background: #30343b; }
.rng::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.5); border: 3px solid rgba(255,255,255,.9); }
.rng::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 0; }
.rng.bright { background: linear-gradient(90deg, #2b2f36, #fff7e0); }
.rng.kelvin { background: linear-gradient(90deg, #ff9a2e, #ffd59a 25%, #fff 50%, #cfe2ff 75%, #9bbcff); }
.rng.gm { background: linear-gradient(90deg, #4cd964, #e9ebef 50%, #ff4fd8); }
.rng.hue { background: linear-gradient(90deg, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00); }
.rng.sat { --h: 0; background: linear-gradient(90deg, #fff, hsl(var(--h) 100% 50%)); }
.rng.red { background: linear-gradient(90deg, #2b2f36, #ff3b3b); }
.rng.green { background: linear-gradient(90deg, #2b2f36, #3bff6a); }
.rng.blue { background: linear-gradient(90deg, #2b2f36, #3b6bff); }
.rng.cw { background: linear-gradient(90deg, #2b2f36, #e6f0ff); }
.rng.ww { background: linear-gradient(90deg, #2b2f36, #ffc978); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: -4px; }
.chips button { padding: 7px 12px; border-radius: 999px; background: var(--card-2); font-size: 13px; color: #dfe2e7; }
.swatch-big { height: 64px; border-radius: 16px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); transition: background .2s; }
.colors { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.colors button { aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.12); }
.fxgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.fxgrid button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px; border-radius: 14px; background: var(--card-2); font-size: 11px; color: #cfd3da; line-height: 1.15; text-align: center; }
.fxgrid button span { font-size: 22px; }
.fxgrid button.sel { background: #ff9a3c; color: #fff; }
@media (max-width: 340px) { .scenes { grid-template-columns: repeat(3, 1fr); } .fxgrid { grid-template-columns: repeat(4, 1fr); } }
#viewLuzes > .card { padding: 16px; }
#viewLuzes .card-title { text-align: left; font-size: 14px; color: var(--muted); margin-bottom: 10px; font-weight: 600; letter-spacing: .02em; }
body.l-busy .lamp .lamp-info small::after { content: " · enviando…"; color: var(--accent-2); }
html:not([data-site="office"]) main { padding-bottom: 12px; }
html[data-site="led"] #error { display: none !important; }
html[data-site="led"] #helpBtn { visibility: hidden; }
