/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black:       #000;
  --white:       #fff;
  --gray-1:      #0c0c0c;
  --gray-2:      #141414;
  --gray-3:      #1e1e1e;
  --border:      rgba(255,255,255,0.07);
  --muted:       rgba(255,255,255,0.32);
  --muted2:      rgba(255,255,255,0.14);

  /* Gradient palette (dialed.gg) */
  --g0: rgb(148, 45,220);
  --g1: rgb( 90, 60,235);
  --g2: rgb( 40,100,240);
  --g3: rgb(  0,180,220);
  --g4: rgb( 16,240,160);

  --correct:  #3ecf6e;
  --wrong:    #f24f4f;
  --reveal:   #f5c842;

  --font: 'Inter', -apple-system, system-ui, sans-serif;
}

html, body {
  height: 100%;
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  /* Native-app feel: no double-tap zoom, no 300ms tap delay (honored
     by iOS Safari 13+ and Android Chrome). Does NOT block scroll/tap/
     drag. Elements with JS-driven drag (.picker-viewport, .piano-select)
     set their own touch-action: none. Pinch is killed by the gesture
     guard in index.html. */
  touch-action: manipulation;
}
/* iOS Safari rubber-bands the page even under overflow:hidden — pinning
   the body kills the phantom scroll (and its stray right-edge bar).
   Inner lists (.custom-body, .explore-grid, .results-center) keep their
   own scroll and never chain it to the page. */
body {
  position: fixed;
  inset: 0;
  width: 100%;
}
* { -webkit-tap-highlight-color: transparent; }

/* ── Ambience (each note awakens a blurred grain-floor of dots) ── */
.ambience {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.58;
}

/* ── App shell / screens ────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh; /* mobile browsers: track the real visible viewport */
  max-width: 500px;
  margin: 0 auto;
  padding: 0 24px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
}

/* Keyboard focus — visible ring on every control, none on mouse/touch */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid rgba(255,255,255,0.65);
  outline-offset: 2px;
  border-radius: 8px;
}

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

.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.screen[hidden] { display: none; }

.screen-enter { animation: screenIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ── Header (game / explore / custom) ───────────────────────── */
/* The header row and the fixed gear share one top reference so the
   back arrow, the centered content, and the gear sit on one line. */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(20px, env(safe-area-inset-top)) 0 16px;
  flex-shrink: 0;
}
.header-spacer { width: 30px; }

/* Game header: [back] · [streak, centered] · [gear space] */
/* Top-aligned: the STREAK label shares the line with the back arrow
   and the gear, and its big number stacks BELOW without dropping the
   arrow. Custom's round dots keep a 30px box so they still centre on
   the arrow. */
.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
}
.game-header > .btn-icon { justify-self: start; }
.game-header > .header-spacer { justify-self: end; }
.game-center {
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px; /* custom-game round dots breathe */
  min-height: 30px;
  overflow: visible;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
@media (hover: hover) {
  .btn-icon:hover { color: var(--white); background: var(--gray-3); }
}
.btn-icon.active { color: var(--white); }

.level-chip {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--gray-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 5px 12px;
}

/* Round dots */
.round-dots { display: flex; gap: 8px; }
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray-3);
  transition: background 0.2s, transform 0.2s;
}
.dot-current {
  background: var(--white);
  animation: dotPulse 1.6s ease-in-out infinite;
}
.dot-correct { background: var(--correct); }
.dot-wrong   { background: var(--wrong); }
@keyframes dotPulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(0.7); opacity: 0.55; }
}

/* ── Home ───────────────────────────────────────────────────── */
.home-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}

.wordmark {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
  background: linear-gradient(100deg, var(--g0), var(--g1), var(--g2), var(--g3), var(--g4));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 14px;
  color: var(--muted);
  max-width: 260px;
  margin-bottom: 14px;
}

/* ── Piano note selector ────────────────────────────────────── */
/* Three octaves of keys. Lit keys are in the game; tap to drop one
   (at least two must stay). Black keys are drawn, not played — the
   app trains the naturals. */
.piano-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.piano-label,
.count-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Fluid: the three octaves share the full width — every key always
   visible, on any screen, never a scroll. */
.piano-select {
  display: flex;
  gap: 8px;
  justify-content: center;
  width: 100%;
}
.piano-octave {
  position: relative;
  display: flex;
  gap: 2px;
  padding-bottom: 14px;
  flex: 1;
  min-width: 0;
}
.piano-key {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 58px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0 0 5px 5px;
  color: transparent;
  font-family: var(--font);
  font-size: 8.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.piano-key.on {
  background: rgba(255,255,255,0.88);
  border-color: rgba(255,255,255,0.9);
  color: rgba(0,0,0,0.6);
}
@media (hover: hover) {
  .piano-key:not(.on):hover { background: rgba(255,255,255,0.14); color: var(--muted); }
}
/* A real, selectable black key — nested in the white key before it,
   parked dead-centre on the boundary, sitting above it. Lights up like
   a white key when it's in the game. */
.piano-key.black {
  position: absolute;
  top: -1px;
  right: -1px;
  transform: translateX(50%);
  width: 58%;
  max-width: 22px;
  height: 34px;
  flex: none;
  background: #0a0a0a;
  border: 1px solid rgba(255,255,255,0.18);
  border-top: none;
  border-radius: 0 0 4px 4px;
  align-items: center;
  padding-bottom: 0;
  z-index: 2;
}
.piano-key.black.on {
  background: rgba(255,255,255,0.9);
  border-color: rgba(255,255,255,0.92);
  color: rgba(0,0,0,0.6);
}
.piano-octave-label {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 600;
  color: var(--muted2);
  letter-spacing: 0.1em;
}
.piano-key.shake { animation: keyshake 0.3s; }
@keyframes keyshake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}
/* How many opening notes of the mystery melody you hear —
   the player's difficulty dial, right on home. */
