/* Apple-inspired styling: SF system font, #f5f5f7 canvas, white rounded cards, pill buttons. */
:root {
  /* Homey-app style (light): lavender-grey canvas, white tiles */
  --bg: #eef0f6;
  --surface: #ffffff;
  --surface-2: #f2f3f8;
  --surface-3: #e4e6ef;
  --tile: #ffffff;
  --tile-off: #f7f8fb;
  --border: #d9dbe6;
  --hairline: rgba(20, 20, 50, .07);
  --text: #191a2b;
  --muted: #7b7d93;
  --faint: #9a9cb0;
  --primary: #2f7bf6;
  --primary-hover: #4489f8;
  --link: #2f7bf6;
  --green: #2fc46f;
  --orange: #ff8a1f;
  --purple: #a259ff;
  --ok: #2fc46f;
  --ok-text: #1f9a54;
  --warn: #ffb020;
  --bad: #ff4d4f;
  --bad-text: #e0353a;
  --on: #2fc46f;
  --nav: rgba(238, 240, 246, .86);
  --overlay: rgba(20, 20, 40, .35);
  --shadow: 0 1px 2px rgba(20, 20, 60, .04), 0 6px 18px rgba(20, 20, 60, .06);
  --shadow-hover: 0 2px 4px rgba(20, 20, 60, .06), 0 10px 28px rgba(20, 20, 60, .1);
  --radius: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    /* Homey-dashboard style (dark) */
    --bg: #111117;
    --surface: #1d1d25;
    --surface-2: #272731;
    --surface-3: #33333f;
    --tile: #272731;
    --tile-off: #1f1f28;
    --border: #393946;
    --hairline: rgba(255, 255, 255, .07);
    --text: #f3f3f8;
    --muted: #9d9db0;
    --faint: #7c7c90;
    --primary: #3d8bff;
    --primary-hover: #5c9dff;
    --link: #5c9dff;
    --green: #35d07a;
    --orange: #ff8f2b;
    --purple: #b07bff;
    --ok: #35d07a;
    --ok-text: #35d07a;
    --warn: #ffb53a;
    --bad: #ff5a5f;
    --bad-text: #ff7a7e;
    --on: #35d07a;
    --nav: rgba(17, 17, 23, .86);
    --overlay: rgba(0, 0, 0, .6);
    --shadow: none;
    --shadow-hover: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: -.022em;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif; }
h1 { font-size: 56px; line-height: 1.07; font-weight: 700; letter-spacing: -.005em; }
h2 { font-size: 32px; line-height: 1.125; font-weight: 700; letter-spacing: .004em; }
h3 { font-size: 21px; line-height: 1.2; font-weight: 600; letter-spacing: .011em; }
h4 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 14px; letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; letter-spacing: -.016em; }
[hidden] { display: none !important; }
svg.i { display: block; flex: none; }

/* ---------- navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: 52px; padding: 0 max(22px, calc((100% - 1024px) / 2));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.brand .i { color: var(--text); }
.top-actions { display: flex; align-items: center; gap: 4px; }
.nav-link {
  appearance: none; background: none; border: 0; font: inherit; font-size: 14px; color: var(--text); opacity: .8;
  padding: 6px 10px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; border-radius: 8px; letter-spacing: -.01em;
}
.nav-link:hover { opacity: 1; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 64px 22px 8px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.hero .eyebrow { font-size: 21px; font-weight: 600; color: var(--muted); letter-spacing: .011em; }
.hero .lead { font-size: 24px; line-height: 1.17; font-weight: 500; color: var(--muted); max-width: 640px; letter-spacing: .009em; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500;
  padding: 6px 14px; border-radius: 980px; background: var(--surface); box-shadow: var(--shadow); margin-top: 6px;
}

.container { max-width: 1068px; margin: 0 auto; padding: 32px 22px 80px; display: flex; flex-direction: column; gap: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- buttons & inputs ---------- */
.btn {
  appearance: none; border: 0; background: var(--surface-2); color: var(--text);
  border-radius: 980px; padding: 8px 18px; font: inherit; font-size: 15px; font-weight: 500; letter-spacing: -.01em;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  transition: background .2s, opacity .2s, transform .1s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; color: var(--link); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad-text); }
.btn.small { padding: 5px 13px; font-size: 13px; }
.btn.icon { padding: 7px; border-radius: 50%; }
.btn.large { padding: 12px 24px; font-size: 17px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; outline: none; min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 22%, transparent); }
input::placeholder { color: var(--faint); }
textarea { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 13px; min-height: 300px; resize: vertical; letter-spacing: 0; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: -.01em; }
label.field span.hint { font-weight: 400; color: var(--faint); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); margin: 0; }
.input-row { display: flex; gap: 8px; align-items: center; }

/* iOS switch */
.toggle { position: relative; width: 51px; height: 31px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 99px; cursor: pointer; transition: background .25s; }
.toggle span::after {
  content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16);
  transition: transform .25s cubic-bezier(.3, .7, .4, 1);
}
.toggle input:checked + span { background: var(--on); }
.toggle input:checked + span::after { transform: translateX(20px); }
.toggle input:disabled + span { opacity: .4; cursor: default; }
.toggle input:focus-visible + span { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 30%, transparent); }

input[type=range] { width: 100%; accent-color: var(--primary); }

