:root {
  color-scheme: light;
  --page-bg: #ffffff;
  --text: #222222;
  --secondary: #9b9b9f;
  --hairline: #ececef;
  --accent: #009100;
  --accent-pressed: #007a00;
  --tap: #f5f5f7;
  --side: clamp(20px, 5.15vw, 64px);
  --icon-size: clamp(28px, 7.2vw, 38px);
  --row-height: clamp(74px, 18.5vw, 98px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--page-bg);
  color: var(--text);
  font-synthesis: none;
}

* { box-sizing: border-box; }

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

html, body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: var(--page-bg);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

button { font: inherit; }

button:focus-visible {
  outline: 3px solid rgba(0, 145, 0, 0.45);
  outline-offset: 2px;
}

.app-shell {
  position: fixed;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
  background: var(--page-bg);
}

.screen {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  background: var(--page-bg);
}

.screen[hidden] { display: none; }

.navigation-bar {
  height: calc(clamp(62px, 16vw, 82px) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(12px, calc(var(--side) - 12px)) 0;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
}

.navigation-bar h1 {
  margin: 0;
  text-align: center;
  font-size: clamp(20px, 5.4vw, 29px);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.navigation-bar h1:focus { outline: none; }

.nav-back {
  width: 48px;
  height: 48px;
  padding: 10px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #333;
  background: transparent;
  cursor: pointer;
}

.nav-back:not(:disabled):active { background: var(--tap); }
.nav-back--inactive { opacity: 1; }

.nav-back svg {
  width: 27px;
  height: 27px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#settings-screen {
  --settings-side: 18px;
  --settings-icon-size: 24px;
  --settings-row-height: 56px;
}

#settings-screen .navigation-bar {
  height: calc(60px + env(safe-area-inset-top, 0px));
  padding-right: 6px;
  padding-left: 6px;
}

#settings-screen .navigation-bar h1 { font-size: 20px; }
#settings-screen .nav-back { width: 44px; height: 44px; }
#settings-screen .nav-back svg { width: 24px; height: 24px; }

#life-screen .navigation-bar,
#scene-screen .navigation-bar,
#account-screen .navigation-bar {
  height: calc(60px + env(safe-area-inset-top, 0px));
  padding-right: 6px;
  padding-left: 6px;
}

#life-screen .navigation-bar h1,
#scene-screen .navigation-bar h1,
#account-screen .navigation-bar h1 { font-size: 20px; }

#scene-screen .navigation-bar h1 { font-weight: 650; }
#account-screen .navigation-bar h1 { font-weight: 400; }

#life-screen .nav-back,
#scene-screen .nav-back,
#account-screen .nav-back { width: 44px; height: 44px; }

#life-screen .nav-back svg,
#scene-screen .nav-back svg,
#account-screen .nav-back svg { width: 24px; height: 24px; }

.settings-list { padding: 4px 0 28px; }

.setting-row {
  width: 100%;
  min-height: var(--settings-row-height);
  padding: 0 var(--settings-side);
  border: 0;
  display: grid;
  grid-template-columns: var(--settings-icon-size) minmax(0, 1fr) auto 12px;
  gap: 12px;
  align-items: center;
  color: var(--text);
  background: transparent;
  text-align: left;
}

button.setting-row { cursor: default; }
button.setting-row:active { background: var(--tap); }
.setting-row--midea { cursor: pointer !important; }

.row-icon {
  width: var(--settings-icon-size);
  height: var(--settings-icon-size);
  display: grid;
  place-items: center;
  color: #333;
}

