/* =====================================================================
   BLAST RADIUS — a BombFactions transmission
   -----------------------------------------------------------------
   The whole interface. Playback lives in scripts/app.js; the dial, the
   waveform, the colour of the room and the panels live in scripts/blast.js.

   The idea: you are not looking at a music player, you are standing in the
   room the signal is broadcast from.
     env      – the room: an aurora in the current cover's colours, the 3D
                scene full-bleed behind everything, grain, vignette
     topbar   – call sign and live telemetry (every number is real)
     stage    – now transmitting · the dial · who's in range
     dial     – every station in the list on a rotating band; drag it and you
                tune through static; the cover spins in the middle like a
                record; shockwaves leave it on every beat
     deck     – the waveform scrubber and the keys
     drawers  – Index (every station) and System (how the rig behaves)

   Colour is not fixed. blast.js samples each cover and writes its hue to
   --ah / --as; both are registered properties, so the entire room — dial,
   glow, keys, aurora — slides to the new colour whenever the track changes.
   Uranium green is the fallback when a cover has no colour to give.
   ===================================================================== */

@property --ah {
  syntax: "<number>";
  inherits: true;
  initial-value: 84;
}

@property --as {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 100%;
}

@property --al {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 62%;
}

:root {
  color-scheme: dark;

  /* Hue, saturation and lightness of the current cover (lightness is lifted
     for blues and violets so the accent keeps its contrast on black). */
  --ah: 84;
  --as: 100%;
  --al: 62%;
  --accent: hsl(var(--ah) var(--as) var(--al));
  --accent-hi: hsl(var(--ah) var(--as) calc(var(--al) + 16%));
  --accent-deep: hsl(var(--ah) var(--as) calc(var(--al) - 28%));
  --accent-a08: hsl(var(--ah) var(--as) var(--al) / 0.08);
  --accent-a15: hsl(var(--ah) var(--as) var(--al) / 0.15);
  --accent-a30: hsl(var(--ah) var(--as) var(--al) / 0.3);
  --accent-a55: hsl(var(--ah) var(--as) var(--al) / 0.55);
  --counter: hsl(calc(var(--ah) + 150) 85% 58%);

  --void: #04050a;
  --void-a: rgba(4, 5, 10, 0.92);
  --text: #eef1f8;
  --text-2: #c3c8d6;
  --dim: #9aa1b5;
  --faint: #7a8196;
  --hair: rgba(255, 255, 255, 0.09);
  --hair-2: rgba(255, 255, 255, 0.16);
  --hair-3: rgba(255, 255, 255, 0.26);

  --font-display: "Unbounded", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Written by the engine / blast.js. */
  --ui-bass: 0;
  --ui-shimmer: 0;
  --beat: 500ms;
  --transport-dock-h: 150px;

  /* Frame. The stage sits between the bars; --cy is the dial's centre, which
     the scene and the grid both centre on, so the 3D core glows through the
     middle of the dial. */
  --top-h: 68px;
  --deck-h: 156px;
  --dial: min(42vw, calc(100dvh - var(--top-h) - var(--deck-h) - 40px), 660px);
  --cy: calc(var(--top-h) + (100dvh - var(--top-h) - var(--deck-h)) / 2);
  --cx: 50vw;
  /* The two above are CSS's estimate of the dial's centre. Once running,
     blast.js measures the real one and writes it here (frameRoom). */

  transition: --ah 1.8s ease, --as 1.8s ease, --al 1.8s ease;
  font-family: var(--font-body);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

/* Simple mode strips every advanced control from the flow. */
body.is-simple-mode .adv-only {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 999px; }
*::-webkit-scrollbar-track { background: transparent; }

/* =====================================================================
   The room
   ===================================================================== */

.env {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--void);
  animation: env-in 1.4s ease both;
}

.env__aurora {
  position: absolute;
  inset: -25%;
  background:
    radial-gradient(34% 30% at 32% 38%, hsl(var(--ah) var(--as) 50% / 0.34), transparent 70%),
    radial-gradient(30% 28% at 70% 62%, hsl(calc(var(--ah) + 150) 80% 48% / 0.16), transparent 70%),
    radial-gradient(55% 40% at 50% 108%, hsl(var(--ah) var(--as) 42% / 0.26), transparent 70%),
    radial-gradient(40% 30% at 90% 0%, hsl(calc(var(--ah) - 40) 80% 50% / 0.12), transparent 70%);
  animation: aurora 42s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes aurora {
  0% { transform: translate3d(-5%, -3%, 0) rotate(0deg) scale(1); }
  50% { transform: translate3d(3%, 2%, 0) rotate(6deg) scale(1.08); }
  100% { transform: translate3d(5%, -2%, 0) rotate(-4deg) scale(1.02); }
}

/* Range rings around the dial, fading out to the edges. */
.env__grid {
  position: absolute;
  inset: 0;
  background:
    repeating-radial-gradient(circle at var(--cx) var(--cy), transparent 0 calc(var(--dial) * 0.62), rgba(255, 255, 255, 0.045) calc(var(--dial) * 0.62 + 1px), transparent calc(var(--dial) * 0.62 + 2px) calc(var(--dial) * 0.21)),
    linear-gradient(90deg, transparent calc(var(--cx) - 0.5px), rgba(255, 255, 255, 0.04) var(--cx), transparent calc(var(--cx) + 0.5px)),
    linear-gradient(0deg, transparent calc(100% - var(--cy) - 0.5px), rgba(255, 255, 255, 0.04) calc(100% - var(--cy)), transparent calc(100% - var(--cy) + 0.5px));
  -webkit-mask-image: radial-gradient(circle at var(--cx) var(--cy), #000 20%, transparent 75%);
  mask-image: radial-gradient(circle at var(--cx) var(--cy), #000 20%, transparent 75%);
}

/* The 3D scene. Centred on the dial, not the viewport: the box is stretched
   so its middle lands on --cy, and the renderer sizes itself from this box.
   Screen-blended, so the scene's black is transparent and the aurora shows
   through. */
.env__scene {
  --o: calc(var(--cy) - 50dvh);
  --ox: calc(var(--cx) - 50vw);
  position: absolute;
  left: min(0px, calc(2 * var(--ox)));
  width: calc(100vw + 2 * max(var(--ox), calc(-1 * var(--ox))));
  top: min(0px, calc(2 * var(--o)));
  height: calc(100dvh + 2 * max(var(--o), calc(-1 * var(--o))));
  display: block;
  mix-blend-mode: screen;
  opacity: 0.9;
  filter: hue-rotate(calc((var(--ah) - var(--scene-hue, 195)) * 1deg));
  transition: opacity 1s ease;
}

body:not(.is-playing) .env__scene { opacity: 0.35; }

body.visuals-lite .env__scene,
body.visuals-off .env__scene,
body.visualizer-hidden .env__scene {
  display: none;
}

.env__vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 75% 70% at var(--cx) var(--cy), transparent 40%, rgba(4, 5, 10, 0.75) 100%),
    linear-gradient(180deg, rgba(4, 5, 10, 0.6), transparent 18%, transparent 70%, rgba(4, 5, 10, 0.85));
}

.env__grain {
  position: absolute;
  inset: 0;
  opacity: 0.07;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -0.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.9) 0 1px, transparent 1px 3px);
}

