/*
 * Vazirmatn, served from this server (public/fonts) so the app needs nothing from outside: the Persian set and a
 * small Latin set, picked by character range. Both languages use it, so switching language changes no metrics.
 */
@font-face {
  font-family: "Vazirmatn"; src: url("/fonts/Vazirmatn-latin.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Vazirmatn"; src: url("/fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

/*
 * The look is glass: panes that let a soft wallpaper show through, with a bright top rim and a hairline round
 * them. The meaning of the colours does not move between themes -- green is armed, red is disarmed or alarm,
 * amber a warning -- only their depth, so each stays readable on its ground. The dark theme follows the system
 * unless Settings chose a theme (see theme.js); the full-screen alarm is the same in both themes on purpose.
 */
:root {
  --bg: #eef3fc;
  --card: rgba(255, 255, 255, .58);
  --line: rgba(15, 31, 56, .09);
  --text: #0f1f38;
  --muted: #5d6c84;
  --accent: #1f6bff;
  --accent-2: #4b8dff;
  --btn-a: #4b8dff;
  --btn-b: #1f6bff;
  --accent-soft: rgba(31, 107, 255, .13);
  --armed: #15803d;
  --armed-soft: rgba(22, 163, 74, .15);
  --disarmed: #c4262e;
  --disarmed-soft: rgba(220, 38, 38, .13);
  --nav-active: rgba(255, 255, 255, .85);
  --radius: 20px;

  --surface: rgba(255, 255, 255, .8);   /* inputs, the tiles that flash on alarm */
  --sheet: rgba(246, 249, 255, .82);    /* dialogs: more opaque than a card, they sit over everything */
  --desk: #dbe3f1;                      /* the page around the phone-sized shell on a desktop */
  --on-accent: #ffffff;
  --track: rgba(15, 31, 56, .2);
  --track-pending: rgba(15, 31, 56, .12);
  --knob: #ffffff;
  --knob-pending: #f3f5f9;
  --warning: #d97706;
  --scrim: rgba(15, 25, 50, .16);

  /* The glass: a bright rim where light catches the top edge, a hairline round the rest, a soft shadow */
  --rim: rgba(255, 255, 255, .95);
  --hair: rgba(15, 31, 56, .07);
  --lift: 0 1px 2px rgba(20, 50, 110, .05), 0 14px 32px -20px rgba(30, 70, 160, .28);
  --lift-strong: 0 1px 2px rgba(20, 50, 110, .06), 0 30px 60px -28px rgba(30, 70, 160, .38);
  --wall:
    radial-gradient(90% 42% at 50% 0, rgba(70, 135, 255, .26), transparent 70%),
    radial-gradient(70% 40% at 100% 100%, rgba(150, 125, 255, .16), transparent 70%),
    linear-gradient(180deg, #dfe9ff 0%, #edf2fd 45%, #f6f8fd 100%);
  --name: #1d58c4;
  --option-bg: #ffffff;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6c84' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  --wall-in:
    radial-gradient(70% 40% at 100% 100%, rgba(150, 125, 255, .12), transparent 70%),
    linear-gradient(180deg, #edf1fa 0%, #f2f5fb 50%, #f6f8fd 100%);
  --bar: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .04));
  --sheen: rgba(255, 255, 255, .55);
  --edge-top: rgba(255, 255, 255, .85);
  --edge-bottom: rgba(255, 255, 255, .3);
  --lens: linear-gradient(180deg, rgba(255, 255, 255, .72), rgba(255, 255, 255, .28));
  --lens-rim: rgba(255, 255, 255, .7);
  color-scheme: light dark;   /* scrollbars and form controls follow the theme */
}

:root[data-theme="dark"] {
  --bg: #0a1329;
  --card: rgba(255, 255, 255, .065);
  --line: rgba(255, 255, 255, .09);
  --text: #edf2fc;
  --muted: #9aa8c2;
  --accent: #4f8bff;
  --accent-2: #75a5ff;
  --btn-a: #4f8bff;
  --btn-b: #2a60e6;
  --accent-soft: rgba(79, 139, 255, .2);
  --armed: #4ade80;
  --armed-soft: rgba(74, 222, 128, .14);
  --disarmed: #f87171;
  --disarmed-soft: rgba(248, 113, 113, .15);
  --nav-active: rgba(255, 255, 255, .14);

  --surface: rgba(255, 255, 255, .08);
  --sheet: rgba(22, 32, 60, .82);
  --desk: #04070f;
  --track: rgba(255, 255, 255, .2);
  --track-pending: rgba(255, 255, 255, .12);
  --knob: #ffffff;
  --knob-pending: #a8b2c8;
  --warning: #f59e0b;
  --scrim: rgba(0, 0, 0, .5);

  --rim: rgba(255, 255, 255, .22);
  --hair: rgba(255, 255, 255, .07);
  --lift: 0 1px 2px rgba(0, 0, 0, .25), 0 16px 36px -22px rgba(0, 0, 0, .7);
  --lift-strong: 0 1px 2px rgba(0, 0, 0, .3), 0 34px 70px -30px rgba(0, 0, 0, .8);
  --wall:
    radial-gradient(90% 42% at 50% 0, rgba(50, 105, 240, .38), transparent 70%),
    radial-gradient(70% 40% at 100% 100%, rgba(110, 80, 230, .2), transparent 70%),
    linear-gradient(180deg, #0f1d3f 0%, #0a1329 50%, #070c19 100%);
  --name: #edf2fc;
  --option-bg: #18223d;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa8c2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  --wall-in:
    radial-gradient(70% 40% at 100% 100%, rgba(110, 80, 230, .16), transparent 70%),
    linear-gradient(180deg, #0d1730 0%, #0a1329 50%, #070c19 100%);
  --bar: linear-gradient(180deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .02));
  --sheen: rgba(255, 255, 255, .12);
  --edge-top: rgba(255, 255, 255, .28);
  --edge-bottom: rgba(255, 255, 255, .06);
  --lens: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .05));
  --lens-rim: rgba(255, 255, 255, .26);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1329;
    --card: rgba(255, 255, 255, .065);
    --line: rgba(255, 255, 255, .09);
    --text: #edf2fc;
    --muted: #9aa8c2;
    --accent: #4f8bff;
    --accent-2: #75a5ff;
    --btn-a: #4f8bff;
    --btn-b: #2a60e6;
    --accent-soft: rgba(79, 139, 255, .2);
    --armed: #4ade80;
    --armed-soft: rgba(74, 222, 128, .14);
    --disarmed: #f87171;
    --disarmed-soft: rgba(248, 113, 113, .15);
    --nav-active: rgba(255, 255, 255, .14);

    --surface: rgba(255, 255, 255, .08);
    --sheet: rgba(22, 32, 60, .82);
    --desk: #04070f;
    --track: rgba(255, 255, 255, .2);
    --track-pending: rgba(255, 255, 255, .12);
    --knob: #ffffff;
    --knob-pending: #a8b2c8;
    --warning: #f59e0b;
    --scrim: rgba(0, 0, 0, .5);

    --rim: rgba(255, 255, 255, .22);
    --hair: rgba(255, 255, 255, .07);
    --lift: 0 1px 2px rgba(0, 0, 0, .25), 0 16px 36px -22px rgba(0, 0, 0, .7);
    --lift-strong: 0 1px 2px rgba(0, 0, 0, .3), 0 34px 70px -30px rgba(0, 0, 0, .8);
    --wall:
      radial-gradient(90% 42% at 50% 0, rgba(50, 105, 240, .38), transparent 70%),
      radial-gradient(70% 40% at 100% 100%, rgba(110, 80, 230, .2), transparent 70%),
      linear-gradient(180deg, #0f1d3f 0%, #0a1329 50%, #070c19 100%);
    --name: #edf2fc;
    --option-bg: #18223d;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa8c2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    --wall-in:
      radial-gradient(70% 40% at 100% 100%, rgba(110, 80, 230, .16), transparent 70%),
      linear-gradient(180deg, #0d1730 0%, #0a1329 50%, #070c19 100%);
    --bar: linear-gradient(180deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .02));
    --sheen: rgba(255, 255, 255, .12);
    --edge-top: rgba(255, 255, 255, .28);
    --edge-bottom: rgba(255, 255, 255, .06);
    --lens: linear-gradient(180deg, rgba(255, 255, 255, .2), rgba(255, 255, 255, .05));
    --lens-rim: rgba(255, 255, 255, .26);
  }
}

/* A choice made by hand also tells the browser which controls and scrollbars to draw */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* Two copies of the wordmark, one shown at a time: the dark one on the dark theme */
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: inline; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Vazirmatn", Tahoma, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/*
 * One phone-width column, whatever the screen. A control panel is a handheld
 * thing and the layout is built around a thumb; stretched across a desktop
 * monitor the same screen just looks broken, so the shell keeps its width and
 * the desktop simply gets a frame around it.
 */
/*
 * The shell is exactly as tall as the viewport and its middle scrolls, so the
 * rounded corners and the tab bar stay put while a long log moves underneath
 * them. Letting the browser window scroll instead pushed the bar off the
 * bottom of the frame.
 */
.shell {
  position: relative;
  --shell-w: 460px;
  width: min(100%, var(--shell-w));
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  /* Measured by main.js: some phones report 100dvh before the address bar and
     the system navigation have settled, and the tab bar ended up under them */
  height: var(--app-h, 100dvh);
  display: flex;
  flex-direction: column;
  background: var(--wall-in), var(--bg);
  overflow: hidden;
}

.wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* On a desktop the shell is 460px wide -- four tiles fit across it, so the
   original single row is kept there rather than wrapping needlessly. */
@media (min-width: 620px) {
  body { background: var(--desk); overflow: hidden; }
  .shell {
    height: calc(100vh - 48px);
    margin: 24px auto;
    border-radius: 26px;
    box-shadow: 0 1px 0 var(--line), 0 18px 50px rgba(0, 0, 0, .10);
  }
}

.wrap > .inner { padding: 16px 16px 24px; }

header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 16px 4px;
}
header .title { font-size: 1.35rem; font-weight: 700; }

/* With one system the name is just a name; with several it is the way you
   switch, so it gains a chevron and behaves like a button. */
.title.pick {
  display: flex; align-items: center; gap: 4px;
  background: none; border: 0; padding: 0; margin: 0;
  color: inherit; font: inherit; cursor: pointer; max-width: 100%;
}
.title.pick span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.title.pick svg { flex: none; opacity: .55; }

/* One row per system in the picker */
.sysrow {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--card); border: 0; border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
  font: inherit; color: inherit; text-align: start;
}
.sysrow.current { outline: 2px solid var(--accent); }
.sysrow .grow { min-width: 0; }
.sysrow .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/*
 * Persian runs right to left. dir="rtl" on the shell flips flex order, text
 * alignment and scrollbars on its own; what it cannot flip is anything
 * anchored with a physical left or right, so those use logical properties
 * instead and follow the direction by themselves.
 */
