:root{
  --bg-hue: 220;
  --bg-hue2: 260;
  --pulse-alpha: 0.12;
  --bg-sat: 70%;
  --bg-light: 8%;
  --kick: 0;       /* set by JS on transient hits */
  --boom: 1;       /* 0.6..1.8 scale from JS */
  --h3: 300;       /* third hue */
  --rot: 0deg;     /* spoke ring rotation */
  --text:#eef2ff;
  --muted:#a2addd;
  --row-h: 64px; --row-gap: 12px;
}

*{ box-sizing:border-box }
html,body{ height:100%; overflow-x:hidden; -webkit-text-size-adjust:100% }
body{
  margin:0; font-family:system-ui, Segoe UI, Roboto, -apple-system, Arial, sans-serif; color:var(--text);
  overflow-y:hidden;
  isolation: isolate;
  background:
    radial-gradient(1400px 900px at 50% 50%,
      hsla(var(--bg-hue), var(--bg-sat), 55%, calc(var(--pulse-alpha) * .7)),
      transparent 70%),
    radial-gradient(1200px 800px at 18% 22%,
      hsla(var(--bg-hue), var(--bg-sat), 55%, var(--pulse-alpha)),
      transparent 60%),
    radial-gradient(1200px 800px at 82% 78%,
      hsla(var(--bg-hue2), var(--bg-sat), 55%, calc(var(--pulse-alpha) * .8)),
      transparent 60%),
    hsl(var(--bg-hue), var(--bg-sat), var(--bg-light));
  transition: background-color .80s ease-in-out, background-image .80s ease-in-out;
}

/* Core pulse — centered circle, grows on drops */
body::before{
  content:"";
  position:fixed;
  left:50%; top:50%;
  width:120vmin; height:120vmin;         /* circular base, larger than viewport */
  transform: translate(-50%, -50%) scale(var(--boom));
  pointer-events:none;
  z-index:0;

  border-radius:50%;

  /* layered multicolor radial wash */
  background:
    radial-gradient(circle at center,
      hsla(var(--bg-hue),  var(--bg-sat), 72%, calc(var(--pulse-alpha)*0.30)) 0%, /* softer */
      hsla(var(--bg-hue2), var(--bg-sat), 60%, calc(var(--pulse-alpha)*0.22)) 28%,
      hsla(var(--h3),      var(--bg-sat), 55%, calc(var(--pulse-alpha)*0.16)) 52%,
      transparent 70%);

  mix-blend-mode: screen;
  filter: brightness(calc(1 + var(--kick) * 0.7)) blur(calc(var(--kick) * 1.2px));
  transition: filter .08s linear, transform .08s linear;
}


/* Ring + spokes — softened so the canvas bars remain primary */
body::after{
  content:"";
  position:fixed;
  left:50%; top:50%;
  width:100vmin; height:100vmin;
  transform: translate(-50%, -50%) rotate(var(--rot))
             scale(calc(0.85 + (var(--boom) - 1) * 0.6));
  pointer-events:none;
  z-index:0;
  border-radius:50%;

  /* MUCH lighter spokes & halo to avoid fighting with the bars */
  background:
    /* thinner, dimmer spokes */
    repeating-conic-gradient(
      from 0deg,
      hsla(var(--bg-hue), var(--bg-sat), 72%, 0.06) 0deg 8deg,
      transparent 8deg 16deg
    ),
    /* softer ring halo */
    radial-gradient(circle at center,
      transparent 48%,
      hsla(var(--bg-hue2), var(--bg-sat), 68%, calc(.06 + var(--kick)*.15)) 52%,
      hsla(var(--h3),      var(--bg-sat), 60%, calc(.05 + var(--kick)*.12)) 56%,
      transparent 60%
    );

  mask: radial-gradient(circle at center, rgba(0,0,0,1) 0 92%, rgba(0,0,0,0) 100%);
  -webkit-mask: radial-gradient(circle at center, rgba(0,0,0,1) 0 92%, rgba(0,0,0,0) 100%);

  mix-blend-mode: screen;
  filter: brightness(calc(1 + var(--kick) * 0.35));
  transition: transform .12s linear, filter .08s linear, opacity .15s linear;
}