@keyframes env-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* =====================================================================
   Top bar
   ===================================================================== */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  height: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) clamp(16px, 2.4vw, 36px) 0;
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 32px);
  animation: drop-in 0.8s var(--ease-out) 0.15s both;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand__mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  overflow: visible;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
}

.brand__core {
  fill: var(--accent);
  stroke: none;
  filter: drop-shadow(0 0 4px var(--accent));
}

.brand__wave { transform-origin: 24px 24px; }
.brand__wave--2 { opacity: 0.65; }
.brand__wave--3 { opacity: 0.35; }
.brand__cross { stroke: var(--hair-3); stroke-width: 1.2; }

body.is-playing .brand__wave {
  animation: brand-wave calc(var(--beat) * 2) ease-out infinite;
}

body.is-playing .brand__wave--2 { animation-delay: calc(var(--beat) * -0.66); }
body.is-playing .brand__wave--3 { animation-delay: calc(var(--beat) * -1.33); }

@keyframes brand-wave {
  0% { transform: scale(0.4); opacity: 1; }
  100% { transform: scale(1.15); opacity: 0; }
}

.brand__type {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.brand__name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.08rem;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand__name b {
  font-weight: 300;
  margin-left: 0.28em;
  color: var(--accent);
  text-shadow: 0 0 18px var(--accent-a55);
}

.brand__sub {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
}

/* --- telemetry --- */

.telemetry {
  display: flex;
  align-items: stretch;
  margin: 0 auto;
  padding: 0;
  border: 1px solid var(--hair);
  border-radius: 12px;
  background: rgba(6, 8, 14, 0.55);
}

.telemetry__cell {
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 8px 16px;
  border-left: 1px solid var(--hair);
  min-width: 0;
}

.telemetry__cell:first-child { border-left: 0; }

.telemetry dt {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--faint);
}

.telemetry dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

.telemetry dd small {
  margin-left: 4px;
  font-size: 0.56rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--dim);
}

#teleFreq {
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent-a55);
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.62rem !important;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--dim) !important;
}

.live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

.live__on { display: none; }

body.is-playing .live { color: var(--accent) !important; }
body.is-playing .live i {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent), 0 0 22px var(--accent-a55);
  animation: blink 1.4s steps(2, jump-none) infinite;
}
body.is-playing .live__on { display: inline; }
body.is-playing .live__off { display: none; }

@keyframes blink {
  50% { opacity: 0.3; }
}

.signal {
  display: inline-flex !important;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
}

.signal i {
  width: 4px;
  border-radius: 1px;
  background: var(--hair-2);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.signal i:nth-child(1) { height: 30%; }
.signal i:nth-child(2) { height: 45%; }
.signal i:nth-child(3) { height: 62%; }
.signal i:nth-child(4) { height: 80%; }
.signal i:nth-child(5) { height: 100%; }

.signal[data-level="1"] i:nth-child(-n + 1),
.signal[data-level="2"] i:nth-child(-n + 2),
.signal[data-level="3"] i:nth-child(-n + 3),
.signal[data-level="4"] i:nth-child(-n + 4),
.signal[data-level="5"] i:nth-child(-n + 5) {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-a55);
}

/* --- panel buttons --- */

.topbar__actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px 0 13px;
  border: 1px solid var(--hair-2);
  border-radius: 999px;
  background: rgba(6, 8, 14, 0.55);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.hud-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.hud-btn:hover,
.hud-btn[aria-expanded="true"] {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-a15);
  box-shadow: 0 0 22px var(--accent-a15);
}

/* =====================================================================
   Stage
   ===================================================================== */

.stage {
  position: fixed;
  z-index: 10;
  left: 0;
  right: 0;
  top: var(--top-h);
  bottom: var(--deck-h);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--dial) minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 4vw, 80px);
  padding: 0 clamp(20px, 3vw, 56px);
}

/* Both flanking columns sit on a soft pool of dark so they stay legible
   over whatever the scene is doing behind them. */
.now,
.side {
  position: relative;
  isolation: isolate;
}

.now::before,
.side::before {
  content: "";
  position: absolute;
  inset: -70px -90px;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(4, 5, 10, 0.72), rgba(4, 5, 10, 0.4) 60%, transparent);
}

/* --- now transmitting --- */

.now {
  justify-self: end;
  width: min(100%, 460px);
  display: grid;
  gap: 10px;
  animation: rise-in 0.9s var(--ease-out) 0.45s both;
}

.now__eyebrow {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--dim);
}