[dir="rtl"] .sysrow { text-align: right; }

/* A page that replaces the tabs entirely: devices, and the device form */
#pageHeader { display: flex; align-items: center; gap: 8px; padding: 14px 10px 12px; }
#pageHeader .ttl { flex: 1; text-align: center; font-size: 1.1rem; font-weight: 700; }
#pageHeader .side { width: 42px; flex: none; display: flex; justify-content: center; }
/* Bare glyphs here, not the round buttons the main header uses */
#pageHeader .icon-btn { background: none; color: var(--text); }
.pagerule { height: 1px; background: var(--line); margin-bottom: 6px; }

/* One system in the list */
.devrow {
  position: relative; background: var(--card); border-radius: var(--radius);
  padding: 18px 16px 14px; margin-bottom: 12px;
}
.devrow .nm { font-weight: 700; padding-inline-end: 34px; word-break: break-word; }
.devrow.current { outline: 2px solid var(--accent); }
.devrow .edit {
  position: absolute; inset-inline-end: 10px; bottom: 8px;
  background: none; border: 0; padding: 6px; color: var(--muted); cursor: pointer;
}

/* The add button floats over the list, as it does on the phone app */
.fab {
  position: absolute; inset-inline-end: 18px; bottom: 18px; z-index: 5;
  width: 58px; height: 58px; border-radius: 18px; padding: 0;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}

.readonly { background: var(--card); color: var(--muted); }

/* One slot in the user list. The panel has a fixed 32 of them, so free slots
   are shown dimmed rather than hidden behind an add button: which numbers are
   free is part of what you came to find out. */
