:root {
  --bg: #16201a;
  --panel: #1f2b23;
  --panel-2: #283629;
  --line: #34463a;
  --text: #eef2ea;
  --muted: #9fb0a2;
  --accent: #ff7a1a;   /* blaze orange */
  --accent-ink: #1a0d00;
  --stop: #e5484d;
  --ok: #46c46b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding: calc(env(safe-area-inset-top) + 16px) 16px max(24px, env(safe-area-inset-bottom)); }
main { max-width: 560px; margin: 0 auto; display: grid; gap: 16px; }
[hidden] { display: none !important; }
button { font: inherit; }

/* sign in */
.login { max-width: 360px; padding-top: 12vh; justify-items: center; text-align: center; }
.login img { border-radius: 18px; }
.login h1 { margin: 0; font-size: 1.5rem; }
.login form { width: 100%; display: grid; gap: 10px; text-align: left; }
.login label { color: var(--muted); font-size: .9rem; }
.login input { width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 1.1rem; }
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login button { padding: 16px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  font-size: 1.1rem; font-weight: 800; cursor: pointer; }
.err { color: #fff; background: #5a1d20; border: 1px solid var(--stop); border-radius: 10px; padding: 10px 12px; margin: 0; }

header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 1.35rem; margin: 0; letter-spacing: .01em; white-space: nowrap; }
.conn { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #46c46b33; }
.dot.off { background: var(--stop); }
.dot.sleep { background: #6c8cff; }

.devices { display: flex; gap: 8px; overflow-x: auto; }
.devices button { flex: none; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.devices button[aria-pressed=true] { border-color: var(--accent); color: var(--accent); }

#msg { color: var(--muted); font-size: .95rem; margin: 0; }
#msg:empty { display: none; }
#msg.err { color: #fff; background: #5a1d20; border: 1px solid var(--stop); border-radius: 10px; padding: 12px 14px; }
#msg.warn { color: var(--text); background: #3a2f17; border: 1px solid #8a6a2a; border-radius: 10px; padding: 12px 14px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 8px; }

#now { border-color: var(--accent); background: linear-gradient(180deg, #2b2116, var(--panel)); display: grid; gap: 12px; }
#now .title { font-size: 1.3rem; font-weight: 700; }
#now .meta { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .9s linear; }

.row { display: flex; align-items: center; gap: 12px; }
input[type=range] { flex: 1; accent-color: var(--accent); height: 32px; }
.vol { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.seg button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 0; font-size: .95rem; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hint { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }

#play { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 16px;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 14px; padding: 18px 14px;
  font-size: 1.2rem; font-weight: 800; cursor: pointer; }
#play span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#play.stopping { background: var(--stop); color: #fff; letter-spacing: .03em; }
#play:disabled { background: var(--panel-2); color: var(--muted); border: 1px dashed var(--line); cursor: default; font-weight: 600; }

#sounds { display: grid; gap: 10px; }
.sound { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; font-size: 1.05rem; cursor: pointer; }
.sound .pick { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted);
  display: grid; place-items: center; color: var(--accent-ink); font-size: .85rem; font-weight: 900; }
.sound[aria-pressed=true] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #33291c; }
.sound[aria-pressed=true] .pick { background: var(--accent); border-color: var(--accent); }
.sound .name { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.sound .len { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9rem; }
.sound .tag { color: var(--accent); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.empty { color: var(--muted); text-align: center; padding: 12px; }

#sched { display: grid; gap: 12px; }
#sched .label { margin: 0; }
.switch { display: flex; align-items: center; gap: 12px; font-weight: 600; cursor: pointer; }
.switch input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
#windows { display: grid; gap: 8px; }
.win { display: flex; align-items: center; gap: 8px; }
.win input { flex: 1; min-width: 0; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; color-scheme: dark; }
.win span { color: var(--muted); }
.win button { flex: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: none; color: var(--muted); cursor: pointer; }
#sched.off #windows, #sched.off #addWindow { opacity: .5; }
#sched .hint, #sched .link { margin: 0; justify-self: start; }
.btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { background: var(--panel-2); color: var(--muted); border: 1px dashed var(--line); cursor: default; font-weight: 600; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sched-status { margin: 0; font-weight: 600; }
.sched-status:empty { display: none; }

.history { margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: .9rem; display: grid; gap: 4px; }
footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 8px 0; }
