:root {
  color-scheme: dark;

  --bg: #080b10;
  --bg-2: #0d121a;
  --card: rgba(18, 24, 34, 0.78);
  --card-strong: rgba(22, 30, 42, 0.94);
  --card-soft: rgba(255, 255, 255, 0.055);
  --line: rgba(255, 255, 255, 0.105);

  --text: #f4f7fb;
  --text-soft: #a9b4c3;
  --muted: #728094;

  --green: #42e49d;
  --green-2: #18b978;
  --red: #ff5b6e;
  --red-2: #d6344d;
  --yellow: #ffd36a;
  --blue: #73a7ff;
  --purple: #9a7cff;

  --shadow: 0 28px 80px rgba(0, 0, 0, 0.44);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --ease: cubic-bezier(.2,.8,.2,1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at 20% -10%, rgba(115, 167, 255, 0.18), transparent 34%),
    radial-gradient(circle at 96% 12%, rgba(66, 228, 157, 0.13), transparent 34%),
    linear-gradient(180deg, #101722 0%, #080b10 42%, #07090d 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.027) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.027) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.65), transparent 72%);
}

.lm-bg-orb {
  position: fixed;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  filter: blur(54px);
  opacity: .48;
  pointer-events: none;
}

.lm-bg-orb-a {
  top: -110px;
  left: -90px;
  background: rgba(115, 167, 255, .42);
}

.lm-bg-orb-b {
  right: -130px;
  top: 230px;
  background: rgba(66, 228, 157, .28);
}

button,
input,
select {
  font: inherit;
}

button {
  position: relative;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.09), rgba(255,255,255,.035));
  color: var(--text);
  font-weight: 850;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  transition:
    transform 140ms var(--ease),
    border-color 140ms var(--ease),
    background 140ms var(--ease),
    opacity 140ms var(--ease);
}

button:active {
  transform: scale(.985);
}

button.primary {
  border: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.26), transparent 28%),
    linear-gradient(135deg, #41e39e 0%, #24bd82 45%, #0f9c67 100%);
  color: #03120b;
  box-shadow:
    0 16px 36px rgba(30, 210, 139, .23),
    inset 0 1px 0 rgba(255,255,255,.36);
}

button.soft-primary {
  background:
    linear-gradient(135deg, rgba(115, 167, 255, .25), rgba(115, 167, 255, .12));
  color: #dfeaff;
  border: 1px solid rgba(115, 167, 255, .28);
  box-shadow: none;
}

button.danger {
  background: rgba(255, 91, 110, .12);
  border-color: rgba(255, 91, 110, .26);
  color: #ffb8c0;
}

button:disabled {
  opacity: .42;
  cursor: not-allowed;
  transform: none;
}

label {
  display: grid;
  gap: 9px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.055);
  color: var(--text);
  outline: none;
  padding: 0 15px;
  font-size: 16px;
  transition:
    border-color 150ms var(--ease),
    box-shadow 150ms var(--ease),
    background 150ms var(--ease);
}

select {
  appearance: none;
}

input::placeholder {
  color: rgba(169, 180, 195, .48);
}

input:focus,
select:focus {
  border-color: rgba(66, 228, 157, .58);
  background: rgba(255,255,255,.075);
  box-shadow: 0 0 0 4px rgba(66, 228, 157, .11);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 580px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    16px
    calc(106px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.18), transparent 34%),
    rgba(255,255,255,.07);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  font-size: 22px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.04;
  letter-spacing: -.045em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

h2 {
  margin-bottom: 8px;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -.05em;
}

h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.15;
  letter-spacing: -.035em;
}

.presence {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  backdrop-filter: blur(16px);
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 5px rgba(255,211,106,.08);
}

.presence.live .presence-dot {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(66,228,157,.10), 0 0 18px rgba(66,228,157,.55);
}

.presence.offline .presence-dot {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(255,91,110,.12);
}

.presence.sleeping .presence-dot {
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(115,167,255,.10);
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: viewIn 260ms var(--ease) both;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.premium-card,
.hero-card,
.status-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.038)),
    rgba(13, 18, 26, .74);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.premium-card::before,
