/* AOne web app - styled on the AOne app: blue gradient #0098DA -> #0072BC -> #02052F, navy #02052F, cyan #00AEEF */
:root { color-scheme: light dark; }   /* own light + dark themes: browsers must not force-darken the page */
:root {
  --navy: #02052F; --blue: #0072BC; --sky: #0098DA; --cyan: #00AEEF;
  --bg: #eef3f9; --card: #ffffff; --ink: #0d1530; --muted: #5d6b85; --line: #dfe6f0; --off: #c9d3e2;
  --bad: #c2410c; --ok: #0e7c58; --radius: 18px; --shadow: 0 1px 2px rgba(2,5,47,.05), 0 6px 18px rgba(2,5,47,.07);
  --grad: linear-gradient(135deg, var(--sky) 0%, var(--blue) 40%, var(--navy) 100%);
}
/* dark theme (follows the phone, or the choice in the app) */
  html[data-theme="dark"] { --bg: #050925; --card: #0e1538; --ink: #eaf0fa; --muted: #93a3c2; --line: #1c2752; --off: #2a3766; --shadow: none; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; min-height: 100%; }
.testbar { background: #fff4d6; color: #8a5300; font-size: 12px; font-weight: 700; text-align: center; padding: 5px 10px; position: relative; z-index: 3; }
main { max-width: 560px; margin: 0 auto; padding: 0 0 96px; }

/* hero header like the app */
.hero { background: var(--grad); color: #fff; padding: calc(18px + env(safe-area-inset-top)) 18px 54px; border-radius: 0 0 28px 28px; }
.hero .bar { display: flex; align-items: center; justify-content: space-between; }
.hero .brandlogo { height: 26px; width: auto; display: block; }
.hero h1 { font-size: 26px; margin: 22px 0 2px; font-weight: 600; letter-spacing: -.2px; }
.hero .sub { color: rgba(255,255,255,.78); margin: 0; font-size: 15px; }
.iconbtn { border: 0; background: rgba(255,255,255,.16); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer; margin-left: 6px; }
.hero { padding-bottom: 28px; }
.content { padding: 6px 16px 0; position: relative; }
/* section heading: title left, "x of y on" pill right, aligned with the tile grid */
.section { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 2px 12px; }
.section h2 { margin: 0; font-size: 13px; line-height: 1; }
.count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; line-height: 1; white-space: nowrap; }
.count.lit { color: var(--blue); border-color: rgba(0,174,239,.45); background: rgba(0,174,239,.08); }
/* dark theme (follows the phone, or the choice in the app) */ html[data-theme="dark"] .count.lit { color: var(--cyan); } 
.hubpick { margin-top: 14px; }

/* sign-in screen: full gradient */
.signin { position: relative; min-height: 100vh; background: var(--grad); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 18px; }
.signin > .themebtn { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 14px; margin: 0; }
.signin .biglogo { width: 220px; max-width: 70vw; height: auto; margin-bottom: 26px; }
.signin p.tag { color: rgba(255,255,255,.8); margin: -12px 0 22px; font-size: 15px; }
form.auth { width: 100%; max-width: 380px; background: var(--card); border-radius: 22px; padding: 22px; box-shadow: 0 10px 40px rgba(2,5,47,.35); }
form.auth h2 { margin: 0 0 4px; font-size: 20px; color: var(--ink); text-transform: none; letter-spacing: 0; }
label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
input[type=email], input[type=password], form.auth input:not([type]), form.auth input[type=text] { width: 100%; font: inherit; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
.primary { width: 100%; margin-top: 20px; padding: 14px; border: 0; border-radius: 14px; background: var(--blue); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.primary:hover { background: #0065a8; }
.link { background: none; border: 0; color: var(--blue); font: inherit; font-size: 14px; margin-top: 14px; cursor: pointer; padding: 0; }
.error { color: var(--bad); font-size: 14px; margin-top: 10px; min-height: 1em; }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 24px 4px 10px; font-weight: 700; }
.hubpick { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 14px; cursor: pointer; box-shadow: var(--shadow); }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* tiles: 2 columns; glow in the light's own colour when on, dull when off */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { --glow: 0, 174, 239; --glow-strength: 1;
  position: relative; aspect-ratio: 1 / .86; border-radius: 22px; padding: 16px; cursor: pointer; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; user-select: none;
  background: var(--card); box-shadow: var(--shadow); transition: transform .12s, background .3s, box-shadow .3s, color .3s; }
.tile:active { transform: scale(.97); }
.tile:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
.tile:not(.lit) { color: var(--muted); }
.tile:not(.lit) .tname { color: var(--ink); opacity: .72; }
/* lit: two solid colours from the light's colour temperature (set by app.js glow()) - bright, never muddy */
.tile.lit { --g1: 255, 212, 120; --g2: 255, 138, 34; color: #2a1500;
  background:
    radial-gradient(90% 70% at 18% 8%, rgba(255,255,255,.75) 0%, rgba(255,255,255,0) 60%),
    linear-gradient(150deg, rgb(var(--g1)) 0%, rgb(var(--g2)) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35), 0 0 0 1px rgba(var(--g2), .5), 0 10px 30px rgba(var(--g2), calc(.55 * var(--glow-strength))); }
.tile.lit .tname { font-weight: 800; letter-spacing: -.1px; }
.tile.lit .tsub { opacity: .78; font-weight: 600; }
.tile.offline { opacity: .45; }
.tname { font-weight: 700; font-size: 16px; line-height: 1.2; word-break: break-word; }
.tsub { font-size: 13px; margin-top: 3px; opacity: .8; }

.power { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--bg); color: var(--off); transition: background .25s, color .25s, box-shadow .25s; }
.power svg { width: 22px; height: 22px; }
.power.on { background: #fff; color: rgb(var(--g2, var(--glow))); box-shadow: 0 0 0 4px rgba(255,255,255,.4), 0 4px 14px rgba(0,0,0,.14); }
.power.on svg { filter: saturate(1.5) brightness(.9); }
.power:disabled { cursor: default; }
/* dark theme (follows the phone, or the choice in the app) */
  html[data-theme="dark"] .tile:not(.lit) { background: linear-gradient(160deg, #141d4a 0%, #0e1539 100%); box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
  html[data-theme="dark"] .tile:not(.lit) .tname { color: #eef2ff; opacity: 1; }
  html[data-theme="dark"] .tile:not(.lit) .tsub { color: #8e9dc7; opacity: 1; }
  html[data-theme="dark"] .power { background: #1d2860; color: #7d8cc0; }


/* bottom sheet: big power button, dimmer, colour temperature */
.sheet { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.sheet .backdrop { position: absolute; inset: 0; background: rgba(2,5,47,.45); opacity: 0; transition: opacity .25s; }
.sheet .panel { --glow: 0, 174, 239; --glow-strength: 1; --g1: 255, 212, 120; --g2: 255, 138, 34;
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; background: var(--card);
  border-radius: 26px 26px 0 0; padding: 10px 22px calc(26px + env(safe-area-inset-bottom)); transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  max-height: 88vh; overflow-y: auto; box-shadow: 0 -10px 40px rgba(2,5,47,.25); }
.sheet.show { pointer-events: auto; } .sheet.show .backdrop { opacity: 1; } .sheet.show .panel { transform: translateY(0); }
.grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.phead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.pname { font-size: 22px; font-weight: 700; } .psub { color: var(--muted); font-size: 14px; }
.close { border: 0; background: var(--bg); color: var(--ink); width: 36px; height: 36px; border-radius: 50%; font-size: 15px; cursor: pointer; }
.pcenter { display: flex; flex-direction: column; align-items: center; padding: 22px 0 8px; }
.bigpower { width: 112px; height: 112px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--bg); color: var(--off); transition: all .3s; }
.bigpower svg { width: 46px; height: 46px; }
.bigpower.on {
  background: radial-gradient(circle at 32% 26%, rgba(255,255,255,.85) 0%, rgba(255,255,255,0) 45%), linear-gradient(150deg, rgb(var(--g1)), rgb(var(--g2)));
  box-shadow: 0 0 0 10px rgba(var(--g2), calc(.22 * var(--glow-strength))), 0 0 56px rgba(var(--g2), calc(.75 * var(--glow-strength))); }
.bigpower.on svg { color: #2a1500; }
.pstate { margin-top: 14px; font-weight: 600; color: var(--muted); }
.ctl { margin-top: 22px; }
.ctlhead { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.ctlhead .val { color: var(--muted); font-variant-numeric: tabular-nums; }
.ctlfoot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 34px; border-radius: 17px; outline: none; margin: 0; cursor: pointer; }
input[type=range].dim { background: linear-gradient(90deg, #1b2340, rgb(var(--glow))); }
input[type=range].ct { background: linear-gradient(90deg, rgb(255,147,44), rgb(255,214,170), rgb(255,250,244), rgb(214,226,255)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 2px solid rgba(2,5,47,.15); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
input[type=range]::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 2px solid rgba(2,5,47,.15); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
input[type=range]:disabled { opacity: .4; }
/* colour bulbs: White / Colour switch, quick colours, colour and strength sliders */
.ctl.colour .ctlhead { align-items: center; }
.seg { display: inline-flex; background: var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(2,5,47,.18); }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 4px 0 18px; }
.swatch { aspect-ratio: 1; width: 100%; max-width: 46px; justify-self: center; border-radius: 50%; border: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.swatch.on { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ink); }
.swatch:disabled { opacity: .4; }
.ctlhead .val.dot { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
input[type=range].hue { background: linear-gradient(90deg, hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%), hsl(300,100%,50%), hsl(359,100%,50%)); margin-bottom: 14px; }
input[type=range].sat { --hue: 30; background: linear-gradient(90deg, hsl(var(--hue), 30%, 88%), hsl(var(--hue), 100%, 50%)); }
.members { margin-top: 24px; }
.mlist { display: flex; flex-wrap: wrap; gap: 8px; }
.mchip { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.mchip.on { border-color: var(--cyan); box-shadow: inset 0 0 0 1px var(--cyan); }
body.noscroll { overflow: hidden; }

/* bottom tab bar: Rooms | Devices */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; max-width: 560px; margin: 0 auto;
  display: flex; gap: 6px; padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.88); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; box-shadow: 0 -6px 24px rgba(2,5,47,.08); }
/* dark theme (follows the phone, or the choice in the app) */ html[data-theme="dark"] .tabbar { background: rgba(10,16,44,.88); } 
.tab { flex: 1; position: relative; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; border-radius: 14px; cursor: pointer; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--blue); background: rgba(0,174,239,.1); }
/* dark theme (follows the phone, or the choice in the app) */ html[data-theme="dark"] .tab.on { color: var(--cyan); } 
.tab .badge { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--cyan); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
main { padding-bottom: 120px; }

/* add tiles, scene tiles */
.addtile { border: 2px dashed var(--line); background: transparent; box-shadow: none; color: var(--muted); font: inherit; align-items: flex-start; }
.addtile .plus { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: var(--card); color: var(--blue); }
.addtile .tname { color: var(--muted); opacity: 1; }
.tile.scene:not(.lit) { background: linear-gradient(160deg, var(--card), var(--bg)); }
.power.more { font-size: 22px; line-height: 1; color: var(--muted); }

/* forms in the bottom sheet */
.panel.form { padding-top: 10px; }
.field { display: block; margin: 14px 0 0; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.panel input[type=text], .panel input[type=number], .panel input[type=time], .panel select {
  width: 100%; font: inherit; padding: 12px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.panel input.small { width: 90px; }
.panel .primary { margin-top: 18px; }
.ghost { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px; padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer; }
.ghost.wide { width: 100%; margin-top: 10px; }
.ghost.danger, .danger { color: #c4320a; }
.sheetactions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.sheetactions .ghost { flex: 1; }
.checklist { display: grid; gap: 6px; max-height: 42vh; overflow-y: auto; padding: 2px; }
.check { display: grid; grid-template-columns: 24px 1fr; align-items: center; gap: 2px 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--blue); grid-row: span 2; }
.check small { color: var(--muted); font-size: 12px; }
.steps { padding-left: 20px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.found { display: grid; gap: 10px; margin-top: 14px; }
.newdev { border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.newdev .ghost { margin-top: 12px; width: 100%; }
.center { display: block; text-align: center; margin: 14px auto; }

/* schedules */
.cards { display: grid; gap: 12px; }
.card { background: var(--card); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; text-align: left; border: 0; font: inherit; color: var(--ink); }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card.broken { box-shadow: inset 0 0 0 2px rgba(196,50,10,.5); }
.card .warn { margin-top: 10px; font-size: 13px; color: #b54708; background: rgba(245,158,11,.12); padding: 8px 10px; border-radius: 10px; }
.events { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.addcard { color: var(--blue); font-weight: 700; text-align: center; border: 2px dashed var(--line); background: transparent; box-shadow: none; }
.switch { position: relative; flex: none; width: 50px; height: 30px; border-radius: 999px; border: 0; background: var(--off); cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch.on { background: var(--blue); } .switch.on::after { transform: translateX(20px); }
.eventlist { display: grid; gap: 10px; }
.event { background: var(--bg); border-radius: 14px; padding: 10px; display: grid; gap: 8px; }
.eventtop { display: flex; gap: 8px; align-items: center; }
.eventtop select, .eventtop input { flex: 1; min-width: 0; }
.event .close { flex: none; }
.days { display: flex; gap: 6px; }
.day { flex: 1; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.day.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.tabbar .tab span:not(.badge) { font-size: 11px; }
.updating { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 99px; font-size: 12px; background: rgba(255,255,255,.18); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.hint { color: var(--muted); margin: 0; font-size: 14px; }
.list { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.list div { padding: 11px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.list div:last-child { border-bottom: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--ok); } .dot.off { background: var(--off); }
.empty, .notice { color: var(--muted); text-align: center; padding: 26px 10px; background: var(--card); border-radius: 14px; }
.loading { color: var(--muted); text-align: center; padding: 40px 0; }
.busy { pointer-events: none; opacity: .7; }
.splash { min-height: 100vh; display: grid; place-items: center; background: var(--grad); }
.splash img { width: 180px; opacity: .95; }
#toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(120px); background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; transition: transform .25s; max-width: 90vw; z-index: 9; }
#toast.show { transform: translateX(-50%) translateY(0); }
.install { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-top: 12px; font-size: 14px; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); }
.install button { margin-left: auto; border: 0; background: var(--blue); color: #fff; border-radius: 10px; padding: 8px 12px; font-weight: 700; cursor: pointer; }

/* manual latitude / longitude, tucked away behind the postcode option */
details.manual { margin-top: 14px; }
details.manual summary { cursor: pointer; color: var(--muted, #9fb3d9); font-size: 14px; padding: 6px 0; }
details.manual[open] summary { margin-bottom: 8px; }
.event .offset { display: inline-flex; gap: 6px; align-items: center; flex: 1; }
.event .offset input.small { width: 70px; }

/* header icon buttons (refresh, sign out) */
.iconbtn { display: inline-grid; place-items: center; padding: 0; transition: background .2s; }
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn:hover, .iconbtn:focus-visible { background: rgba(255,255,255,.26); }

/* ---- tablets (iPad etc.) and phones in landscape: use the width ---- */
@media (min-width: 700px) {
  main { max-width: 1060px; }
  .hero { padding-left: 28px; padding-right: 28px; border-radius: 0 0 32px 32px; }
  .hero h1 { font-size: 30px; }
  .content { padding: 6px 28px 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
  .tname { font-size: 17px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .list { max-width: 760px; }
  /* tab bar floats at the bottom centre */
  .tabbar { max-width: 620px; bottom: calc(14px + env(safe-area-inset-bottom)); padding-bottom: 8px; border-radius: 22px;
            border: 1px solid var(--line); box-shadow: 0 10px 34px rgba(2,5,47,.22); }
  main { padding-bottom: 130px; }
  /* light controls and forms: floating card instead of a full-width sheet */
  .sheet .panel { max-width: 600px; bottom: 16px; border-radius: 26px; padding-bottom: 26px; max-height: calc(100vh - 32px);
                  transform: translateY(calc(100% + 32px)); }
  .sheet.show .panel { transform: translateY(0); }
}
@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* phones on their side: short screens */
@media (max-height: 520px) and (orientation: landscape) {
  .hero { padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: 16px; }
  .hero h1 { margin-top: 10px; font-size: 22px; }
  .tile { aspect-ratio: 1 / .7; }
  .sheet .panel { max-height: calc(100vh - 16px); }
  .pcenter { padding: 10px 0 4px; }
  .bigpower { width: 88px; height: 88px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .hero { padding-bottom: 12px; border-radius: 0 0 22px 22px; }
  .hero h1 { font-size: 20px; margin-top: 6px; }
  .tabbar { max-width: 360px; padding: 4px 8px; bottom: calc(8px + env(safe-area-inset-bottom)); border-radius: 18px; }
  .tab { flex-direction: row; justify-content: center; padding: 6px 0; font-size: 0; gap: 0; }   /* icons only */
  .tab svg { width: 22px; height: 22px; }
  .tab .badge { top: 0; }
  main { padding-bottom: 76px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
}
@media (max-height: 520px) and (orientation: landscape) { .tab > span:not(.badge) { display: none; } .tab { font-size: 11px; } }

/* ---- dark mode: lit tiles as deep "embers" with a glowing edge and light text ----
   Bright pastel blocks look harsh on a dark screen, and phone browsers that force their own dark mode
   (Samsung Internet) flip bright backgrounds into dark red. Deep colours and light text are left alone. */
/* dark theme (follows the phone, or the choice in the app) */
  html[data-theme="dark"] .tile.lit, html[data-theme="dark"] .sheet .panel { --d1: 214, 110, 20; --d2: 150, 62, 8; --dg: 255, 150, 50; }
  html[data-theme="dark"] .tile.lit { color: #fff3e2;
    background: radial-gradient(80% 60% at 20% 0%, rgba(var(--dg), .35) 0%, rgba(var(--dg), 0) 70%),
                linear-gradient(150deg, rgb(var(--d1)) 0%, rgb(var(--d2)) 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 0 0 1px rgba(var(--dg), .6), 0 8px 28px rgba(var(--dg), calc(.4 * var(--glow-strength))); }
  html[data-theme="dark"] .tile.lit .tsub { opacity: .88; }
  html[data-theme="dark"] .power.on { background: rgba(255,255,255,.16); color: #fff6e8; box-shadow: 0 0 0 1px rgba(255,255,255,.3), 0 0 18px rgba(var(--dg), .6); }
  html[data-theme="dark"] .power.on svg { filter: none; }
  html[data-theme="dark"] .bigpower.on { background: radial-gradient(circle at 32% 26%, rgba(var(--dg), .45) 0%, rgba(var(--dg), 0) 55%), linear-gradient(150deg, rgb(var(--d1)), rgb(var(--d2)));
    box-shadow: 0 0 0 10px rgba(var(--dg), calc(.16 * var(--glow-strength))), 0 0 50px rgba(var(--dg), calc(.55 * var(--glow-strength))); }
  html[data-theme="dark"] .bigpower.on svg { color: #fff6e6; }
  html[data-theme="dark"] input[type=range].dim { background: linear-gradient(90deg, #1b2340, rgb(var(--d1))); }


/* device-type icon, top left of each tile (GU10, strip, controller, plug...) */
.ttype { position: absolute; top: 14px; left: 14px; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: var(--bg); color: var(--muted); }
.ttype .ticon { width: 21px; height: 21px; }
.tile.lit .ttype { background: rgba(255,255,255,.42); color: inherit; }
html[data-theme="dark"] .tile:not(.lit) .ttype { background: rgba(255,255,255,.06); color: #9fb0da; }
html[data-theme="dark"] .tile.lit .ttype { background: rgba(255,255,255,.14); }
.list .oname { display: inline-flex; align-items: center; gap: 8px; }
.licon { width: 20px; height: 20px; color: var(--muted); flex: none; }

/* sign-up, activation, add a hub */
.authalt { margin-top: 14px; text-align: center; color: var(--muted); font-size: 14px; }
button.link.inline { display: inline; padding: 0; margin: 0; width: auto; }
form.auth .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
form.auth small.hint { display: block; font-size: 12px; margin-top: 4px; }
form.auth .check.accept { margin-top: 14px; grid-template-columns: 24px 1fr; font-size: 13px; line-height: 1.35; color: var(--ink); }
form.auth .check.accept input { grid-row: auto; }
form.auth .check.accept a { color: var(--blue); }
input.codein { font-size: 28px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }
.claim h2 { margin: 0 0 10px; font-size: 20px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.claim .steps { margin: 0 0 16px; padding-left: 20px; color: var(--ink); font-size: 14px; line-height: 1.5; }
.claim .steps li { margin-bottom: 4px; }
.claim label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
.claim input { width: 100%; font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px;
  padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.claim small.hint { display: block; font-size: 12px; margin-top: 4px; }
.claim .primary { margin-top: 14px; width: 100%; }
.claim video.scanner { width: 100%; border-radius: 14px; margin: 8px 0; background: #000; }
.panelcard { background: var(--card); border-radius: 22px; padding: 20px; box-shadow: var(--shadow); margin-top: 18px; }
.chip.add { border-style: dashed; color: var(--blue); }
.claim .primary { margin-top: 6px; }
.claim .scanstatus { margin-top: 10px; min-height: 1em; }
.claim details.manual { margin-top: 18px; }
.claim details.manual summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.claim details.manual .hint { margin: 8px 0; font-size: 13px; }

/* sharing a hub */
.field select, .sheet input[type=date] { width: 100%; font: inherit; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.sheet input[type=date] { margin-top: 8px; }
.sharelist { display: grid; gap: 8px; margin-bottom: 8px; }
.sharerow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--bg); }
.sharerow.expired { opacity: .55; }
.sharerow .sname { font-weight: 700; }
.sharerow .smeta { font-size: 12px; color: var(--muted); word-break: break-all; }
.sharerow .ghost { flex: none; padding: 8px 12px; }
/* five header buttons on a narrow phone */
@media (max-width: 420px) { .hero .iconbtn { width: 36px; height: 36px; margin-left: 4px; } .hero .iconbtn svg { width: 18px; height: 18px; } .hero .brandlogo { height: 22px; } }

/* plugs and relays: live power, timers */
.powernow { display: flex; justify-content: space-between; align-items: baseline; margin-top: 18px; padding: 12px 14px; border-radius: 14px; background: var(--bg); }
.powernow span { color: var(--muted); font-size: 14px; font-weight: 600; }
.powernow b { font-size: 22px; font-variant-numeric: tabular-nums; }
.ctl.timer .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ctl.timer .chip { box-shadow: none; }
.ctl.timer .timernote { margin: -4px 0 10px; font-weight: 700; color: var(--blue); }
html[data-theme="dark"] .ctl.timer .timernote { color: var(--cyan); }
.ctl.timer .timerother { display: flex; gap: 8px; margin-top: 10px; }
.ctl.timer .timerother input { width: 120px; font: inherit; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
/* settings: link styled as button, help */
a.btnlink { display: block; text-align: center; text-decoration: none; box-sizing: border-box; margin-top: 10px; }
.primary.danger { background: #c4320a; }
.primary.danger:hover { background: #a82a08; }
details.voice { margin-top: 12px; }
details.voice .steps { padding-left: 20px; font-size: 14px; line-height: 1.5; color: var(--ink); }

/* needs attention */
.attention { margin: 16px 0 4px; padding: 14px 16px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); border-left: 4px solid #e0a106; }
.attention.ok { border-left-color: var(--ok); }
.attention.bad { border-left-color: var(--bad); }
.attention .ahead { font-weight: 700; margin-bottom: 6px; }
.attention ul { margin: 6px 0; padding-left: 20px; font-size: 14px; line-height: 1.5; }
.attention .aitem { padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.attention .aitem summary { cursor: pointer; }
.attention .aitem .hint { margin: 6px 0 2px; font-size: 13px; }
.attention .link { margin-top: 8px; font-size: 13px; display: block; }
.attention .alertopt { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.attention .alertopt input { width: 18px; height: 18px; accent-color: var(--blue); }
/* holiday mode */
.holidaycard.on { box-shadow: inset 0 0 0 2px rgba(0,174,239,.55), var(--shadow); }

/* add-to-home-screen guide */
.manual.install-guide > div > b { display: block; margin: 12px 0 2px; }
.manual.install-guide .primary.wide { margin: 8px 0 4px; }

/* "Unknown device" (failed pairing) in Other devices */
.list .unrec .meta { display: inline-flex; align-items: center; gap: 10px; }
.list .unrec .badge.warn { font-size: 12px; color: #b54708; background: rgba(245,158,11,.14); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.list .unrec button.link { margin: 0; font-size: 13px; }
html[data-theme="dark"] .list .unrec .badge.warn { color: #fbbf24; background: rgba(251,191,36,.14); }
.attention .aitem .ghost.danger { margin-top: 6px; }