.count-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.count-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.count-select { display: flex; gap: 8px; }
.count-pill {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
@media (hover: hover) {
  .count-pill:hover { color: var(--white); border-color: rgba(255,255,255,0.25); }
}
.count-pill.wide {
  width: auto;
  padding: 0 14px;
  border-radius: 100px;
}
.count-pill.active {
  background: var(--white);
  color: var(--black);
  border-color: var(--white);
}
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 100px;
  padding: 14px 20px;
  color: var(--white);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
@media (hover: hover) {
  .btn-secondary:hover:not(:disabled) {
    border-color: rgba(255,255,255,0.35);
    background: rgba(255,255,255,0.04);
  }
}
.btn-secondary:active:not(:disabled) { transform: scale(0.97); }

/* Action column: endless Play first, the rest stays quiet */
.home-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: min(100%, 250px);
  margin-top: 8px;
}

/* doubled class — .btn-pill is declared later and would override */
.btn-pill.btn-start { padding: 16px 20px; font-size: 15px; width: 100%; }

/* Organic exit: the controls dissolve like breath on glass while the
   Play pill decomposes — a small pop, then it scatters into the water
   (an ambience drop is born underneath it, js/app.js). */
.home-center.leaving > :not(.home-actions) {
  animation: homeOut 0.46s cubic-bezier(0.55, 0, 0.45, 1) both;
}
.home-center.leaving > :nth-child(1) { animation-delay: 0.02s; }
.home-center.leaving > :nth-child(2) { animation-delay: 0.05s; }
.home-center.leaving > :nth-child(3) { animation-delay: 0.09s; }
.home-center.leaving > :nth-child(4) { animation-delay: 0.13s; }
.home-center.leaving > :nth-child(5) { animation-delay: 0.16s; }
.home-center.leaving .home-actions > :not(.btn-start) {
  animation: homeOut 0.4s cubic-bezier(0.55, 0, 0.45, 1) both;
}
/* ID-scoped so the decompose beats the Hard electric animation on exit */
#screen-home .home-center.leaving .btn-start {
  animation: playDecompose 0.46s cubic-bezier(0.4, 0, 0.6, 1) both;
  pointer-events: none;
}
@keyframes homeOut {
  to { opacity: 0; transform: translateY(14px) scale(0.92); filter: blur(6px); }
}
@keyframes playDecompose {
  0%   { transform: scale(1);    opacity: 1;    filter: blur(0); }
  30%  { transform: scale(1.05); opacity: 0.9;  filter: blur(0.5px); }
  100% { transform: scale(0.82); opacity: 0;    filter: blur(12px); }
}

/* ── Toggle pills (octave / hear) ───────────────────────────── */
.toggle-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 9px 16px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
@media (hover: hover) {
  .toggle-pill:hover { color: var(--white); border-color: rgba(255,255,255,0.25); }
}
.toggle-pill.active {
  color: var(--white);
  border-color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.07);
}

/* Endless difficulty — three chips under Play, same family as the
   custom presets but they never leave endless. Hard flips into a
   glitched, redder reality (the register you must now name exactly). */