#beatCanvas{
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity .55s ease-in-out, transform .55s ease-in-out, filter .55s ease-in-out;
  z-index: 0;
  will-change: transform, opacity, filter;
  mix-blend-mode: screen;
  filter: drop-shadow(0 0 8px rgba(255,255,255,.18))
          drop-shadow(0 0 18px rgba(255,255,255,.10));
}
body.is-playing #beatCanvas{
  opacity: .40;
  transform: none;
  filter: drop-shadow(0 0 10px rgba(255,255,255,.22))
          drop-shadow(0 0 24px rgba(255,255,255,.12));
}


body::before,
body::after { opacity: 0; transition: opacity .15s linear; }
body.is-playing::before,
body.is-playing::after { opacity: 1; }

/* Hide radial spokes and the old pulse wash; keep only the canvas bars */
body::after,
body::before{
  display: none !important;
}

body::before, body::after{ will-change: transform, opacity, filter; }
body.is-playing::before,
body.is-playing::after { opacity: 1; }


.pulse-wrap{ min-height:100dvh; display:grid; place-items:center; padding:12px }
.card{
  width:100%; max-width:720px; margin:0 auto;
  background:rgba(255,255,255,.03); border:1px solid rgba(255,255,255,.1);
  border-radius:20px; padding:16px; box-shadow:0 10px 40px rgba(0,0,0,.35);
  contain:layout paint;
}
.player{ display:flex; flex-direction:column; max-height:92dvh; width:100%; }
h1{ font-size:clamp(22px, 5vw, 42px); margin:0 0 6px }
h1 img {max-width: clamp(70px, 7vw, 120px);}

.auth .card{ max-width:320px; }
.auth form{ display:grid; gap:10px; width:100%; }
input:not([type="checkbox"]){
  width:100%; padding:12px; border-radius:10px; font-size:16px;
  background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.12); color:var(--text)
}
.auth .remember{ display:flex; flex-direction: row; align-items:center; margin: 8px 0; width: fit-content;}
.auth input[type="checkbox"]{ width:auto; margin-right:2px; align-items: center; }
.auth label{ font-size:16px }

/* Center the auth card vertically & horizontally */
body:has(.card.auth){
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 12px;               /* keeps your background breathing room */
}

/* Auth card specifics */
.card.auth{ max-width: 360px; width: 100%; }
.auth form label{ display: grid; gap: 6px; }

.row, .row-split{ width:100% }
.row{ display:flex; gap:10px; align-items:center; flex-wrap:wrap }
.row-split{ display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap }
.muted{ color:var(--muted) }
.btn,button{ appearance:none; border:none; background:rgba(255,255,255,.08); color:var(--text); padding:10px 14px; border-radius:12px; cursor:pointer; font-size:clamp(14px, 3.6vw, 16px) }
.btn:hover,button:hover{ filter:brightness(1.08) }

.card.auth .iconLogoWrap{
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ===================== FILTER TABS ===================== */
.filters {
  display: flex;
  margin-top: 15px;
  margin-bottom: 12px;
  width: 100%;
}

.seg {
  display: inline-flex;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  overflow: hidden;
  padding: 2px;
}

.seg-btn {
  flex: 1;
  padding: 10px 18px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: clamp(14px, 3.6vw, 16px);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 10px;
}

.seg-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

/* Active state — bright + smooth transition */
.seg-btn.active,
.seg-btn[aria-selected="true"]{
  color: #fff;
  font-weight: 700;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.35),
    0 0 12px rgba(122,167,255,0.55);
}

.seg-btn.active { animation: tabPulse 0.3s ease; }

@keyframes tabPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}