/* ---------- pairing ---------- */
.pairing { display: flex; gap: 40px; padding: 40px; align-items: center; flex-wrap: wrap; justify-content: center; }
.pairing .qr { width: 200px; height: 200px; background: #fff; border-radius: 18px; padding: 12px; flex: none; box-shadow: 0 0 0 1px var(--hairline); }
.pairing .qr img { width: 100%; height: 100%; display: block; }
.pairing .info { flex: 1; min-width: 260px; max-width: 460px; display: flex; flex-direction: column; gap: 14px; }
.pin { font: 600 34px/1 "SF Mono", ui-monospace, Menlo, monospace; letter-spacing: .04em; }
.steps { margin: 0; padding-left: 22px; color: var(--muted); font-size: 15px; }
.steps li { margin: 4px 0; }
.steps b { color: var(--text); font-weight: 600; }

/* ---------- device cards (Home-app style tiles) ---------- */
.device { padding: 22px; display: flex; flex-direction: column; gap: 18px; transition: box-shadow .25s, transform .25s; }
.device:hover { box-shadow: var(--shadow-hover); }
.device.offline .controls { opacity: .5; }
.device-head { display: flex; gap: 14px; align-items: center; }
.device-icon {
  width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2); color: var(--faint);
  display: grid; place-items: center; flex: none; transition: background .25s, color .25s;
}
.device-icon.on { background: var(--tint, var(--warn)); color: #fff; }
.device-title { flex: 1; min-width: 0; }
.device-name { font-size: 19px; font-weight: 600; letter-spacing: .012em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-sub { font-size: 14px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }
.controls { display: flex; flex-direction: column; }
.ctl { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; border-top: 1px solid var(--hairline); padding: 6px 0; }
.ctl:first-child { border-top: 0; }
.ctl-label { font-size: 16px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ctl-label span.t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 500;
  padding: 4px 11px; border-radius: 980px; background: var(--surface-2); color: var(--muted); white-space: nowrap; letter-spacing: -.01em;
}
.badge.active { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); color: #b25000; }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, var(--surface)); color: var(--ok-text); }
.badge.bad { background: color-mix(in srgb, var(--bad) 13%, var(--surface)); color: var(--bad-text); }
.badge.blue { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--link); }
@media (prefers-color-scheme: dark) { .badge.active { color: var(--warn); } }
.battery { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.battery .bar { width: 28px; height: 13px; border-radius: 4px; border: 1.5px solid var(--faint); padding: 1.5px; position: relative; }
.battery .bar::after { content: ""; position: absolute; right: -4px; top: 3px; width: 2px; height: 4px; border-radius: 0 2px 2px 0; background: var(--faint); }
.battery .fill { height: 100%; border-radius: 1.5px; background: var(--ok); }
.battery.low .fill { background: var(--bad); }
.cover-btns { display: flex; gap: 6px; }
.ctl-stack { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 0; }
.seg { display: flex; flex-wrap: wrap; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 11px; }
.seg button {
  flex: 1 1 auto; appearance: none; border: 0; background: none; font: inherit; font-size: 13px; font-weight: 500; color: var(--text);
  padding: 6px 7px; border-radius: 8px; cursor: pointer; letter-spacing: -.01em; white-space: nowrap;
}
.seg button.on { background: var(--surface); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); }
.seg button:disabled { opacity: .45; cursor: default; }
@media (prefers-color-scheme: dark) { .seg button.on { background: var(--surface-3); } }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .temp { font-size: 22px; font-weight: 600; min-width: 52px; text-align: center; letter-spacing: -.01em; }
.device-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.error-box { background: color-mix(in srgb, var(--bad) 9%, var(--surface)); color: var(--bad-text); border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.info-box { background: var(--surface-2); border-radius: 16px; padding: 16px 18px; font-size: 15px; }
.info-box ol { margin: 8px 0 0; padding-left: 22px; }
.info-box li { margin: 4px 0; }

.empty { text-align: center; padding: 64px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty .i { color: var(--faint); }
.empty p { color: var(--muted); max-width: 440px; }

/* ---------- sheet / modal ---------- */
.overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: 50;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto;
  animation: fade .2s ease;
}
.modal {
  width: 100%; max-width: 760px; background: var(--surface); border-radius: 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25); display: flex; flex-direction: column;
  animation: rise .3s cubic-bezier(.2, .8, .2, 1);
}
.modal.wide { max-width: 980px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 26px 30px 6px; gap: 12px; }
.modal-head h3 { font-size: 28px; font-weight: 700; letter-spacing: .007em; }
.modal-head .btn.icon { background: var(--surface-2); color: var(--muted); }
.modal-body { padding: 18px 30px 26px; display: flex; flex-direction: column; gap: 24px; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 18px 30px; border-top: 1px solid var(--hairline); flex-wrap: wrap; }
.modal-foot .right { display: flex; gap: 10px; margin-left: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.985); } }

/* segmented control */
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 12px; }
.tab {
  flex: 1; text-align: center; padding: 8px 12px; border-radius: 9px; cursor: pointer; font: inherit; font-weight: 500; font-size: 14px;
  color: var(--text); border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; letter-spacing: -.01em;
}
.tab.active { background: var(--surface); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); }
@media (prefers-color-scheme: dark) { .tab.active { background: var(--surface-3); } }