.now__pip {
  width: 22px;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.now__title {
  position: relative;
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.7rem, 2.9vw, 3.2rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  text-shadow: 0 0 40px var(--accent-a30);
}

.now__title[data-len="long"] { font-size: clamp(1.4rem, 2.3vw, 2.5rem); }
.now__title[data-len="xlong"] { font-size: clamp(1.2rem, 1.9vw, 2.05rem); }

/* Decode effect: while a new title arrives, the real text is held invisible
   and a scrambled copy (written by blast.js to data-decode) resolves over it. */
.now__title.is-decoding { color: transparent; }

.now__title.is-decoding::after {
  content: attr(data-decode);
  position: absolute;
  inset: 0;
  color: var(--accent-hi);
  text-shadow: 0 0 22px var(--accent-a55);
}

.now__artist {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.now__artist::before {
  content: "";
  width: 14px;
  height: 1px;
  background: currentColor;
}

.now__chips {
  display: flex;
  gap: 6px;
}

.chip-read {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--hair-2);
  border-radius: 8px;
  font-family: var(--font-mono);
}

.chip-read span {
  font-size: 0.5rem;
  letter-spacing: 0.22em;
  color: var(--faint);
}

.chip-read b {
  font-size: 0.86rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.chip-read.is-locked,
.chip-read--sync { border-color: var(--accent-a55); }
.chip-read--sync b,
.chip-read.is-locked b { color: var(--accent); }
.chip-read[hidden] { display: none; }

.now__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.now__next {
  margin: 8px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--hair);
  font-size: 0.86rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now__next-label {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: 0.54rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--faint);
}

.share-feedback {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--accent);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.share-feedback.is-visible { opacity: 1; transform: none; }

/* --- in range --- */

.side {
  justify-self: start;
  width: min(100%, 300px);
  display: grid;
  gap: 26px;
  animation: rise-in 0.9s var(--ease-out) 0.55s both;
}

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

.side__label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--faint);
}

.roster {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.roster__btn {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.roster__name {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roster__count {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* Share of the library, drawn as a hairline under each name. */
.roster__btn::after {
  content: "";
  position: absolute;
  left: 10px;
  bottom: 3px;
  height: 2px;
  width: calc((100% - 20px) * var(--share, 0));
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.55;
}

.roster__btn:hover { background: rgba(255, 255, 255, 0.04); border-color: var(--hair); }
.roster__btn:hover .roster__name { color: var(--text); }

.roster__btn.is-on { border-color: var(--accent-a55); background: var(--accent-a08); }
.roster__btn.is-on .roster__name { color: var(--accent); }
.roster__btn.is-live .roster__name::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 8px 1px 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.scene__hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--dim);
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes drop-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: none; }
}

@keyframes lift-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

/* =====================================================================
   The dial
   ===================================================================== */

.dial {
  position: relative;
  width: var(--dial);
  height: var(--dial);
  container-type: size;
  user-select: none;
  -webkit-user-select: none;
}

.dial > * {
  position: absolute;
  inset: 0;
}

/* --- shockwaves: one leaves the record on every beat --- */

.dial__shock {
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

body.is-playing .dial__shock { opacity: 1; }

/* Bass glow around the record. A fixed glow whose opacity follows --ui-bass
   (written every frame by the 3D scene): opacity is a compositor change,
   where a bass-sized box-shadow would repaint a big blur sixty times a
   second. */
.dial__shock::before {
  content: "";
  position: absolute;
  inset: 17%;
  border-radius: 50%;
  box-shadow: 0 0 90px 10px var(--accent-a55);
  opacity: calc(0.15 + var(--ui-bass) * 0.85);
  will-change: opacity;
}

.dial__shock i {
  position: absolute;
  inset: 17%;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 24px var(--accent-a55), inset 0 0 24px var(--accent-a30);
  opacity: 0;
  animation: shock calc(var(--beat) * 3) cubic-bezier(0.05, 0.6, 0.3, 1) infinite;
  animation-play-state: paused;
  will-change: transform, opacity;
}

.dial__shock i:nth-child(2) { animation-delay: calc(var(--beat) * -1); }
.dial__shock i:nth-child(3) { animation-delay: calc(var(--beat) * -2); }

body.is-playing .dial__shock i { animation-play-state: running; }

@keyframes shock {
  0% { transform: scale(1); opacity: 0.85; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* --- lite profile: a ring of bars around the band (iOS) --- */

.dial__lite {
  display: none;
  pointer-events: none;
}

body.visuals-lite .dial__lite { display: block; }
body.visualizer-hidden .dial__lite { display: none; }

.dial__lite i {
  position: absolute;
  left: calc(50% - 1.5px);
  bottom: 50%;
  width: 3px;
  height: 14%;
  border-radius: 3px;
  transform-origin: 50% 100%;
  rotate: calc(var(--i, 0) * 360deg / 28);
  background: linear-gradient(0deg, var(--accent), var(--accent-hi));
  box-shadow: 0 0 10px var(--accent-a55);
  opacity: 0.5;
  transform: translateY(-51cqw) scaleY(0.14);
  animation: lite-meter calc(var(--lite-beat, 268ms) * var(--lite-beats, 2))
    calc(var(--lite-beat, 268ms) * var(--lite-phase, 0) * -2) ease-in-out infinite alternate;
  animation-play-state: paused;
}

body.is-playing .dial__lite i { animation-play-state: running; }

@keyframes lite-meter {
  from { transform: translateY(-51cqw) scaleY(0.14); opacity: 0.4; }
  to { transform: translateY(-51cqw) scaleY(var(--lite-peak, 0.6)); opacity: 0.95; }
}

/* --- bezel: the fixed outer ring and the progress arc --- */

.dial__bezel {
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  animation: bezel-in 1.2s var(--ease-out) 0.1s both;
}

.dial__bezel-ring {
  fill: none;
  stroke: var(--hair-2);
  stroke-width: 1.5;
}

.bz { stroke: var(--hair-2); stroke-width: 2; }
.bz--major { stroke: var(--hair-3); stroke-width: 3; }

.dial__arc-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 10;
}

.dial__arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 8px var(--accent));
  transition: stroke-dashoffset 0.25s linear;
}

@keyframes bezel-in {
  from { opacity: 0; transform: rotate(-40deg) scale(0.9); }
  to { opacity: 1; transform: none; }
}

/* --- the band: every station, rotating under the needle --- */

.dial__band {
  z-index: 2;
  border-radius: 50%;
  touch-action: none;
  cursor: grab;
  transition: transform 1.1s var(--ease-out);
  outline: none;
}

.dial__band > svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  animation: band-in 1.4s var(--ease-out) 0.2s both;
}

.dial__band.is-dragging { cursor: grabbing; transition: none; }
body.is-booting .dial__band { transition: none; }

.dial__band:focus-visible > svg {
  filter: drop-shadow(0 0 10px var(--accent));
}

@keyframes band-in {
  from { opacity: 0; transform: rotate(120deg) scale(1.06); }
  to { opacity: 1; transform: none; }
}