.mode-row {
  display: flex;
  gap: 6px;
  width: 100%;
}
.mode-chip {
  flex: 1;
  background: none;
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 9px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
@media (hover: hover) {
  .mode-chip:hover { color: var(--white); border-color: rgba(255,255,255,0.25); }
}
.mode-chip.active {
  background: var(--white);
  color: var(--black);
  border-color: var(--white);
}
.mode-chip[data-mode="hard"].active {
  background: #e23b3b;            /* same red as the electrified Play button */
  color: var(--white);
  border-color: #e23b3b;
  box-shadow: 0 0 14px rgba(226,59,59,0.35);
}

/* ── Custom game screen ─────────────────────────────────────── */
.custom-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 10px 0 32px;
}
.preset-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.preset-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.preset-chip {
  background: none;
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  padding: 7px 13px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
@media (hover: hover) {
  .preset-chip:hover { color: var(--white); border-color: rgba(255,255,255,0.25); }
}
.preset-chip.active {
  background: var(--white);
  color: var(--black);
  border-color: var(--white);
}
/* doubled class — .btn-pill is declared later and would override */
.btn-pill.btn-custom-start {
  width: min(100%, 250px);
  padding: 15px 20px;
  font-size: 15px;
  margin-top: 4px;
}
.piano-select { touch-action: none; }
.piano-select.shake { animation: keyshake 0.3s; }


/* Glitch burst when modes flip to/from hardcore — discrete steps()
   jumps + RGB-split shadows, no easing, like a corrupted frame. */
@keyframes glitch {
  0%   { clip-path: inset(0);           transform: none; }
  8%   { clip-path: inset(8% 0 55% 0);  transform: translate(-5px, 2px) skewX(-4deg);
         box-shadow: -3px 0 0 rgba(242,79,79,0.85), 3px 0 0 rgba(0,224,255,0.85); }
  16%  { clip-path: inset(45% 0 12% 0); transform: translate(5px, -2px) skewX(3deg);
         box-shadow: 3px 0 0 rgba(242,79,79,0.85), -3px 0 0 rgba(0,224,255,0.85); }
  24%  { clip-path: inset(70% 0 2% 0);  transform: translate(-4px, 1px); }
  32%  { clip-path: inset(2% 0 78% 0);  transform: translate(4px, -1px) skewX(-2deg);
         box-shadow: -2px 0 0 rgba(242,79,79,0.85), 2px 0 0 rgba(0,224,255,0.85); }
  45%  { clip-path: inset(30% 0 40% 0); transform: translate(-2px, 2px); }
  60%  { clip-path: inset(0);           transform: none;
         box-shadow: 0 0 18px rgba(242,79,79,0.35); }
  100% { clip-path: inset(0);           transform: none; box-shadow: none; }
}
.glitching { animation: glitch 0.5s steps(1, end) both; }

/* ── The gear + settings panel (every screen) ───────────────── */
.btn-gear {
  position: fixed;
  top: max(20px, env(safe-area-inset-top)); /* same reference as .header */
  right: max(16px, env(safe-area-inset-right));
  z-index: 61;
}

.config-panel {
  position: fixed;
  top: calc(max(14px, env(safe-area-inset-top)) + 42px);
  right: max(16px, env(safe-area-inset-right));
  z-index: 60;
  width: min(320px, calc(100vw - 32px));
  background: rgba(16, 16, 18, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
.config-panel[hidden] { display: none; }

.config-section { display: flex; flex-direction: column; gap: 10px; }

.config-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.config-instruments { display: flex; gap: 6px; }
.instrument-btn {
  flex: 1;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 100px;
  padding: 8px 4px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
@media (hover: hover) {
  .instrument-btn:hover { color: var(--white); border-color: rgba(255,255,255,0.2); }
}
.instrument-btn.active {
  background: var(--white);
  color: var(--black);
  border-color: var(--white);
}

@keyframes pop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── Picker ─────────────────────────────────────────────────── */
#ruler-container {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch; /* the wheel claims all the vertical room */
  justify-content: center;
}

/* ── Picker wheel ───────────────────────────────────────────── */
/* A drum of notes past a fixed centre — many notes visible, the
   edges tilt away in 3D and blur out. Scroll/drag moves the list;
   whichever note is centred is the selection. --item-h / --rows are
   set from JS (ITEM_HEIGHT / ROWS) so CSS and physics never drift. */
.note-picker {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}

.picker-viewport {
  position: relative;
  width: 100%;
  flex: 1;                          /* the drum owns ALL the height */
  min-height: 0;
  overflow: hidden;
  perspective: 1000px;              /* the drum curve lives here */
  touch-action: none;               /* JS owns the drag — no browser pan/zoom */
  cursor: grab;
  outline: none;
  /* fade the top/bottom edges so notes dissolve off the drum */
  -webkit-mask-image: linear-gradient(to bottom,
     transparent 0%, #000 13%, #000 87%, transparent 100%);
          mask-image: linear-gradient(to bottom,
     transparent 0%, #000 13%, #000 87%, transparent 100%);
}
.picker-viewport:active { cursor: grabbing; }
/* Result phase: the wheel is frozen — plain cursor (no grab hand), and only
   the round's revealed note is clickable (tap it to replay the music). */
.picker-viewport.locked,
.picker-viewport.locked:active { cursor: default; }
.picker-viewport.locked .picker-item { cursor: default; }
.picker-viewport.locked .picker-item.correct,
.picker-viewport.locked .picker-item.reveal { cursor: pointer; }

/* One drum item = the note, its music captioned right underneath */
.picker-item {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: var(--item-h, 54px);
  margin-top: calc(var(--item-h, 54px) / -2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  /* only the SELECTED note is white — the rest of the drum recedes
     into grey so the choice is never ambiguous */
  color: rgba(255,255,255,0.38);
  cursor: pointer;
  transform-origin: center center;
  will-change: transform, opacity, filter;
  /* colour is the only thing that eases; transform/opacity/filter are
     driven every frame by JS and must not lag behind the finger */
  transition: color 0.2s ease;
}
.pi-note {
  font-size: var(--note-size, 44px); /* grows with the row height (ruler.js) */
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}
.pi-melody {
  font-size: var(--cap-size, 11px);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
  min-height: 11px;   /* keeps every note on the same ladder, caption or not */
  color: rgba(255,255,255,0.34);
  max-width: 82vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}
.picker-item.is-center { color: var(--white); }
.picker-item.is-center .pi-melody { color: rgba(255,255,255,0.6); }
.picker-item.correct { color: var(--correct); }
.picker-item.wrong   { color: var(--wrong); }
.picker-item.reveal  { color: var(--reveal); }
.picker-item.correct .pi-melody { color: rgba(62,207,110,0.8); }
.picker-item.wrong   .pi-melody { color: rgba(242,79,79,0.8); }
.picker-item.reveal  .pi-melody { color: rgba(245,200,66,0.8); }
/* The verdict rides here as a full sentence (green when correct, yellow when
   revealed) — let it wrap under the note instead of truncating. */
.picker-item.correct .pi-melody,
.picker-item.reveal  .pi-melody {
  white-space: normal;
  max-width: 88vw;
  line-height: 1.25;
}

/* ── Footer (game) ──────────────────────────────────────────── */
.footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 0 28px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

.feedback {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  min-height: 18px;
  text-align: center;
  letter-spacing: 0.01em;
  transition: color 0.2s;
}
.feedback.correct { color: var(--correct); }
.feedback.wrong   { color: var(--wrong); }

.footer-actions { display: flex; gap: 10px; align-items: center; }

/* Replay — the secondary of the two guessing buttons (submit is the
   solid primary). Bordered ghost pill so the pair reads clearly.
   Doubled class: .btn-pill is declared later and would otherwise win
   the cascade and repaint this solid white (the old "buggy" replay). */
.btn-pill.btn-replay {
  background: none;
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--white);
}
@media (hover: hover) {
  .btn-pill.btn-replay:hover:not(:disabled) {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.32);
  }
}
.btn-replay svg { flex-shrink: 0; }
.btn-replay[hidden] { display: none; }

.btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--white);
  color: var(--black);
  border: none;
  border-radius: 100px;
  padding: 14px 32px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s, opacity 0.15s;
}
@media (hover: hover) {
  .btn-pill:hover:not(:disabled) { background: #e8e8e8; }
}
.btn-pill:active:not(:disabled) { transform: scale(0.97); }
.btn-pill:disabled {
  background: var(--gray-3);
  color: var(--muted);
  cursor: default;
}
.btn-pill[hidden] { display: none; }

/* Hard endless mode electrifies Play — persistent red with a continuous
   electric pulse (RGB-split zaps between glowing beats). Mirrors the red
   Hard chip; the one-shot glitch on select hands off into this. */
.btn-pill.btn-start.hard:not(:disabled) {
  background: #e23b3b;
  color: #fff;
  animation: hardElectric 1.8s infinite;
}
@media (hover: hover) {
  .btn-pill.btn-start.hard:not(:disabled):hover { background: #ec4a4a; }
}
@keyframes hardElectric {
  0%, 44%, 100% { transform: none; box-shadow: 0 0 14px rgba(242,79,79,0.45); }
  46% { transform: translate(-2px, 1px) skewX(-3deg); box-shadow: -3px 0 0 rgba(0,224,255,0.7), 3px 0 0 rgba(242,79,79,0.9), 0 0 22px rgba(242,79,79,0.7); }
  49% { transform: translate(2px, -1px) skewX(2deg);  box-shadow: 3px 0 0 rgba(0,224,255,0.7), -3px 0 0 rgba(242,79,79,0.9), 0 0 22px rgba(242,79,79,0.7); }
  52% { transform: none; box-shadow: 0 0 16px rgba(242,79,79,0.55); }
  72% { transform: translate(1.5px, 0) skewX(1.5deg); box-shadow: 2px 0 0 rgba(0,224,255,0.6), -2px 0 0 rgba(242,79,79,0.85), 0 0 24px rgba(242,79,79,0.8); }
  75% { transform: none; box-shadow: 0 0 18px rgba(242,79,79,0.6); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-pill.btn-start.hard:not(:disabled) { animation: none; box-shadow: 0 0 16px rgba(242,79,79,0.5); }
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 100px;
  transition: color 0.15s;
}
@media (hover: hover) {
  .btn-ghost:hover { color: var(--white); }
}

/* ── Results ────────────────────────────────────────────────── */
/* Centers when short, scrolls when tall (margin:auto on the ends
   collapses gracefully) — the big score can never be cropped again. */
.results-center {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
  padding: 24px 0;
}
.results-center > :first-child { margin-top: auto; }
.results-center > :last-child  { margin-bottom: auto; }

/* Mode badge — which run this was: Endless · Easy/Medium/Hard, or
   Custom. A hairline pill; Hard keeps its red identity from home. */
.results-mode {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
}
.results-mode:empty { display: none; }
.results-mode.hard {
  color: #f76b6b;
  border-color: rgba(242,79,79,0.5);
}

.results-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.results-score {
  font-size: 84px;
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1.1;      /* breathing room — clipped ascenders no more */
  padding: 0 0.08em;     /* gradient text clips at the box edge otherwise */
  flex-shrink: 0;
}
.results-score.perfect {
  background: linear-gradient(100deg, var(--g0), var(--g2), var(--g4));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* The breakdown is a piano — each asked key wears its score:
   successes (green) / attempts, right where the note lives. */
.results-breakdown {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 8px;
}
.results-piano {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(100%, 340px);
}
.results-octave {
  position: relative;
  display: flex;
  gap: 3px;
  padding-right: 18px; /* room for the octave label */
}
.results-key {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 64px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0 0 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  padding-bottom: 5px;
}
/* An asked key lights up like a real ivory. Only a note answered
   100% right turns fully green — no borders, no glow; every other
   asked key just stays white. */
.results-key.all-ok, .results-key.mixed, .results-key.all-ko {
  background: rgba(255,255,255,0.92);
  border-color: rgba(255,255,255,0.92);
}
.results-key.all-ok {
  background: var(--correct);
  border-color: var(--correct);
}
.rk-count {
  font-size: 11px;
  font-weight: 700;
  /* the count takes the KEY's own colour rather than a fixed hue:
     near-black on the ivory keys, deep green on a fully-green one */
  color: rgba(0,0,0,0.5);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.rk-count b { font-weight: 800; } /* successes emphasised, not recoloured */
.rk-name {
  font-size: 8.5px;
  font-weight: 600;
  color: var(--muted2);
  line-height: 1;
}
.results-key.all-ok .rk-count { color: rgba(3,54,26,0.82); }
.results-key.mixed .rk-name,
.results-key.all-ko .rk-name { color: rgba(0,0,0,0.5); }
.results-key.all-ok .rk-name { color: rgba(3,54,26,0.7); }
/* Real black key on the results keyboard — stays black even when it
   scored, showing its count in light (green when answered 100%). */
.results-key.black {
  position: absolute;
  top: -1px;
  right: -1.5px;
  transform: translateX(50%);
  width: 56%;
  max-width: 26px;
  height: 42px;
  flex: none;
  gap: 3px;
  background: #0c0c0c;
  border: 1px solid rgba(255,255,255,0.16);
  border-top: none;
  border-radius: 0 0 4px 4px;
  z-index: 2;
}
.results-key.black .rk-name  { color: var(--muted); }
.results-key.black .rk-count { color: rgba(255,255,255,0.9); }
.results-key.black.all-ok {
  background: #0c0c0c;
  border-color: var(--correct);
}
.results-key.black.all-ok .rk-count { color: var(--correct); }
.results-octave-label {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted2);
}

.results-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-shrink: 0;
}

/* ── Explore ────────────────────────────────────────────────── */
.explore-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.explore-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding-bottom: 16px;
}

.explore-presets {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-bottom: 14px;
  flex-shrink: 0;
}

/* A borderless tracklist — the notes float on the void like the
   picker does, separated by hairlines. No cards, no boxes. */
.explore-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  padding-bottom: 28px;
}

.explore-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.055);
}
.explore-row:last-child { border-bottom: none; }

/* each note carries its ambience hue — the same close, barely
   saturated mauve→teal family the drops wake on the floor */
.explore-row[data-note="do"]  { --note: 178,128,184; }
.explore-row[data-note="re"]  { --note: 159,128,184; }
.explore-row[data-note="mi"]  { --note: 141,128,184; }
.explore-row[data-note="fa"]  { --note: 128,141,184; }
.explore-row[data-note="sol"] { --note: 128,159,184; }
.explore-row[data-note="la"]  { --note: 128,178,184; }
.explore-row[data-note="si"]  { --note: 128,184,172; }

.explore-note {
  background: none;
  border: none;
  color: var(--white);
  font-family: var(--font);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  transition: transform 0.12s, color 0.15s;
}
.explore-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(var(--note), 0.9);
  flex-shrink: 0;
}
@media (hover: hover) {
  .explore-note:hover { color: rgb(var(--note)); }
}
.explore-note:active { transform: scale(0.95); }

