* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  background: #0a0a0f;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app {
  width: 100vmin;
  height: 100vmin;
  position: relative;
  overflow: hidden;
}

/* ─── Screens ─────────────────────────────────── */

.screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  flex-direction: column;
  padding: clamp(12px, 3.5vmin, 20px);
}
.screen.active { display: flex; }

/* ─── Header ─────────────────────────────────── */

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: clamp(8px, 2vmin, 14px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: clamp(8px, 2vmin, 14px);
  flex-shrink: 0;
}

.app-title {
  font-size: clamp(15px, 3.8vmin, 20px);
  font-weight: 800;
  color: #fff;
  letter-spacing: 2px;
}

.screen-title {
  font-size: clamp(14px, 3.5vmin, 18px);
  font-weight: 700;
  color: #fff;
  letter-spacing: 1.5px;
  flex: 1;
  text-align: right;
}

.back-btn {
  font-size: clamp(13px, 3.2vmin, 16px);
  font-weight: 600;
  color: #4fc3f7;
  cursor: pointer;
  min-height: 60px;
  min-width: 80px;
  display: flex;
  align-items: center;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #333;
  flex-shrink: 0;
  transition: background 0.4s;
}
.status-dot.online  { background: #4caf50; }
.status-dot.offline { background: #f44336; }

/* ─── Home: Device Cards ─────────────────────── */

.device-list {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2vmin, 12px);
  flex: 1;
  justify-content: center;
}

.device-card {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: clamp(12px, 3vmin, 18px) clamp(12px, 3vmin, 18px);
  cursor: pointer;
  transition: background 0.2s;
  min-height: 76px;
}
.device-card:active { background: rgba(255,255,255,0.15); }

.device-icon {
  font-size: clamp(22px, 5.5vmin, 30px);
  margin-right: clamp(10px, 2.5vmin, 16px);
  line-height: 1;
}

.device-info { flex: 1; }

.device-name {
  font-size: clamp(13px, 3.3vmin, 17px);
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}

.device-status {
  font-size: clamp(11px, 2.7vmin, 14px);
  color: rgba(255,255,255,0.5);
  margin-top: 3px;
}

.device-arrow {
  font-size: 22px;
  color: rgba(255,255,255,0.25);
  margin-left: 6px;
}

.refresh-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.18);
  text-align: center;
  margin-top: 8px;
  flex-shrink: 0;
}

/* ─── Scrollable List ────────────────────────── */

.scroll-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2vmin, 10px);
  padding-bottom: 4px;
}
.scroll-list::-webkit-scrollbar { display: none; }

/* ─── Toggle Cards (Lights + Locks) ─────────── */

.toggle-card {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: clamp(12px, 3vmin, 16px);
  min-height: 68px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.toggle-card:active { opacity: 0.7; }

.toggle-card.on {
  background: rgba(79,195,247,0.1);
  border-color: rgba(79,195,247,0.35);
}
.toggle-card.unlocked {
  background: rgba(244,67,54,0.1);
  border-color: rgba(244,67,54,0.35);
}

.toggle-info { flex: 1; }

.toggle-label {
  font-size: clamp(13px, 3.3vmin, 16px);
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

.toggle-state {
  font-size: clamp(11px, 2.7vmin, 13px);
  color: rgba(255,255,255,0.45);
  margin-top: 3px;
}
.toggle-card.on .toggle-state { color: #4fc3f7; }
.toggle-card.unlocked .toggle-state { color: #ef9a9a; }

/* Toggle switch pill */
.toggle-switch {
  width: 44px;
  height: 24px;
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: rgba(255,255,255,0.5);
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: left 0.2s, background 0.2s;
}
.toggle-card.on .toggle-switch { background: #4fc3f7; }
.toggle-card.on .toggle-switch::after { left: 23px; background: #0a0a0f; }

/* Lock icon */
.lock-icon {
  font-size: clamp(18px, 4.5vmin, 24px);
  flex-shrink: 0;
  margin-left: 8px;
}

/* ─── Detail: Status + Actions ───────────────── */

.current-status {
  font-size: clamp(12px, 3vmin, 15px);
  color: rgba(255,255,255,0.55);
  margin-bottom: clamp(10px, 2.5vmin, 16px);
  flex-shrink: 0;
}
.current-status span {
  color: #fff;
  font-weight: 600;
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2vmin, 12px);
  flex: 1;
  justify-content: center;
}

.action-btn {
  width: 100%;
  min-height: 76px;
  border: none;
  border-radius: 14px;
  font-size: clamp(13px, 3.3vmin, 17px);
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.action-btn:active { opacity: 0.7; transform: scale(0.98); }

.btn-primary   { background: #4fc3f7; color: #0a0a0f; }
.btn-secondary { background: rgba(255,255,255,0.13); color: #fff; border: 1px solid rgba(255,255,255,0.2); }
.btn-danger    { background: rgba(244,67,54,0.2); color: #ef9a9a; border: 1px solid rgba(244,67,54,0.35); }

/* ─── Feedback Toast ─────────────────────────── */

.feedback {
  position: absolute;
  bottom: clamp(20px, 5vmin, 36px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10,10,20,0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: clamp(11px, 2.8vmin, 14px);
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.15);
  white-space: nowrap;
  z-index: 100;
  transition: opacity 0.4s;
}
.feedback.success { border-color: rgba(76,175,80,0.6); color: #a5d6a7; }
.feedback.error   { border-color: rgba(244,67,54,0.6); color: #ef9a9a; }
.feedback.hidden  { opacity: 0; pointer-events: none; }