/* ===================== CONTROLS ===================== */
.controls{align-items: center; justify-content: center; gap: 15px;}

.transport{
  display:flex; align-items:center; justify-content: center; gap:12px; margin-bottom:12px;
}

/* --- SEEK: full width, time centered below --- */
.seekrow {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

#seek {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.15);
}

/* --- thumbs --- */
#seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, #d6e4ff);
  border: 2px solid rgba(0,0,0,.25);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
#seek::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0,0,0,.25);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

/* --- TIME centered under the seek bar --- */
.time {
  text-align: center;
  white-space: nowrap;
  font-size: clamp(12px, 3.2vw, 16px);
  align-self: center;
}

/* --- Extra safety for Samsung width quirks --- */
.transport,
.seekrow,
#seek { min-width: 0; }

/* ===================== TRACKLIST ===================== */
.tracklist{
  margin-top:8px; flex:1 1 auto; overflow:auto; padding-right:4px;
  max-height: calc(var(--row-h) * 7 + var(--row-gap) * 6);
}
.track{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  height:var(--row-h); padding:0 12px; margin: calc(var(--row-gap)/2) 0;
  border-radius:12px; width:100%;
  background:rgba(255,255,255,.03); border:1px solid rgba(255,255,255,.07);
}
.track-meta{
  display:grid; min-width:0; flex:1 1 auto;
}
.track-title{
  font-size:clamp(14px, 3.8vw, 20px);
  font-weight:600; color:var(--text);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.track-artist{
  font-size:clamp(9px, 3.2vw, 12px);
  color:var(--muted);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

/* Hide legacy single-line title if it still exists */
.track .title{ display:none; }

.track .play-btn{
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  min-width: 84px;
  padding: 10px 0;
  position: relative;        /* anchor for absolute spinner */
}
.track.active{ box-shadow: inset 0 0 0 2px rgba(255,255,255,.18); background:rgba(255,255,255,.06) }


/* ===================== BYTEBEATS SCROLLBAR ===================== */
#trackList::-webkit-scrollbar {
  width: 10px;
}

#trackList::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  margin: 4px; /* adds top/bottom breathing room */
}

#trackList::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg,
    hsla(var(--bg-hue), var(--bg-sat), 55%, 0.8),
    hsla(var(--bg-hue2), var(--bg-sat), 60%, 0.8)
  );
  border-radius: 10px;
  box-shadow: 0 0 8px hsla(var(--bg-hue2), 90%, 65%, 0.4);
  transition: all 0.25s ease;
}

#trackList::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg,
    hsla(var(--bg-hue), 90%, 60%, 1),
    hsla(var(--bg-hue2), 90%, 70%, 1)
  );
  box-shadow: 0 0 10px hsla(var(--bg-hue2), 90%, 75%, 0.6);
}

/* Firefox support */
#trackList {
  scrollbar-width: thin;
  scrollbar-color: hsla(var(--bg-hue2), 90%, 65%, 0.6) rgba(255,255,255,0.05);
}

/* Footer stays visible */
.footer{ display:flex; justify-content:space-between; align-items:center; margin-top:8px; color:var(--muted); width:100%; font-size:clamp(12px, 3.4vw, 16px); }


/* Spinner */
/* ---------- SPINNER: single source of truth ---------- */

/* Base spinner shape (works anywhere, e.g., sentinel) */
.btn-spinner{
  display: inline-block;
  width: 18px;
  height: 18px;
}
.btn-spinner > i{
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25);
  border-top-color: rgba(255,255,255,.95);
  animation: bb_spin .8s linear infinite;      /* rotate ONLY the inner element */
}

/* When the spinner is inside the row button, center it absolutely in the button */
.track .play-btn{ position: relative; }         /* ensure containing block */
.track .play-btn .btn-spinner{
  position: absolute;           /* scoped: does NOT affect sentinel spinners */
  left: 0; right: 0; top: 0; bottom: 0;
  margin: auto;                 /* centers within the 84px button */
  pointer-events: none;
}