.explore-side {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
}
.explore-side-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.explore-melody {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 0;
  cursor: pointer;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
}
@media (hover: hover) {
  .explore-melody:hover:not(:disabled) { color: var(--white); }
}
.explore-melody:disabled { opacity: 0.3; cursor: default; }

.explore-pick {
  background: none;
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--muted);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
@media (hover: hover) {
  .explore-pick:hover { color: var(--white); border-color: rgba(255,255,255,0.25); }
}
.explore-pick[aria-expanded="true"] {
  color: var(--white);
  border-color: rgba(255,255,255,0.3);
}

.explore-style {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted2);
  min-height: 12px;
  padding-right: 34px; /* sits under the title, clear of the ▾ */
}

/* Melody menu — the same quiet panel language as the config sheet */
.explore-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 224px;
  max-width: 76vw;
  background: rgba(16,16,18,0.96);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 40px rgba(0,0,0,0.5);
}
.explore-menu.up { top: auto; bottom: calc(100% + 6px); }
.explore-menu[hidden] { display: none; }

.explore-option {
  background: none;
  border: none;
  border-radius: 10px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  padding: 9px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  transition: color 0.12s, background 0.12s;
}
.explore-option .opt-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.explore-option .opt-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(var(--note), 0.95);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s;
}
.explore-option.active .opt-dot { opacity: 1; }
.explore-option small {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted2);
  flex-shrink: 0;
}
@media (hover: hover) {
  .explore-option:hover { color: var(--white); background: rgba(255,255,255,0.05); }
}
.explore-option.active { color: var(--white); }