.tk { stroke: rgba(255, 255, 255, 0.18); stroke-width: 1.5; }
.tk--st { stroke: rgba(255, 255, 255, 0.5); stroke-width: 2.5; }
.tk--major { stroke: var(--text-2); stroke-width: 3.5; }

.tk--on {
  stroke: var(--accent);
  stroke-width: 6;
  filter: drop-shadow(0 0 6px var(--accent));
}

.tl {
  fill: var(--dim);
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-anchor: middle;
}

.tl--on { fill: var(--accent); }

/* --- the record --- */

.dial__disc {
  z-index: 3;
  inset: 17%;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  background: #0a0b12;
  box-shadow:
    0 0 0 1px var(--hair-2),
    0 0 0 10px rgba(4, 5, 10, 0.7),
    0 0 0 11px var(--hair),
    0 0 40px var(--accent-a30),
    0 30px 80px rgba(0, 0, 0, 0.6);
  animation: disc-in 1s var(--ease-out) 0.35s both;
}

.dial__art {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #0a0b12 center / cover no-repeat;
  animation: spin 28s linear infinite;
  animation-play-state: paused;
}

body.is-playing .dial__art { animation-play-state: running; }

/* Grooves and a fixed sheen: the cover turns underneath the light. */
.dial__disc::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background:
    conic-gradient(from 20deg, transparent 0 8%, rgba(255, 255, 255, 0.14) 12%, transparent 17% 52%, rgba(255, 255, 255, 0.09) 58%, transparent 64%),
    repeating-radial-gradient(circle, rgba(0, 0, 0, 0.14) 0 1px, transparent 1px 5px),
    radial-gradient(circle, transparent 60%, rgba(0, 0, 0, 0.45) 100%);
}

/* Press the record to play or pause. */
.dial__disc::before {
  content: "▶";
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font-size: 12cqw;
  color: var(--text);
  text-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
  background: rgba(4, 5, 10, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
}

body.is-playing .dial__disc::before { content: "❚❚"; font-size: 9cqw; }
.dial__disc:hover::before { opacity: 1; }

/* Standby: the record rests, a little dimmer, until the station goes live. */
.dial__art { transition: filter 0.8s ease; }
body:not(.is-playing) .dial__art { filter: saturate(0.7) brightness(0.72); }

.dial__spindle {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 9%;
  height: 9%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--void) 0 28%, #d9dce6 30% 42%, #6b7082 44% 100%);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.6);
}

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

@keyframes disc-in {
  from { opacity: 0; transform: scale(0.55) rotate(-60deg); }
  to { opacity: 1; transform: none; }
}

/* --- readout: what you're tuning past --- */

.dial__readout {
  z-index: 4;
  inset: 17%;
  border-radius: 50%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.6cqw;
  padding: 0 7cqw;
  text-align: center;
  pointer-events: none;
  background: radial-gradient(circle, rgba(4, 5, 10, 0.94) 55%, rgba(4, 5, 10, 0.8));
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.dial.is-tuning .dial__readout { opacity: 1; transform: none; }

.dial__readout-freq {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 13cqw;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent-a55);
  font-variant-numeric: tabular-nums;
}

.dial__readout-unit {
  font-family: var(--font-mono);
  font-size: 2.1cqw;
  letter-spacing: 0.4em;
  color: var(--dim);
}

.dial__readout-title {
  margin-top: 1.5cqw;
  max-width: 100%;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 3.1cqw;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--text);
}

.dial__readout-artist {
  font-family: var(--font-mono);
  font-size: 2.1cqw;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
}

.dial.is-static .dial__readout-freq { animation: flicker 0.12s steps(2) infinite; }

@keyframes flicker {
  50% { opacity: 0.55; }
}

/* --- needle --- */

.dial__needle {
  z-index: 5;
  inset: auto;
  left: 50%;
  top: -1.5%;
  width: 3px;
  height: 14.5%;
  margin-left: -1.5px;
  border-radius: 2px;
  pointer-events: none;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  box-shadow: 0 0 12px var(--accent), 0 0 30px var(--accent-a55);
}

.dial__needle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -12px;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top: 10px solid var(--accent-hi);
  filter: drop-shadow(0 0 6px var(--accent));
}

/* =====================================================================
   Deck
   ===================================================================== */

.deck {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--deck-h);
  padding: 0 clamp(16px, 2.4vw, 36px) calc(16px + env(safe-area-inset-bottom, 0px));
  display: grid;
  align-content: end;
  gap: 12px;
  background: linear-gradient(0deg, rgba(4, 5, 10, 0.96) 0%, rgba(4, 5, 10, 0.86) 62%, rgba(4, 5, 10, 0));
  animation: lift-in 0.8s var(--ease-out) 0.3s both;
}

/* --- scrubber: the track's real waveform --- */

.scrub {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 14px;
}

.scrub__time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.scrub__time--end { text-align: right; color: var(--dim); }

.scrub__bar {
  position: relative;
  height: 42px;
  cursor: pointer;
  touch-action: none;
  border-radius: 6px;
}

/* Masked by the waveform image blast.js renders from the decoded track; until
   one exists (or on the bare-element path, where there is no PCM) the mask is
   a plain centre line. */
.scrub__wave {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.2);
  -webkit-mask: var(--wave, linear-gradient(transparent 46%, #000 46% 54%, transparent 54%)) center / 100% 100% no-repeat;
  mask: var(--wave, linear-gradient(transparent 46%, #000 46% 54%, transparent 54%)) center / 100% 100% no-repeat;
}

.scrub__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent) 70%, var(--accent-hi));
}

.scrub__head {
  position: absolute;
  top: -5px;
  bottom: -5px;
  left: 0;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: var(--text);
  box-shadow: 0 0 10px var(--accent), 0 0 2px #fff;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.scrub__head.is-hidden { opacity: 0; }

.scrub__bar:hover .scrub__wave { background: rgba(255, 255, 255, 0.3); }

/* --- keys --- */

.deck__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.deck__left,
.deck__right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.deck__left { justify-self: start; }
.deck__right { justify-self: end; }

.deck__extra {
  display: flex;
  gap: 8px;
}

.key,
.ghost-btn {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--hair-2);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-2);
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease,
    box-shadow 0.18s ease, transform 0.12s ease;
}

.key {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
}

