:root {
  color-scheme: dark;
  --background: #111827;
  --surface: #1f2937;
  --text: #f9fafb;
  --muted: #9ca3af;
  --accent: #fbbf24;
  --danger: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 8px;
}

.app-header h1 { margin: 0; font-size: 1.6rem; }
.header-actions { display: flex; gap: 8px; }

button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 1.2rem;
}

#status-message { min-height: 1.4em; margin: 4px 0 12px; color: var(--muted); }
#status-message.error { color: var(--danger); }

#lights-list { display: grid; gap: 12px; max-width: 520px; margin: 0 auto; }

.light-card { padding: 16px; border-radius: 16px; background: var(--surface); }
.light-card.offline { opacity: 0.5; }

.light-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.light-name { flex: 1; margin: 0; font-size: 1.1rem; }

.online-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.light-card:not(.offline) .online-dot { background: #34d399; }

.switch { position: relative; width: 56px; height: 32px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.switch-track {
  position: absolute; inset: 0; border-radius: 16px;
  background: #4b5563; transition: background 0.2s;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: white; transition: transform 0.2s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(24px); }

.slider-label, .color-label {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; color: var(--muted);
}
.slider-label input { flex: 1; }
.color-input { width: 56px; height: 36px; border: 0; background: none; padding: 0; }

dialog {
  width: min(90vw, 420px); border: 0; border-radius: 16px;
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog form { display: grid; gap: 12px; }
dialog label { display: grid; gap: 6px; color: var(--muted); }
dialog input {
  padding: 12px; border: 1px solid #374151; border-radius: 10px;
  background: var(--background); color: var(--text); font-size: 1rem;
}