/* ══ Streak number + arcade celebration (celebrate.js) ══════════ */
/* The streak stacks in the game header: the STREAK label sits on the
   header line (level with the back arrow and the gear), and its big
   number drops right beneath it, dead-centre. celebrate.js toggles
   is-pop / is-bounce / is-milestone on the number and spawns
   particles, rings, glows and combo flashes in the overlay below. */
.streak-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.streak-label {
  /* line-height matches the back arrow's box so the word centres on
     the same line as the arrow and the gear */
  line-height: 30px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.streak-num {
  display: block;
  margin-top: 4px;
  font-size: clamp(52px, 15vw, 72px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  transform-origin: center center;
  transition: color 0.3s ease;
}
.streak-num[data-tier="1"] { color: var(--white); }
.streak-num[data-tier="2"] {
  color: var(--white);
  text-shadow: 0 0 14px rgba(90, 130, 240, 0.55);
}
.streak-num[data-tier="3"] {
  background: linear-gradient(100deg, var(--g0), var(--g2), var(--g4));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 12px rgba(40, 180, 220, 0.6));
}

.streak-num.is-pop      { animation: streakPop 0.26s cubic-bezier(0.34,1.56,0.64,1); }
.streak-num.is-bounce   { animation: streakBounce 0.52s cubic-bezier(0.28,1.4,0.5,1); }
.streak-num.is-milestone{ animation: streakMilestone 0.72s cubic-bezier(0.30,1.5,0.5,1); }
.streak-num.is-pulse    { animation: streakPulse 0.4s ease-in-out; }

@keyframes streakPop {
  0% { transform: scale(1); } 45% { transform: scale(1.22); } 100% { transform: scale(1); }
}
@keyframes streakBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.55) rotate(-3deg); }
  55% { transform: scale(0.9) rotate(2deg); }
  75% { transform: scale(1.15); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes streakMilestone {
  0% { transform: scale(1); }
  25% { transform: scale(1.95) rotate(-6deg); }
  45% { transform: scale(0.86) rotate(5deg); }
  65% { transform: scale(1.32) rotate(-2deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes streakPulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.5; transform: scale(1.08); }
}

/* Overlay — decorative, never blocks input. */
.celebrate-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  overflow: hidden;
}
.celebrate-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Expanding ring shockwave. left/top = its centre (set by JS). */
.celebrate-ring {
  position: absolute;
  width: var(--ring-size, 120px);
  height: var(--ring-size, 120px);
  border: var(--ring-thick, 3px) solid var(--ring-color, #fff);
  border-radius: 50%;
  animation: celebrateRing 0.85s cubic-bezier(0.15,0.6,0.3,1) forwards;
}
@keyframes celebrateRing {
  0%   { transform: translate(-50%,-50%) scale(0.15); opacity: 0.9; }
  70%  { opacity: 0.5; }
  100% { transform: translate(-50%,-50%) scale(1);    opacity: 0; }
}

/* Soft radial glow flash. */
.celebrate-glow {
  position: absolute;
  width: calc(var(--glow-size, 150px) * 2);
  height: calc(var(--glow-size, 150px) * 2);
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-color, rgba(90,130,240,0.5)) 0%, transparent 68%);
  animation: celebrateGlow 0.72s ease-out forwards;
}
@keyframes celebrateGlow {
  0%   { transform: translate(-50%,-50%) scale(0.4); opacity: 0; }
  30%  { opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1.15); opacity: 0; }
}

