:root {
  --bg: #0d0f13;
  --panel: #15181f;
  --panel-2: #1c2029;
  --line: #2a2f3a;
  --text: #e6e9ef;
  --muted: #9aa3b2;
  --dim: #6b7383;
  --accent: #4f9cf9;
  --accent-2: #f2a33c;
  --good: #4ec98a;
  --bad: #ef6a6a;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

kbd {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 5px;
  color: var(--muted);
  vertical-align: middle;
}

/* ---------------------------------------------------------------- masthead */

.masthead {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #11141a, var(--bg));
}
.masthead-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 22px;
}
.masthead h1 {
  margin: 0 0 12px;
  font-size: 25px;
  letter-spacing: -0.01em;
}
.lede {
  margin: 0 0 8px;
  max-width: 76ch;
  color: var(--muted);
}
.lede em { color: var(--text); font-style: normal; font-weight: 600; }

/* ------------------------------------------------------------------ layout */

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 24px 60px;
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.panel h2 { margin: 0 0 4px; font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.panel h3 { margin: 0 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.hint { color: var(--dim); font-size: 12.5px; margin: 4px 0 0; }
.hint strong { color: var(--muted); }

/* ------------------------------------------------------------------ tracks */

.track-list { list-style: none; margin: 12px 0 0; padding: 0; }
.track-list li { margin-bottom: 6px; }
.track-list button {
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  padding: 9px 11px;
  cursor: pointer;
  font: inherit;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
}
.track-list button:hover { border-color: var(--line); }
.track-list button[aria-current="true"] { border-color: var(--accent); background: #1b2433; }
.track-title { font-weight: 600; font-size: 13.5px; }
.track-sub { grid-column: 1 / -1; color: var(--dim); font-size: 11.5px; }
.track-list button[data-nodrums="true"] .track-title { color: var(--muted); }
.track-list button[data-nodrums="true"] .track-sub { color: var(--accent-2); }
.perc {
  font: 11px/1 ui-monospace, monospace;
  color: var(--accent-2);
  white-space: nowrap;
}
/* Second grid column: the percussiveness score plus the per-track spinner, so
   it is obvious *which* track you are waiting on, not just that you are. */
.track-flags { align-self: center; display: flex; align-items: center; gap: 7px; }
/* Unranked tracks render an empty .perc; without this the flex gap still
   applies and pushes the spinner off the column edge. */
.perc:empty { display: none; }
.track-list button:not([data-loading="true"]) .spinner { display: none; }
.track-meta { margin: 14px 0 0; color: var(--dim); font-size: 12px; border-top: 1px solid var(--line); padding-top: 12px; }

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

.stage { display: grid; gap: 20px; }

.status {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.status[data-kind="error"] { border-left-color: var(--bad); color: #ffb4b4; }
.status[data-kind="ok"] { border-left-color: var(--good); }
.status[hidden] { display: none; }
/* Nudged down so it sits on the first line's centre, not above it, when the
   message wraps to several lines. */
.status .spinner { margin-top: 3px; }
.status:not([data-busy="true"]) .spinner { display: none; }

/* ----------------------------------------------------------------- spinner */

.spinner {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-sm { width: 11px; height: 11px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Still has to read as "busy", so pulse instead of rotate. */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: pulse 1.4s ease-in-out infinite; border-color: var(--accent); }
  @keyframes pulse { 50% { opacity: .25; } }
}

.now-playing h2 { margin: 0; font-size: 20px; letter-spacing: -0.01em; text-transform: none; color: var(--text); }
.np-sub { margin: 3px 0 0; color: var(--dim); font-size: 13px; }

/* --------------------------------------------------------------------- A/B */

.ab { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .ab { grid-template-columns: 1fr; } }

.arm {
  display: grid;
  gap: 3px;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  transition: border-color .12s, background .12s, color .12s;
}
.arm:hover { border-color: #3b4250; }
.arm[aria-pressed="true"] {
  border-color: var(--accent);
  background: #1a2231;
  color: var(--text);
}
.arm-tag {
  font: 700 11px/1 ui-monospace, monospace;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.arm[aria-pressed="true"] .arm-tag { color: var(--accent); }
.arm-name { font-weight: 600; font-size: 15px; }
.arm-detail { font-size: 12px; color: var(--dim); }

/* ---------------------------------------------------------------- controls */

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 620px) { .controls { grid-template-columns: 1fr; } }

.control-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.control-head label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.control-head output { font: 600 17px/1 ui-monospace, monospace; color: var(--accent); }

/* --thumb is the full thumb diameter, border included. The scale labels below
   are positioned from it, so both must agree or the labels drift. */
input[type="range"] {
  --thumb: 16px;
  width: 100%;
  appearance: none;
  height: 22px;
  /* Chrome gives range inputs a 2px side margin; it would offset the track from
     the label row below and put every label 2px off. */
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--line); border-radius: 2px; }
input[type="range"]::-moz-range-track { height: 4px; background: var(--line); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  box-sizing: border-box;
  width: var(--thumb); height: var(--thumb);
  margin-top: calc((4px - var(--thumb)) / 2);
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0d0f13;
}
input[type="range"]::-moz-range-thumb {
  box-sizing: border-box;
  width: var(--thumb); height: var(--thumb);
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0d0f13;
}

/* The thumb centre travels between thumb/2 and (100% - thumb/2), so a label can
   only line up with its value if it is placed on that same inset track. --at is
   the value's 0..1 position, written by layoutScales() in app.mjs. */
.scale {
  position: relative;
  height: 12px;
  font: 11px/1 ui-monospace, monospace;
  color: var(--dim);
}
.scale > span {
  --thumb: 16px;
  position: absolute;
  top: 0;
  left: calc(var(--thumb) / 2 + var(--at, 0) * (100% - var(--thumb)));
  transform: translateX(-50%);
  white-space: nowrap;
}

/* Tells you whether you're hearing the product or the feature. */
.proc-note {
  margin: 0;
  font-size: 12.5px;
  padding: 7px 11px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.proc-note[data-active="false"] { color: var(--good); border-left: 3px solid var(--good); }
.proc-note[data-active="true"] { color: var(--accent-2); border-left: 3px solid var(--accent-2); }
.proc-note:empty { display: none; }

/* --------------------------------------------------------------- transport */

.transport { display: flex; align-items: center; gap: 14px; }
.scrub { flex: 1; }
.time { font: 12px/1 ui-monospace, monospace; color: var(--muted); min-width: 92px; }

button.primary {
  background: var(--accent);
  color: #06121f;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font: 600 14px/1 inherit;
  cursor: pointer;
}
button.primary:disabled { background: var(--line); color: var(--dim); cursor: default; }
button.primary kbd { background: rgba(0,0,0,.2); border-color: rgba(0,0,0,.3); color: #06121f; }

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 7px;
  padding: 6px 11px;
  font: 13px/1.2 inherit;
  cursor: pointer;
}
button.ghost:hover:not(:disabled) { border-color: #3b4250; color: var(--text); }
button.ghost:disabled { opacity: .45; cursor: default; }

.loop-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.loop-state { font: 12px/1 ui-monospace, monospace; color: var(--accent-2); }

/* ------------------------------------------------------------------- stems */

.stem-table { width: 100%; border-collapse: collapse; margin: 12px 0 10px; font-size: 13px; }
.stem-table th {
  text-align: left;
  font: 600 11px/1 inherit;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  padding: 0 10px 7px 0;
  border-bottom: 1px solid var(--line);
}
.stem-table td { padding: 8px 10px 8px 0; border-bottom: 1px solid #21252e; }
.stem-table tr[data-silent="true"] td { color: var(--dim); }
.stem-name { font-weight: 600; }
.badge {
  display: inline-block;
  font: 600 10.5px/1 ui-monospace, monospace;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge[data-routing="key"] { border-color: #35507a; color: #8fbdf5; }
.badge[data-routing="bypass"] { border-color: #7a5a2a; color: var(--accent-2); }
.toggle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--dim);
  border-radius: 5px;
  padding: 3px 9px;
  font: 11px/1.3 inherit;
  cursor: pointer;
}
.toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: #16202f; }

/* ------------------------------------------------------ details / footer */

details {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 14px;
}
details summary { cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--muted); }
details[open] summary { margin-bottom: 8px; color: var(--text); }
details ul { margin: 6px 0 0; padding-left: 20px; color: var(--muted); font-size: 13px; }
details li { margin-bottom: 5px; }

pre {
  margin: 8px 0 0;
  font: 11.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  white-space: pre-wrap;
  background: #0f1218;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}
pre:empty { display: none; }
.pass { color: var(--good); }
.fail { color: var(--bad); }

.foot {
  border-top: 1px solid var(--line);
  padding: 18px 24px 40px;
}
.foot p { max-width: 1180px; margin: 0 auto; color: var(--dim); font-size: 12px; }
