:root {
  --bg: #0e0d12;
  --surface: #181720;
  --surface-2: #22202c;
  --line: #2e2b3a;
  --text: #f3f1f8;
  --muted: #a29fb2;
  --accent: #ff5aa5;
  --accent-ink: #1a0610;
  --danger: #ff6b6b;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

main { max-width: 520px; margin: 0 auto; }

header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
h1 { margin: 0; font-size: 1.5rem; line-height: 1.2; }
h2 { margin: 28px 0 10px; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.eyebrow { margin: 0; font-size: .8rem; color: var(--muted); }

.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 4px #ff6b6b22; }
.dot.on { background: #4ade80; box-shadow: 0 0 0 4px #4ade8022; }

.stack { display: grid; gap: 10px; }

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 12px 12px 16px;
}
.row.muted { opacity: .75; }
.row .name { font-weight: 600; }
.row .val { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 8px; font-weight: 400; }

input[type=range] {
  grid-column: 1 / 2;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  touch-action: pan-y;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 10px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--surface-2) var(--fill, 0%));
}
input[type=range]::-moz-range-track { height: 10px; border-radius: 999px; background: var(--surface-2); }
input[type=range]::-moz-range-progress { height: 10px; border-radius: 999px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -9px;
  border-radius: 50%; background: #fff; border: 3px solid var(--accent);
}
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
input[type=range]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.mute {
  grid-column: 2; grid-row: 1 / 3;
  width: 52px; height: 52px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  display: grid; place-items: center; cursor: pointer;
  transition: background .15s, transform .1s;
}
.mute:active { transform: scale(.94); }
.mute[aria-pressed=true] { background: var(--danger); color: #230808; border-color: var(--danger); }
.mute:focus-visible, .chip:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mute svg { width: 24px; height: 24px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 48px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer;
}
.chip[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }

#login { padding-top: 18vh; }
#loginForm { display: grid; gap: 12px; }
#loginForm label { color: var(--muted); }
#pin {
  height: 56px; font-size: 1.5rem; letter-spacing: .3em; text-align: center;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
}
#pin:focus-visible { outline: 2px solid var(--accent); }
.primary {
  min-height: 52px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; cursor: pointer;
}
#loginError { color: var(--danger); min-height: 1.5em; margin: 0; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
  max-width: 488px; margin: 0 auto; padding: 12px 16px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: none; }

#login { max-width: 420px; }

@media (max-width: 360px) {
  body { padding-left: 12px; padding-right: 12px; }
  h1 { font-size: 1.3rem; }
  .row { padding: 10px 10px 10px 12px; gap: 2px 8px; }
  .mute { width: 48px; height: 48px; }
  .chip { padding: 0 14px; }
}

@media (min-width: 720px) {
  body { padding-left: 32px; padding-right: 32px; }
  #app { max-width: 880px; }
  h1 { font-size: 1.9rem; }
  .stack { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .row { padding: 16px 16px 16px 20px; }
  .mute { width: 56px; height: 56px; }
  .chips { gap: 10px; }
  #toast { left: 50%; right: auto; width: 420px; transform: translate(-50%, 8px); }
  #toast.show { transform: translate(-50%, 0); }
}

@media (min-width: 1100px) {
  #app { max-width: 1040px; }
  #outputs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-height: 520px) and (orientation: landscape) {
  body { padding-top: 8px; padding-bottom: 12px; }
  h2 { margin-top: 16px; }
  input[type=range] { height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