/* Full-screen vignette pulse at big milestones. */
.celebrate-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 38%, var(--vig-color, rgba(40,180,220,0.3)) 125%);
  animation: celebrateVignette 0.9s ease-out forwards;
}
@keyframes celebrateVignette {
  0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: 0; }
}

/* "COMBO xN" flash. left/top = centre (set by JS). --cd flips the
   drift: 1 floats up, -1 floats DOWN — used when the anchor sits at
   the top of the screen so the text never leaves the viewport. */
.celebrate-combo {
  position: absolute;
  font-family: var(--font);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 0 18px rgba(40, 180, 220, 0.8), 0 2px 8px rgba(0,0,0,0.6);
  animation: celebrateCombo 1.1s cubic-bezier(0.2,1,0.4,1) forwards;
}
.celebrate-combo.big { font-size: 40px; }
@keyframes celebrateCombo {
  0%   { transform: translate(-50%,-50%) translateY(calc(var(--cd,1) * 6px)) scale(0.6); opacity: 0; }
  20%  { transform: translate(-50%,-50%) translateY(calc(var(--cd,1) * -10px)) scale(1.15); opacity: 1; }
  55%  { transform: translate(-50%,-50%) translateY(calc(var(--cd,1) * -34px)) scale(1); opacity: 1; }
  100% { transform: translate(-50%,-50%) translateY(calc(var(--cd,1) * -72px)) scale(0.95); opacity: 0; }
}

/* The edge dopamine — an inward glow hugging the screen border,
   deeper and hotter as the streak climbs (celebrate.js sets the
   colour and spread proportionally to the score). */
.celebrate-edge {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 calc(var(--edge-spread, 24px) * 1.9) var(--edge-spread, 24px)
              var(--edge-color, rgba(90,130,240,0.3));
  animation: celebrateEdge 1s ease-out forwards;
}
@keyframes celebrateEdge {
  0%   { opacity: 0; }
  22%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Screen shake at very high streaks. --shake-amp set by JS. */
.celebrate-shake { animation: celebrateShake 0.52s cubic-bezier(0.36,0.07,0.19,0.97); }
@keyframes celebrateShake {
  10%,90% { transform: translate(calc(var(--shake-amp,6px) * -0.4), 0); }
  20%,80% { transform: translate(calc(var(--shake-amp,6px) * 0.7), 0); }
  30%,50%,70% { transform: translate(calc(var(--shake-amp,6px) * -1), 0); }
  40%,60% { transform: translate(var(--shake-amp,6px), 0); }
}

/* ══ Debug panel (always loaded; ?nodebug hides) ═══════════════ */
.debug-panel {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 200;
  width: 210px;
  background: rgba(14, 14, 16, 0.94);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 10px;
  font-family: var(--font);
  box-shadow: 0 12px 30px rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
}
.debug-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 8px;
}
/* Collapsed: a ~28px corner dot — never on top of the game's footer
   buttons, even on the narrowest phone. Tap it to open the panel. */
