:root {
  --bg: #0d0d12;
  --panel: #17171f;
  --line: #2a2a36;
  --text: #ececf3;
  --muted: #8b8b9c;
  --light: hsl(30 80% 60%);
  --hue: 30;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(20px, env(safe-area-inset-top)) 16px 20px;
  overflow: hidden;
}

.glow {
  position: absolute;
  inset: -60% -20% auto;
  height: 220%;
  background: radial-gradient(closest-side, var(--light), transparent);
  filter: blur(30px);
  transition: opacity .3s, background .3s;
  pointer-events: none;
}

h1 { position: relative; margin: 0; font-size: clamp(1.15rem, 5.6vw, 1.6rem); letter-spacing: .02em; white-space: nowrap; }
h2 { margin: 0 0 12px; font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

.install {
  position: relative;
  margin-left: auto;
  padding: 8px 12px;
  background: #0008;
  border-radius: 999px;
  white-space: nowrap;
  font-size: .9rem;
}
.install[hidden] { display: none; }

.power {
  position: relative;
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all .2s;
}
.power[aria-pressed="true"] {
  color: var(--bg);
  background: var(--light);
  border-color: var(--light);
  box-shadow: 0 0 24px var(--light);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 48px;
  display: grid;
  gap: 14px;
}

section, main > details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.row-head { display: flex; justify-content: space-between; align-items: center; }
.row-head h2 { margin: 0; }

button {
  font: inherit;
  color: var(--text);
  background: #22222c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
button:disabled { opacity: .4; cursor: not-allowed; }
button.ghost { background: transparent; }
button.small { padding: 4px 9px; }

.devices { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.devices li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #1f1f28;
}
.devices .name {
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px dashed transparent;
  padding: 2px 0;
}
.devices .name:focus { outline: none; border-bottom-color: var(--muted); }
.devices .status { font-size: .8rem; color: var(--muted); }
.devices li.on .status { color: #6fdc8c; }
.devices li.on .status::before { content: "● "; }
.devices li.off .status::before { content: "○ "; }
.devices input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--light); }

.hint { margin: 10px 0 0; color: var(--muted); font-size: .9rem; }
.notice { margin: 0; padding: 12px 16px; border-radius: 12px; background: #3a1f1f; color: #ffb4b4; }

.swatch {
  height: 56px;
  border-radius: 12px;
  margin-bottom: 14px;
  background: var(--light);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background .15s;
}
.swatch.active { border-color: var(--text); }

.slider { display: grid; gap: 8px; margin: 10px 0; }
.slider span { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); }
.slider output { color: var(--text); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  border-radius: 14px;
  background: #2a2a36;
  outline: none;
  margin: 0;
}
input[type="range"].hue {
  background: linear-gradient(90deg, hsl(0 100% 50%), hsl(60 100% 50%), hsl(120 100% 50%), hsl(180 100% 50%), hsl(240 100% 50%), hsl(300 100% 50%), hsl(360 100% 50%));
}
input[type="range"].sat {
  background: linear-gradient(90deg, #fff, hsl(var(--hue) 100% 50%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--bg);
  box-shadow: 0 1px 6px #0008;
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--bg);
}

.presets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 14px; }
.presets button { aspect-ratio: 1; border-radius: 50%; border: 2px solid #0006; padding: 0; }

#effects h3 { margin: 14px 0 4px; font-size: .95rem; color: var(--text); }
#effects h3:first-child { margin-top: 0; }
#effects details { border-top: 1px solid var(--line); }
#effects details:first-child { border-top: 0; }
summary { padding: 10px 0; cursor: pointer; font-weight: 500; }
main > details summary { padding: 0; }
main > details[open] summary { margin-bottom: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 12px; }
.chips button { font-size: .9rem; border-radius: 999px; }
.chips button.active { background: var(--light); color: var(--bg); border-color: var(--light); }

.toggle { display: flex; align-items: center; gap: 10px; margin-top: 6px; color: var(--muted); }
.toggle input { width: 20px; height: 20px; accent-color: var(--light); }

.timer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.timer .toggle { margin: 0; color: var(--text); }
.timer .time {
  font: inherit;
  color: var(--text);
  background: #22222c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
}
.timer:has(.enabled:not(:checked)) .time,
.timer:has(.enabled:not(:checked)) .days { opacity: .45; }
.days { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days button { padding: 8px 0; border-radius: 999px; font-size: .85rem; }
.days button[aria-pressed="true"] { background: var(--light); color: var(--bg); border-color: var(--light); }

code { color: var(--text); }