.status-card::before,
.hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255,255,255,.12), transparent 22%, transparent 70%, rgba(255,255,255,.045));
  pointer-events: none;
  opacity: .65;
}

.centered-card {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  min-height: 360px;
  padding: 36px 24px;
  text-align: center;
}

.centered-card p,
.setup-cover p,
.panel-title p,
.form-note,
.state-copy,
.empty-inline {
  color: var(--text-soft);
  line-height: 1.45;
}

.loader-ring {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255,255,255,.10);
  border-top-color: var(--green);
  border-radius: 999px;
  animation: spin 850ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.setup-cover {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  margin-bottom: 14px;
}

.setup-cover h2,
.setup-cover p {
  margin-bottom: 0;
}

.setup-icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  flex: 0 0 68px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.22), transparent 32%),
    linear-gradient(135deg, rgba(66,228,157,.22), rgba(115,167,255,.16));
  border: 1px solid rgba(255,255,255,.12);
  font-size: 32px;
}

.setup-progress {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.progress-pill {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.045);
  color: var(--muted);
  padding: 10px 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 950;
  white-space: nowrap;
}

.progress-pill.active {
  border-color: rgba(66,228,157,.55);
  background: rgba(66,228,157,.13);
  color: #c7ffe8;
  box-shadow: 0 0 30px rgba(66,228,157,.09);
}

.progress-pill.done {
  border-color: rgba(115,167,255,.35);
  background: rgba(115,167,255,.11);
  color: #dbe8ff;
}

.setup-panel {
  display: none;
  gap: 16px;
  padding: 18px;
}

.setup-panel.active {
  display: grid;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 2px;
}

.panel-title p {
  margin: 6px 0 0;
  font-size: 13px;
}

.panel-emoji {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 17px;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line);
  font-size: 22px;
}

.instruction-list {
  display: grid;
  gap: 10px;
}

.instruction-list div {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.045);
}

.instruction-list strong {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: rgba(66,228,157,.13);
  color: var(--green);
}

.instruction-list span {
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.35;
}

.instruction-list b {
  color: var(--text);
}

.mini-status,
.calibration-card,
.calibration-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.045);
}

.mini-status span,
.calibration-card span {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
}

.mini-status strong,
.calibration-card strong {
  font-size: 14px;
  text-align: right;
}

.form-note {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status-card {
  padding: 20px;
  transition:
    border-color 220ms var(--ease),
    background 220ms var(--ease);
}

.status-card.locked {
  border-color: rgba(66,228,157,.30);
  background:
    radial-gradient(circle at 82% 12%, rgba(66,228,157,.24), transparent 28%),
    linear-gradient(180deg, rgba(18, 55, 39, .78), rgba(13, 18, 26, .74));
}

.status-card.unlocked {
  border-color: rgba(255,91,110,.34);
  background:
    radial-gradient(circle at 82% 12%, rgba(255,91,110,.25), transparent 28%),
    linear-gradient(180deg, rgba(57, 23, 31, .78), rgba(13, 18, 26, .74));
}

.status-card.offline {
  border-color: rgba(255,255,255,.12);
  background:
    radial-gradient(circle at 82% 12%, rgba(160,170,184,.14), transparent 28%),
    linear-gradient(180deg, rgba(26, 31, 40, .82), rgba(13, 18, 26, .74));
}

.status-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

#doorNameLabel {
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 850;
}

#stateText {
  margin: 0;
  font-size: clamp(44px, 13vw, 70px);
  line-height: .88;
  letter-spacing: -.075em;
}

.status-icon {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  flex: 0 0 86px;
  border-radius: 30px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.22), transparent 36%),
    rgba(255,255,255,.075);
  border: 1px solid var(--line);
  font-size: 46px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.10);
}

.state-copy {
  margin: 15px 0 18px;
  font-size: 15px;
}

.trust-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.trust-strip div,
.metric-card {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.047);
}
.metric-card-wide {
  grid-column: 1 / -1;
}

.trust-strip span,
.metric-card span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.trust-strip strong,
.metric-card strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.warning-stack {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.warning-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid rgba(255,211,106,.26);
  border-radius: 22px;
  padding: 14px;
  background: rgba(255,211,106,.11);
  color: #ffe3a0;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.38;
  box-shadow: 0 14px 34px rgba(0,0,0,.16);
}

