:root {
  color-scheme: light;
  --background: #f3f5f7;
  --surface: #ffffff;
  --surface-muted: #edf0f2;
  --ink: #171a1f;
  --muted: #7b818a;
  --line: #e1e5e9;
  --primary: #2d7ff9;
  --primary-soft: #e7f0ff;
  --teal: #1e9992;
  --warning: #d28b24;
  --danger: #d15454;
  --visual-bg: #dfeaf7;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--background);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(45, 127, 249, 0.28);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: calc(98px + var(--safe-bottom));
  overflow: hidden;
  background: var(--background);
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.icon-button svg {
  width: 26px;
  height: 26px;
  stroke-width: 2.3;
}

.unit-connection {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: rgba(239, 247, 255, 0.9);
  font-size: 10px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--warning);
}

.unit-connection.is-online .status-dot {
  background: var(--teal);
}

.unit-connection.is-offline .status-dot {
  background: var(--danger);
}

.climate-visual {
  position: relative;
  background: var(--visual-bg);
}

.ac-image {
  display: block;
  width: 100%;
  aspect-ratio: 11 / 6;
  object-fit: cover;
  transition: filter 240ms ease, opacity 240ms ease;
}

.unit-readout {
  position: absolute;
  z-index: 2;
  top: 27%;
  left: 50%;
  display: inline-flex;
  min-height: 31px;
  max-width: calc(100% - 88px);
  padding: 5px 9px;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(237, 247, 255, 0.2);
  border-radius: 6px;
  color: #f5fbff;
  background: rgba(37, 53, 66, 0.78);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.12), 0 2px 5px rgba(29, 44, 56, 0.2);
  transform: translateX(-50%);
  transition: opacity 220ms ease, background 220ms ease;
}