.row-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row-label {
  min-width: 0;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.row-value {
  color: var(--secondary);
  font-size: 15px;
  white-space: nowrap;
}

.chevron {
  width: 8px;
  height: 8px;
  border-top: 2px solid #9b9b9d;
  border-right: 2px solid #9b9b9d;
  transform: rotate(45deg);
}

.setting-block { padding-bottom: 12px; }

.setting-row--switch {
  grid-template-columns: var(--settings-icon-size) minmax(0, 1fr) auto;
  cursor: default;
}

.setting-description {
  max-width: 980px;
  margin: -8px var(--settings-side) 0;
  padding-left: calc(var(--settings-icon-size) + 12px);
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.ios-switch {
  --switch-width: 52px;
  position: relative;
  width: var(--switch-width);
  height: calc(var(--switch-width) * 0.58);
  padding: 0;
  border: 0;
  border-radius: 999px;
  flex: 0 0 auto;
  background: #e5e5ea;
  cursor: pointer;
  transition: background-color 160ms ease;
}

.ios-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(var(--switch-width) * 0.58 - 4px);
  height: calc(var(--switch-width) * 0.58 - 4px);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ios-switch[aria-checked="true"] { background: var(--accent); }
.ios-switch[aria-checked="true"]::after { transform: translateX(calc(var(--switch-width) * 0.42)); }
.ios-switch:active { background: #d4d4d9; }
.ios-switch[aria-checked="true"]:active { background: var(--accent-pressed); }

#scene-screen,
#scene-screen .navigation-bar {
  background: #eaf0f8;
}

.scene-content {
  min-height: calc(100dvh - 60px - env(safe-area-inset-top, 0px));
  padding: 10px 18px 36px;
  background: linear-gradient(180deg, #eaf0f8 0%, #f5f7fa 58%, #ffffff 100%);
}

.scene-intro {
  margin: 0 0 14px;
  color: #888c94;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

.scene-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.scene-group {
  margin: 0;
  border: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 12px 38px rgba(38, 51, 71, 0.075);
}

.scene-heading {
  min-height: 168px;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "copy copy"
    "visual toggle";
  gap: 14px 12px;
  align-items: end;
}

.scene-heading-copy { grid-area: copy; align-self: start; }
.scene-heading .scene-switch { grid-area: toggle; justify-self: end; }

.scene-heading-copy h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.scene-heading-copy p {
  margin: 6px 0 0;
  color: #96999f;
  font-size: 14px;
  line-height: 1.45;
}

.association-flow {
  grid-area: visual;
  align-self: end;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}

.association-trigger {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #333;
  background: transparent;
}

.association-arrow {
  color: #b8bac0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  font-size: 28px;
  font-weight: 300;
}

.association-devices {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.association-devices > span {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #8b8d91;
  background: transparent;
  transition: color 160ms ease, background-color 160ms ease;
}

.association-trigger svg,
.association-device svg {
  width: 65%;
  height: 65%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.association-device.is-enabled {
  color: #333;
  background: transparent;
}

.scene-options {
  border-top: 1px solid var(--hairline);
  transition: opacity 160ms ease;
}

.scene-group.is-disabled .scene-options { opacity: 0.38; }
.scene-group.is-disabled .association-trigger {
  color: #9a9a9e;
  background: transparent;
}

.scene-group.is-disabled .association-device {
  color: #9a9a9e;
  background: transparent;
}

.option-row {
  width: 100%;
  min-height: 56px;
  padding: 6px 16px;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 22px;
  gap: 10px;
  align-items: center;
  color: var(--text);
  background: transparent;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}

.option-row:last-child { border-bottom: 0; }
.option-row:not(:disabled):active { background: var(--tap); }
.option-row:disabled { color: #77777b; cursor: default; }

.appliance-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #8b8d91;
  background: transparent;
  transition: color 160ms ease, background-color 160ms ease;
}

.appliance-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.option-label { min-width: 0; }

.option-row[aria-checked="true"] .appliance-icon {
  color: #333;
  background: transparent;
}

.option-row:disabled .appliance-icon {
  color: #9a9a9e;
  background: transparent;
}

.checkmark {
  position: relative;
  width: 22px;
  height: 22px;
  border: 2px solid #c9c9cd;
  border-radius: 50%;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.option-row[aria-checked="true"] .checkmark {
  border-color: var(--accent);
  background: var(--accent);
}

.option-row[aria-checked="true"] .checkmark::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 9px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
}

.feature-menu {
  padding: 8px 18px 36px;
}

.menu-intro {
  margin: 0 0 12px;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.5;
}

.feature-card {
  border: 1px solid #ebebee;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 5px 22px rgba(0, 0, 0, 0.035);
}

.feature-row {
  width: 100%;
  min-height: 72px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 10px;
  gap: 10px;
  align-items: center;
  color: var(--text);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.feature-row:last-child { border-bottom: 0; }
.feature-row:active { background: var(--tap); }

.feature-icon {
  width: 34px;
  height: 34px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #333;
  background: transparent;
}

.feature-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.feature-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.feature-copy strong {
  font-size: 18px;
  font-weight: 400;
  line-height: 1.25;
}

.feature-copy small {
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.4;
}

.account-screen { overflow: hidden; }

.account-content {
  min-height: calc(100dvh - 60px - env(safe-area-inset-top, 0px));
  padding: 48px 18px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.brand-connection {
  width: min(100%, 460px);
  display: grid;
  grid-template-columns: minmax(88px, 1fr) minmax(54px, 0.62fr) minmax(88px, 1fr);
  gap: 12px;
  align-items: center;
}

.brand-tile {
  height: 96px;
  padding: 10px;
  border: 1px solid #ebebee;
  border-radius: 18px;
  display: grid;
  place-items: center;
  opacity: 0;
  background: #fff;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.07);
}

.brand-tile--leap { transform: translateX(-18px) scale(0.94); }
.brand-tile--midea { transform: translateX(18px) scale(0.94); }

.brand-tile img {
  display: block;
  width: 94%;
  max-height: 78%;
  object-fit: contain;
}

.connection-track {
  position: relative;
  height: 32px;
  display: flex;
  align-items: center;
}

.connection-line {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: #e5e5ea;
}

.connection-line::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #009100, #39aee8, #1686ca);
  transform: scaleX(0);
  transform-origin: left center;
}

.signal-dot {
  position: absolute;
  left: 0;
  width: 12px;
  height: 12px;
  border: 3px solid #fff;
  border-radius: 50%;
  opacity: 0;
  background: #009100;
  box-shadow: 0 0 0 5px rgba(0, 145, 0, 0.18);
  transform: translateX(-50%);
}

.connection-result {
  width: min(100%, 420px);
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.status-orb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: transparent;
}

.status-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #c8f0d7;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-turn 0.8s linear infinite;
}

.status-check {
  display: none;
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.connection-result h2 {
  margin: 18px 0 0;
  font-size: 20px;
  font-weight: 650;
  line-height: 1.35;
}

.connection-result p {
  margin: 7px 0 0;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.5;
}

.confirm-button {
  width: min(100%, 280px);
  min-height: 48px;
  margin-top: 26px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 22px rgba(0, 145, 0, 0.22);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  animation: confirm-in 0.35s ease-out both;
}

.confirm-button[hidden] { display: none; }
.confirm-button:active { background: var(--accent-pressed); transform: scale(0.985); }

.account-screen.is-connecting .brand-tile--leap {
  animation: logo-in-left 0.55s cubic-bezier(0.2, 0.85, 0.25, 1) forwards;
}

.account-screen.is-connecting .brand-tile--midea {
  animation: logo-in-right 0.55s 0.14s cubic-bezier(0.2, 0.85, 0.25, 1) forwards;
}

.account-screen.is-connecting .connection-line::after {
  animation: line-fill 1.7s 0.62s ease-in-out forwards;
}

.account-screen.is-connecting .signal-dot {
  animation: signal-travel 1.7s 0.62s ease-in-out forwards;
}

.account-screen.is-connected .brand-tile {
  opacity: 1;
  transform: none;
}

.account-screen.is-connected .connection-line::after { transform: scaleX(1); }
.account-screen.is-connected .signal-dot { left: 100%; opacity: 1; background: #1686ca; }

.account-screen.is-connected .status-orb {
  background: var(--accent);
  animation: success-pop 0.42s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.account-screen.is-connected .status-spinner { display: none; }
.account-screen.is-connected .status-check { display: block; }

@keyframes logo-in-left {
  to { opacity: 1; transform: none; }
}

@keyframes logo-in-right {
  to { opacity: 1; transform: none; }
}

@keyframes line-fill {
  to { transform: scaleX(1); }
}

@keyframes signal-travel {
  0% { left: 0; opacity: 0; }
  8%, 92% { opacity: 1; }
  100% { left: 100%; opacity: 1; background: #1686ca; }
}

@keyframes spinner-turn {
  to { transform: rotate(360deg); }
}

@keyframes success-pop {
  0% { transform: scale(0.72); }
  100% { transform: scale(1); }
}

@keyframes confirm-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 760px) {
  :root {
    --side: clamp(56px, 7vw, 112px);
    --icon-size: 38px;
    --row-height: 94px;
  }

  .scene-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