.key--text {
  padding: 0 15px;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.key svg,
.ghost-btn svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: currentColor;
}

.key svg .stroke,
.ghost-btn svg * {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ghost-btn svg .fill { fill: currentColor; stroke: none; }

.key:hover,
.ghost-btn:hover {
  color: var(--text);
  border-color: var(--accent-a55);
  background: var(--accent-a08);
  box-shadow: 0 0 20px var(--accent-a15);
}

.key:active,
.ghost-btn:active { transform: scale(0.95); }

.key:disabled,
.ghost-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* Lit: shuffle, repeat, mute, beatmatch, wake lock — whatever is on. */
.icon-btn--active,
.key[aria-pressed="true"].sys__switch {
  color: var(--accent-hi);
  border-color: var(--accent);
  background: var(--accent-a15);
  box-shadow: inset 0 0 14px var(--accent-a15), 0 0 18px var(--accent-a15);
}

.ghost-btn {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

.ghost-btn[aria-pressed="true"],
.ghost-btn.icon-btn--active {
  color: var(--accent-hi);
  border-color: var(--accent);
  background: var(--accent-a15);
}

#muteToggle .icon-mute,
#muteToggle[data-state="muted"] .icon-vol { display: none; }
#muteToggle[data-state="muted"] .icon-mute { display: block; }

/* --- transport --- */

.transport {
  display: grid;
  grid-template-columns: repeat(5, auto);
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  gap: 6px 14px;
}

.transport__btn { width: 50px; height: 50px; }
.transport__btn--blend { position: relative; border-radius: 50%; }
.transport__btn--cut { border-radius: 10px; color: var(--dim); }

.transport__btn--blend::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--hair-2);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

body.is-blend-armed .transport__btn--blend { border-color: var(--accent-a55); }
body.is-blend-armed .transport__btn--blend::before {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

body.is-blending .transport__btn--blend {
  color: var(--accent-hi);
  background: var(--accent-a15);
  box-shadow: 0 0 22px var(--accent-a30);
}

body.is-blending .transport__btn--blend::before { animation: blink 0.6s steps(2, jump-none) infinite; }

.transport__play {
  position: relative;
  width: 78px;
  height: 78px;
  margin: 0 6px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, var(--accent-hi), var(--accent) 55%, var(--accent-deep));
  color: var(--void);
  font-size: 1.55rem;
  line-height: 1;
  box-shadow:
    0 0 0 6px rgba(4, 5, 10, 0.9),
    0 0 0 7px var(--accent-a55),
    0 0 44px var(--accent-a55);
}

.transport__play:hover {
  color: var(--void);
  background: radial-gradient(circle at 50% 30%, #fff, var(--accent-hi) 45%, var(--accent));
  border: 0;
  box-shadow: 0 0 0 6px rgba(4, 5, 10, 0.9), 0 0 0 7px var(--accent), 0 0 60px var(--accent-a55);
}

/* A halo that leaves the key on every beat. */
.transport__play::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}

body.is-playing .transport__play::after {
  animation: halo var(--beat) ease-out infinite;
}

@keyframes halo {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.35); opacity: 0; }
}

.transport__play.is-loading {
  background: rgba(4, 5, 10, 0.8);
  color: var(--accent);
  box-shadow: 0 0 0 6px rgba(4, 5, 10, 0.9), 0 0 0 7px var(--accent), 0 0 30px var(--accent-a30);
}

.transport__tag {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--faint);
  user-select: none;
}

.transport__tag--play { color: var(--text-2); }
body.is-blend-armed .transport__tag--blend { color: var(--accent); }

/* --- latch + gain --- */

.latch {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--hair-2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--dim);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.latch:hover { color: var(--text); border-color: var(--accent-a55); }

.latch__lamp {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hair-2);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.latch__desc { display: none; }

.latch.is-armed {
  color: var(--accent-hi);
  border-color: var(--accent-a55);
  background: var(--accent-a08);
}

.latch.is-armed .latch__lamp {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.gain {
  display: inline-flex;
  align-items: center;
  width: clamp(96px, 9vw, 150px);
  height: 44px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.14);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.14);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 4px;
  background: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 4px var(--accent-a30), 0 0 14px var(--accent-a55);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 4px var(--accent-a30), 0 0 14px var(--accent-a55);
}

.gain input[type="range"]::-webkit-slider-runnable-track {
  background:
    linear-gradient(90deg, var(--accent-deep), var(--accent)) 0 0 / var(--fill, 80%) 100% no-repeat,
    rgba(255, 255, 255, 0.14);
}

input[type="range"]:disabled { opacity: 0.35; cursor: not-allowed; }

/* =====================================================================
   Drawers: Index and System
   ===================================================================== */

.drawer,
.panel {
  position: fixed;
  z-index: 50;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-left: 1px solid var(--hair-2);
  background:
    radial-gradient(120% 40% at 100% 0%, var(--accent-a08), transparent 70%),
    #080a12;
  box-shadow: -40px 0 100px rgba(0, 0, 0, 0.65);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 0.5s var(--ease-out), visibility 0s linear 0.5s;
}

.drawer { width: min(500px, 100vw); }
.panel { width: min(420px, 100vw); overflow-y: auto; }

.drawer.is-open,
.panel.is-open {
  transform: none;
  visibility: visible;
  transition: transform 0.5s var(--ease-out), visibility 0s;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(2, 3, 6, 0.5);
  animation: env-in 0.3s ease both;
}

.scrim[hidden] { display: none; }

.drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer__eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent);
}

.drawer__title {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.15;
  text-transform: uppercase;
}

.drawer__stats {
  margin: 6px 0 0;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.drawer__stats[hidden] { display: none; }

.drawer__close { flex: 0 0 auto; }

/* --- filters --- */

.filter-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.filter-panel__field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.filter-panel__field--wide,
.filter-panel__actions { grid-column: 1 / -1; }

.filter-panel__label,
.card__label,
.slider-field__label,
.queue-panel__title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--faint);
}

.field {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--hair-2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.84rem;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.field:hover { border-color: var(--hair-3); }
.field:focus { outline: none; border-color: var(--accent); background: var(--accent-a08); }
.field::placeholder { color: var(--faint); }

select.field {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--dim) 50%),
    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