.debug-panel.collapsed {
  width: auto;
  padding: 6px 9px;
  cursor: pointer;
  border-radius: 100px;
}
.debug-panel.collapsed .debug-head { margin-bottom: 0; }
.debug-panel.collapsed .debug-word,
.debug-panel.collapsed .debug-hide,
.debug-panel.collapsed .debug-body { display: none; }
.debug-word { font-style: normal; }
.debug-body { display: flex; flex-direction: column; gap: 9px; }
.debug-group-title {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted2);
  margin-bottom: 5px;
}
.debug-row { display: flex; flex-wrap: wrap; gap: 5px; }
.debug-chip {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--white);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 9px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
@media (hover: hover) {
  .debug-chip:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.28); }
}
.debug-chip.active {
  background: rgba(255,255,255,0.22);
  border-color: var(--white);
  color: var(--white);
}
.debug-chip[data-hint="subtle"]    { border-color: rgba(90,130,240,0.4); }
.debug-chip[data-hint="great"]     { border-color: rgba(40,180,220,0.45); }
.debug-chip[data-hint="milestone"] { border-color: rgba(16,240,160,0.5); }
.debug-chip[data-hint="euphoric"]  {
  border-color: transparent;
  background: linear-gradient(100deg, rgba(148,45,220,0.5), rgba(16,240,160,0.5));
}
.debug-hide { font-size: 9px; padding: 3px 7px; letter-spacing: 0.1em; }

/* Floating stand-in streak used when no game is open. */
#debug-streak {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  pointer-events: none;
}

/* ── Explore: live song search ──────────────────────────────── */
.explore-search {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  margin-bottom: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  color: var(--muted);
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.explore-search:focus-within { border-color: rgba(255,255,255,0.32); }
.explore-search svg { flex: none; opacity: 0.6; }
#explore-q {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--white);
  font-family: var(--font);
  font-size: 15px;
}
#explore-q::placeholder { color: var(--muted); }
#explore-q::-webkit-search-cancel-button { -webkit-appearance: none; }

/* `hidden` alone loses to the flex display rules below, so make it win
   for the three swappable Explore blocks (browse ⇄ search results). */
.explore-presets[hidden],
.explore-grid[hidden],
.explore-results[hidden] { display: none; }

/* Results mirror the explore tracklist — floating rows, hairlines. */
.explore-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  padding-bottom: 28px;
}
.exr-status {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 26px 8px;
}
.exr-status code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: var(--white);
}
.exr-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.055);
}
.exr-row:last-child { border-bottom: none; }
.exr-chip {
  flex: none;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  color: var(--white);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}
