:root {
  --bg: #07090d;
  --panel: rgba(255, 255, 255, 0.028);
  --panel-line: rgba(255, 255, 255, 0.07);
  --text: #e8ecf3;
  --muted: #8b93a7;
  --teal: #4fd8c4;
  --violet: #7c6cff;
  --amber: #ffb454;
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(124, 108, 255, 0.12), transparent 60%),
    radial-gradient(900px 550px at 95% 0%, rgba(79, 216, 196, 0.10), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(124, 108, 255, 0.07), transparent 60%);
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- header ---------- */

.top {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 12px; }

.wordmark {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.035em;
  background: linear-gradient(92deg, var(--teal) 10%, var(--violet) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tag { color: var(--muted); font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; }

.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- cards ---------- */

.card {
  background: linear-gradient(180deg, var(--panel), rgba(255, 255, 255, 0.012));
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text); }

.hint { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.hint b { color: var(--text); font-weight: 600; }

/* ---------- buttons & inputs ---------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: #0a0d12;
  background: linear-gradient(92deg, var(--teal), #6fdcc0);
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s, opacity 0.15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.35; cursor: default; }

.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
.btn.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.09); filter: none; }
.btn.ghost.active { border-color: var(--teal); color: var(--teal); box-shadow: 0 0 14px rgba(79, 216, 196, 0.18); }

.btn.sm { padding: 5px 11px; font-size: 12.5px; }

.btn.big {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 12px 0;
}

.rec-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #c22f3e;
  box-shadow: 0 0 0 3px rgba(194, 47, 62, 0.25);
}
.btn.big.sampling .rec-dot { animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(194, 47, 62, 0.12); } }

.select, .text {
  appearance: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px 12px;
}
.select { padding-right: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b93a7' fill='none' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.select.sm { padding: 6px 24px 6px 10px; font-size: 12.5px; }
.select option, .select optgroup { background: #12151c; color: var(--text); }
.text:focus, .select:focus { border-color: rgba(79, 216, 196, 0.5); }
.text::placeholder { color: #8b93a7; } /* was 0.6 alpha — 2.85:1, below the 4.5:1 minimum */

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 22px;
  background: transparent;
  cursor: pointer;
  width: 100%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(79, 216, 196, 0.7), rgba(124, 108, 255, 0.7));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  margin-top: -5px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(79, 216, 196, 0.7), rgba(124, 108, 255, 0.7));
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
}

.hidden { display: none !important; }

/* available to assistive tech, invisible on screen */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* One visible focus treatment for every control. Teal is the app's accent, so
   it is paired with an offset ring rather than a colour change alone. */
.btn:focus-visible,
.play:focus-visible,
.select:focus-visible,
.text:focus-visible,
.seg button:focus-visible,
.vs-rail:focus-visible,
input[type="range"]:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

/* ---------- stage ---------- */

.transport { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }

.play {
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: #071015;
  background: linear-gradient(135deg, var(--teal), var(--violet));
  box-shadow: 0 6px 24px rgba(79, 216, 196, 0.35);
  display: grid;
  place-items: center;
  transition: transform 0.12s, box-shadow 0.2s;
  flex-shrink: 0;
}
.play svg { width: 26px; height: 26px; }
.play:hover { transform: scale(1.05); }
.play.running { box-shadow: 0 6px 30px rgba(124, 108, 255, 0.45); }