.usrow {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--card); border: 0; border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 9px;
  font: inherit; color: inherit; text-align: start; cursor: pointer;
}
.usrow .num { width: 24px; flex: none; color: var(--muted); font-size: .76rem; font-weight: 700; }
.usrow .grow { flex: 1; min-width: 0; }
.usrow .nm { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usrow .sub { display: block; font-size: .78rem; color: var(--muted); }
.usrow.empty { opacity: .5; }
.usrow .tag {
  flex: none; font-size: .67rem; font-weight: 700; padding: 3px 8px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.usrow > svg { flex: none; opacity: .4; }
[dir="rtl"] .usrow > svg { transform: scaleX(-1); }

/* A box you tick. The same idea as .toggle, small enough to sit eight to a
   card, which is what the permission and reporting lists need. */
.chk {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 2px; font: inherit; color: inherit; text-align: start;
}
.chk .box {
  width: 22px; height: 22px; flex: none; border-radius: 7px;
  border: 2px solid var(--line); display: grid; place-items: center; color: var(--on-accent);
}
.chk.on .box { background: var(--accent); border-color: var(--accent); }
.chk .box svg { width: 14px; height: 14px; stroke-width: 3.4; opacity: 0; }
.chk.on .box svg { opacity: 1; }
.chk .lb { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ticks read faster as a grid than as a long column */
.chkgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }

/* A tick that can be changed, rather than one that only reports */
button.chk { border: 0; background: none; cursor: pointer; }
button.chk:active .box { border-color: var(--accent); }

/* One remote key: which key, what it does, and to what */
.keyrow { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.keyrow .kn { width: 46px; flex: none; font-size: .76rem; font-weight: 700; color: var(--muted); }
.keyrow select { flex: 1; min-width: 0; padding: 10px 9px; font-size: .84rem; }

.cardttl {
  font-size: .72rem; font-weight: 700; color: var(--muted);
  letter-spacing: .05em; text-transform: uppercase; margin: 0 0 2px;
}

/* What a setting is, and what the panel says it is. Values wrap rather than
   being cut: a phone number or a remote's serial is no use half shown. */
.inforow {
  display: flex; align-items: baseline; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.inforow:last-child { border-bottom: 0; }
.inforow .k { flex: none; font-size: .82rem; color: var(--muted); }
.inforow .v { flex: 1; text-align: end; font-weight: 600; word-break: break-word; }

/* The same row, when tapping it changes what it says */
button.inforow {
  width: 100%; font: inherit; color: inherit; background: none;
  border: 0; border-bottom: 1px solid var(--line); cursor: pointer; text-align: start;
}
button.inforow:last-child { border-bottom: 0; }
button.inforow svg { flex: none; width: 16px; height: 16px; opacity: .4; }
button.inforow:active .v { opacity: .55; }
[dir="rtl"] button.inforow svg { transform: scaleX(-1); }

/*
 * The Save bar. Sits at the foot of the screen rather than the foot of the
 * form, because a user with a remote and both reporting channels open is a
 * long way from the bottom and should not have to scroll back to it.
 */
.savebar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; gap: 10px; padding: 12px 0 4px;
  background: linear-gradient(to top, var(--bg) 62%, transparent);
}
.savebar > * { flex: 1; }

/* A setting chosen from a list rather than typed */
.selrow { display: flex; align-items: center; gap: 12px; padding: 7px 0;
  border-bottom: 1px solid var(--line); }
.selrow:last-child { border-bottom: 0; }
.selrow .k { flex: none; font-size: .82rem; color: var(--muted); }
.selrow select { flex: 1; min-width: 0; padding: 9px; font-size: .85rem; }
header .tools { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 42px; height: 42px; border: 0; border-radius: 50%; padding: 0;
  background: var(--card); color: var(--text);
  cursor: pointer; display: inline-grid; place-items: center; flex: none;
  line-height: 0;
}
.icon-btn svg { display: block; }
.icon-btn:active { background: var(--line); }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
label { display: block; font-size: .8rem; color: var(--muted); margin: 12px 0 6px; }
input, select {
  width: 100%; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); color: var(--text); font: inherit;
}
/* Sign-in boxes: the text sits in the middle; dir="auto" on them makes the caret and the text follow what is typed */
input.ctr { text-align: center; }
input.ctr::placeholder { text-align: center; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 0; border-radius: 12px; padding: 13px 16px;
  background: linear-gradient(180deg, var(--btn-a), var(--btn-b)); color: var(--on-accent);
}
button.secondary { background: var(--card); color: var(--text); }
button.ghost { background: transparent; color: var(--accent); padding: 8px; }
button:disabled { opacity: .45; cursor: default; }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }

.msg { padding: 11px 14px; border-radius: 12px; margin-bottom: 12px; font-size: .87rem; }
.msg.ok { background: var(--armed-soft); color: var(--armed); }
.msg.err { background: var(--disarmed-soft); color: var(--disarmed); }

/*
 * The command result floats over the foot of the screen instead of sitting in
 * the flow at the top: as a block it pushed the tiles and buttons down every
 * time it appeared, so the thing you were about to press moved as you pressed
 * it. Anchored to the shell, so it stays inside the phone on a desktop.
 */
#msg {
  position: absolute; inset-inline: 16px; bottom: 96px; z-index: 15;
  margin: 0; text-align: center; pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .13);
  animation: msgin .18s ease both;
}
@keyframes msgin {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
/* Without the tab bar there is nothing to clear, so it sits lower */
.shell:not(:has(nav:not([hidden]))) #msg { bottom: 24px; }
[hidden] { display: none !important; }

.badge { font-size: .72rem; padding: 3px 10px; border-radius: 999px; background: var(--card); color: var(--muted); }
.badge.on { background: var(--armed-soft); color: var(--armed); }
.badge.off { background: var(--disarmed-soft); color: var(--disarmed); }

.statusline { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
/* The panel being reachable and our own connection being up are two different
   things, so they get two different marks rather than one ambiguous word. */
.livedot { width: 8px; height: 8px; border-radius: 50%; background: var(--track); flex: none; }
.livedot.up { background: var(--armed); }

.strip { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.chip {
  flex: 1; text-align: center; background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 9px 12px; font-weight: 600;
}
.arrow {
  width: 36px; height: 36px; border-radius: 50%; padding: 0; flex: none;
  background: transparent; color: var(--text);
  display: inline-grid; place-items: center; line-height: 0;
}
.arrow svg { display: block; }
/*
 * In Persian the row reads from the right, so "previous" is the button on the right and "next" the one on
 * the left: the arrows are mirrored with it, like the chevron of a user row above. The back arrow of a page
 * header points the way back, which is to the right.
 */
[dir="rtl"] .arrow svg, [dir="rtl"] #pageBack svg { transform: scaleX(-1); }

/*
 * One row, shared out between whatever is on show: four areas get a quarter
 * each, a single area gets the whole width.
 *
 * minmax(0, 1fr) rather than a plain 1fr, which means minmax(auto, 1fr) and
 * will not let a track shrink below its own content. A long area name was
 * therefore widening its column until the whole row ran off the side of the
 * screen. With a zero minimum the quarters are real quarters and the name
 * wraps inside its tile instead of deciding how wide the tile is.
 */
.tiles {
  display: grid; grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 8px; margin-bottom: 20px;
}
.tile {
  background: var(--card); border: 2px solid transparent; border-radius: var(--radius);
  padding: 16px 6px; text-align: center; cursor: pointer;
}
.tile.armed { background: var(--armed-soft); }
.tile.disarmed { background: var(--disarmed-soft); }
.tile.alarm { background: var(--surface); border-color: var(--disarmed); animation: pulse 1.4s infinite; }
.tile .glyph { line-height: 1; }
.tile .nm {
  font-size: .82rem; margin-top: 8px;
  /* Breaks a long name across lines rather than letting it widen the tile,
     and stops at two so four tiles keep the same height */
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile .st { font-size: .85rem; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.tile.armed .st { color: var(--armed); }
.tile.disarmed .st, .tile.alarm .st { color: var(--disarmed); }

@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .55 } }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.actions.trio { grid-template-columns: 1fr 2fr 1fr; }
.act {
  background: var(--card); border-radius: var(--radius); padding: 16px 6px;
  text-align: center; font-weight: 600; font-size: .82rem; color: var(--text);
}
.act svg { display: block; width: 26px; height: 26px; margin: 0 auto 6px; }
.tile svg { width: 30px; height: 30px; }
.ov svg { width: 40px; height: 40px; }
svg { stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
/* The artwork taken from the Android app is drawn filled, not stroked */
svg.filled { stroke: none; fill: currentColor; }
/* Three dots drawn as round caps on hairline strokes came out almost
   invisible; they need a weight of their own rather than a bigger box. */
.i-kebab { stroke-width: 3.2; }
.act.trouble { background: var(--surface); border: 2px solid var(--disarmed); color: var(--disarmed); }
.act.quiet { background: var(--surface); border: 2px solid var(--line); color: var(--muted); }

.listrow {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
}
.listrow .nm { font-weight: 700; }
.listrow .val { font-weight: 600; }
.star { background: none; border: 0; padding: 4px; cursor: pointer; font-size: 1.15rem; color: var(--text); }

.toggle { width: 52px; height: 30px; border-radius: 999px; background: var(--track); position: relative; border: 0; padding: 0; cursor: pointer; flex: none; direction: ltr; }
.toggle.on { background: var(--accent); }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--knob); transition: transform .15s; }
.toggle.on::after { transform: translateX(22px); }

/* Held still while the panel is asked what really happened. Declared after
   .toggle.on so it wins on the same specificity whichever way it was set. */
.toggle.pending { background: var(--track-pending); cursor: default; animation: breathe 1.1s ease-in-out infinite; }
.toggle.pending::after { background: var(--knob-pending); }
@keyframes breathe { 50% { opacity: .5; } }

/* Every card the height of the fullest one, so the list does not jump around
   as areas gain and lose their "who did it" lines. */
.ov {
  display: flex; align-items: center; gap: 14px; border-radius: var(--radius);
  padding: 18px; margin-bottom: 12px; background: var(--card);
  min-height: var(--ov-height, 112px);
}
.ov.armed { background: var(--armed-soft); }
.ov.disarmed { background: var(--disarmed-soft); }
.ov.alarm { background: var(--surface); border: 2px solid var(--disarmed); }
.ov .glyph { flex: none; }
/* The state of an area is shown in its own colour, as in the Android app */
.tile.armed .glyph, .ov.armed .glyph { color: var(--armed); }
.tile.disarmed .glyph, .ov.disarmed .glyph, .tile.alarm .glyph, .ov.alarm .glyph { color: var(--disarmed); }
.ov .state { font-size: 1.2rem; font-weight: 700; }
.ov.armed .state { color: var(--armed); }
.ov.disarmed .state, .ov.alarm .state { color: var(--disarmed); }
.ov.alarm .nm, .ov.alarm .why { color: var(--disarmed); }

.logitem {
  display: flex; gap: 12px; padding: 13px 16px; margin-bottom: 9px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair), var(--lift);
}
.logitem.alarm { background: var(--disarmed-soft); }
.logitem .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--muted); }
.logitem.alarm .dot { background: var(--disarmed); }
.logitem.warning .dot { background: var(--warning); }

