:root {
  --bg: #020611;
  --surface: rgba(16, 28, 52, 0.55);
  --surface-2: rgba(24, 40, 72, 0.7);
  --line: rgba(143, 166, 200, 0.16);
  --text: #eef3ff;
  --muted: #8fa6c8;
  --dim: #7d8ca8;
  --accent: #5fd4ff;
  --accent-2: #3d8bff;
  --violet: #a99bff;
  --warn: #ffb86b;
  --danger: #ff7a8a;
  --radius: 20px;
  --font-head: 'Sora', system-ui, sans-serif;
  --font-body: 'Manrope', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.glow {
  position: fixed; inset: -20% -10% auto; height: 70vh; pointer-events: none; z-index: 0;
  background: radial-gradient(60% 60% at 70% 20%, rgba(61, 139, 255, 0.22), transparent 70%),
              radial-gradient(40% 40% at 15% 10%, rgba(95, 212, 255, 0.12), transparent 70%);
}

.app { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 48px; }

.top-actions { display: flex; align-items: center; gap: 8px; }
button.pill { cursor: default; }
.native button.pill { cursor: pointer; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-size: 15px; }
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }
.field small { display: block; color: var(--dim); font-size: 12px; margin-top: 5px; }
.btn { width: 100%; padding: 14px; border-radius: 14px; font-weight: 600; font-size: 15px; margin-top: 6px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--bg); }
.btn.ghost { border: 1px solid var(--line); color: var(--muted); }
.btn:disabled { opacity: 0.6; }
.form-error { color: var(--danger); font-size: 13.5px; min-height: 1em; margin: 4px 0 8px; }
.help { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 14px; padding: 12px 14px; margin: 0 0 18px; }
.help ol { margin: 6px 0 0; padding-left: 18px; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 20px; }
/* CERUS wordmark (same as the website: Sora 600, wide tracking). Uses the theme's text colour,
   so it is white on the dark theme and charcoal on the soft theme. */
@font-face { /* bundled (SIL Open Font License) so the logo renders instantly and offline */
  font-family: 'CERUS Sora'; font-weight: 600; font-style: normal; font-display: block;
  src: url('fonts/sora-latin-600-normal.woff2') format('woff2');
}
.wordmark { font-family: 'CERUS Sora', 'Sora', var(--font-head), system-ui, sans-serif; font-weight: 600; letter-spacing: 0.28em; color: var(--text); line-height: 1; white-space: nowrap; }
.brand { display: flex; align-items: center; }
.brand .wordmark { font-size: 18px; }
.pill { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.live { color: #6ff0b4; border-color: rgba(111, 240, 180, 0.3); }
.pill.demo { color: var(--warn); border-color: rgba(255, 184, 107, 0.3); }

.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin: 0 0 6px; }
.hero h1 { font-family: var(--font-head); font-weight: 300; font-size: clamp(26px, 6vw, 40px); line-height: 1.15; margin: 0 0 18px; letter-spacing: -0.01em; }
.hero h1 b { font-weight: 500; color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; backdrop-filter: blur(12px); }
.stat .v { font-family: var(--font-head); font-size: 22px; font-weight: 500; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.stat .k { font-size: 12px; color: var(--dim); }

.block { margin-top: 28px; }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.block-head .label { margin: 0; }
.label { font-family: var(--font-mono); font-weight: 500; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line); background: var(--surface); }
.icon-btn:hover { color: var(--text); }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.scenes, .rooms { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 4px; }
.scenes::-webkit-scrollbar, .rooms::-webkit-scrollbar { display: none; }
.scene { flex: 0 0 auto; min-width: 140px; text-align: left; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(61, 139, 255, 0.18), rgba(169, 155, 255, 0.08)); transition: transform 0.15s, border-color 0.15s; }
.scene:hover { border-color: rgba(95, 212, 255, 0.4); }
.scene:active { transform: scale(0.97); }
.scene svg { color: var(--accent); margin-bottom: 10px; display: block; }
.scene span { font-family: var(--font-head); font-size: 14px; font-weight: 500; }
.scene.busy { opacity: 0.6; pointer-events: none; }