.now { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.now-label { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
#nowPlaying { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.master { display: flex; align-items: center; gap: 10px; width: 200px; color: var(--muted); }
.master svg { width: 18px; height: 18px; flex-shrink: 0; }

.tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.timer { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.timer svg { width: 17px; height: 17px; flex-shrink: 0; }
.timer-left { font-size: 12px; color: var(--teal); font-variant-numeric: tabular-nums; min-width: 0; }

#recBtn.recording {
  border-color: rgba(194, 47, 62, 0.65);
  color: #ff8a96;
  box-shadow: 0 0 14px rgba(194, 47, 62, 0.25);
  animation: recblink 1.4s infinite;
}
@keyframes recblink { 50% { box-shadow: 0 0 4px rgba(194, 47, 62, 0.1); } }

#scope {
  display: block;
  width: 100%;
  height: 230px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
}

/* ---------- eq ---------- */

.bands {
  display: flex;
  gap: 10px;
  height: 190px;
  padding: 4px 2px 0;
}

.vs { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }

.vs-rail {
  position: relative;
  width: 100%;
  max-width: 44px;
  flex: 1;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  cursor: ns-resize;
  touch-action: none;
}

.vs-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, hsl(var(--h) 78% 64% / 0.9), hsl(var(--h) 78% 52% / 0.22));
  pointer-events: none;
}

.vs-thumb {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5), 0 0 0 4px hsl(var(--h) 78% 60% / 0.22);
  pointer-events: none;
}

.vs-mark {
  position: absolute;
  left: -4px; right: -4px;
  height: 2px;
  transform: translateY(50%);
  background: var(--amber);
  box-shadow: 0 0 8px rgba(255, 180, 84, 0.7);
  border-radius: 2px;
  pointer-events: none;
}

.vs-lab { margin-top: 8px; font-size: 11px; color: var(--muted); }

.eq-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- sources ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  gap: 12px;
}