.unit-temperature {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.unit-temperature strong {
  font-size: 16px;
  font-weight: 650;
  line-height: 1;
}

.unit-temperature small {
  color: rgba(235, 244, 251, 0.7);
  font-size: 9px;
}

.unit-readout-divider {
  width: 1px;
  height: 15px;
  background: rgba(235, 244, 251, 0.24);
}

body[data-power="off"] .unit-readout {
  opacity: 0.62;
  background: rgba(75, 83, 89, 0.74);
}

body[data-power="off"] .ac-image {
  filter: grayscale(0.84) saturate(0.18) brightness(1.06);
  opacity: 0.78;
}

body[data-power="on"] .ac-image {
  animation: unit-breathe 3.8s ease-in-out infinite;
}

@keyframes unit-breathe {
  0%, 100% { opacity: 0.96; }
  50% { opacity: 1; }
}

.airflow-visual {
  --airflow-color: rgba(47, 139, 255, 0.74);
  position: absolute;
  top: 48%;
  right: 16%;
  bottom: 11%;
  left: 16%;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.air-stream {
  position: absolute;
  top: -8%;
  width: 13%;
  height: 112%;
  border-radius: 50% 50% 42% 42%;
  background: linear-gradient(to bottom, var(--airflow-color), rgba(255, 255, 255, 0));
  filter: blur(1px);
  opacity: 0.56;
  transform-origin: 50% 0;
}

.air-stream:nth-child(1) { left: 0; animation-delay: -1.7s; }
.air-stream:nth-child(2) { left: 14.5%; animation-delay: -0.6s; }
.air-stream:nth-child(3) { left: 29%; animation-delay: -2.2s; }
.air-stream:nth-child(4) { left: 43.5%; animation-delay: -1.1s; }
.air-stream:nth-child(5) { left: 58%; animation-delay: -2.9s; }
.air-stream:nth-child(6) { left: 72.5%; animation-delay: -0.2s; }
.air-stream:nth-child(7) { right: 0; animation-delay: -2.5s; }

body[data-power="on"] .airflow-visual {
  opacity: 0.76;
}

body[data-power="on"] .air-stream {
  animation: air-current 3.2s ease-in-out infinite;
}

body[data-mode="auto"] .airflow-visual { --airflow-color: rgba(121, 99, 247, 0.66); }
body[data-mode="cool"] .airflow-visual { --airflow-color: rgba(42, 140, 255, 0.76); }
body[data-mode="dry"] .airflow-visual { --airflow-color: rgba(27, 166, 143, 0.68); }
body[data-mode="heat"] .airflow-visual { --airflow-color: rgba(235, 125, 56, 0.72); }
body[data-mode="fan-only"] .airflow-visual { --airflow-color: rgba(28, 164, 181, 0.68); }

@keyframes air-current {
  0%, 100% { opacity: 0.3; transform: translateY(-7px) scaleX(0.8); }
  46% { opacity: 0.76; transform: translateY(8px) scaleX(1.1); }
  70% { opacity: 0.45; transform: translateY(2px) scaleX(0.92); }
}

.climate-visual.is-mode-changing .airflow-visual {
  animation: mode-airflow-shift 720ms cubic-bezier(0.18, 0.76, 0.28, 1);
}

@keyframes mode-airflow-shift {
  0% { opacity: 0.12; transform: translateY(-14px); }
  50% { opacity: 0.95; transform: translateY(3px); }
  100% { opacity: 0.76; transform: translateY(0); }
}

.temperature-panel,
.primary-controls,
.features-section {
  margin-right: 14px;
  margin-left: 14px;
}

.temperature-panel {
  margin-top: 14px;
  padding: 18px 18px 20px;
  border: 1px solid rgba(23, 26, 31, 0.04);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(36, 46, 58, 0.05);
}

.temperature-stepper {
  display: grid;
  grid-template-columns: 60px 1fr 60px;
  align-items: center;
  gap: 12px;
}

.round-button {
  display: grid;
  width: 58px;
  height: 58px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #555c64;
  background: var(--surface-muted);
  cursor: pointer;
}

.round-button svg {
  width: 27px;
  height: 27px;
}

.round-button:active {
  transform: scale(0.96);
}

.target-temperature {
  display: flex;
  align-items: baseline;
  justify-content: center;
  min-width: 0;
  color: #4c535c;
}

.target-temperature strong {
  font-size: 54px;
  font-weight: 450;
  line-height: 1;
}

.target-temperature span {
  margin-left: 4px;
  font-size: 24px;
}

.temperature-range {
  width: 100%;
  height: 34px;
  margin: 15px 0 0;
  accent-color: var(--primary);
}

.temperature-range::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(to right, var(--primary) var(--range-progress, 56%), var(--surface-muted) var(--range-progress, 56%));
}

.temperature-range::-webkit-slider-thumb {
  width: 28px;
  height: 28px;
  margin-top: -8px;
  border: 4px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 2px 8px rgba(20, 65, 130, 0.24);
  -webkit-appearance: none;
}

.primary-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.setting-button {
  display: grid;
  grid-template-columns: 1fr 44px;
  align-items: center;
  min-width: 0;
  min-height: 108px;
  padding: 18px;
  border: 1px solid rgba(23, 26, 31, 0.04);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.setting-copy {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.setting-copy strong {
  font-size: 20px;
  font-weight: 650;
}

.setting-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setting-icon {
  display: grid;
  color: var(--primary);
  place-items: center;
}

.setting-icon svg {
  width: 36px;
  height: 36px;
  stroke-width: 1.9;
}

.mode-icon {
  color: #178bb4;
}

.features-section {
  margin-top: 10px;
  padding: 18px 12px 16px;
  border: 1px solid rgba(23, 26, 31, 0.04);
  border-radius: 8px;
  background: var(--surface);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 6px 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
}

.section-heading span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px 4px;
}

.feature-button {
  display: grid;
  min-width: 0;
  padding: 0;
  place-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.feature-button > span:last-child {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feature-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 50%;
  color: #68717b;
  background: var(--surface-muted);
  transition: color 160ms ease, background 160ms ease;
}

.feature-icon svg {
  width: 27px;
  height: 27px;
  stroke-width: 1.8;
}

.feature-button.is-active .feature-icon {
  color: var(--primary);
  background: var(--primary-soft);
}

.bottom-dock {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: calc(84px + var(--safe-bottom));
  padding: 8px max(18px, calc((100vw - 480px) / 2 + 18px)) var(--safe-bottom);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
}

.dock-button {
  display: grid;
  min-width: 0;
  padding: 3px;
  place-items: center;
  gap: 3px;
  border: 0;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.dock-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  color: #5f6770;
  background: var(--surface-muted);
}

.dock-icon svg {
  width: 27px;
  height: 27px;
}

.power-button .dock-icon {
  color: var(--surface);
  background: var(--primary);
}

body[data-power="on"] .power-button .dock-icon {
  background: var(--danger);
}

.sheet-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  background: rgba(20, 26, 34, 0.34);
}

.bottom-sheet {
  position: fixed;
  z-index: 21;
  right: 0;
  bottom: 0;
  left: 0;
  max-width: 480px;
  max-height: min(72vh, 560px);
  margin: 0 auto;
  padding: 8px 16px calc(18px + var(--safe-bottom));
  overflow: auto;
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  box-shadow: 0 -16px 42px rgba(21, 31, 43, 0.16);
}

.bottom-sheet.is-mode-sheet {
  max-height: min(48vh, 370px);
}

.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 2px;
  background: #d4d8dd;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}

.sheet-header h2 {
  margin: 0;
  font-size: 20px;
}

.sheet-options {
  display: grid;
  gap: 8px;
}

.bottom-sheet.is-mode-sheet .sheet-options {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.sheet-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.sheet-option.is-selected {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.sheet-option svg {
  width: 20px;
  height: 20px;
}

.sheet-mode-option {
  display: grid;
  min-width: 0;
  min-height: 118px;
  padding: 12px 4px 10px;
  place-items: center;
  align-content: center;
  gap: 8px;
  border-color: transparent;
  color: #66717d;
  background: transparent;
}

.sheet-mode-option:hover,
.sheet-mode-option:focus-visible {
  border-color: currentColor;
  background: #f7f9fb;
}

.sheet-mode-option.is-selected {
  border-color: currentColor;
  background: #f8fbff;
}

.mode-option-symbol {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: currentColor;
}

.mode-option-symbol::after {
  position: absolute;
  top: calc(50% + 11px);
  left: 7px;
  width: 30px;
  height: 2px;
  content: "";
  opacity: 0;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor;
  transform: scaleX(0.4);
  transform-origin: left center;
}

.mode-option-symbol svg {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  stroke-width: 1.8;
}

.mode-option-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
  text-align: center;
}

.mode-option-copy strong {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
}

.mode-option-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-auto { color: #7865de; }
.mode-cool { color: #287ff0; }
.mode-dry { color: #199a84; }
.mode-heat { color: #d66b2c; }
.mode-fan-only { color: #24869c; }

.sheet-mode-option.is-selected .mode-option-symbol::after {
  animation: mode-option-gust 1.45s ease-out infinite;
}

.mode-auto.is-selected .mode-option-symbol svg { animation: mode-auto-pulse 1.7s ease-in-out infinite; }
.mode-cool.is-selected .mode-option-symbol svg { animation: mode-cool-spin 2.8s linear infinite; }
.mode-dry.is-selected .mode-option-symbol svg { animation: mode-dry-drop 1.2s ease-in-out infinite; }
.mode-heat.is-selected .mode-option-symbol svg { animation: mode-heat-rays 1.6s ease-in-out infinite; }
.mode-fan-only.is-selected .mode-option-symbol svg { animation: mode-fan-drift 1.1s ease-in-out infinite; }

@keyframes mode-option-gust {
  0% { opacity: 0; transform: translateX(-8px) scaleX(0.4); }
  32% { opacity: 0.72; }
  100% { opacity: 0; transform: translateX(9px) scaleX(1.22); }
}

@keyframes mode-auto-pulse {
  0%, 100% { transform: scale(0.88); }
  50% { transform: scale(1.08); }
}

@keyframes mode-cool-spin {
  to { transform: rotate(180deg); }
}

@keyframes mode-dry-drop {
  0%, 100% { transform: translateY(-2px); }
  55% { transform: translateY(4px); }
}

@keyframes mode-heat-rays {
  0%, 100% { transform: scale(0.9); opacity: 0.72; }
  50% { transform: scale(1.08); opacity: 1; }
}

@keyframes mode-fan-drift {
  0%, 100% { transform: translateX(-3px); }
  50% { transform: translateX(4px); }
}

.toast {
  position: fixed;
  z-index: 30;
  right: 18px;
  bottom: calc(102px + var(--safe-bottom));
  left: 18px;
  max-width: 420px;
  min-height: 44px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--surface);
  background: #252b33;
  font-size: 13px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(20, 25, 31, 0.22);
}

.is-pending {
  pointer-events: none;
  opacity: 0.64;
}

[hidden] {
  display: none !important;
}

@media (min-width: 481px) {
  body {
    background: #e8ebef;
  }

  .app-shell {
    box-shadow: 0 0 40px rgba(31, 43, 57, 0.08);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