select.field option { background: #0c0e18; color: var(--text); }

.filter-panel__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-panel__mix-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-panel__mix-actions [hidden] { display: none; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  cursor: pointer;
}

.toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

/* --- queue + history --- */

.playlist__decks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.playlist__decks:not(:has(> .queue-panel:not([hidden]))) { display: none; }

.queue-panel {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 10px;
  border: 1px solid var(--hair);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.queue-panel[hidden] { display: none; }

.queue-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.queue-panel__header .ghost-btn { min-height: 28px; padding: 0 10px; }

.queue-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  max-height: 96px;
  overflow-y: auto;
}

.queue-panel__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.76rem;
  color: var(--text-2);
}

.queue-panel__item--empty { color: var(--faint); }

.queue-panel__track,
.queue-panel__history-btn {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-panel__history-btn {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.queue-panel__history-btn:hover { color: var(--accent); }

.queue-panel__remove,
.playlist__action-btn {
  appearance: none;
  flex: 0 0 auto;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--hair-2);
  border-radius: 999px;
  background: rgba(4, 5, 10, 0.6);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.queue-panel__remove:hover,
.playlist__action-btn:hover {
  color: var(--accent-hi);
  border-color: var(--accent);
  background: var(--accent-a15);
}

.playlist__action-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-a55); }

/* --- the station list ---
   Rows are 54px plus a 6px gap: the 60px rhythm getPlaylistPageSize() in
   app.js divides the list height by. Change one, change the other. */

.playlist {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0 -6px;
  padding: 0 6px;
  list-style: none;
  display: grid;
  align-content: start;
  gap: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.playlist__item {
  --row-bg: rgba(255, 255, 255, 0.025);
  position: relative;
  min-height: 54px;
  display: grid;
  grid-template-columns: 3.6em auto 40px minmax(0, 1fr) auto;
  grid-template-areas:
    "index drag art info duration"
    "actions actions actions actions actions";
  align-items: center;
  column-gap: 10px;
  padding: 6px 12px 6px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--row-bg);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.playlist__item:hover {
  --row-bg: rgba(255, 255, 255, 0.055);
  border-color: var(--hair);
}

.playlist__item:focus-visible { outline-offset: 1px; }

/* The list number is replaced by the station's frequency (data-freq on the
   number itself, set by blast.js), so the index and the dial agree. */
.playlist__index {
  grid-area: index;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}

.playlist__index[data-freq] { font-size: 0; }

.playlist__index[data-freq]::before {
  content: attr(data-freq);
  font-size: 0.66rem;
}

.playlist__drag-handle {
  grid-area: drag;
  width: 10px;
  color: var(--faint);
  font-size: 0.7rem;
  letter-spacing: -2px;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.playlist__drag-handle[hidden] { display: none; }
.playlist__item:hover .playlist__drag-handle { opacity: 1; }

.playlist__art {
  grid-area: art;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0a0b12 center / cover no-repeat;
  box-shadow: 0 0 0 1px var(--hair-2);
}

.playlist__info {
  grid-area: info;
  min-width: 0;
  display: grid;
  gap: 3px;
}

.playlist__title,
.playlist__artist {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist__title { font-size: 0.88rem; font-weight: 600; color: var(--text); }

.playlist__artist {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.playlist__meta { display: none; }

.playlist__duration {
  grid-area: duration;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}

.playlist__actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.pill {
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pill--new { color: var(--void); background: var(--accent); }

.playlist__item.is-active {
  --row-bg: var(--accent-a08);
  border-color: var(--accent-a55);
  box-shadow: inset 3px 0 0 var(--accent), 0 0 30px var(--accent-a08);
}

.playlist__item.is-active .playlist__title { color: var(--accent-hi); }
.playlist__item.is-active .playlist__index,
.playlist__item.is-active .playlist__duration { color: var(--accent); }
.playlist__item.is-active .playlist__art { box-shadow: 0 0 0 2px var(--accent), 0 0 14px var(--accent-a55); }

body.is-playing .playlist__item.is-active .playlist__art { animation: spin 6s linear infinite; }

.playlist__item.is-dragging { opacity: 0.4; }

.playlist__item.is-drop-before::before,
.playlist__item.is-drop-after::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.playlist__item.is-drop-before::before { top: -4px; }
.playlist__item.is-drop-after::after { bottom: -4px; }

/* Pointers with room: row actions ride over the row on hover or focus, so
   rows stay one line. Touch keeps them permanently visible. */
@media (hover: hover) and (min-width: 901px) {
  .playlist__item { grid-template-areas: "index drag art info duration"; }

  .playlist__actions {
    position: absolute;
    right: 10px;
    top: 50%;
    margin: 0;
    flex-wrap: nowrap;
    padding-left: 36px;
    transform: translateY(-50%);
    background: linear-gradient(90deg, transparent, #0c0e17 30px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  .playlist__item:hover .playlist__actions,
  .playlist__item:focus-within .playlist__actions {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Fade the list edges only when there's more to see. */
.playlist--scrolled.playlist--at-end {
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 24px);
  mask-image: linear-gradient(180deg, transparent, #000 24px);
}

.playlist--scrollable:not(.playlist--scrolled):not(.playlist--at-end) {
  -webkit-mask-image: linear-gradient(0deg, transparent, #000 24px);
  mask-image: linear-gradient(0deg, transparent, #000 24px);
}

.playlist--scrolled:not(.playlist--at-end) {
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 24px, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(180deg, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}

.drawer__pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--hair);
}

.drawer__page {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}

/* --- mix menu (built and positioned by app.js) --- */

.mix-menu {
  position: absolute;
  z-index: 80;
  min-width: 220px;
  max-width: 290px;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--hair-2);
  border-radius: 14px;
  background: #0b0d16;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 30px var(--accent-a08);
}

.mix-menu__title {
  margin: 0;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 0.54rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--faint);
}

.mix-menu__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-2);
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.mix-menu__option:hover { background: var(--accent-a15); color: var(--text); }
.mix-menu__check { width: 1.1em; color: var(--accent); }
.mix-menu__option--new { color: var(--accent); font-weight: 600; }

/* --- system panel --- */

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

.sys__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--hair);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.sys__row--scenes { flex-wrap: wrap; }

.sys__copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.sys__copy b {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
}

.sys__copy span {
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--dim);
}

.sys__switch { min-width: 86px; min-height: 38px; }

.segmented {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--hair-2);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
}

.segmented__btn {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}

.segmented__btn:hover { color: var(--text); }

.segmented__btn.is-active {
  color: var(--void);
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent-a30);
}

/* Scene picker: the engine renders numbered buttons into here. */
.scenes {
  display: flex;
  gap: 6px;
}

.visualizer-mode-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--hair-2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.visualizer-mode-btn:hover { border-color: var(--accent); color: var(--text); }

.visualizer-mode-btn.is-active {
  color: var(--void);
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent-a55);
}

/* The scenes are 3D rooms; none of them exists on the lite or off profiles. */
body.visuals-lite .sys__row--scenes,
body.visuals-off .sys__row--scenes { display: none; }

.sys__keys {
  padding: 12px 14px;
  border: 1px solid var(--hair);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.sys__keys summary {
  list-style: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-2);
}

.sys__keys summary::-webkit-details-marker { display: none; }
.sys__keys summary::after { content: " +"; color: var(--accent); }
.sys__keys[open] summary::after { content: " −"; }

.sys__keys p {
  margin: 10px 0 0;
  font-size: 0.76rem;
  line-height: 2;
  color: var(--dim);
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 5px;
  border: 1px solid var(--hair-3);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.7em;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
}

.sys__credits {
  display: grid;
  gap: 10px;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--hair);
}

.sys__credits-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--faint);
}