/* Part of the frame rather than pinned to the window, so it sits on the
   rounded edge instead of floating over it */
nav {
  flex: none; background: var(--bg);
  border-top: 1px solid var(--line); display: flex; justify-content: space-around;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
@media (min-width: 620px) {
  nav { border-radius: 0 0 26px 26px; }
}
/* Six tabs have to share a phone's width, so each one takes an equal share
   and clips its own label rather than pushing the row wider than the screen */
nav button {
  flex: 1; min-width: 0; max-width: 84px;
  background: none; color: var(--muted); font-size: .68rem; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; border-radius: 999px;
}
nav .navlabel { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav button svg { width: 22px; height: 22px; }
nav button.active { background: var(--nav-active); color: var(--text); }

.scrim { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: 20px; z-index: 20; }
.modal { background: var(--surface); border-radius: 22px; padding: 22px; width: 100%; max-width: 420px; max-height: 85vh; overflow: auto; }
.modal h2 { margin: 0 0 4px; font-size: 1.15rem; text-align: center; }
.modal .sub { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 16px; }
.modal .foot { display: flex; gap: 10px; margin-top: 20px; }
.modal .foot > * { flex: 1; }

.alarmfull { position: fixed; inset: 0; background: #b3261e; color: #fff; z-index: 30; display: grid; place-items: center; text-align: center; padding: 30px; }
.alarmfull .bell {
  width: 130px; height: 130px; border-radius: 50%; background: #fff; color: #b3261e;
  display: grid; place-items: center; margin: 0 auto 24px;
  animation: ring 1.1s ease-in-out infinite;
}
.alarmfull .bell svg { width: 62px; height: 62px; stroke-width: 1.6; }
@keyframes ring {
  0%, 100% { transform: rotate(0) scale(1); }
  10% { transform: rotate(-16deg) scale(1.06); }
  20% { transform: rotate(14deg) scale(1.06); }
  30% { transform: rotate(-11deg) scale(1.04); }
  40% { transform: rotate(9deg) scale(1.03); }
  50% { transform: rotate(0) scale(1.02); }
}
.alarmfull::before {
  content: ""; position: absolute; inset: 0; background: #7f1d1d;
  animation: flash 1.1s steps(1) infinite; z-index: -1;
}
@keyframes flash { 0%, 49% { opacity: 0 } 50%, 100% { opacity: .5 } }
.alarmfull .pill { display: inline-block; background: #fff; color: #18181b; font-weight: 700; padding: 8px 26px; border-radius: 999px; letter-spacing: .06em; }
.alarmfull h1 { font-size: 1.4rem; margin: 26px 0 6px; }

/*
 * Shown while the first panel list is on its way, then faded out. It sits
 * inside the shell rather than over the page so that on a desktop the app
 * opens as the same rounded phone it is about to become, instead of the
 * window going blank white first.
 */
/*
 * White whatever the theme is. The mark is drawn as two overlapping shapes
 * with the gap between them left open, so the page behind it becomes part of
 * the logo -- on a dark ground it stops reading as a mark at all.
 */
#splash {
  position: absolute; inset: 0; background: #fff; z-index: 40;
  border-radius: inherit;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  /* Sits low rather than centred, as the Android app's does */
  padding-bottom: 26%;
  transition: opacity .35s ease;
}
/*
 * The mark is 780x738, near enough square but not quite. Width is what is
 * capped and height:auto keeps its real ratio, rather than a fixed height
 * forcing it square; the percentage keeps it off the edges of a narrow phone.
 */
#splash img { width: min(132px, 34%); height: auto; animation: rise .5s ease both; }

/*
 * The name is text rather than part of the image: it stays sharp at any
 * density, and it is the one word on this screen a screen reader should say.
 * Always Latin, always this weight -- it is a name, not a label, so it is
 * neither translated nor themed.
 */
#splash .name {
  margin-top: 18px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 2rem; font-weight: 700; letter-spacing: -.01em;
  color: #303030;
  animation: rise .5s .06s ease both;
}
#splash.gone { opacity: 0; pointer-events: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/*
 * Keyboard users need to see where they are. :focus-visible shows the ring for the keyboard and not for
 * a tap or a click, so nothing changes for the thumb.
 */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline-offset: 0; }

/*
 * Whoever has asked their system for less motion gets a still page. The alarm's flashing stays: it is
 * not decoration, it is the warning.
 */
@media (prefers-reduced-motion: reduce) {
  #splash img, #splash .name, .msg, .toggle.pending, .toggle::after { animation: none !important; transition: none !important; }
}

/* ==================================================================== glass
 * The panes. Cards and rows are translucent with a rim and a soft lift; only what floats over moving
 * content -- the tab bar, the dialogs, the sign-in card -- also blurs what is behind it, because a blur on
 * every one of 32 user rows costs a phone more than it shows on a smooth wallpaper.
 */
.card, .tile, .act, .ov, .listrow, .usrow, .devrow, .sysrow, button.secondary {
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair), var(--lift);
}
.badge, .icon-btn { box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair); }
.tile.alarm, .ov.alarm, .act.trouble, .act.quiet { box-shadow: var(--lift); }
.sysrow.current, .devrow.current { outline: 0; box-shadow: inset 0 0 0 2px var(--accent), var(--lift); }
#pageHeader .icon-btn { box-shadow: none; }