/* Loading state: keep button footprint; hide label; no extra padding */
.track .play-btn.is-loading{
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  color: transparent !important;   /* hides text without shifting width */
  cursor: progress;
  padding: 10px 0;                 /* keep original height */
  min-width: 84px; width: 84px;    /* prevents any width jitter */
}

@keyframes bb_spin { to { transform: rotate(360deg); } }



@media (max-width:360px){ .card{ max-width:94vw } }

/* ========= GENRE BUTTON (aligned with transport controls) ========= */
#genreBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.10);
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  user-select: none;

  /* Width behavior */
  min-width: 132px;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .2s ease, border .2s ease;
}
#genreBtn:hover { filter: brightness(1.08); }
#genreBtn:active { transform: translateY(1px); }
#genreBtn:focus-visible {
  outline: 2px solid #7aa7ff;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(122,167,255,.35);
}
#genreLabel {
  display: inline-block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Caret indicator */
#genreBtn::after {
  content: "▾";
  font-size: .9em;
  opacity: .8;
  margin-left: 2px;
  flex: 0 0 auto;
}
#genreBtn[aria-expanded="true"]::after { content: "▴"; }

/* ========= SHEET (40% viewport, sticky head, list-only scroll) ========= */
.sheet { position: fixed; inset: 0; display: none; z-index: 50; }
.sheet[aria-hidden="false"] { display: block; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); }

/* Panel is a column; capped to 50vh */
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  max-height: 40vh;                           /* <= cap height */
  background: rgba(0, 52, 80, 1);
  border-top-left-radius: 16px; border-top-right-radius: 16px;
  box-shadow: 0 -10px 30px rgba(0,0,0,.2);
}

/* Sticky head stays visible while list scrolls */
.sheet-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid #eee;
  color: var(--muted);
  background: rgba(0, 52, 80, 0.98);          /* solid so content under doesn’t show */
  backdrop-filter: saturate(120%) blur(4px);   /* nice frosted look on iOS */
}
.sheet-close { background: transparent; border: 0; font-size: 1.1rem; cursor: pointer; }

/* Body is the ONLY scrolling region */
.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;                            /* scroll here */
  -webkit-overflow-scrolling: touch;           /* momentum on iOS */
  scroll-behavior: smooth;
  padding: .25rem 0;
}

/* List inside the body (no independent scrolling) */
.genre-list {
  list-style: none; margin: 0; padding: 0;
}

/* Items */
.sheet-body li {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem; border-bottom: 1px solid #f3f3f3; cursor: pointer;
}
.sheet-body li[aria-selected="true"] { background: #8292d6; color: var(--text); }
.sheet-body .count { opacity: .7; font-variant-numeric: tabular-nums; }

/* ===================== ByteBeats Scrollbar (sheet-body) ===================== */
/* WebKit browsers (Chrome, Edge, Safari) */
.sheet-body::-webkit-scrollbar { width: 10px; }
.sheet-body::-webkit-scrollbar-track {
  background: rgba(255,255,255,.05);
  border-radius: 10px;
  margin: 4px;                                 /* top/bottom breathing room */
}
.sheet-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg,
    hsla(var(--bg-hue), var(--bg-sat), 55%, .85),
    hsla(var(--bg-hue2), var(--bg-sat), 60%, .85)
  );
  border-radius: 10px;
  box-shadow: 0 0 8px hsla(var(--bg-hue2), 90%, 65%, .4);
  transition: all .25s ease;
}
.sheet-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg,
    hsla(var(--bg-hue), 90%, 60%, 1),
    hsla(var(--bg-hue2), 90%, 70%, 1)
  );
  box-shadow: 0 0 10px hsla(var(--bg-hue2), 90%, 75%, .6);
}
#trackList::-webkit-scrollbar-button,
.sheet-body::-webkit-scrollbar-button {
  display: none;
  height: 0;
  width: 0;
}