.src {
  border-radius: 14px;
  padding: 13px 13px 9px;
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.src.on {
  border-color: rgba(79, 216, 196, 0.4);
  background: linear-gradient(180deg, rgba(79, 216, 196, 0.07), rgba(124, 108, 255, 0.045));
  box-shadow: 0 0 22px rgba(79, 216, 196, 0.1);
}

.src-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.src-ic { color: var(--muted); display: grid; place-items: center; transition: color 0.2s; }
.src-ic svg { width: 25px; height: 25px; }
.src.on .src-ic { color: var(--teal); }

.src-name { min-width: 0; flex: 1; line-height: 1.25; }
.src-name b { font-size: 13.5px; display: block; }
.src-name small { color: var(--muted); font-size: 11px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-name.clicky { cursor: pointer; }
.src-name.clicky:hover small { color: var(--teal); }

.src-extra { margin-top: 7px; }
.src-extra .select { width: 100%; }
.src-note { display: inline-block; margin-top: 6px; font-size: 11px; color: var(--muted); }
.src-note:hover { color: var(--amber); }

/* toggle */
.switch { position: relative; display: inline-block; width: 36px; height: 21px; flex-shrink: 0; }
/* visually hidden but still a real 1px box — a 0x0 control gives the focus
   ring nothing to draw around, leaving keyboard users with no position cue */
.switch input {
  position: absolute;
  top: 0; left: 0;
  width: 1px; height: 1px;
  margin: 0;
  opacity: 0;
}
.switch input:focus-visible + span {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}
.switch span {
  position: absolute; inset: 0;
  border-radius: 21px;
  background: rgba(255, 255, 255, 0.1);
  transition: background 0.2s;
  cursor: pointer;
}
.switch span::before {
  content: "";
  position: absolute;
  width: 15px; height: 15px;
  left: 3px; top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.switch input:checked + span { background: linear-gradient(92deg, var(--teal), var(--violet)); }
.switch input:checked + span::before { transform: translateX(15px); }

/* ---------- duo panels ---------- */

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
/* grid items default to min-width:auto, which lets the embed's minimum size
   push the card wider than the screen — this lets them shrink instead */
.duo > .card { min-width: 0; }
@media (max-width: 920px) { .duo { grid-template-columns: 1fr; } }

.yt-row { display: flex; gap: 8px; }
.yt-row .text { flex: 1; min-width: 0; }

.yt-wrap {
  margin-top: 12px;
  /* YouTube's terms require a player viewport of at least 200x200px, and a
     plain 16:9 box falls under 200px tall on every phone in portrait. The
     explicit width keeps aspect-ratio deriving height from width — without it
     min-height drives the ratio backwards and the box overflows the page. */
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 200px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.yt-wrap iframe { width: 100%; height: 100%; display: block; }

.yt-vol { display: flex; align-items: center; gap: 12px; margin-top: 10px; color: var(--muted); font-size: 12.5px; }
.yt-vol label { white-space: nowrap; }

/* ---------- masking lab ---------- */

.lab-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.seg { display: inline-flex; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  appearance: none; border: none; background: transparent;
  color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 6px 11px; border-radius: 8px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg button.on { background: rgba(79, 216, 196, 0.16); color: var(--teal); font-weight: 700; }
/* a check mark, not just a tint — selection must not rely on colour alone.
   The space is always reserved so toggling causes no layout shift. */
.seg button::before { content: "✓"; opacity: 0; margin-right: 5px; }
.seg button.on::before { opacity: 1; }

.lab-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.lab-progress .bar { flex: 1; height: 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.lab-progress .bar i { display: block; height: 100%; width: 0; border-radius: 5px; background: linear-gradient(90deg, var(--teal), var(--violet)); transition: width 0.15s linear; }
.lab-progress span { font-size: 12px; color: var(--muted); min-width: 34px; text-align: right; }

.lab-view { position: relative; }

#labCanvas {
  display: block;
  width: 100%;
  height: 96px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
}

/* real text rather than pixels painted into the canvas */
.lab-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0 14px;
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}

.lab-apply { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.lab-apply .btn { flex: 1; white-space: nowrap; }
.lab-apply .btn.ghost { flex: 0; }

/* ---------- footer / toast ---------- */

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 20px 34px;
}

footer a { color: var(--muted); text-decoration: underline; margin-left: 6px; }
footer a:hover { color: var(--text); }

/* ---------- document pages (privacy, terms) ---------- */

.doc { max-width: 780px; margin: 0 auto; padding: 0 20px 60px; }
.doc .card { padding: 30px 34px; }
.doc h1 { font-size: 34px; letter-spacing: -0.02em; margin-bottom: 6px; color: var(--text); background: none; -webkit-text-fill-color: currentColor; }
.doc .updated { color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.doc h2 {
  font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--teal); margin: 32px 0 10px;
}
.doc h2:first-of-type { margin-top: 0; }
.doc h3 { font-size: 15px; margin: 20px 0 6px; color: var(--text); }
.doc p, .doc li { color: #c3cad8; margin-bottom: 12px; line-height: 1.62; }
.doc ul { padding-left: 20px; }
.doc li { margin-bottom: 8px; }
.doc a { color: var(--teal); }
.doc strong { color: var(--text); }
.doc .lede {
  background: rgba(79, 216, 196, 0.07);
  border-left: 3px solid var(--teal);
  border-radius: 0 10px 10px 0;
  padding: 16px 18px;
  margin-bottom: 26px;
}
.doc .lede p:last-child { margin-bottom: 0; }
.doc .warn {
  background: rgba(255, 180, 84, 0.08);
  border-left: 3px solid var(--amber);
  border-radius: 0 10px 10px 0;
  padding: 16px 18px;
  margin: 18px 0;
}
.doc .warn p:last-child, .doc .warn ul:last-child { margin-bottom: 0; }
.doc .warn h3 { margin-top: 0; color: var(--amber); }

/* unmistakable in the rendered page so it cannot ship unfilled */
.todo {
  background: #ffb454;
  color: #1a1205;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 5px;
}

.doc-nav { display: flex; gap: 16px; font-size: 13px; margin-bottom: 22px; }
.doc-nav a { color: var(--muted); text-decoration: none; }
.doc-nav a:hover, .doc-nav a[aria-current] { color: var(--teal); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  background: #171b24;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: min(480px, 90vw);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  /* the visualiser keeps rendering — it is the point of the panel — but
     main.js throttles it hard, and drift is disabled entirely */
}

@media (max-width: 640px) {
  .bands { gap: 5px; height: 160px; }
  .vs-lab { font-size: 9.5px; }
  .master { width: 140px; }
  #scope { height: 160px; }
}