/* Something pressed gives a little, as a real pane would */
.tile, .act, .usrow, .sysrow, .listrow, button.inforow, .icon-btn, button, nav button {
  transition: transform .18s cubic-bezier(.2, .8, .2, 1), background-color .2s, box-shadow .2s, opacity .2s, color .2s;
}
.tile:active, .act:active, .usrow:active, .sysrow:active, button:active:not(:disabled):not(.toggle) { transform: scale(.97); }

input, select {
  background: var(--surface); border: 0; border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--hair);
  transition: background-color .2s, box-shadow .2s;
}
input:focus, select:focus {
  outline: 0; box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-soft);
}
input::placeholder { color: var(--muted); opacity: .7; }

select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  color: var(--text);
  background-image: var(--chevron); background-repeat: no-repeat; background-size: 16px;
  background-position: left 12px center;
  padding-inline-end: 36px;
}
[dir="ltr"] select { background-position: right 12px center; }
.keyrow select, .selrow select { padding-inline-end: 34px; background-size: 14px; }
select option, select optgroup { background-color: var(--option-bg); color: var(--text); }

/* The main action: a blue pane with light along its top edge */
button { border-radius: 14px; }
button.primary, .modal .foot button:not(.secondary):not(.ghost), #authBtn, #addPanelBtn, .savebar button:not(.secondary):not(.ghost) {
  background: linear-gradient(180deg, var(--btn-a), var(--btn-b));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 10px 22px -12px rgba(31, 107, 255, .8);
}
button.secondary { background: var(--card); }
button:disabled { box-shadow: none !important; }

.toggle { box-shadow: inset 0 0 0 1px var(--hair); }
.toggle.on { background: linear-gradient(180deg, var(--btn-a), var(--btn-b)); }
.toggle::after { box-shadow: 0 2px 6px rgba(0, 0, 0, .22); transition: transform .28s cubic-bezier(.3, 1.4, .5, 1); }

.chk .box { border-color: var(--track); transition: background-color .15s, border-color .15s; }

.fab {
  background: linear-gradient(180deg, var(--btn-a), var(--btn-b)); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 14px 28px -12px rgba(31, 107, 255, .8);
}

/* The save bar floats over the end of a long form, on a strip of frosted glass */
.savebar {
  background: transparent; margin: 0 -16px; padding: 12px 16px calc(8px + env(safe-area-inset-bottom));
  -webkit-backdrop-filter: blur(18px) saturate(170%); backdrop-filter: blur(18px) saturate(170%);
  -webkit-mask: linear-gradient(to top, #000 78%, transparent); mask: linear-gradient(to top, #000 78%, transparent);
}

/* The result of a command: a small glass capsule over the foot of the screen */
#msg {
  border-radius: 16px; -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--rim), var(--lift-strong);
}
.msg { border-radius: 14px; }

.inforow, button.inforow, .selrow { border-bottom-color: var(--line); }
.pagerule { background: var(--line); }

/* ---- Headers: no bar of their own, the wallpaper runs up under them ---- */
header { padding: 16px 18px 6px; }
header .title { font-weight: 800; }
#pageHeader .ttl { font-weight: 800; }

/* The name of the system and its state sit in a pane of their own, like the buttons beside them */
#appHeader { align-items: center; }
/* The name of the app, in the middle of the row between the system's name and the buttons */
#appHeader .brand {
  flex: 1 0 auto; display: flex; justify-content: center; align-items: center; gap: 7px;
  font-weight: 800; font-size: 1.05rem; letter-spacing: .02em; color: var(--name); line-height: 1;
}
#appHeader .brand img { width: 24px; height: auto; filter: drop-shadow(0 3px 6px rgba(30, 80, 190, .2)); }
#appHeader > .grow {
  flex: 0 1 auto; padding: 8px 16px 9px; border-radius: 22px;
  background: var(--card);
  -webkit-backdrop-filter: blur(18px) saturate(170%); backdrop-filter: blur(18px) saturate(170%);
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair), var(--lift);
}
#appHeader .title { font-size: 1.15rem; line-height: 1.5; }
#appHeader .statusline { margin-top: 2px; }
#pageHeader .ttl {
  flex: 0 1 auto; margin: 0 auto; padding: 8px 18px; border-radius: 20px; font-size: 1rem;
  background: var(--card);
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair), var(--lift);
}

/* ---- The tab bar: a floating pane, with a pill that slides to the chosen tab ---- */
nav {
  position: relative; flex: none; margin: 0 12px calc(10px + env(safe-area-inset-bottom)); padding: 6px;
  border: 0; border-radius: 26px;
  background: var(--card);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair), var(--lift-strong);
}
@media (min-width: 620px) {
  nav { border-radius: 26px; margin-bottom: 12px; }
}
nav button { position: relative; z-index: 1; border-radius: 20px; padding: 7px 4px; }
nav button.active { background: transparent; color: var(--accent); }
nav .navpill {
  position: absolute; top: 6px; bottom: 6px; left: 0; width: 0; z-index: 0; border-radius: 20px;
  background: var(--nav-active);
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair), 0 4px 12px -6px rgba(20, 50, 120, .3);
  transform-origin: 50% 50%;
}

/*
 * Only the tab you are on says its name: the others are icons alone. The chosen one takes more of the bar,
 * with its icon and name side by side inside the pill; the name opens out rather than popping in.
 */