/* Firefox */
.sheet-body {
  scrollbar-width: thin;
  scrollbar-color: hsla(var(--bg-hue2),90%,65%,.6) rgba(255,255,255,.05);
}


/* ========= ALBUM BUTTON (mirrors Genre) ========= */
#albumBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.10);
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  user-select: none;

  /* Width behavior */
  min-width: 132px;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .2s ease, border .2s ease;
}
#albumBtn:hover { filter: brightness(1.08); }
#albumBtn:active { transform: translateY(1px); }
#albumBtn:focus-visible {
  outline: 2px solid #7aa7ff;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(122,167,255,.35);
}

#albumLabel {
  display: inline-block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Caret indicator */
#albumBtn::after {
  content: "▾";
  font-size: .9em;
  opacity: .8;
  margin-left: 2px;
  flex: 0 0 auto;
}
#albumBtn[aria-expanded="true"]::after { content: "▴"; }



/* Keep transport on one line by default (desktop/tablet) */
.transport { flex-wrap: nowrap; }
.transport > * { min-width: 0; }

/* Range input spillover guard */
input[type="range"]{
  width: 100%;
  max-width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  overflow: hidden;
}
#seek { width: 100%; max-width: 100%; min-width: 0; }

.tracklist { overflow-x: hidden; overscroll-behavior: contain; }
html, body { overflow-x: hidden; }



/* Screen-reader-only helper (used in JS markup) */
.sr-only{
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Sentinel spinner inside the tracklist */
#sentinel.loading{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  color: var(--muted);
}
#sentinel .loading-text{ opacity: .9; }


/* =========================================================
   MOBILE LAYOUT — EVERYTHING RESPONSIVE AT ≤ 575px
   ========================================================= */
@media (max-width: 575px) {
  .card{
    max-width: 99vw;
    width: 100%;
    padding: 14px;
    border-radius: 16px;
  }
  .player{ max-height: 92dvh; width: 100%; }

  h1{ font-size: clamp(20px, 7vw, 32px); }


  .filters{ width: 100%; }
  .seg{ width: 100%; }
  .seg-btn{ padding: 10px 12px; }

  .controls{ gap: 12px; }
  .transport{
    flex-wrap: wrap !important;  /* override default nowrap */
    justify-content: center;
    gap: 10px;
  }

  /* Put Genre under transport buttons and full width */
  #genreBtn{
    order: 2;
    width: 100%;
    max-width: none;
    margin-top: 6px;
    justify-content: center;
  }
  #genreLabel{
    text-align: center;
    max-width: 90%;
  }

  .seekrow{ gap: 8px; }
  .time{ font-size: clamp(12px, 3.6vw, 15px); }

  /* Tracklist gets a touch more room & never causes horizontal scroll */
  .tracklist{
    margin-top: 8px;
    max-height: calc(100dvh - 320px); /* safety cap; adjust if your header/footer change */
    padding-right: 2px;
    overflow-x: hidden;
  }

  /* Ensure every child can shrink to avoid overflow */
  .transport > *,
  .row > *,
  .row-split > *,
  .track > * {
    min-width: 0;
    max-width: 100%;
  }

  /* Mobile: stack filters; Album below Genre */
  #albumBtn{
    order: 3;              /* comes after #genreBtn (order:2) */
    width: 100%;
    max-width: none;
    margin-top: 6px;
    justify-content: center;
  }
  #albumLabel{
    text-align: center;
    max-width: 90%;
  }

  .sheet-body::-webkit-scrollbar { width: 8px; }

  /* ===== ANDROID RIGHT-EDGE OVERFLOW FIX (safe & minimal) ===== */
  .player,
  .card,
  .controls,
  .transport,
  .seekrow,
  .row,
  .row-split,
  .tracklist {
    max-width: 100%;
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce){
  #beatCanvas{ display:none !important; }
  body::before, body::after{ opacity: .3 !important; transition: none !important; }
}
