* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  min-height: 100dvh;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 8px 8px 10px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}

.panel {
  background: #fff;
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.04);
}

.section + .section {
  margin-top: 6px;
}

.section h2 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
}

.section.compact {
  padding: 0;
}

.trend-chart {
  width: 100%;
  height: 150px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
  position: relative;
}

.trend-chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.trend-legend {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
}

.trend-tooltip {
  position: absolute;
  min-width: 96px;
  font-size: 11px;
  color: #111827;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 5px 6px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  pointer-events: none;
}

.legend::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 2px;
  margin-right: 5px;
  vertical-align: middle;
}

.legend.temp::before {
  background: #ef4444;
}

.legend.humidity::before {
  background: #3b82f6;
}

.switch-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.switch-grid.single {
  grid-template-columns: 1fr;
}

.switch-card {
  border: none;
  border-radius: 10px;
  padding: 7px 6px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.switch-card.is-on {
  background: #fff8e8;
}

.switch-card.is-off {
  background: #f9fafb;
}

.lamp-icon {
  font-size: 26px;
  line-height: 1;
  margin-bottom: 8px;
  filter: grayscale(1);
  opacity: 0.55;
}

.switch-card.is-on .lamp-icon {
  filter: none;
  opacity: 1;
}

.switch-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  color: #374151;
}

button {
  border: none;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  cursor: pointer;
  min-height: 28px;
  min-width: 54px;
  padding: 4px 14px;
  font-size: 12px;
  line-height: 1;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.secondary {
  background: #9ca3af;
  min-width: auto;
  padding: 6px 10px;
}

button.toggle.on {
  background: #f59e0b;
}

button.toggle.off {
  background: #111827;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #9ca3af;
}

.env-info {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  margin-right: 6px;
  font-size: 12px;
}

.env-info span {
  background: #ffffff;
  border-radius: 999px;
  padding: 3px 8px;
  color: #4b5563;
  border: 1px solid #e5e7eb;
}

@media (min-width: 768px) {
  .container {
    padding: 10px;
  }

  .header h1 {
    font-size: 20px;
  }

  .panel {
    padding: 10px;
  }

  .section h2 {
    font-size: 14px;
  }

  .switch-card {
    min-height: 96px;
    padding: 8px 7px;
  }
}