nav { align-items: center; gap: 2px; }
nav button {
  flex: 1 1 0; max-width: none; height: 48px; padding: 0 10px;
  flex-direction: row; justify-content: center; align-items: center; gap: 0;
  color: var(--muted); font-size: .8rem; font-weight: 700;
}
nav button svg { width: 22px; height: 22px; flex: none; }
nav button .navlabel { display: none; white-space: nowrap; }
/*
 * The chosen tab is as wide as its icon and its whole name, never cut; the others share what is left.
 * Its width is there at once (only the name fades in), so the pill can be sent straight to it.
 */
nav button.active { flex: 0 0 auto; color: var(--accent); padding: 0 16px; }
nav button.active .navlabel { display: block; margin-inline-start: 7px; animation: labelin .3s .06s ease both; }
@keyframes labelin { from { opacity: 0; transform: translateX(-4px); } }
[dir="rtl"] nav button.active .navlabel { animation-name: labelin-rtl; }
@keyframes labelin-rtl { from { opacity: 0; transform: translateX(4px); } }
nav .navpill { top: 50%; bottom: auto; height: 48px; margin-top: -24px; border-radius: 22px; }
nav button { border-radius: 22px; }

/*
 * Liquid glass: the bar floats over the content, which scrolls on underneath it and shows through,
 * blurred and brightened. The rim is a gradient border, bright where light would catch the top edge; the
 * pill on the chosen tab is a lens of clearer glass with its own highlight.
 */
nav {
  position: absolute; z-index: 6; margin: 0; border-radius: 30px;
  inset-inline: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--bar);
  -webkit-backdrop-filter: blur(12px) saturate(230%) brightness(1.06); backdrop-filter: blur(12px) saturate(230%) brightness(1.06);
  box-shadow: inset 0 1px 0 var(--edge-top), inset 0 -1px 0 var(--edge-bottom), 0 14px 34px -14px rgba(20, 50, 120, .32);
}
/* The sheen: light lying on the upper half of the glass, fading out before the middle */
nav::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, var(--sheen), transparent 55%);
}
nav .navpill {
  background: var(--lens);
  box-shadow: inset 0 1.5px 1px var(--lens-rim), inset 0 -1px 2px var(--edge-bottom), inset 0 0 0 1px var(--edge-bottom),
    0 6px 16px -8px rgba(20, 50, 120, .35);
}
@media (min-width: 620px) {
  nav { margin: 0; bottom: 12px; }
}
/* Room at the end of every tab for the bar that floats over it, and for the result capsule above that */
.shell:has(nav:not([hidden])) .wrap > .inner { padding-bottom: 92px; }

/* ---- Dialogs: a sheet of glass over a blurred page ---- */
.scrim { -webkit-backdrop-filter: blur(6px) saturate(140%); backdrop-filter: blur(6px) saturate(140%); }
.modal {
  background: var(--sheet); border-radius: 28px;
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair), var(--lift-strong);
}
.modal h2 { font-weight: 800; }
.scrim.fresh { animation: fadein .22s ease both; }
.scrim.fresh .modal { animation: popin .34s cubic-bezier(.2, 1.1, .3, 1) both; }
@keyframes fadein { from { opacity: 0; } }
@keyframes popin { from { opacity: 0; transform: translateY(14px) scale(.96); } }

/* ---- Moving between screens and tabs: the new one rises into place ---- */
.view-in { animation: viewin .34s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes viewin { from { opacity: 0; transform: scale(.985); } }

/* ---- Splash: the name of the app on the light wallpaper, whatever the theme ---- */
#splash {
  background:
    radial-gradient(90% 42% at 50% 0, rgba(70, 135, 255, .26), transparent 70%),
    linear-gradient(180deg, #dfe9ff 0%, #edf2fd 45%, #f6f8fd 100%);
}
#splash img { width: min(108px, 30%); filter: drop-shadow(0 8px 16px rgba(30, 80, 190, .22)); }
#splash .name {
  font-family: "Vazirmatn", system-ui, sans-serif; font-weight: 800; font-size: 2.1rem;
  letter-spacing: .02em; color: #1d58c4;
}

/* ==================================================================== sign-in */
/* The scroller's content is at least as tall as the scroller, so the sign-in screen can fill exactly that */
.wrap > .inner { min-height: 100%; display: flex; flex-direction: column; }
.wrap > .inner > * { flex: none; }
#authView:not([hidden]) { flex: 1 0 auto; display: flex; flex-direction: column; }
/* The sign-in screen alone keeps the soft blue light at the top */
.shell:has(#authView:not([hidden])) { background: var(--wall), var(--bg); }
#authView .top { display: flex; justify-content: flex-start; padding-top: 2px; }
#authView .langchip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 99px;
  direction: ltr; font-size: .78rem; font-weight: 500; color: var(--muted); text-decoration: none;
  background: var(--card);
  -webkit-backdrop-filter: blur(20px) saturate(170%); backdrop-filter: blur(20px) saturate(170%);
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair);
}
#authView .langchip::before {
  content: ""; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: var(--globe) center / contain no-repeat; mask: var(--globe) center / contain no-repeat;
  --globe: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3c3 3.2 3 14.8 0 18M12 3c-3 3.2-3 14.8 0 18'/%3E%3C/svg%3E");
}
#authView .mid { margin: auto 0; padding: 12px 6px; }
.hero { text-align: center; margin: 0 0 28px; }
.hero-mark { display: block; width: 62px; height: auto; margin: 0 auto 12px; filter: drop-shadow(0 6px 12px rgba(30, 80, 190, .22)); }
.hero-name { margin: 0; font-weight: 800; font-size: 1.75rem; line-height: 40px; letter-spacing: .02em; color: var(--name); }

/* The pane: its rim is a gradient border, bright at the top edge and fading down the sides */
.authcard {
  position: relative; margin: 0; padding: 24px 20px 20px; border-radius: 28px;
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--lift-strong);
}
.authcard::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(180deg, var(--rim), transparent 45%, transparent 80%, var(--rim));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fld { position: relative; }
/* A hidden label and the hint sit between the two boxes, so it is "any later box", not "the next one" */
.fld ~ .fld { margin-top: 12px; }
.fld input { height: 52px; padding: 0 44px; border-radius: 15px; font-size: 1rem; }
.fld .eye {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; padding: 0; border-radius: 12px; background: transparent; color: var(--muted);
  display: grid; place-items: center; box-shadow: none;
}
.fld .eye:active { transform: translateY(-50%) scale(.92); }
.fld .eye svg { width: 19px; height: 19px; }
.fld .eye[aria-pressed="true"] { color: var(--accent); }
#phoneHint { margin: 8px 4px 0; line-height: 20px; min-height: 40px; }
#authView #forgotRow { margin: 10px 4px 0; text-align: start; }
#authView #forgotRow a { color: var(--muted); text-decoration: none; font-size: .8rem; line-height: 20px; }
.authcard #authBtn { width: 100%; height: 52px; padding: 0; margin-top: 16px; font-size: 1rem; font-weight: 700; border-radius: 15px; }
#authView .alt { margin: 18px 0 0; text-align: center; }
#authView .textlink {
  background: none; border: 0; padding: 4px 6px; box-shadow: none;
  font-size: .86rem; font-weight: 600; color: var(--accent); line-height: 20px;
}
.by { display: flex; justify-content: center; align-items: center; height: 34px; margin: 22px 0 4px; line-height: 0; opacity: .8; }
.by img { height: 34px; width: auto; }