@media (hover: hover) {
  .exr-chip:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3); }
}
.exr-solf { font-size: 15px; font-weight: 700; }
.exr-oct  { font-size: 9px; color: var(--muted); margin-top: 2px; }
.exr-caret { font-size: 7px; color: var(--muted); margin-top: 1px; line-height: 1; }
.exr-meta { flex: 1; min-width: 0; }
.exr-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.exr-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.exr-key { color: rgba(255,255,255,0.24); }
.exr-play {
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
@media (hover: hover) {
  .exr-play:hover { color: var(--white); border-color: rgba(255,255,255,0.3); }
}
.exr-meta { cursor: pointer; }

/* ── Explore albums — genre pools, horizontally scrollable ───── */
.explore-presets {
  flex-wrap: nowrap;
  justify-content: flex-start;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.explore-presets::-webkit-scrollbar { display: none; }
.album-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
@media (hover: hover) {
  .album-chip:hover { color: var(--white); border-color: rgba(255,255,255,0.28); }
}
.album-chip.active { color: #000; background: var(--white); border-color: var(--white); }
.album-emoji { font-size: 14px; line-height: 1; }

/* ── Toast — brief confirmation ("song → note") ──────────────── */
#toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translate(-50%, 12px);
  z-index: 90;
  max-width: 80vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255,255,255,0.95);
  color: #000;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* No scrollbar while browsing notes / results — the list still scrolls. */
.explore-grid,
.explore-results { scrollbar-width: none; -ms-overflow-style: none; }
.explore-grid::-webkit-scrollbar,
.explore-results::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* ── Search result: add-to-playlist "+" + popover ───────────── */
.exr-add {
  flex: none;
  width: 34px; height: 34px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 21px; line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
@media (hover: hover) {
  .exr-add:hover { color: #000; background: var(--white); border-color: var(--white); }
}
.add-menu {
  position: fixed;
  z-index: 95;
  min-width: 168px;
  max-width: 72vw;
  background: #0e0c11;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 14px 44px rgba(0,0,0,0.65);
}
.add-opt {
  display: flex; align-items: center; gap: 9px;
  background: none; border: none;
  color: var(--white); font-family: var(--font); font-size: 14px; font-weight: 500;
  text-align: left; padding: 9px 11px; border-radius: 8px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.add-opt span { opacity: 0.55; flex: none; }
@media (hover: hover) { .add-opt:hover { background: rgba(255,255,255,0.08); } }
.add-opt.add-new { color: var(--muted); margin-top: 3px; border-top: 1px solid rgba(255,255,255,0.08); }

/* Note picker on a search result — swap the song to another opening note */
.note-menu {
  position: fixed;
  z-index: 95;
  background: #0e0c11;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(4, 44px);
  gap: 4px;
  box-shadow: 0 14px 44px rgba(0,0,0,0.65);
}
.note-opt {
  background: rgba(255,255,255,0.05);
  border: 1px solid transparent;
  color: var(--white);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 0;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
@media (hover: hover) { .note-opt:hover { background: rgba(255,255,255,0.12); } }
.note-opt.active  { border-color: var(--white); background: rgba(255,255,255,0.14); }
.note-opt.loading { opacity: 0.45; }

/* Section switcher — a vertical list: pick which PART of the song plays.
   Overrides the note grid (labels like "Chorus" need the width). */
.section-menu { grid-template-columns: 1fr; min-width: 152px; gap: 3px; }
.sec-opt {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 9px 12px; text-align: left;
}
.sec-name { font-size: 13px; }
.sec-note { font-size: 12px; font-weight: 600; color: var(--muted); }
.sec-note sub { font-size: 9px; opacity: 0.8; }
.sec-opt.active .sec-note { color: rgba(255,255,255,0.7); }

/* Which section will play — on a search row's subtitle, and in Explore. */
.exr-sec { color: rgba(255,255,255,0.5); }
.ex-sec {
  font-style: normal; font-size: 10px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted); opacity: 0.7; margin-left: 4px;
}

/* ── Playlist chips in the collections row ──────────────────── */
/* Segmented pill: a play area + a big pencil edit button, one shared outline. */
.playlist-chip { padding: 0; gap: 0; overflow: hidden; cursor: default; }
.pl-open, .pl-menu {
  background: none; border: none; color: inherit; font: inherit; cursor: pointer;
}
.pl-open {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 8px 7px 14px;
}
.pl-menu {
  display: inline-flex; align-items: center; justify-content: center;
  align-self: stretch;
  border-left: 1px solid rgba(255,255,255,0.14);
  padding: 4px 12px;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
}
@media (hover: hover) { .pl-menu:hover { opacity: 1; background: rgba(255,255,255,0.08); } }
.playlist-chip.active .pl-menu { border-left-color: rgba(0,0,0,0.18); }
@media (hover: hover) { .playlist-chip.active .pl-menu:hover { background: rgba(0,0,0,0.06); } }
.new-playlist { color: var(--muted); border-style: dashed; }

/* Edit-playlist box: icon picker + a red, one-tap Delete (Cancel sits beside it) */
.dlg-icons { display: flex; flex-wrap: wrap; gap: 6px; }
.dlg-icon {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
  color: var(--white);   /* text glyphs like ♫ stay visible on the dark button */
  background: none; border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px; cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
@media (hover: hover) { .dlg-icon:hover { border-color: rgba(255,255,255,0.4); } }
.dlg-icon.active { background: var(--white); border-color: var(--white); color: #000; }
.dlg-spacer { flex: 1; }
/* Doubled class — .dlg-btn is declared later and would otherwise repaint
   Delete grey (the cascade bug that made it look broken). Red by default. */
.dlg-btn.dlg-del { color: #f24f4f; border-color: rgba(242,79,79,0.45); }
@media (hover: hover) { .dlg-btn.dlg-del:hover { background: #f24f4f; color: #fff; border-color: #f24f4f; } }

/* ── Search filters: opening-note + genre, sorted by popularity ── */
.explore-filters { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; flex-shrink: 0; }
.filter-row {
  display: flex; gap: 6px; flex-wrap: nowrap;
  overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: none; white-space: nowrap;
  font-family: var(--font); font-size: 12px; font-weight: 600;
  color: var(--muted);
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
@media (hover: hover) { .filter-chip:hover { color: var(--white); border-color: rgba(255,255,255,0.25); } }
.filter-chip.active { color: #000; background: var(--white); border-color: var(--white); }
.filter-chip .album-emoji { font-size: 13px; }
.note-pill .x { margin-left: 5px; opacity: 0.7; }

/* Explore grid: a "find songs for this note" + on each row ─────── */
.explore-note { flex: 1; text-align: left; }
.explore-find {
  flex: none;
  width: 30px; height: 30px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  background: none; color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
@media (hover: hover) { .explore-find:hover { color: #000; background: var(--white); border-color: var(--white); } }

/* ── Create-playlist dialog ─────────────────────────────────── */
.dialog-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.62);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.dialog {
  width: 100%; max-width: 340px;
  background: #0e0c11;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.dlg-title { font-size: 17px; font-weight: 700; margin: 0; }
.dlg-input {
  background: #050409; border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px; padding: 11px 13px;
  color: var(--white); font: 500 15px var(--font); outline: none;
}
.dlg-input:focus { border-color: rgba(140,180,255,0.45); }
.dlg-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.dlg-themes { display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow-y: auto; }
.dlg-theme {
  font: 600 12px var(--font); color: var(--muted); white-space: nowrap;
  background: none; border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px; padding: 6px 11px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.dlg-theme.active { color: #000; background: var(--white); border-color: var(--white); }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.dlg-btn {
  font: 600 14px var(--font); border-radius: 10px; padding: 9px 18px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.14); background: none; color: var(--muted);
}
@media (hover: hover) { .dlg-cancel:hover { color: var(--white); } }
.dlg-ok { background: var(--white); color: #000; border-color: var(--white); }