.sys__links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sys__links svg { width: 15px; height: 15px; }

.sys__made {
  margin: 4px 0 0;
  font-size: 0.72rem;
  color: var(--faint);
}

.sys__made a { color: var(--dim); text-underline-offset: 3px; }
.sys__made a:hover { color: var(--accent); }

/* =====================================================================
   Advanced dialog
   ===================================================================== */

.advanced-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--hair-2);
  border-radius: 20px;
  background:
    radial-gradient(100% 50% at 50% 0%, var(--accent-a08), transparent 70%),
    #090b14;
  color: var(--text);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.8), 0 0 60px var(--accent-a08);
}

.advanced-dialog[open] {
  display: flex;
  flex-direction: column;
}

.advanced-dialog::backdrop {
  background: rgba(2, 3, 6, 0.72);
}

.advanced-dialog > .drawer__head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--hair);
}

.advanced-dialog__body {
  display: grid;
  gap: 10px;
  padding: 14px 20px 20px;
  overflow-y: auto;
}

.advanced-dialog__note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--accent-a55);
  border-left-width: 3px;
  border-radius: 10px;
  background: var(--accent-a08);
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--text-2);
}

.advanced-dialog__note[hidden] { display: none; }

.card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--hair);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card__title {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.card__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.sleep-timer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.sleep-timer__field { display: grid; gap: 6px; min-width: 140px; }

.sleep-timer__status {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--dim);
}

.slider-field {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--hair);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
}

.slider-field__value {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.slider-field:has(input:disabled) { opacity: 0.5; }

/* =====================================================================
   Wide screens
   ===================================================================== */

@media (min-width: 1600px) {
  .latch__desc {
    display: inline;
    max-width: 18em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--dim);
  }
}

/* =====================================================================
   Local FM presets
   ===================================================================== */