.rooms { margin-bottom: 14px; }
.room { flex: 0 0 auto; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; }
.room[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.card { position: relative; text-align: left; min-height: 150px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); backdrop-filter: blur(14px); display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  --fill: linear-gradient(160deg, rgba(95, 212, 255, 0.22), rgba(61, 139, 255, 0.12));
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  transition: border-color 0.35s var(--ease), box-shadow 0.45s var(--ease), transform 0.35s var(--ease), opacity 0.3s;
  overflow: hidden; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
/* on/off: the colour grows out of the spot that was pressed, and shrinks back into it */
.card::before { content: ''; position: absolute; inset: 0; background: var(--fill); pointer-events: none;
  clip-path: circle(0 at var(--x, 50%) var(--y, 50%)); transition: clip-path 0.5s var(--ease); }
.card.on::before { clip-path: circle(150% at var(--x, 50%) var(--y, 50%)); transition-duration: 0.6s; }
.card > * { position: relative; }
.card:active { transform: scale(0.96); transition-duration: 0.12s; }
.card.on { border-color: rgba(95, 212, 255, 0.45); }
.card.offline { opacity: 0.5; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.card .ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: rgba(143, 166, 200, 0.12); color: var(--muted);
  transition: background 0.4s var(--ease), color 0.4s var(--ease), box-shadow 0.4s var(--ease), transform 0.45s var(--ease); }
.card.on .ico { background: var(--accent); color: var(--bg); box-shadow: 0 0 24px rgba(95, 212, 255, 0.45); }
.card:active .ico { transform: scale(0.9); }
.card .name { font-family: var(--font-head); font-size: 15px; font-weight: 500; line-height: 1.25; transition: color 0.4s var(--ease); }
.card .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; transition: color 0.4s var(--ease); }
.card .more { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: var(--dim); transition: color 0.4s var(--ease); }
.card .more:hover { color: var(--text); background: rgba(143, 166, 200, 0.12); }
.card .more svg { width: 18px; height: 18px; }
.card > .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.5s var(--ease), background 0.4s; }
.card.pending { pointer-events: none; }
.card.pending .ico { animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

.empty { color: var(--muted); text-align: center; padding: 40px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 17, 0.6); backdrop-filter: blur(4px); z-index: 20; }
.sheet { position: fixed; z-index: 21; left: 50%; bottom: 0; transform: translateX(-50%); width: min(520px, 100%); max-height: 88vh; overflow-y: auto;
  background: #0a1426; border: 1px solid var(--line); border-bottom: 0; border-radius: 26px 26px 0 0; padding: 10px 20px max(24px, env(safe-area-inset-bottom));
  animation: up 0.25s ease-out; }