.section { display: flex; flex-direction: column; gap: 14px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* grouped lists (iOS Settings style) */
.list { display: flex; flex-direction: column; background: var(--surface-2); border-radius: 16px; overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; position: relative; }
.list-row + .list-row::before { content: ""; position: absolute; top: 0; left: 64px; right: 0; border-top: 1px solid var(--hairline); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row img.icon { width: 36px; height: 36px; border-radius: 9px; object-fit: cover; background: var(--surface); }
.list-row .ph-icon { width: 36px; height: 36px; border-radius: 9px; background: var(--surface); color: var(--muted); display: grid; place-items: center; flex: none; }

table { width: 100%; border-collapse: collapse; font-size: 14px; letter-spacing: -.01em; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.table-wrap { background: var(--surface-2); border-radius: 16px; overflow-x: auto; }
td.value { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0; }
tr.flash td.value { animation: flash 1.4s ease; }
@keyframes flash { from { background: color-mix(in srgb, var(--primary) 25%, transparent); } }

/* function editor */
.svc { border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.svc.disabled { opacity: .55; }
.svc input[type=text], .svc input[type=number], .svc select { background-color: var(--surface); }
.svc-top { display: grid; grid-template-columns: auto 1.1fr 1.4fr 110px auto; gap: 10px; align-items: center; }
.svc-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.svc-opts label.field { font-size: 12px; }
details > summary { cursor: pointer; font-size: 15px; color: var(--link); list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: " ›"; }
details[open] > summary::after { content: " ⌄"; }

/* logs */
.logs { background: #1d1d1f; color: #f5f5f7; border-radius: 18px; padding: 16px; font: 12.5px/1.6 "SF Mono", ui-monospace, Menlo, monospace; height: 60vh; overflow-y: auto; letter-spacing: 0; }
.logs .warn { color: #ffd60a; }
.logs .error { color: #ff6961; }
.logs .time { color: #86868b; }
.logs .tag { color: #64d2ff; }

/* toasts */
.toasts { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 12px 20px; border-radius: 980px; box-shadow: 0 10px 40px rgba(0,0,0,.2); font-size: 15px; animation: rise .3s ease; max-width: 90vw;
}
.toast.bad { background: var(--bad); color: #fff; }

.spinner { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 734px) {
  h1 { font-size: 40px; }
  h2 { font-size: 28px; }
  .hero { padding-top: 40px; }
  .hero .lead { font-size: 19px; }
  .topbar { padding: 0 16px; }
  .container { padding: 24px 16px 60px; }
  .hide-sm { display: none; }
  .pairing { padding: 28px 22px; gap: 24px; }
  .svc-top { grid-template-columns: auto 1fr auto; }
  .svc-top .svc-name, .svc-top .svc-dp { grid-column: 1 / -1; }
  .overlay { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
}


/* =====================================================================
   Dashboard (Homey style)
   ===================================================================== */
.topbar { height: auto; padding: 18px max(20px, calc((100% - 1180px) / 2)) 14px; align-items: center; }
.home-title h1 { font-size: 30px; line-height: 1.1; font-weight: 800; letter-spacing: -.01em; }
.home-sub { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.top-actions { gap: 8px; }
.round-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); transition: transform .1s, background .2s;
}
.round-btn:hover { background: var(--surface-2); }
.round-btn:active { transform: scale(.94); }
.round-btn.primary { background: var(--primary); color: #fff; }
.round-btn.primary:hover { background: var(--primary-hover); }
@media (prefers-color-scheme: dark) { .round-btn { background: var(--surface-2); } }

.dash { max-width: 1180px; margin: 0 auto; padding: 6px 20px 80px; display: flex; flex-direction: column; gap: 22px; }
.dash .section-head { margin-bottom: 12px; }
.dash .section-head h2 { font-size: 22px; font-weight: 800; }

/* summary cards (top of the Homey app) */
.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.summary:empty { display: none; }
.sum-card { background: var(--surface); border-radius: 16px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); min-width: 0; }
.sum-icon { width: 38px; height: 38px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.sum-text { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.3; }
.sum-text b { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-text span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* widgets (Homey dashboard), masonry columns */
.widgets { columns: 3 300px; column-gap: 14px; }
.widgets:empty { display: none; }
.widget {
  break-inside: avoid; margin: 0 0 14px; background: var(--surface); border-radius: 22px; padding: 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; color: var(--text);
}
.w-head { display: flex; align-items: center; gap: 12px; }
.w-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.w-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.w-title b { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-title span { font-size: 13px; color: var(--muted); }
.w-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.w-row .ctl { min-height: 38px; padding: 2px 0; }
.w-row + .w-row .ctl { border-top: 1px solid var(--hairline); }
.w-round {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.25); color: inherit;
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.w-round.ghost { background: var(--surface-2); color: var(--muted); }
.w-round:disabled { opacity: .35; cursor: default; }

/* light widget: gradient in the lamp's own colour */
.wlight.on { color: #1b1206; }
.wlight.on .w-icon { background: rgba(255,255,255,.4); color: #1b1206; }
.wlight.on .w-title span { color: rgba(27, 18, 6, .7); }
.w-range { -webkit-appearance: none; appearance: none; height: 34px; border-radius: 17px; background: var(--surface-2); overflow: hidden; cursor: pointer; }
.w-range::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.25); border: 0; }
.w-range::-moz-range-thumb { width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 0; }
.wlight.on .w-range { background: rgba(255,255,255,.35); }
.w-range:disabled { opacity: .5; cursor: default; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,.8); cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.swatch:active { transform: scale(.92); }

/* climate widget */
.wac.cool { background: linear-gradient(135deg, #2f8cff, #1fb6ff); color: #fff; }
.wac.heat { background: linear-gradient(135deg, #ff7a18, #ff4f3a); color: #fff; }
.wac.auto { background: linear-gradient(135deg, #7b61ff, #2f8cff); color: #fff; }
.wac.cool .w-icon, .wac.heat .w-icon, .wac.auto .w-icon { background: rgba(255,255,255,.22); color: #fff; }
.wac.cool .w-title span, .wac.heat .w-title span, .wac.auto .w-title span { color: rgba(255,255,255,.8); }
.wac:not(.cool):not(.heat):not(.auto) .w-round { background: var(--surface-2); color: var(--text); }
.ac-temps { display: flex; align-items: center; gap: 14px; }
.ac-now { font-size: 30px; font-weight: 700; display: flex; flex-direction: column; line-height: 1; }
.ac-now small { font-size: 12px; font-weight: 500; opacity: .75; margin-top: 4px; }
.ac-arrow { opacity: .6; font-size: 20px; }
.ac-target { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.ac-target b { font-size: 34px; font-weight: 800; min-width: 74px; text-align: center; letter-spacing: -.02em; }
.w-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 0; border-radius: 999px; padding: 7px 13px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--text);
}
.wac.cool .chip, .wac.heat .chip, .wac.auto .chip { background: rgba(255,255,255,.2); color: #fff; }
.chip.on { background: #fff !important; color: #111 !important; }
.chip:disabled { opacity: .45; cursor: default; }

/* action buttons, like Homey Flow buttons */
.wactions { gap: 10px; }
.flow {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; cursor: pointer; text-align: left;
  background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 7px 16px 7px 7px; font: inherit;
  transition: transform .1s, background .2s;
}
.flow:hover { background: var(--surface-3); }
.flow:active { transform: scale(.98); }
.flow:disabled { opacity: .45; cursor: default; }
.flow-play { width: 32px; height: 32px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; flex: none; padding-left: 2px; }
.flow.done .flow-play { padding-left: 0; }
.flow-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.flow-text b { font-size: 14px; font-weight: 600; }
.flow-text small { font-size: 12px; color: var(--muted); }

/* device tiles (Homey app) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 12px; }
.tile {
  position: relative; aspect-ratio: 1 / 1; border: 0; border-radius: 20px; padding: 14px; cursor: pointer; text-align: left;
  background: var(--tile-off); color: var(--text); display: flex; flex-direction: column; font: inherit;
  box-shadow: var(--shadow); transition: transform .12s, background .2s, box-shadow .2s; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.tile:hover { box-shadow: var(--shadow-hover); }
.tile:active { transform: scale(.96); }
.tile.on { background: var(--tile); }
.tile.glow.on { background: linear-gradient(160deg, var(--glow), var(--tile) 70%); }
.tile.offline { opacity: .55; }
.tile-top { display: flex; justify-content: space-between; align-items: flex-start; }
.tile-icon { color: var(--faint); transition: color .2s; }
.tile.on .tile-icon { color: var(--text); }
.tile-name { margin-top: auto; font-size: 14px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 18px; }
.tile-more { position: absolute; right: 10px; bottom: 12px; color: var(--faint); opacity: 0; transition: opacity .2s; padding: 2px; }
.tile:hover .tile-more, .tile:focus-visible .tile-more { opacity: 1; }
@media (hover: none) { .tile-more { opacity: .7; } }
.tdot { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 3px var(--tile), 0 0 10px rgba(0,0,0,.08); }
.tbadge { min-width: 24px; height: 24px; border-radius: 12px; padding: 0 7px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--faint); }
.tbadge.orange { background: var(--orange); }
.tbadge.blue { background: var(--primary); }
.tbadge.warn { background: var(--warn); color: #241600; }
.tbadge.muted { background: var(--surface-3); color: var(--muted); }

/* device detail sheet */
.sheet-head { display: flex; align-items: center; gap: 16px; }
.tile-icon.big { width: 64px; height: 64px; border-radius: 18px; background: var(--surface-2); display: grid; place-items: center; color: var(--faint); }
.sheet-head.on .tile-icon.big { background: color-mix(in srgb, var(--tint) 22%, var(--surface)); color: var(--text); }
.sheet-sub { font-size: 20px; font-weight: 700; }
.sheet-controls { background: var(--surface-2); border-radius: 18px; padding: 6px 16px; }
.modal .widget { box-shadow: none; margin: 0; }
.modal .wlight:not(.on) { background: var(--surface-2); }

@media (max-width: 734px) {
  .topbar { padding: 14px 16px 10px; }
  .home-title h1 { font-size: 26px; }
  .dash { padding: 4px 14px 60px; gap: 18px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .widgets { columns: 1; order: 3; }
  #devices-section { order: 2; }
  .summary { order: 1; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 11px; border-radius: 18px; }
  .tile-name { font-size: 13px; }
}
@media (max-width: 330px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }


/* camera widget (Homey-style image card) */
.wcam { padding: 0; overflow: hidden; }
.cam-frame { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; padding: 0; background: #0d0d12; cursor: pointer; overflow: hidden; border-radius: 22px; }
.cam-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #8e8e98; font-size: 13px; }
.cam-frame:not(.noimg) .cam-img + .cam-empty { visibility: hidden; }
.cam-frame.noimg .cam-img { display: none; }
.cam-overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 16px 12px; display: flex; flex-direction: column; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,.65)); color: #fff; }
.cam-overlay b { font-size: 16px; }
.cam-overlay small { font-size: 12px; opacity: .8; }
.cam-live { position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 700; letter-spacing: .05em; color: #fff; background: rgba(255, 59, 48, .9); padding: 3px 8px; border-radius: 6px; }
.cam-live:empty { display: none; }
.cam-liveview { background: #000; border-radius: 16px; overflow: hidden; aspect-ratio: 16 / 9; display: grid; place-items: center; }
.cam-liveview img { width: 100%; height: 100%; object-fit: contain; }
.cam-preview { width: 100%; border-radius: 14px; }

/* =====================================================================
   Liquid Glass (Apple iOS 26 style) — layered over the dashboard theme
   ===================================================================== */
:root {
  --glass: rgba(255, 255, 255, .52);
  --glass-strong: rgba(255, 255, 255, .74);
  --glass-soft: rgba(255, 255, 255, .34);
  --glass-edge: rgba(255, 255, 255, .7);
  --glass-shade: rgba(255, 255, 255, .25);
  --glass-shadow: 0 1px 1px rgba(30, 40, 90, .04), 0 10px 30px rgba(30, 40, 90, .10);
  --blur: blur(26px) saturate(185%);
  --bg-base: #e9eef8;
  --blob-1: #9fc5ff;
  --blob-2: #ffc6e2;
  --blob-3: #ffe1a8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --glass: rgba(38, 40, 54, .46);
    --glass-strong: rgba(60, 63, 82, .62);
    --glass-soft: rgba(38, 40, 54, .3);
    --glass-edge: rgba(255, 255, 255, .16);
    --glass-shade: rgba(255, 255, 255, .06);
    --glass-shadow: 0 1px 1px rgba(0, 0, 0, .2), 0 12px 36px rgba(0, 0, 0, .38);
    --bg-base: #0b0d16;
    --blob-1: #2b4cff;
    --blob-2: #8a2bff;
    --blob-3: #ff4f8b;
  }
}

body { background: var(--bg-base); }
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .75; animation: drift 28s ease-in-out infinite alternate; }
.bg span:nth-child(1) { width: 60vmax; height: 60vmax; left: -15vmax; top: -20vmax; background: var(--blob-1); }
.bg span:nth-child(2) { width: 50vmax; height: 50vmax; right: -18vmax; top: 10vmax; background: var(--blob-2); animation-duration: 34s; }
.bg span:nth-child(3) { width: 45vmax; height: 45vmax; left: 20vmax; bottom: -25vmax; background: var(--blob-3); animation-duration: 40s; }
@media (prefers-color-scheme: dark) { .bg span { opacity: .38; } }
@keyframes drift { to { transform: translate(6vmax, 4vmax) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .bg span { animation: none; } }

/* the glass material */
.card, .sum-card, .widget, .tile, .round-btn, .modal, .seg, .tabs, .list, .table-wrap, .sheet-controls, .flow, .chip, .toast {
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}
.card, .sum-card, .widget, .tile, .modal {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-shade);
}
.tile { background: var(--glass-soft); }
.tile.on { background: var(--glass-strong); }
.tile.glow.on { background: linear-gradient(160deg, var(--glow), var(--glass-strong) 72%); }
.tile:hover, .widget:hover { box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-shade), 0 0 0 1px var(--glass-edge); }
.sum-icon, .w-icon, .tile-icon.big { background: var(--glass-soft); box-shadow: inset 0 0 0 1px var(--glass-edge); }

/* header: greeting */
.topbar { position: relative; background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; align-items: flex-start; padding-top: 26px; }
.brand-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--muted);
  padding: 4px 10px 4px 8px; border-radius: 999px; background: var(--glass-soft); border: 1px solid var(--glass-edge);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); margin-bottom: 10px;
}
.home-title h1#greeting { font-size: 38px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.home-sub { font-size: 16px; color: var(--text); opacity: .85; margin-top: 8px; gap: 8px; }
.home-sub b { font-weight: 700; }
.home-status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.link-btn { appearance: none; border: 0; background: none; color: var(--link); font: inherit; font-size: 15px; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; padding: 0; }
.round-btn { background: var(--glass); border: 1px solid var(--glass-edge); box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-shade); width: 44px; height: 44px; }
.round-btn.primary { background: color-mix(in srgb, var(--primary) 85%, transparent); border-color: rgba(255,255,255,.35); }
.top-actions { position: sticky; top: 14px; }

/* weather widget */
.wweather { background: linear-gradient(160deg, rgba(64, 156, 255, .78), rgba(118, 196, 255, .55)); color: #fff; border-color: rgba(255,255,255,.45); }
.wweather.night { background: linear-gradient(160deg, rgba(36, 48, 120, .82), rgba(88, 70, 170, .6)); }
.ww-top { display: flex; justify-content: space-between; align-items: flex-start; }
.ww-loc { font-size: 15px; font-weight: 600; opacity: .92; }
.ww-temp { font-size: 54px; font-weight: 300; line-height: 1; letter-spacing: -.03em; margin-top: 2px; }
.ww-now { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 14px; font-weight: 600; }
.ww-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; opacity: .9; }
.ww-meta span { display: inline-flex; align-items: center; gap: 4px; }
.ww-days { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.25); }
.ww-day { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; }
.ww-day span { opacity: .85; text-transform: capitalize; }
.ww-day b { font-size: 14px; }
.ww-day small { opacity: .7; }

/* rooms */
.rooms { display: flex; flex-direction: column; gap: 22px; }
.room-title { font-size: 17px; font-weight: 700; margin: 0 0 10px 4px; opacity: .9; }

/* glass details */
.seg, .tabs { background: var(--glass-soft); border: 1px solid var(--glass-edge); }
.tab.active, .seg button.on { background: var(--glass-strong); box-shadow: 0 2px 10px rgba(0,0,0,.08), inset 0 1px 0 var(--glass-shade); }
.flow { background: var(--glass-soft); border: 1px solid var(--glass-edge); }
.flow:hover { background: var(--glass-strong); }
.chip { background: var(--glass-soft); border: 1px solid var(--glass-edge); }
.sheet-controls, .list, .table-wrap { background: var(--glass-soft); border: 1px solid var(--glass-edge); }
.overlay { background: rgba(10, 14, 30, .22); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal { background: var(--glass-strong); }
.modal input[type=text], .modal input[type=password], .modal input[type=number], .modal select, .modal textarea {
  background-color: color-mix(in srgb, var(--surface) 70%, transparent); border-color: var(--glass-edge);
}
.btn { background: var(--glass-soft); border: 1px solid var(--glass-edge); }
.btn:hover { background: var(--glass-strong); }
.btn.primary { background: var(--primary); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.ph-icon.avatar { border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--purple)); color: #fff; font-weight: 700; }
.link-row { width: 100%; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left; }
.link-row:hover { background: var(--glass-soft); }
.toast { background: color-mix(in srgb, var(--text) 75%, transparent); border: 1px solid var(--glass-edge); }
.pairing { background: var(--glass); }
.wcam { border-color: var(--glass-edge); }
.wlight.on, .wac.cool, .wac.heat, .wac.auto { border-color: rgba(255,255,255,.4); }

@media (max-width: 734px) {
  .home-title h1#greeting { font-size: 30px; }
  .topbar { padding-top: 18px; }
  .ww-temp { font-size: 46px; }
}

/* Respect "Reduce transparency": solid surfaces, no blur */
@media (prefers-reduced-transparency: reduce) {
  .bg { display: none; }
  .card, .sum-card, .widget, .tile, .round-btn, .modal, .seg, .tabs, .list, .table-wrap, .sheet-controls, .flow, .chip, .toast, .brand-chip {
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .card, .sum-card, .widget, .modal { background: var(--surface); }
  .tile { background: var(--tile-off); }
  .tile.on { background: var(--tile); }
}

/* rooms side by side on wide screens */
.rooms { flex-direction: row; flex-wrap: wrap; gap: 22px 30px; }
.room { flex: 0 1 auto; min-width: 0; }
.room .tiles { display: flex; flex-wrap: wrap; gap: 12px; }
.room .tile { width: 138px; }
@media (max-width: 734px) {
  .rooms { flex-direction: column; gap: 20px; }
  .room { width: 100%; }
  .room .tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .room .tile { width: auto; }
}

/* =====================================================================
   Tidy grid, edit mode (drag & drop), avatars
   ===================================================================== */
.widgets { columns: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: stretch; }
.wslot { position: relative; display: flex; min-width: 0; }
.wslot > .widget { flex: 1; margin: 0; }
.dash { gap: 26px; }
.dash > section > .section-head, #overview-section .section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.head-actions { display: flex; gap: 8px; }
.room-title { margin-left: 2px; }

/* edit mode */
.editing .wslot > .widget, .editing .tile { animation: jiggle .32s ease-in-out infinite alternate; }
.editing .wslot:nth-child(2n) > .widget, .editing .tile:nth-child(2n) { animation-delay: -.16s; }
@keyframes jiggle { from { transform: rotate(-.35deg); } to { transform: rotate(.35deg); } }
@media (prefers-reduced-motion: reduce) { .editing .wslot > .widget, .editing .tile { animation: none; } }
.editing .wslot > .widget { pointer-events: none; user-select: none; }
.edit-overlay { position: absolute; inset: 0; pointer-events: none; border-radius: 22px; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 55%, transparent); }
.drag-handle {
  pointer-events: auto; touch-action: none; cursor: grab; position: absolute; top: 10px; left: 10px; width: 34px; height: 34px;
  border-radius: 50%; display: grid; place-items: center; color: var(--text);
  background: var(--glass-strong); border: 1px solid var(--glass-edge); box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); z-index: 2;
}
.drag-handle:active { cursor: grabbing; }
.edit-hide {
  pointer-events: auto; position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--glass-edge);
  background: var(--glass-strong); color: var(--bad-text); display: grid; place-items: center; cursor: pointer; z-index: 2;
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.tile .tile-handle { top: auto; left: auto; right: 8px; bottom: 8px; width: 30px; height: 30px; }
.editing .tile .tile-more { display: none; }
.editing .tile { cursor: default; }
.sort-placeholder { background: transparent !important; border: 2px dashed color-mix(in srgb, var(--primary) 50%, transparent) !important; box-shadow: none !important; border-radius: 22px; animation: none !important; }
.sort-placeholder > * { visibility: hidden; }
.tile.sort-placeholder { border-radius: 20px; }
.dragging { box-shadow: 0 24px 60px rgba(0, 0, 0, .28) !important; transform: scale(1.03); animation: none !important; transition: none !important; }
.dragging > .widget { animation: none !important; }
.edit-hint { font-size: 14px; color: var(--muted); margin: -4px 0 14px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.edit-hint .i { display: inline-block; }
.hidden-tray { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding: 12px; border-radius: 18px; border: 2px dashed var(--glass-edge); }

/* avatars + profile */
.avatar { border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center; flex: none; background: var(--glass-soft); color: var(--muted); }
.avatar.initials { background: linear-gradient(135deg, var(--primary), var(--purple)); color: #fff; font-weight: 700; }
.round-btn.avatar-btn { padding: 0; overflow: hidden; }
.round-btn.avatar-btn .avatar { width: 100% !important; height: 100% !important; }
.profile-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.avatar-edit { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; }
.avatar-cam { position: absolute; right: 0; bottom: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; border: 3px solid var(--surface); }
.profile-name { font-size: 22px; font-weight: 700; }
.profile-photo-btns { display: flex; gap: 8px; margin-top: 10px; }
.list-row > .avatar { margin-right: 2px; }

@media (max-width: 734px) {
  #overview-section { order: 3; }
  .widgets { grid-template-columns: 1fr; gap: 14px; }
}

/* =====================================================================
   Clean solid background (no colour gradient) — overrides the glass tokens
   ===================================================================== */
:root {
  --bg-base: #f6f7fb;
  --glass: #ffffff;
  --glass-strong: #ffffff;
  --glass-soft: #eef0f5;
  --glass-edge: rgba(15, 20, 40, .07);
  --glass-shade: rgba(255, 255, 255, 0);
  --glass-shadow: 0 1px 2px rgba(15, 20, 40, .04), 0 6px 20px rgba(15, 20, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-base: #0e0f13;
    --glass: #1b1c22;
    --glass-strong: #25262e;
    --glass-soft: #16171c;
    --glass-edge: rgba(255, 255, 255, .07);
    --glass-shade: rgba(255, 255, 255, .03);
    --glass-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
.bg { display: none; }
body { background: var(--bg-base); }
/* solid surfaces don't need blur (also lighter on older devices) */
.card, .sum-card, .widget, .tile, .round-btn, .seg, .tabs, .list, .table-wrap, .sheet-controls, .flow, .chip, .brand-chip {
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.tile { background: var(--glass-soft); box-shadow: none; }
.tile.on { background: var(--glass-strong); box-shadow: var(--glass-shadow); }
.tile.glow.on { background: linear-gradient(160deg, var(--glow), var(--glass-strong) 70%); }
.sum-icon, .w-icon, .tile-icon.big { background: var(--glass-soft); box-shadow: none; }
.wweather { border-color: transparent; }
.modal { background: var(--surface); }
.wweather { background: linear-gradient(160deg, #3b86ff, #62b3ff); }
.wweather.night { background: linear-gradient(160deg, #24307a, #4f3fa6); }
/* the dragged item (incl. its handle) must not catch the pointer, or the drop target can't be found */
.dragging, .dragging * { pointer-events: none !important; }
.drag-handle .i circle { fill: currentColor; }
/* without rooms the tile grid sits directly in .rooms: give it the full width again */
.rooms > .tiles { flex: 1 1 100%; width: 100%; }
/* header edges line up with the dashboard content (.dash: 1180px incl. 20px padding) */
.topbar { padding-left: max(20px, calc((100% - 1140px) / 2)); padding-right: max(20px, calc((100% - 1140px) / 2)); }
@media (max-width: 734px) {
  .topbar { padding-left: 16px; padding-right: 16px; }
  .dash { padding-left: 16px; padding-right: 16px; }
}
/* camera image fills its card when the row is taller than 16:9 (e.g. next to the weather card) */
.wcam .cam-frame { flex: 1 1 auto; min-height: 0; }
/* phone: the four header buttons don't fit next to the greeting; pin them top-right beside the brand chip */
@media (max-width: 734px) {
  .home-title { min-width: 0; width: 100%; }
  .top-actions { position: absolute; top: 14px; right: 16px; gap: 6px; }
  .top-actions .round-btn { width: 40px; height: 40px; }
  .brand-chip { margin-top: 8px; margin-bottom: 18px; }
}

/* =====================================================================
   Card sizes (S / M / L): a 6-column grid on desktop, 4 on tablet, 2 on phone
   ===================================================================== */
.widgets { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.wslot.size-s { grid-column: span 1; }
.wslot.size-m { grid-column: span 2; }
.wslot.size-l { grid-column: span 3; }
@media (max-width: 999px) {
  .widgets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .wslot.size-l { grid-column: span 4; }
}
@media (max-width: 734px) {
  .widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .wslot.size-m, .wslot.size-l { grid-column: span 2; }
}

/* small cards: the essentials only, title on its own line */
.size-s .widget { padding: 14px; gap: 10px; }
.size-s .w-head { flex-wrap: wrap; row-gap: 10px; }
.size-s .w-head > .w-title { order: 3; flex-basis: 100%; }
.size-s .w-head > :last-child:not(.w-title) { margin-left: auto; }
.size-s .w-title b, .size-s .w-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.size-s .ww-meta, .size-s .ww-days, .size-s .w-chips, .size-s .ac-now, .size-s .ac-arrow,
.size-s .swatches, .size-s .wstatus .w-row, .size-s .cam-overlay small { display: none; }
.size-s .ww-top { flex-direction: column; gap: 8px; }
.size-s .ww-now { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; }
.size-s .ww-now .i { width: 26px; height: 26px; }
.size-s .ww-temp { font-size: 42px; }
.size-s .ac-temps { justify-content: center; }
.size-s .wcam .cam-frame { min-height: 120px; }
.size-s .cam-overlay { padding: 20px 12px 10px; }
.size-s .cam-overlay b { font-size: 14px; }

/* size picker in edit mode */
.edit-size {
  pointer-events: auto; position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 2;
  display: flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: var(--glass-strong); border: 1px solid var(--glass-edge); box-shadow: var(--glass-shadow);
}
.edit-size button {
  appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 700;
  width: 30px; height: 26px; border-radius: 999px; cursor: pointer;
}
.edit-size button:hover { color: var(--text); }
.edit-size button.on { background: var(--primary); color: #fff; }
.wslot > .widget { min-width: 0; }
.size-s .w-range { width: 100%; min-width: 0; }

/* =====================================================================
   Slimify brand theme
   Brand colours from the logo: blue #2c68ff → green #00dd68, text #2e2d2c.
   Rounded type and "squircle" icon shapes echo the rounded mark (corner ≈ 34%).
   ===================================================================== */
:root {
  --brand-blue: #2c68ff;
  --brand-green: #00dd68;
  --brand-grad: linear-gradient(45deg, #2c68ff, #00dd68);
  --brand-grad-night: linear-gradient(45deg, #17245e, #2c68ff);
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  --bg: #f4f6f9;
  --bg-base: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --surface-3: #e2e6ec;
  --tile: #ffffff;
  --tile-off: #eef1f5;
  --border: #dde2e9;
  --hairline: rgba(46, 45, 44, .08);
  --text: #2e2d2c;
  --muted: #6e6e6b;
  --faint: #a2a29e;
  --primary: #2c68ff;
  --primary-hover: #4a7eff;
  --link: #2c68ff;
  --green: #00c95f;
  --ok: #00c95f;
  --ok-text: #00a24c;
  --on: #00dd68;
  --nav: rgba(244, 246, 249, .86);
  --glass: #ffffff;
  --glass-strong: #ffffff;
  --glass-soft: #eef1f5;
  --glass-edge: rgba(46, 45, 44, .07);
  --glass-shadow: 0 1px 2px rgba(30, 40, 60, .04), 0 8px 24px rgba(30, 40, 60, .06);
  --shadow: var(--glass-shadow);
  --radius: 24px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --bg-base: #0f1114;
    --surface: #181b20;
    --surface-2: #22262c;
    --surface-3: #2d323a;
    --tile: #22262c;
    --tile-off: #181b20;
    --border: #2f343c;
    --hairline: rgba(255, 255, 255, .07);
    --text: #f3f4f2;
    --muted: #a3a6a2;
    --faint: #767a76;
    --primary: #4d82ff;
    --primary-hover: #6b97ff;
    --link: #6b97ff;
    --green: #1fe57d;
    --ok: #1fe57d;
    --ok-text: #33e88a;
    --nav: rgba(15, 17, 20, .86);
    --glass: #181b20;
    --glass-strong: #22262c;
    --glass-soft: #14171b;
    --glass-edge: rgba(255, 255, 255, .07);
    --glass-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
body { font-family: var(--font); letter-spacing: -.01em; background: var(--bg); }
h1, h2, h3, h4 { font-family: var(--font); }
h1, h2 { font-weight: 800; letter-spacing: -.02em; }
input, select, textarea, button { font-family: inherit; }
textarea, code, .mono, td.value { font-family: "SF Mono", ui-monospace, Menlo, monospace; }
::selection { background: rgba(44, 104, 255, .2); }

/* logo lockup (mark + wordmark, same proportions as the logo file) */
.brand-chip { display: none; }
.brand-logo { display: inline-flex; align-items: flex-start; gap: 9px; color: var(--text); margin-bottom: 14px; }
.brand-logo .logo-mark { width: 30px; height: 30px; flex: none; }
.brand-logo .logo-word { height: 26px; width: auto; margin-top: 2.5px; }
.home-status { flex-wrap: wrap; gap: 6px 12px; }
.home-status #bridge-state { display: inline-flex; align-items: center; gap: 6px; }
.home-name { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--text); }
.home-name:empty, .home-name:has(#bridge-name:empty) { display: none; }

/* brand gradient for primary actions and "on" states */
.btn { border-radius: 999px; }
.btn.primary, .round-btn.primary { background: var(--brand-grad); border-color: transparent; color: #fff; }
.btn.primary:hover, .round-btn.primary:hover { background: var(--brand-grad); filter: brightness(1.06); }
.toggle input:checked + span { background: var(--brand-grad); }
.edit-size button.on { background: var(--brand-grad); }
.dot.ok { background: var(--brand-green); }

/* squircle icons */
.w-icon { border-radius: 14px; }
.sum-icon { border-radius: 13px; }
.tile-icon.big { border-radius: 22px; }
.sheet-head.on .tile-icon.big { background: var(--brand-grad); color: #fff; }

/* device tiles: the icon sits in a squircle that turns into the brand mark when on */
.tile { border-radius: 22px; }
.tile .tile-icon { width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; background: var(--surface); color: var(--faint); transition: background .2s, color .2s; }
.tile .tile-icon .i { width: 24px; height: 24px; }
.tile.on .tile-icon { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 12px rgba(44, 104, 255, .25); }
@media (prefers-color-scheme: dark) { .tile .tile-icon { background: var(--surface-2); } }

/* widgets in brand colours */
.widget { border-radius: 24px; }
.wweather { background: var(--brand-grad); }
.wweather.night { background: var(--brand-grad-night); }
.wac.cool { background: linear-gradient(45deg, #2c68ff, #4fa3ff); }
.wac.auto { background: var(--brand-grad); }

/* footer signature */
.brand-footer { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 0 16px 36px; color: var(--faint); font-size: 13px; }
.brand-footer .logo-mark { width: 18px; height: 18px; }
.brand-footer b { color: var(--muted); font-weight: 800; letter-spacing: -.01em; }

@media (max-width: 734px) {
  .brand-logo .logo-mark { width: 28px; height: 28px; }
  .brand-logo .logo-word { height: 24px; margin-top: 2.4px; }
  .brand-logo { margin-top: 6px; margin-bottom: 16px; }
  .tile .tile-icon { width: 40px; height: 40px; border-radius: 14px; }
  .tile .tile-icon .i { width: 22px; height: 22px; }
}

/* login page */
.login { position: relative; overflow: hidden; border-radius: 28px; }
.login::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--brand-grad); }
.login-brand { display: flex; justify-content: center; align-items: flex-start; gap: 13px; color: var(--text); }
.login-brand .logo-mark { width: 52px; height: 52px; flex: none; }
.login-brand .logo-word { height: 45px; width: auto; margin-top: 4.4px; }
.brand-tagline { margin-top: -6px; font-size: 11px; font-weight: 700; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); }

/* Montserrat (SIL Open Font License, see brand/montserrat-OFL.txt), self-hosted so it also works offline */
@font-face {
  font-family: "Montserrat"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("brand/montserrat-latin.woff2") format("woff2-variations"), url("brand/montserrat-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Montserrat"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("brand/montserrat-latin-ext.woff2") format("woff2-variations"), url("brand/montserrat-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
:root { --font: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
/* Montserrat is wider than SF: no negative tracking, slightly smaller body text */
body { font-size: 16px; letter-spacing: 0; }
.small { letter-spacing: 0; }
h1, h2 { letter-spacing: -.015em; }
h3, h4 { letter-spacing: 0; }

/* =====================================================================
   Tab bar (iOS style): fixed at the bottom, one screen per tab
   ===================================================================== */
.off-page { display: none !important; }
.tabbar {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; gap: 2px; padding: 6px;
  border-radius: 999px; border: 1px solid var(--glass-edge);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 10px 30px rgba(30, 40, 60, .14), 0 1px 3px rgba(30, 40, 60, .08);
}
.tabbar:empty { display: none; }
.tab-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 88px; padding: 7px 14px 6px; border-radius: 999px;
  color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none !important;
  transition: background .2s, color .2s; -webkit-tap-highlight-color: transparent;
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--brand-blue); background: color-mix(in srgb, var(--brand-blue) 10%, transparent); }
.tab-item.active span { font-weight: 700; }
@media (prefers-color-scheme: dark) {
  .tabbar { box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
  .tab-item.active { color: #7aa2ff; background: rgba(77, 130, 255, .16); }
}
/* room for the bar under the content */
.dash { padding-bottom: 40px; }
.brand-footer { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.toasts { bottom: calc(100px + env(safe-area-inset-bottom)); }

@media (max-width: 734px) {
  .tabbar { left: 12px; right: 12px; transform: none; justify-content: space-around; bottom: max(10px, env(safe-area-inset-bottom)); padding: 5px; }
  .tab-item { min-width: 0; flex: 1; padding: 7px 2px 6px; font-size: 10.5px; }
}

/* header: greeting + weather only on the home screen, a large page title elsewhere */
body:not([data-tab="thuis"]) #weather-line, body:not([data-tab="thuis"]) .home-status { display: none; }

/* summary cards are links to their screen */
a.sum-card { color: inherit; text-decoration: none !important; transition: transform .1s, box-shadow .2s; }
a.sum-card:hover { box-shadow: var(--glass-shadow), 0 0 0 1px var(--glass-edge); }
a.sum-card:active { transform: scale(.98); }

/* devices screen: count + edit on one line */
#devices-section .section-head { align-items: center; }

/* cameras screen */
.camera-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.camera-grid .wcam .cam-frame { aspect-ratio: 16 / 9; }

/* settings / activity rendered as a page instead of a sheet */
.page-loading { display: grid; place-items: center; padding: 60px 0; color: var(--muted); }
.page-body { display: flex; flex-direction: column; gap: 16px; }
.page-settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 16px; align-items: start; }
.page-body .section {
  background: var(--surface); border: 1px solid var(--glass-edge); border-radius: 24px; padding: 20px 22px; box-shadow: var(--glass-shadow);
}
.page-body .section h4 { font-size: 13px; color: var(--brand-blue); letter-spacing: .06em; }
.page-logs .logs { height: calc(100vh - 290px); min-height: 320px; border-radius: 24px; }
@media (max-width: 734px) {
  .page-body .section { padding: 18px 16px; }
  .page-logs .logs { height: calc(100vh - 260px); }
}
/* short screens: keep the footer at the bottom instead of halfway */
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body > main.dash { flex: 1 0 auto; width: 100%; box-sizing: border-box; }