.local-fm-dialog { width: min(560px, calc(100vw - 24px)); }
.local-fm__body { gap: 14px; }
.local-fm__intro,
.local-fm__status {
  margin: 0;
  color: var(--dim);
  font-size: 0.78rem;
  line-height: 1.5;
}
.local-fm__stations {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.local-fm__station {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px 12px;
  padding: 14px;
  border: 1px solid var(--hair-2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}
.local-fm__freq {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}
.local-fm__freq small { font-size: 0.5rem; }
.local-fm__details { display: grid; gap: 4px; min-width: 0; }
.local-fm__details b { font-size: 0.85rem; }
.local-fm__details small { color: var(--dim); font-size: 0.68rem; line-height: 1.4; }
.local-fm__action { white-space: nowrap; }
.local-fm__backup {
  grid-column: 2 / -1;
  width: fit-content;
  color: var(--dim);
  font-size: 0.68rem;
  text-underline-offset: 3px;
}
.local-fm__backup:hover { color: var(--accent); }
.local-fm__status { min-height: 1.5em; }
.hud-btn.is-fm-playing { color: var(--accent); border-color: var(--accent); }
body.is-local-fm .now__next,
body.is-local-fm .now__actions { display: none; }
body.is-local-fm #progressBar { pointer-events: none; opacity: 0.45; }
/* Keep the whole track row clickable while live FM is selected. */
body.is-local-fm .playlist__actions { display: none; }


@media (max-width: 480px) {
  .local-fm__station { grid-template-columns: 60px minmax(0, 1fr); }
  .local-fm__action { grid-column: 2; justify-self: start; }
}

/* =====================================================================
   Narrower desktops: the side column bows out before the dial shrinks
   ===================================================================== */

@media (max-width: 1180px) and (min-width: 901px) {
  /* The dial sits right of centre here, so the room re-centres on it. */
  :root {
    --dial: min(50vw, calc(100dvh - var(--top-h) - var(--deck-h) - 40px), 620px);
    --cx: calc(100vw - clamp(20px, 3vw, 56px) - var(--dial) / 2);
  }
  .stage { grid-template-columns: minmax(0, 1fr) var(--dial); }
  .side { display: none; }
  .telemetry__cell--clock,
  .telemetry__cell--signal { display: none; }
  .hud-btn { width: 40px; padding: 0; justify-content: center; }
  .hud-btn__label { display: none; }
}

/* =====================================================================
   Phone & small tablet: one column, deck docked to the bottom
   ===================================================================== */

@media (max-width: 900px) {
  :root {
    --top-h: 56px;
    --tele-h: 30px;
    --deck-h: 206px;
    --dial: min(82vw, calc(100dvh - var(--top-h) - var(--tele-h) - var(--deck-h) - 200px), 580px);
    /* Pre-script estimate; blast.js measures the real centre (frameRoom). */
    --cy: calc(var(--top-h) + var(--tele-h) + 18px + var(--dial) / 2);
  }

  .topbar { gap: 10px; }
  .brand__mark { width: 32px; height: 32px; }
  .brand__name { font-size: 0.92rem; }
  .brand__sub { font-size: 0.5rem; letter-spacing: 0.14em; }
  .hud-btn { width: 40px; padding: 0; justify-content: center; }
  .hud-btn__label { display: none; }
  .topbar__actions { margin-left: auto; }

  .telemetry {
    position: fixed;
    left: 0;
    right: 0;
    top: calc(var(--top-h) + env(safe-area-inset-top, 0px));
    height: var(--tele-h);
    margin: 0;
    justify-content: center;
    border: 0;
    border-top: 1px solid var(--hair);
    border-bottom: 1px solid var(--hair);
    border-radius: 0;
    background: rgba(4, 5, 10, 0.6);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .telemetry::-webkit-scrollbar { display: none; }
  .telemetry__cell { display: flex; align-items: center; padding: 0 12px; }
  .telemetry dt { display: none; }
  .telemetry dd { font-size: 0.7rem; }
  .live { font-size: 0.56rem !important; letter-spacing: 0.16em; }
  .telemetry__cell--clock { display: none; }

  .stage {
    top: calc(var(--top-h) + var(--tele-h) + env(safe-area-inset-top, 0px));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 18px 20px 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Auto margins centre the pair when there's slack and fall back to zero
     (scrolling from the top) when there isn't. */
  .dial { flex: 0 0 auto; order: 1; margin-top: auto; }

  .now {
    order: 2;
    justify-self: auto;
    width: 100%;
    max-width: 520px;
    /* Fixed height, so a one-line title and a two-line one don't shift the
       centred dial on every track change. */
    min-height: 196px;
    align-content: start;
    margin-bottom: auto;
    justify-items: center;
    text-align: center;
    gap: 8px;
  }

  .now__eyebrow { justify-content: center; }
  .now__title { font-size: clamp(1.4rem, 6.4vw, 2.2rem); -webkit-line-clamp: 2; }
  .now__title[data-len="long"] { font-size: clamp(1.2rem, 5.2vw, 1.8rem); }
  .now__title[data-len="xlong"] { font-size: clamp(1.05rem, 4.4vw, 1.5rem); }
  .now__artist { justify-content: center; font-size: 0.7rem; }
  .now__artist::before { display: none; }
  .now__actions { justify-content: center; }
  .now__next { width: 100%; text-align: center; font-size: 0.8rem; }

  .side { display: none; }

  /* Portrait: the scene gets a square frame sized to the dial (the same
     proportion the landscape layout ends up with) and fades out at its edges,
     instead of a tall canvas that would blow the core up past the band. */
  .env__scene {
    left: calc(var(--cx) - var(--dial) * 0.815);
    top: calc(var(--cy) - var(--dial) * 0.815);
    width: calc(var(--dial) * 1.63);
    height: calc(var(--dial) * 1.63);
    -webkit-mask-image: radial-gradient(closest-side, #000 62%, transparent);
    mask-image: radial-gradient(closest-side, #000 62%, transparent);
  }

  .deck {
    height: auto;
    min-height: var(--deck-h);
    gap: 10px;
    padding-top: 26px;
    background: linear-gradient(0deg, rgba(4, 5, 10, 0.98) 0%, rgba(4, 5, 10, 0.94) 80%, rgba(4, 5, 10, 0));
  }

  .scrub { grid-template-columns: 40px minmax(0, 1fr) 40px; gap: 10px; }
  .scrub__time { font-size: 0.64rem; }
  .scrub__bar { height: 34px; }

  .deck__row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "transport transport"
      "left right";
    gap: 12px 8px;
  }

  .transport { grid-area: transport; justify-self: center; gap: 5px 10px; }
  .deck__left { grid-area: left; }
  .deck__right { grid-area: right; }

  .key { min-width: 42px; min-height: 42px; border-radius: 12px; }
  .transport__btn { width: 46px; height: 46px; }
  .transport__btn--blend,
  .transport__play { border-radius: 50%; }
  .transport__play { width: 66px; height: 66px; font-size: 1.35rem; }

  /* Shorter lite bars: the ring has less room to radiate into on a phone. */
  .dial__lite i { height: 9%; }
  .key--text { padding: 0 11px; font-size: 0.58rem; }
  .latch { min-height: 42px; padding: 0 11px; font-size: 0.56rem; }
  /* Phones have volume keys; the mute key stays, the fader goes. */
  .gain { display: none; }

  .deck__extra { display: none; }

  /* Panels become sheets that rise from the bottom edge. */
  .drawer,
  .panel {
    top: auto;
    left: 0;
    width: auto;
    height: min(92dvh, calc(100dvh - 24px));
    border-left: 0;
    border-top: 1px solid var(--hair-2);
    border-radius: 22px 22px 0 0;
    transform: translateY(105%);
    box-shadow: 0 -30px 80px rgba(0, 0, 0, 0.7);
  }

  .panel { height: auto; max-height: 88dvh; }

  .drawer::before,
  .panel::before {
    content: "";
    align-self: center;
    flex: 0 0 auto;
    width: 44px;
    height: 4px;
    margin: -6px 0 -4px;
    border-radius: 4px;
    background: var(--hair-3);
  }

  .advanced-dialog {
    position: fixed;
    inset: auto 0 0;
    width: auto;
    max-width: none;
    max-height: min(90dvh, calc(100dvh - 16px));
    margin: 0;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
  }

  .advanced-dialog__body { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 420px) {
  :root { --deck-h: 200px; }
  .brand__sub { display: none; }
  .transport { gap: 5px 7px; }
  .transport__btn { width: 42px; height: 42px; min-width: 42px; }
  .transport__play { width: 62px; height: 62px; margin: 0 2px; }
  .latch { padding: 0 11px; gap: 7px; }
  .filter-panel { grid-template-columns: 1fr; }
  .telemetry__cell { padding: 0 9px; }
}

@media (max-width: 900px) and (max-height: 700px) {
  :root { --dial: min(70vw, calc(100dvh - var(--top-h) - var(--tele-h) - var(--deck-h) - 150px), 440px); }
  .now__next { display: none; }
}

/* =====================================================================
   Quiet modes
   ===================================================================== */

body.visualizer-hidden .env__aurora { animation: none; }
body.visualizer-hidden .dial__shock { display: none; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .dial__shock,
  .transport__play::after { display: none; }
}