@keyframes up { from { transform: translate(-50%, 30px); opacity: 0; } }
@media (min-width: 700px) { .sheet { bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: 26px; border-bottom: 1px solid var(--line); animation: none; } .sheet-grip { display: none; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.sheet-head h3 { font-family: var(--font-head); font-weight: 500; font-size: 22px; margin: 0; }

.ctl { padding: 16px 0; border-top: 1px solid var(--line); }
.ctl-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ctl-label { font-size: 14px; font-weight: 600; }
.ctl-sub { font-size: 12.5px; color: var(--muted); }
.ctl-value { font-family: var(--font-mono); color: var(--accent); font-size: 13px; }

.toggle { width: 52px; height: 30px; border-radius: 30px; background: rgba(143, 166, 200, 0.25); position: relative; transition: background 0.2s; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle[aria-checked="true"]::after { transform: translateX(22px); }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 36px; background: transparent; margin-top: 10px; }
input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 8px; background: var(--track, linear-gradient(90deg, var(--accent-2), var(--accent))); }
input[type="range"]::-moz-range-track { height: 8px; border-radius: 8px; background: var(--track, linear-gradient(90deg, var(--accent-2), var(--accent))); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -8px; border-radius: 50%; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4); }
input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #fff; }
.range-temp { --track: linear-gradient(90deg, #ffb86b, #fff3e0, #cfe8ff); }

.seg { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.seg button { padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 500; text-transform: capitalize; }
.seg button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: rgba(95, 212, 255, 0.1); }

.stepper { display: flex; align-items: center; justify-content: center; gap: 28px; padding: 6px 0 4px; }
.stepper button { width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--line); font-size: 26px; font-weight: 300; background: var(--surface-2); }
.stepper .big { font-family: var(--font-head); font-size: 54px; font-weight: 300; min-width: 130px; text-align: center; }
.stepper .big small { font-size: 20px; color: var(--muted); }

.readings { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.reading { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.reading .v { font-family: var(--font-head); font-size: 22px; }
.reading .k { font-size: 12px; color: var(--muted); text-transform: capitalize; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 30; pointer-events: none;
  background: #13213b; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 13.5px; transition: 0.25s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255, 122, 138, 0.5); color: var(--danger); }

/* ---------- tab bar ---------- */
.app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.tabbar { position: fixed; z-index: 15; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; gap: 4px; padding: 6px; border-radius: 22px; background: rgba(10, 20, 38, 0.86); border: 1px solid var(--line);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); }
.tab { display: flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 16px; color: var(--muted); font-weight: 600; font-size: 14px; }
.tab svg { width: 20px; height: 20px; }
.tab[aria-current="page"] { background: var(--text); color: var(--bg); }

/* ---------- cameras ---------- */
.cam-hero h1 { margin-bottom: 4px; }
.notice { margin-top: 18px; padding: 12px 14px; border-radius: 14px; font-size: 13.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); }
.notice b { color: var(--text); }
.notice button { color: var(--accent); font-weight: 600; padding: 0; margin-left: 4px; }
.notice.warn { border-color: rgba(255, 184, 107, 0.35); }
#cam-filter { margin: 0 -16px 0; flex: 1; min-width: 0; }
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.cam { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #050b16; text-align: left; aspect-ratio: 16 / 10; }
.cam:active { transform: scale(0.99); }
.cam img, .cam .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam .ph { display: grid; place-items: center; color: var(--dim); background: radial-gradient(60% 60% at 50% 40%, rgba(61, 139, 255, 0.14), transparent 70%), #07101f; }
.cam .ph svg { width: 34px; height: 34px; }
.cam .shade { position: absolute; inset: auto 0 0 0; padding: 28px 14px 12px; background: linear-gradient(transparent, rgba(2, 6, 17, 0.92)); display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.cam .cname { font-family: var(--font-head); font-weight: 500; font-size: 15px; color: #fff; }
.cam .cmeta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cam .tags { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.tag { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 7px; border-radius: 6px; background: rgba(2, 6, 17, 0.7); color: var(--muted); border: 1px solid var(--line); }
.tag.live { background: #e5484d; color: #fff; border-color: transparent; }
.tag.off { color: var(--danger); }
.cam .play { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, 0.14); color: #fff; flex: none; }
.cam .play svg { width: 18px; height: 18px; fill: currentColor; stroke: none; margin-left: 2px; }
.cam.offline img { filter: grayscale(1) brightness(0.45); }

.events { display: flex; flex-direction: column; gap: 8px; }
.event { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-align: left; width: 100%; }
.event .thumb { width: 88px; aspect-ratio: 16 / 10; border-radius: 10px; background: #07101f center / cover no-repeat; flex: none; }
.event .etitle { font-weight: 600; font-size: 14px; text-transform: capitalize; }
.event .emeta { font-size: 12.5px; color: var(--muted); }

/* camera sheet */
.cam-preview { position: relative; border-radius: 16px; overflow: hidden; background: #050b16; aspect-ratio: 16 / 9; margin-bottom: 14px; }
.cam-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-preview .tags { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.cam-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cam-actions .btn { margin: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.cam-actions .btn svg { width: 18px; height: 18px; }
.pad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); gap: 6px; justify-content: center; margin-top: 10px; }
.pad button { border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--text); touch-action: none; user-select: none; -webkit-user-select: none; }
.pad button:active, .pad button.held { background: var(--accent); color: var(--bg); }
.pad .c { background: transparent; border: 0; }
.pb-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.pb-quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pb-quick button { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* in-page video viewer (web version / demo) */
.viewer { position: fixed; inset: 0; z-index: 40; background: #000; display: flex; flex-direction: column; }
.viewer-top { display: flex; align-items: center; gap: 12px; padding: max(12px, env(safe-area-inset-top)) 16px 12px; }
.viewer-top strong { display: block; font-family: var(--font-head); }
.viewer-top small { color: var(--muted); }
.viewer video { flex: 1; width: 100%; min-height: 0; background: #000; }

/* boot loader — shown while the app starts and the first device list loads */
.boot { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(50% 40% at 50% 45%, rgba(61, 139, 255, 0.18), transparent 70%), var(--bg); transition: opacity 0.45s ease, visibility 0.45s; }
.boot.done { opacity: 0; visibility: hidden; }
.boot-word { font-size: clamp(30px, 9vw, 40px); padding-left: 0.32em; letter-spacing: 0.32em;
  opacity: 0; filter: blur(6px); animation: boot-track 1s cubic-bezier(.22,1,.36,1) 0.1s forwards; }
.boot-bar { width: 120px; height: 2px; border-radius: 2px; background: rgba(143, 166, 200, 0.15); overflow: hidden; opacity: 0; animation: boot-rise 0.4s ease-out 1s forwards; }
.boot-bar span { display: block; width: 40%; height: 100%; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: boot-slide 1.1s ease-in-out infinite; }
/* letters glide together from wide tracking into the wordmark */
@keyframes boot-track { from { opacity: 0; letter-spacing: 0.9em; padding-left: 0.9em; filter: blur(6px); } to { opacity: 1; letter-spacing: 0.32em; padding-left: 0.32em; filter: blur(0); } }
@keyframes boot-rise { to { opacity: 1; transform: none; } }
@keyframes boot-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) {
  .boot-word, .boot-bar { opacity: 1; transform: none; filter: none; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* settings sections */
.form-section { font-family: var(--font-head); font-size: 16px; font-weight: 500; margin: 22px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.form-section span { display: block; font-family: var(--font-body); font-size: 12.5px; font-weight: 400; color: var(--dim); margin-top: 2px; }
.opt { font-weight: 400; font-style: normal; color: var(--dim); }
.mono { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.btn:disabled { opacity: 0.45; }
.form-sub { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); margin: 16px 0 10px; }
.adv { margin: 4px 0 14px; }
.adv summary { cursor: pointer; color: var(--muted); font-size: 13.5px; font-weight: 600; padding: 6px 0 12px; }
.viewer-snap { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; background: #000; }
.viewer-snap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-badge { position: absolute; top: 12px; right: 16px; }
.viewer-ptz { padding: 12px 16px max(18px, env(safe-area-inset-bottom)); background: #050b16; border-top: 1px solid var(--line); }
.viewer-ptz .ctl { border-top: 0; padding: 4px 0; }

/* ---------- Add device ---------- */
.head-actions { display: flex; gap: 8px; }
.pair-lead { font-family: var(--font-head); font-size: 16px; margin: 0 0 14px; }
.pair-option { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; padding: 16px; margin-bottom: 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); transition: transform 0.2s, border-color 0.2s; }
.pair-option:active { transform: scale(0.98); }
.pair-option b { display: block; font-family: var(--font-head); font-weight: 500; font-size: 15px; }
.pair-option small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; line-height: 1.4; }
.pair-ico { flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--accent); color: var(--bg); }
.pair-ico svg, .pair-ok svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pair-steps, .pair-tips { margin: 0 0 16px; padding-left: 20px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.pair-steps li, .pair-tips li { margin-bottom: 8px; }
.pair-steps b, .pair-tips b { color: var(--text); font-weight: 600; }
.pair-warn { font-size: 13px; color: var(--warn); background: rgba(255, 184, 77, 0.1); border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; }
.pair-check { display: flex; gap: 10px; align-items: center; font-size: 14px; margin: 4px 0 10px; }
.pair-check input { width: 20px; height: 20px; accent-color: var(--accent); }

.pair-radar { --p: 0; position: relative; width: 150px; height: 150px; margin: 8px auto 6px; display: grid; place-items: center; }
.pair-radar span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: pair-wave 2.4s cubic-bezier(0.2, 0.6, 0.3, 1) infinite; }
.pair-radar span:nth-child(2) { animation-delay: 0.8s; }
.pair-radar span:nth-child(3) { animation-delay: 1.6s; }
.pair-radar i { width: 54px; height: 54px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--accent-2), var(--accent)); box-shadow: 0 0 30px rgba(95, 212, 255, 0.45); }
@keyframes pair-wave { 0% { transform: scale(0.35); opacity: 0.9; } 100% { transform: scale(1); opacity: 0; } }
.pair-count { text-align: center; font-family: var(--font-mono); color: var(--muted); margin: 0 0 14px; }
.pair-progress { list-style: none; padding: 0; margin: 0 0 14px; }
.pair-progress li { position: relative; padding: 8px 0 8px 30px; color: var(--dim); font-size: 14px; transition: color 0.3s; }
.pair-progress li::before { content: ''; position: absolute; left: 4px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; border: 2px solid currentColor; box-sizing: border-box; }
.pair-progress li.active { color: var(--text); }
.pair-progress li.active::before { border-color: var(--accent); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.pair-progress li.done { color: var(--muted); }
.pair-progress li.done::before { background: var(--accent); border-color: var(--accent); }
.pair-keep { text-align: center; }
.pair-found-row { display: flex; justify-content: space-between; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); margin-bottom: 8px; font-size: 14px; }
.pair-found-row small { color: var(--muted); }
.pair-ok { width: 64px; height: 64px; margin: 4px auto 18px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--bg); animation: pair-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
.pair-ok svg { width: 32px; height: 32px; stroke-width: 2.4; }
@keyframes pair-pop { from { transform: scale(0.4); opacity: 0; } }

/* ---------- 5 tabs, lists, admin ---------- */
.tabbar.many { gap: 2px; padding: 5px; max-width: calc(100% - 20px); }
.tabbar.many .tab { flex-direction: column; gap: 3px; padding: 8px 10px; font-size: 10.5px; min-width: 58px; }
.tabbar.many .tab svg { width: 20px; height: 20px; }
.accent { color: var(--accent); }
.list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.row:not(.static):active { transform: scale(0.99); }
.row-ico { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(143, 166, 200, 0.12); color: var(--muted); }
.row-ico.ok { color: var(--accent); background: rgba(95, 212, 255, 0.12); }
.row-ico.bad { color: var(--danger); background: rgba(255, 107, 107, 0.1); }
.row-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.row-main { flex: 1; min-width: 0; }
.row-main b { display: block; font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-time { flex: none; color: var(--dim); font-size: 12px; }
.dot { flex: none; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dot.ok { color: #3ddc97; } .dot.bad { color: var(--danger); }
.search { display: block; margin-bottom: 10px; }
.search input { width: 100%; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.kv div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.kv span { display: block; font-size: 11.5px; color: var(--muted); }
.kv b { font-weight: 600; font-size: 13.5px; word-break: break-all; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.chip { padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 13px; }
.chip.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.chip.check input { accent-color: var(--accent); }
.chip.check:has(input:checked) { border-color: var(--accent); color: var(--accent); }
.btn.small { padding: 9px 14px; font-size: 13px; width: auto; margin: 0; }
.btn-row { display: flex; gap: 8px; }
.btn.danger { color: var(--danger); }
.card.door .btn, .card.lock .btn { align-self: flex-start; position: relative; }
.perm-group { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; }
.trust-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 16px; }
.site-pill { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--font-mono); }
@media (min-width: 900px) { .brand .wordmark { font-size: 26px; } }

/* Weather under the greeting */
.weather { display: flex; align-items: center; gap: 12px; margin: 10px 0 14px; }
.w-ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: rgba(95, 212, 255, 0.12); color: var(--accent); flex: none; }
.w-ico svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.w-temp { font-family: var(--font-head); font-size: 34px; font-weight: 300; line-height: 1; }
.w-text { min-width: 0; }
.w-text b { display: block; font-weight: 600; font-size: 14px; }
.w-text small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Location picker under the CERUS logo */
.brand.with-loc { flex-direction: column; align-items: flex-start; gap: 6px; }
.loc-btn { display: inline-flex; align-items: center; gap: 5px; max-width: 60vw; padding: 3px 8px 3px 4px; margin-left: -4px; border-radius: 10px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.loc-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-btn svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.loc-btn svg:first-child { color: var(--accent); }
.loc-btn .chev { width: 13px; height: 13px; opacity: 0.7; }
.loc-btn:hover, .loc-btn:focus-visible { color: var(--text); background: rgba(143, 166, 200, 0.1); }
.sb-brand .loc-btn { max-width: 200px; font-size: 12px; }
body.sb-collapsed .sb-brand .loc-btn span, body.sb-collapsed .sb-brand .loc-btn .chev { display: none; }
@media (min-width: 900px) { .brand.with-loc .loc-btn { display: none; } }

/* ---------- Device views: large tiles · small tiles · list · by room · by type ---------- */
.layout-wrap { position: relative; }
.layout-menu { position: absolute; z-index: 30; top: calc(100% + 8px); inset-inline-end: 0; min-width: 196px; padding: 6px; border-radius: 16px;
  background: var(--surface-2, #0f1b31); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35); display: flex; flex-direction: column; gap: 2px;
  animation: menu-in 0.18s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
.layout-menu button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; color: var(--text); font-size: 14px; text-align: start; }
.layout-menu button svg, #layout-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.layout-menu button[aria-checked="true"] { color: var(--accent); background: rgba(95, 212, 255, 0.1); }
.layout-menu button:hover { background: rgba(143, 166, 200, 0.1); }

.card .sw { display: none; }
.card-body { min-width: 0; }

/* Small tiles (also used inside groups) */
.grid.layout-small, .dgroup-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.layout-small .card, .dgroup-grid .card { min-height: 112px; padding: 12px; gap: 8px; border-radius: 18px; }
.layout-small .card .ico, .dgroup-grid .card .ico { width: 34px; height: 34px; border-radius: 11px; }
.layout-small .card .ico svg, .dgroup-grid .card .ico svg { width: 18px; height: 18px; }
.layout-small .card .name, .dgroup-grid .card .name { font-size: 13px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.layout-small .card .meta, .dgroup-grid .card .meta { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layout-small .card .more, .dgroup-grid .card .more { width: 24px; height: 24px; }
.layout-small .card .more svg, .dgroup-grid .card .more svg { width: 15px; height: 15px; }

/* List */
.grid.layout-list { grid-template-columns: 1fr; gap: 8px; }
.layout-list .card { flex-direction: row; align-items: center; min-height: 0; padding: 11px 14px; gap: 14px; border-radius: 18px; }
.layout-list .card-top { display: contents; }
.layout-list .card .ico { order: 0; width: 40px; height: 40px; border-radius: 12px; flex: none; }
.layout-list .card-body { order: 1; flex: 1; }
.layout-list .card .name { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layout-list .card .sw { order: 2; display: block; position: relative; flex: none; width: 44px; height: 26px; border-radius: 26px; background: rgba(143, 166, 200, 0.25);
  transition: background 0.35s var(--ease); }
.layout-list .card .sw::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); transition: transform 0.35s var(--ease); }
.layout-list .card.on .sw { background: var(--accent); }
.layout-list .card.on .sw::after { transform: translateX(18px); }
[dir="rtl"] .layout-list .card.on .sw::after { transform: translateX(-18px); }
.layout-list .card[data-kind="sensor"] .sw, .layout-list .card[data-kind="door"] .sw, .layout-list .card[data-kind="generic"] .sw { display: none; }
.layout-list .card .more { order: 3; flex: none; }
.layout-list .card:active { transform: scale(0.985); }

/* Grouped by room / type */
.grid.layout-rooms, .grid.layout-types { display: block; }
.dgroup { margin-bottom: 20px; }
.dgroup-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 2px 10px; }
.dgroup-head h3 { margin: 0; font-family: var(--font-head); font-size: 16px; font-weight: 600; }
.dgroup-head small { color: var(--muted); font-size: 12px; }
.dgroup-btn { padding: 7px 12px; border-radius: 12px; border: 1px solid var(--line); color: var(--text); font-size: 12.5px; font-weight: 600; background: var(--surface); flex: none; }
.dgroup-btn:active { transform: scale(0.96); }
.dgroup-grid { display: grid; }

/* ---------- Arabic (right-to-left) ---------- */
html[lang="ar"] body { font-family: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', var(--font-body, system-ui), sans-serif; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] .card .name, html[lang="ar"] .eyebrow, html[lang="ar"] .label,
html[lang="ar"] .form-sub, html[lang="ar"] .form-section, html[lang="ar"] .w-temp { font-family: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', var(--font-head), sans-serif; }
html[lang="ar"] .eyebrow, html[lang="ar"] .label, html[lang="ar"] .form-sub, html[lang="ar"] .sb-label { letter-spacing: 0; }
[dir="rtl"] .card, [dir="rtl"] .scene, [dir="rtl"] .event, [dir="rtl"] .cam, [dir="rtl"] .pair-option, [dir="rtl"] .row, [dir="rtl"] .auth-field { text-align: right; }
[dir="rtl"] .card > .bar { left: auto; right: 0; }
[dir="rtl"] .toggle::after { left: auto; right: 3px; }
[dir="rtl"] .toggle[aria-checked="true"]::after { transform: translateX(-22px); }
[dir="rtl"] .help ol, [dir="rtl"] .pair-steps, [dir="rtl"] .pair-tips { padding-left: 0; padding-right: 20px; }
[dir="rtl"] .stat .v small { margin-left: 0; margin-right: 2px; }
[dir="rtl"] .notice button { margin-left: 0; margin-right: 4px; }
[dir="rtl"] .cam .tags, [dir="rtl"] .cam-preview .tags { left: auto; right: 10px; }
[dir="rtl"] .viewer-badge { right: auto; left: 16px; }
[dir="rtl"] .pair-progress li { padding: 8px 30px 8px 0; }
[dir="rtl"] .pair-progress li::before { left: auto; right: 4px; }
[dir="rtl"] .loc-btn { margin-left: 0; margin-right: -4px; padding: 3px 4px 3px 8px; }
[dir="rtl"] .wordmark, [dir="rtl"] .boot-word { direction: ltr; }
[dir="rtl"] .w-temp, [dir="rtl"] .stat .v, [dir="rtl"] .mono, [dir="rtl"] .kv b { direction: ltr; unicode-bidi: isolate; }
.lang-btn { font-weight: 700; font-size: 13px; }
.layout-list .card .ico, .layout-list .card .more { position: relative; } /* card-top is display:contents in list view */
#empty .btn { margin-top: 12px; }
