:root {
  --bg: #0d0d0d;
  --card: #1a1a1a;
  --text: #e8e8e8;
  --muted: #8a8a8a;
  --accent: #4caf50;
  --accent-hover: #66bb6a;
  --danger: #f44336;
  --border: #333;
  --radius: 12px;
  --shadow: 0 4px 12px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin:0; padding:0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
#app {
  max-width: 500px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 80px;
  min-height: 100vh;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}
.logo svg { width:24px; height:24px; }

/* Status Badge */
.status-badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  transition: var(--transition);
}
.status-badge.online { background: rgba(76,175,80,0.2); color: #66bb6a; border: 1px solid rgba(76,175,80,0.3); }
.status-badge.offline { background: rgba(244,67,54,0.2); color: #ef5350; border: 1px solid rgba(244,67,54,0.3); }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Input Groups */
.input-group {
  margin-bottom: 12px;
}
.input-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.input-group input[type="text"],
.input-group input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111;
  color: var(--text);
  font-size: 1rem;
  transition: var(--transition);
}
.input-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76,175,80,0.1);
}

/* Buttons */
.button-group { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-primary, .btn-secondary {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  flex: 1;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: #2a2a2a;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #2f2f2f; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: 8px 12px; font-size: 0.85rem; min-width: auto; }

/* Hint */
.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.4;
}

/* Error Message */
.error-message {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(244,67,54,0.15);
  border: 1px solid rgba(244,67,54,0.3);
  color: #ef5350;
  font-size: 0.9rem;
}

/* Grid Container */
.grid-container {
  display: grid;
  gap: 12px;
}

/* Light / Group Card */
.light-card, .group-card {
  background: #111;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  transition: var(--transition);
  position: relative;
}
.light-card:active, .group-card:active { transform: scale(0.98); }
.light-card .title, .group-card .title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.light-card .title h3, .group-card .title h3 {
  font-size: 1rem;
  font-weight: 600;
}
.light-card .type {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Toggle Switch */
.toggle-switch {
  width: 48px;
  height: 26px;
  background: #333;
  border-radius: 13px;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  border: 1px solid var(--border);
}
.toggle-switch.on {
  background: var(--accent);
  border-color: rgba(76,175,80,0.3);
}
.toggle-switch .knob {
  width: 22px;
  height: 22px;
  background: #e8e8e8;
  border-radius: 50%;
  position: absolute;
  top: 1px;
  left: 1px;
  transition: var(--transition);
}
.toggle-switch.on .knob { left: 24px; }

/* Slider */
.slider-container {
  margin-top: 10px;
}
.slider-container label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.slider-container input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #333;
  outline: none;
}
.slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #111;
}
.color-btn {
  margin-top: 8px;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #151515;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.color-btn:hover { background: #1f1f1f; }
.color-preview {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #333;
}

/* Timer */
#timer-status {
  display: flex;
  align-items: center;
  gap: 8px;
}
#timer-countdown {
  font-weight: 700;
  color: var(--accent);
}

/* Loading */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 360px;
}
.modal-content h3 { margin-bottom: 16px; color: var(--accent); }
.color-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.color-controls input[type="color"] {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* Responsive */
@media (max-width: 400px) {
  #app { padding: 12px; }
  .btn-primary, .btn-secondary { min-width: 100px; }
}