.warning-card.critical {
  border-color: rgba(255,91,110,.32);
  background: rgba(255,91,110,.12);
  color: #ffc3ca;
}

.warning-card.info {
  border-color: rgba(115,167,255,.28);
  background: rgba(115,167,255,.12);
  color: #d3e2ff;
}

.premium-card {
  padding: 18px;
  margin-top: 14px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-heading h3 {
  margin: 0;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.045);
  padding: 10px;
  transition: transform 160ms var(--ease), background 160ms var(--ease);
}

.event-item:active {
  transform: scale(.99);
}

.event-symbol {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background: rgba(66,228,157,.13);
  color: var(--green);
  font-size: 24px;
}

.event-symbol.unlocked,
.event-symbol.critical {
  background: rgba(255,91,110,.13);
  color: var(--red);
}

.event-symbol.warning {
  background: rgba(255,211,106,.13);
  color: var(--yellow);
}

.event-symbol.info {
  background: rgba(115,167,255,.13);
  color: var(--blue);
}

.event-title {
  font-weight: 900;
  font-size: 14px;
}

.event-subtitle {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.35;
}

.event-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
}

.empty-inline {
  padding: 10px 0;
  font-size: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 66px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.toggle-row:first-of-type {
  border-top: 0;
}

.toggle-row span {
  display: grid;
  gap: 4px;
}

.toggle-row strong {
  color: var(--text);
  font-size: 14px;
}

.toggle-row small {
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.35;
}

.toggle-row input {
  appearance: none;
  width: 58px;
  height: 34px;
  min-height: 34px;
  flex: 0 0 58px;
  border-radius: 999px;
  padding: 3px;
  background: rgba(255,255,255,.12);
  border: 1px solid var(--line);
  cursor: pointer;
}

.toggle-row input::before {
  content: "";
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,.86);
  box-shadow: 0 5px 16px rgba(0,0,0,.22);
  transition: transform 180ms var(--ease), background 180ms var(--ease);
}

.toggle-row input:checked {
  border-color: rgba(66,228,157,.50);
  background: rgba(66,228,157,.38);
}

.toggle-row input:checked::before {
  transform: translateX(24px);
  background: #ffffff;
}

.bottom-nav {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  width: min(calc(100% - 24px), 548px);
  margin: 0 auto;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 28px;
  background: rgba(15, 20, 29, .82);
  box-shadow:
    0 20px 50px rgba(0,0,0,.45),
    inset 0 1px 0 rgba(255,255,255,.08);
  backdrop-filter: blur(24px);
  padding: 7px;
}

.nav-button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 62px;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.nav-button span {
  font-size: 22px;
  line-height: 1;
}

.nav-button small {
  font-size: 11px;
  font-weight: 900;
}

.nav-button.active {
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.18), transparent 35%),
    rgba(255,255,255,.10);
  color: var(--text);
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(100px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 548px;
  margin: 0 auto;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 22px;
  background: rgba(18,24,34,.92);
  color: var(--text);
  padding: 14px 16px;
  box-shadow: 0 18px 46px rgba(0,0,0,.42);
  backdrop-filter: blur(20px);
  font-size: 14px;
  font-weight: 820;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(.98);
  transition:
    opacity 180ms var(--ease),
    transform 180ms var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@media (max-width: 390px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 16px;
  }

  h1 {
    font-size: 24px;
  }

  .presence {
    padding: 0 10px;
  }

  .setup-progress {
    gap: 5px;
  }

  .progress-pill {
    font-size: 10px;
    padding-left: 4px;
    padding-right: 4px;
  }

  .status-icon {
    width: 74px;
    height: 74px;
    flex-basis: 74px;
    border-radius: 26px;
    font-size: 38px;
  }

  .trust-strip,
  .metric-grid,
  .button-grid {
    grid-template-columns: 1fr;
  }

  .event-item {
    grid-template-columns: 48px 1fr;
  }

  .event-time {
    grid-column: 2;
    text-align: left;
  }
}