@media (prefers-reduced-motion: reduce) {
  .view-in, .scrim.fresh, .scrim.fresh .modal { animation: none !important; }
  nav .navpill, .toggle::after, button, .tile, .act { transition: none !important; }
}

/* ---- Top bars: the same floating glass as the tab bar; the content scrolls on underneath them ---- */
#appHeader, #pageHeader {
  position: absolute; z-index: 6; top: 10px; inset-inline: 12px; margin: 0;
  min-height: 70px; padding: 12px 10px; border-radius: 28px; gap: 6px;
  background: var(--bar);
  -webkit-backdrop-filter: blur(12px) saturate(230%) brightness(1.06); backdrop-filter: blur(12px) saturate(230%) brightness(1.06);
  box-shadow: inset 0 1px 0 var(--edge-top), inset 0 -1px 0 var(--edge-bottom), 0 14px 34px -14px rgba(20, 50, 120, .32);
}
#appHeader { padding-inline-start: 18px; }
#appHeader::before, #pageHeader::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, var(--sheen), transparent 55%);
}
#appHeader > *, #pageHeader > * { position: relative; }
/* Inside one pane, no panes of their own */
#appHeader > .grow, #pageHeader .ttl {
  padding: 0; background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
}
#pageHeader .ttl { flex: 1; font-size: 1.05rem; }
#appHeader .icon-btn, #pageHeader .icon-btn { background: transparent; box-shadow: none; width: 42px; height: 42px; }
#appHeader .icon-btn:active, #pageHeader .icon-btn:active { background: var(--lens); box-shadow: inset 0 1px 1px var(--lens-rim); }
/* Room above every screen for the bar floating over it, with air between the two */
.shell:has(#appHeader:not([hidden])) .wrap > .inner,
.shell:has(#pageHeader:not([hidden])) .wrap > .inner { padding-top: 110px; }

/* ---- Schedules ---- */
.schedrow { cursor: pointer; padding: 14px 16px; }
.schedrow.paused { opacity: .55; }
.schedrow .sr-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.schedrow .sr-time { font-size: 1.7rem; font-weight: 800; letter-spacing: .02em; line-height: 1.1; }
.schedrow .sr-days { display: flex; gap: 5px; margin: 10px 0 8px; }
.schedrow .sr-days span {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: .78rem; font-weight: 700; color: var(--muted); background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair);
}
.schedrow .sr-days span.on { color: #fff; background: linear-gradient(180deg, var(--btn-a), var(--btn-b)); box-shadow: none; }
.schedrow .sr-what { font-size: .95rem; }
.schedrow .sr-foot { margin-top: 6px; }
.schedrow .sr-foot .bad { color: var(--disarmed); }
.schedrow .sr-foot .good { color: var(--armed); }

.daypick { display: flex; gap: 6px; justify-content: space-between; }
.daychip {
  flex: 1; height: 42px; padding: 0; border-radius: 13px; font-weight: 700; font-size: .9rem;
  background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1px var(--hair);
}
.daychip.on { background: linear-gradient(180deg, var(--btn-a), var(--btn-b)); color: #fff; box-shadow: 0 6px 14px -8px rgba(31, 107, 255, .8); }
.timepick { align-items: center; gap: 8px; }
.timepick select { text-align: center; font-size: 1.15rem; font-weight: 700; }
.timepick .colon { flex: none; font-size: 1.3rem; font-weight: 800; }
.modal .foot #schDelete { flex: 0.8; }

#schCode::placeholder { letter-spacing: normal; }

/*
 * The language and theme capsules stay in the same corner whichever language the page is in: they are
 * how you change it, and a control that jumps to the other side when pressed is hard to press twice.
 */
#authView .top { direction: ltr; justify-content: flex-start; gap: 8px; }
#authView .themechip { border: 0; cursor: pointer; font: inherit; font-size: .78rem; font-weight: 500; }
#authView .themechip::before {
  --globe: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 3a9 9 0 0 0 0 18z' fill='black'/%3E%3C/svg%3E");
}
#authView .themechip[data-mode="light"]::before {
  --globe: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E");
}
#authView .themechip[data-mode="dark"]::before {
  --globe: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z'/%3E%3C/svg%3E");
}
.by { height: 46px; }
.by img { height: 46px; }

.forpick { gap: 10px; }
.forpick .unit { flex: 1; display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: .85rem; }
.forpick input { text-align: center; font-size: 1.1rem; font-weight: 700; }
.forpick input::-webkit-outer-spin-button, .forpick input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.forpick input[type=number] { -moz-appearance: textfield; }

/* The two buttons of the top bar sit as a pair rather than as two separate things */
#appHeader .tools { gap: 0; }
#appHeader .tools .icon-btn { width: 38px; }

/* ---- The picker: a drop-down's choices on a sheet of glass (picker.js) ---- */
.pick-scrim {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: var(--scrim); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: fadein .18s ease both;
}
.pick-sheet {
  width: 100%; max-width: 360px; max-height: min(70vh, 520px); display: flex; flex-direction: column;
  padding: 16px 12px 12px; border-radius: 28px;
  background: var(--sheet);
  -webkit-backdrop-filter: blur(18px) saturate(180%); backdrop-filter: blur(18px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair), var(--lift-strong);
  animation: popin .3s cubic-bezier(.2, 1.1, .3, 1) both;
}
.pick-scrim.closing { animation: fadeout .16s ease both; }
.pick-scrim.closing .pick-sheet { animation: popout .16s ease both; }
@keyframes fadeout { to { opacity: 0; } }
@keyframes popout { to { opacity: 0; transform: scale(.96); } }
.pick-title { text-align: center; font-weight: 800; font-size: 1rem; margin: 0 0 12px; color: var(--text); }
.pick-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 2px; }
.pick-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 13px 16px; border-radius: 16px; text-align: start;
  background: var(--card); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--hair);
}
.pick-item.on {
  background: linear-gradient(180deg, var(--btn-a), var(--btn-b)); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 18px -10px rgba(31, 107, 255, .8);
}
.pick-item.on::after {
  content: ""; width: 18px; height: 18px; flex: none; background: currentColor;
  -webkit-mask: var(--tick) center / contain no-repeat; mask: var(--tick) center / contain no-repeat;
  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
.pick-sheet.grid .pick-list { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pick-sheet.grid .pick-item { justify-content: center; padding: 12px 0; font-size: 1rem; font-variant-numeric: tabular-nums; }
.pick-sheet.grid .pick-item.on::after { display: none; }
.pick-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- Clearer glass: less frosting, more of what is behind showing through ---- */
:root { --card: rgba(255, 255, 255, .46); --sheet: rgba(246, 249, 255, .62); }
:root[data-theme="dark"] { --card: rgba(255, 255, 255, .055); --sheet: rgba(22, 32, 60, .6); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --card: rgba(255, 255, 255, .055); --sheet: rgba(22, 32, 60, .6); }
}
nav, #appHeader, #pageHeader {
  -webkit-backdrop-filter: blur(6px) saturate(200%) brightness(1.05); backdrop-filter: blur(6px) saturate(200%) brightness(1.05);
}
.modal { -webkit-backdrop-filter: blur(16px) saturate(180%); backdrop-filter: blur(16px) saturate(180%); }
.authcard { -webkit-backdrop-filter: blur(16px) saturate(180%); backdrop-filter: blur(16px) saturate(180%); }

