/* Gaya "Tile padat" (preview 3). Aturan lengkap: ../STYLE.md */
:root{
  --bg:#0F1215; --tile:#1B1F24; --tile2:#262B31; --line:#323840;
  --text:#E8EAED; --muted:#9AA3AD; --accent:#4C8DFF; --power:#1D3557;
  --ok:#7EE2A8; --okdot:#3DDC84; --warn:#FFC46B; --bad:#FF8A80; --baddot:#FF5449; --badbg:#3A1E1E; --warnbg:#3A2F1A;
  --r:18px;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{background:var(--bg);color:var(--text);font-family:Inter,system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-font-smoothing:antialiased;touch-action:manipulation;overscroll-behavior-y:none;-webkit-text-size-adjust:100%}
.grid,.top,.sheet{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
body{min-height:100vh;min-height:100dvh}
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer;-webkit-tap-highlight-color:transparent;text-align:left}
button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
button:disabled{color:inherit;cursor:default}
.ic{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;flex:none;display:block}
.ic.s14{width:14px;height:14px}.ic.s22{width:22px;height:22px}

.app{max-width:480px;margin:0 auto;padding:max(14px,env(safe-area-inset-top)) 14px max(24px,env(safe-area-inset-bottom))}
.top{display:flex;justify-content:space-between;align-items:center;margin:6px 4px 12px}
.top h1{font:600 19px/1.2 Inter,sans-serif}
.conn{font:500 12px Inter,sans-serif;color:var(--muted);display:flex;gap:6px;align-items:center;padding:6px 8px;border-radius:99px}
.conn i{width:7px;height:7px;border-radius:50%;background:var(--muted)}
.conn.ok{color:var(--ok)}.conn.ok i{background:var(--okdot)}
.conn.bad{color:var(--bad)}.conn.bad i{background:var(--baddot)}
.conn.warn{color:var(--warn)}.conn.warn i{background:var(--warn)}
.conn.demo span::after{content:" · demo";color:var(--muted)}

.grid{display:grid;grid-template-columns:1fr 1fr;gap:9px;
  grid-template-areas:"daya daya" "suhu suhu" "mode mode" "kipas swing" "status status" "riwayat riwayat"}
.t{background:var(--tile);border-radius:var(--r);padding:13px 14px;display:block;width:100%;min-width:0;transition:opacity .2s,background .2s}
.lbl{font:500 12px Inter,sans-serif;color:var(--muted);display:flex;gap:6px;align-items:center}
.t b{font:600 17px/1.25 Inter,sans-serif;display:block;margin-top:5px}

.pwr .row2{display:flex;justify-content:space-between;align-items:center}
.pwr.on{background:var(--power)}
.tg{width:46px;height:28px;border-radius:14px;background:#3A4048;position:relative;flex:none;transition:background .2s}
.tg::after{content:"";position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;background:#fff;transition:left .2s}
.pwr.on .tg{background:var(--accent)}.pwr.on .tg::after{left:21px}

.temp{display:flex;align-items:center;justify-content:space-between;margin-top:6px}
.sq{width:52px;height:52px;border-radius:14px;background:var(--tile2);display:grid;place-items:center}
.sq:active{background:var(--line)}
.sq:disabled{opacity:.35;cursor:default}
.tv{font:600 44px/1 Inter,sans-serif;letter-spacing:-.02em;font-variant-numeric:tabular-nums}
.hint{display:block;font:400 11px Inter,sans-serif;color:var(--muted);text-align:center;margin-top:6px}

.seg{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;margin-top:9px}
.seg button{height:54px;border-radius:12px;background:var(--tile2);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;color:#C8CDD3}
.seg button small{font:500 10.5px Inter,sans-serif}
.seg button[aria-checked="true"]{background:var(--accent);color:#fff}

.pick .chev{margin-left:auto;opacity:.6}
.fb{display:flex;gap:4px;margin-top:10px;align-items:flex-end;height:20px}
.fb i{width:14px;border-radius:3px;background:var(--line);display:block}
.fb i.a{background:var(--accent)}

.stt p{font:400 12px/1.4 Inter,sans-serif;color:var(--muted);margin-top:6px}
.stt.ok .lbl{color:var(--ok)}
.stt.wait .lbl{color:var(--accent)}
.stt.warn{background:var(--warnbg)}.stt.warn .lbl{color:var(--warn)}
.stt.bad{background:var(--badbg)}.stt.bad .lbl{color:var(--bad)}
.spin{width:14px;height:14px;border-radius:50%;border:2px solid currentColor;border-right-color:transparent;animation:sp 0.8s linear infinite;flex:none}
@keyframes sp{to{transform:rotate(360deg)}}

.hist ol{list-style:none;margin-top:8px}
.hist li{display:grid;grid-template-columns:42px 1fr auto;gap:8px;padding:7px 0;border-top:1px solid var(--tile2);font:400 12.5px/1.35 Inter,sans-serif;align-items:baseline}
.hist li:first-child{border-top:0}
.hist time{color:var(--muted);font-variant-numeric:tabular-nums}
.hist em{font-style:normal;font-size:11px;color:var(--muted);text-align:right}
.hist em.ok{color:var(--ok)}
.hist .empty{display:block;color:var(--muted);grid-template-columns:none}

.foot{font:400 11.5px/1.45 Inter,sans-serif;color:#6F7882;text-align:center;margin:16px 10px 0}

/* Terkunci saat alat offline / belum tersambung */
.locked .ctl{opacity:.32;filter:grayscale(1);pointer-events:none}

/* Pilihan kipas / swing */
.sheet{position:fixed;inset:0;z-index:20;display:flex;align-items:flex-end;justify-content:center}
.sheet[hidden]{display:none}
.sheet-bg{position:absolute;inset:0;background:rgba(0,0,0,.55)}
.sheet-box{position:relative;width:100%;max-width:480px;background:#15191D;border-radius:22px 22px 0 0;padding:16px 14px max(18px,env(safe-area-inset-bottom));animation:up .18s ease-out}
@keyframes up{from{transform:translateY(30px);opacity:0}}
.sheet-head{display:flex;justify-content:space-between;align-items:center;margin:0 4px 12px}
.sheet-head b{font:600 16px Inter,sans-serif}
.x{font:500 13px Inter,sans-serif;color:var(--muted);padding:8px}
.opts{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}
.opts button{height:52px;border-radius:12px;background:var(--tile2);text-align:center;font:500 14px Inter,sans-serif}
.opts button[aria-checked="true"]{background:var(--accent);color:#fff}

/* Halaman link belum lengkap */
.gate{position:fixed;inset:0;display:grid;place-items:center;padding:24px;background:var(--bg)}
.gate[hidden]{display:none}
.gate-box{width:100%;max-width:360px;text-align:center}
.gate-icon{width:64px;height:64px;border-radius:16px;margin-bottom:14px}
.gate h1{font:600 22px Inter,sans-serif}
.gate p{color:var(--muted);font:400 14px/1.5 Inter,sans-serif;margin:10px 0 18px}
.gate-form{display:flex;flex-direction:column;gap:10px}
.gate-form input{width:100%;height:50px;border-radius:12px;border:1px solid var(--line);background:var(--tile);color:var(--text);padding:0 14px;font:400 16px Inter,sans-serif}
.gate-form input:focus{outline:2px solid var(--accent);outline-offset:1px}
.gate-form .btn{height:50px;text-align:center}
.demo-link{display:inline-block;margin-top:16px;color:var(--muted);font:500 13px Inter,sans-serif}
.btn{display:inline-block;background:var(--accent);color:#fff;text-decoration:none;font:600 15px Inter,sans-serif;padding:12px 18px;border-radius:12px}

/* Petunjuk pasang aplikasi */
.install{display:flex;gap:10px;align-items:flex-start;background:#16263D;border:1px solid #24406A;border-radius:var(--r);padding:12px 12px 12px 14px;margin-bottom:9px}
.install[hidden]{display:none}
.install div{flex:1}
.install b{font:600 14px Inter,sans-serif}
.install p{font:400 12.5px/1.45 Inter,sans-serif;color:#B9C6D8;margin-top:3px}
.install-go{background:var(--accent);color:#fff;font:600 13px Inter,sans-serif;padding:8px 12px;border-radius:10px;align-self:center}
.install-go[hidden]{display:none}

/* Laptop: grid 4 kolom */
@media (min-width:860px){
  .app{max-width:980px;padding-top:36px}
  .top{margin-bottom:16px}.top h1{font-size:24px}
  .grid{grid-template-columns:repeat(4,1fr);gap:12px;
    grid-template-areas:"daya daya status status" "suhu suhu mode mode" "suhu suhu kipas swing" "riwayat riwayat riwayat riwayat"}
  .t{padding:18px 20px}
  .suhu{display:flex;flex-direction:column;justify-content:center}
  .suhu .temp{margin-top:14px}
  .tv{font-size:72px}
  .sq{width:64px;height:64px;border-radius:18px}
  .seg button{height:64px}
  .hist ol{columns:2;column-gap:28px}
  .hist li{break-inside:avoid}
  .hist li:first-child{border-top:1px solid var(--tile2)}
  .sheet{align-items:center}
  .sheet-box{max-width:420px;border-radius:22px}
}
@media (hover:hover){
  .t.pick:hover,.pwr:hover{filter:brightness(1.12)}
  .sq:hover,.seg button:hover,.opts button:hover{filter:brightness(1.15)}
}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
.fb.auto i.a{opacity:.45}