/* The picker sits over a dialog that is glass too: a little more body, so the two do not read as one */
.pick-sheet { background: var(--pick-bg); }
:root { --pick-bg: rgba(246, 249, 255, .86); }
:root[data-theme="dark"] { --pick-bg: rgba(20, 30, 56, .88); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --pick-bg: rgba(20, 30, 56, .88); } }

/* ---- Time wheels (schedules.js): three rows, the middle one is the value ---- */
.wheels {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 132px; padding: 0 18px; border-radius: 22px;
  background: var(--card);
  -webkit-backdrop-filter: blur(10px) saturate(180%); backdrop-filter: blur(10px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair);
}
/* The band the chosen numbers sit in, across both wheels */
.wheels::before {
  content: ""; position: absolute; left: 10px; right: 10px; top: 50%; height: 40px; margin-top: -20px;
  border-radius: 13px; background: var(--accent-soft); pointer-events: none;
}
.wheels .colon { position: relative; font-size: 1.45rem; font-weight: 800; color: var(--accent); padding-bottom: 3px; }
.wheel { position: relative; width: 80px; height: 132px; }
.wheel-scroll {
  height: 100%; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior: contain; outline: 0;
  -webkit-mask: linear-gradient(transparent, #000 35%, #000 65%, transparent);
  mask: linear-gradient(transparent, #000 35%, #000 65%, transparent);
}
.wheel-scroll::-webkit-scrollbar { display: none; }
.wheel-scroll:focus-visible { box-shadow: inset 0 0 0 1.5px var(--accent); border-radius: 13px; }
.wheel-pad { height: 46px; }
.wheel-item {
  height: 40px; display: grid; place-items: center; scroll-snap-align: center; cursor: pointer;
  font-size: 1.2rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums;
  transition: color .15s, font-size .15s;
}
.wheel-item.on { color: var(--text); font-size: 1.55rem; font-weight: 800; }

/* ---- Drop-downs as liquid glass: the closed box, and the sheet that opens from it ---- */
select {
  background-color: var(--card);
  -webkit-backdrop-filter: blur(10px) saturate(180%); backdrop-filter: blur(10px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair), 0 6px 16px -12px rgba(20, 50, 120, .35);
}
select:focus { box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-soft); }
:root { --pick-bg: rgba(246, 249, 255, .5); }
:root[data-theme="dark"] { --pick-bg: rgba(20, 30, 56, .5); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --pick-bg: rgba(20, 30, 56, .5); } }
.pick-scrim { -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.pick-sheet {
  -webkit-backdrop-filter: blur(22px) saturate(210%) brightness(1.05); backdrop-filter: blur(22px) saturate(210%) brightness(1.05);
  box-shadow: inset 0 1.5px 0 var(--rim), inset 0 -1px 0 var(--hair), 0 30px 60px -24px rgba(20, 50, 120, .45);
}
.pick-item { background: var(--card); box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair); }

/*
 * An app, not a page: its words are labels and buttons, so a long press or a drag does not select them
 * or bring up the copy menu. Fields stay selectable, since that is how text is corrected.
 */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img { -webkit-user-drag: none; user-drag: none; }
/* iOS zooms into any field whose text is smaller than 16px; at 16px it leaves the page alone */
input, select, textarea { font-size: max(16px, 1em); }

/*
 * The buttons of a dialog stay in sight. A long dialog (a schedule, a user's settings) scrolls under
 * them instead of carrying them off the bottom of a phone's screen.
 */
.modal .foot {
  position: sticky; bottom: -22px; z-index: 2;
  margin: 20px -22px -22px; padding: 12px 22px 22px;
  /* Only the buttons: no strip of their own behind them */
  background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
}
.modal .foot > button.secondary {
  -webkit-backdrop-filter: blur(14px) saturate(180%); backdrop-filter: blur(14px) saturate(180%);
}

/* ---- Operating by SMS (sms.js) ---- */
/* The bar over the dashboard saying commands now go by text message */
.smsbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 14px;
  border-radius: var(--radius); background: var(--card); color: var(--text);
  font-size: .85rem; font-weight: 600; line-height: 1.6;
  -webkit-backdrop-filter: blur(10px) saturate(180%); backdrop-filter: blur(10px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--rim), inset 0 0 0 1px var(--hair), var(--lift);
}
.smsbar > svg { width: 22px; height: 22px; color: var(--accent); flex: none; }
.smsbar .grow { flex: 1; }
.smsbar button { flex: none; padding: 8px 14px; font-size: .8rem; }
/* Siren off: one wide button, only while there is something to silence */
.act.bell {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  margin-bottom: 12px; padding: 14px; font-size: .92rem; background: var(--disarmed); color: #fff;
}
.act.bell svg { width: 22px; height: 22px; margin: 0; }
/* An area kept for SMS mode, whose state is not known */
.tile.unknown, .ov.unknown { background: var(--card); }
.tile.unknown .st, .tile.unknown .glyph, .ov.unknown .glyph, .ov.unknown .state { color: var(--muted); }
/* The message about to be sent, as it will read, with the code hidden */
.smsmsg {
  margin: 4px 0 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair); text-align: left;
}
.smsmsg .to { font-size: .8rem; color: var(--muted); }
.smsmsg .body { margin-top: 4px; font: 700 1.05rem/1.4 ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
/* Settings: every button one size, in one column, with the switch centred on the same column */
.setrow > button.secondary {
  flex: none; width: 112px; height: 44px; padding: 0 8px; font-size: .9rem; white-space: nowrap;
}
.setrow > .toggle { margin-inline: 30px; }
.setbtns > button { flex: 1; height: 48px; padding: 0 8px; font-size: .9rem; white-space: nowrap; }
.smsnote {
  margin-top: 14px; padding: 12px 14px; border-radius: 14px; font-size: .9rem; line-height: 1.8;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair);
}
.smsnote p { margin: 4px 0 0; }
/* The alarm screen's two buttons, alike in every way */
.alarmbtns { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 30px; }
.alarmfull .alarmbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 220px; padding: 13px 20px;
  border: 0; border-radius: 999px; background: #fff; color: #b3261e; font-weight: 800; font-size: .95rem;
}
.alarmfull .alarmbtn svg { width: 22px; height: 22px; }
