/* Frontier Music — modern dark UI with glassmorphism + Spotify-style gradients. */

:root {
  /* spotify-ish vibrant accent + supporting palette */
  --accent:        #1ed760;
  --accent-2:      #5b8def;
  --accent-pink:   #ff5fa2;
  --accent-purple: #8a5cf7;
  --text:          #ffffff;
  --text-dim:      rgba(255,255,255,.62);
  --text-faint:    rgba(255,255,255,.42);
  --glass:         rgba(255,255,255,.06);
  --glass-strong:  rgba(255,255,255,.10);
  --border:        rgba(255,255,255,.08);
  --shadow:        0 10px 40px rgba(0,0,0,.5);
  --radius:        16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* hide scrollbars across the app — Mini App vibe */
*::-webkit-scrollbar { width: 0; height: 0; display: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }

html, body {
  margin: 0; padding: 0;
  /* Tint the WebView background so iOS over-scroll exposes the same dark purple
     as our gradient — no black bands appearing on rubber-band. */
  background-color: #14081f;
  color: var(--text);
  font: 15px/1.4 -apple-system,BlinkMacSystemFont,"SF Pro Display","SF Pro Text","Segoe UI",Roboto,system-ui,sans-serif;
  /* Disable iOS rubber-band bounce */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  min-height: 100vh;
}
html { background: #14081f; }
body {
  padding-top: 0;                 /* .top handles safe-area itself, no double padding */
  padding-bottom: calc(180px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

/* aurora gradient background — fixed behind everything */
.bg-aurora {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(80vw 60vh at 20% 0%,   rgba(138,92,247,.35), transparent 60%),
    radial-gradient(70vw 50vh at 90% 10%,  rgba(255,95,162,.25), transparent 60%),
    radial-gradient(90vw 70vh at 50% 100%, rgba(30,215,96,.18),  transparent 60%),
    linear-gradient(180deg, #14081f 0%, #08070d 60%, #050008 100%);
}

/* ── top header ───────────────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 30;
  /* Push below Telegram's floating Close/Menu buttons in fullscreen mode
     (var --tg-top set by JS via tg.contentSafeAreaInset).
     Fallback to device safe-area, plus extra 30px for the buttons themselves. */
  padding-top: calc(var(--tg-top, env(safe-area-inset-top, 0)) + 8px);
  padding-right: 18px;
  padding-bottom: 10px;
  padding-left: 18px;
  /* Solid match to the page background so the header isn't a visible plate. */
  background: #14081f;
}
.top h1 {
  margin: 0 0 16px;
  font-size: 22px; font-weight: 700; letter-spacing: -.01em;
  text-align: center;
  background: linear-gradient(90deg, #fff, #c9b3ff 70%, #ff95c6);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

.search-wrap {
  position: relative;
  display: flex; align-items: center;
}
.search-wrap.hidden { display: none; }
.search-wrap .search-ico {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-dim);
  pointer-events: none;
}
.search-wrap input {
  flex: 1; width: 100%;
  padding: 13px 14px 13px 42px;
  background: var(--glass);
  color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  font-size: 15px; outline: none;
  backdrop-filter: blur(8px);
  transition: border-color .15s, background .15s;
}
.search-wrap input::placeholder { color: var(--text-faint); }
.search-wrap input:focus {
  border-color: rgba(30,215,96,.5);
  background: var(--glass-strong);
}

/* ── track list ───────────────────────────────────────────────────────── */
.list { padding: 8px 12px 4px; }

.hint {
  padding: 60px 20px;
  color: var(--text-dim);
  text-align: center;
  font-size: 15px;
}

.row {
  display: flex; gap: 14px; align-items: center;
  padding: 10px 10px;
  border-radius: 14px;
  cursor: pointer; user-select: none;
  transition: background .15s, transform .08s;
}
.row:active { transform: scale(.985); background: var(--glass); }
.row.playing {
  background: linear-gradient(90deg, rgba(30,215,96,.10), rgba(138,92,247,.06));
  box-shadow: inset 0 0 0 1px rgba(30,215,96,.25);
}
.row.playing .t { color: var(--accent); }

.cover {
  width: 52px; height: 52px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2a1d4f, #4a2068) center / cover no-repeat;
  flex: 0 0 52px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  position: relative;
  overflow: hidden;
}
.cover::after {
  /* subtle shine */
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.08), transparent 50%);
  pointer-events: none;
}
.txt { flex: 1; min-width: 0; }
.txt .t, .txt .a {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.txt .t { font-weight: 600; font-size: 15px; letter-spacing: -.005em; }
.txt .a { color: var(--text-dim); font-size: 13px; margin-top: 3px; }
.dur { color: var(--text-faint); font-size: 12.5px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }

/* ── player (edge-to-edge frost bar, same geometry inside) ──── */
.player {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(70px + env(safe-area-inset-bottom));
  z-index: 40;
  border-radius: 0;
  background: rgba(255,255,255,.72);
  border-top: 1px solid rgba(255,255,255,.45);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  box-shadow: 0 -4px 20px rgba(0,0,0,.35);
}
.player.hidden { display: none; }

.player-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px 20px;       /* less top, more bottom → cover sits visually higher */
  cursor: pointer;
}
.cover-sm {
  width: 52px;
  height: 52px;
  border-radius: 9px;
  flex: 0 0 52px;
  background-color: #2a1d4f;
  background-image: linear-gradient(135deg, #2a1d4f, #4a2068);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.player-text { flex: 1; min-width: 0; }
.player-title {
  font-weight: 700; font-size: 16px; letter-spacing: -.01em;
  color: #0d0d10;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-artist {
  color: rgba(13,13,16,.5);
  font-size: 14px;
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* heart: outline by default, red-filled when liked */
.ico-btn {
  background: transparent; border: none; padding: 4px;
  color: rgba(13,13,16,.55); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .08s;
  flex: 0 0 auto;
}
.ico-btn svg { width: 28px; height: 28px; }
.ico-btn:active { transform: scale(.9); }
.ico-btn.fav .heart-fill    { display: none; }
.ico-btn.fav .heart-outline { display: block; }
.ico-btn.fav.on { color: #ff3b30; }
.ico-btn.fav.on .heart-outline { display: none; }
.ico-btn.fav.on .heart-fill    { display: block; }

/* main play button — just an icon, no circle behind it */
.play-btn {
  background: transparent;
  color: #0d0d10;
  border: none; cursor: pointer;
  padding: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  transition: transform .08s;
}
.play-btn svg { width: 30px; height: 30px; }
.play-btn:active { transform: scale(.9); }

/* —— expanded portion (revealed on tap) —— */
.player-expand {
  display: none;                  /* truly gone in collapsed — no phantom height */
}
.player.expanded .player-expand {
  display: block;
  margin: 14px 14px 12px;
}

input#seek {
  width: 100%; margin: 0;
  appearance: none; -webkit-appearance: none;
  height: 4px;
  background: rgba(13,13,16,.15);
  border-radius: 2px; outline: none;
  cursor: pointer;
}
input#seek::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #0d0d10;
  border: none;
  box-shadow: 0 0 0 4px rgba(13,13,16,.12);
  cursor: pointer;
}
input#seek::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #0d0d10; border: none;
  box-shadow: 0 0 0 4px rgba(13,13,16,.12);
}

.time {
  display: flex; justify-content: space-between;
  color: rgba(13,13,16,.5); font-size: 11.5px;
  margin: 6px 2px 8px;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex; justify-content: center; align-items: center; gap: 28px;
}
button.ctl {
  background: transparent; color: #0d0d10;
  border: none; cursor: pointer;
  padding: 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .08s;
}
button.ctl svg { width: 28px; height: 28px; }
button.ctl:active { transform: scale(.9); }

/* ── bottom tab bar ─────────────────────────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0;
  bottom: 0;
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-around; align-items: center;
  background: linear-gradient(180deg, rgba(8,7,13,.4) 0%, rgba(8,7,13,.92) 60%);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-top: 1px solid rgba(255,255,255,.06);
  z-index: 50;
}
.tab {
  flex: 1; max-width: 120px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: transparent; border: none;
  padding: 8px 6px;
  color: var(--text-faint);
  cursor: pointer;
  transition: color .2s, transform .08s;
  font: inherit;
}
.tab svg {
  width: 24px; height: 24px;
  transition: stroke .2s, fill .2s, filter .2s;
}
.tab span {
  font-size: 11px; font-weight: 600;
  letter-spacing: .02em;
}
.tab:active { transform: scale(.94); }
.tab.active {
  color: var(--accent);
}
.tab.active svg {
  filter: drop-shadow(0 0 8px rgba(30,215,96,.55));
}

/* ── Now-Playing fullscreen overlay ─────────────────────────────────── */
/* Don't hide underlying UI — NP has its own opaque bg. Just block interaction. */
body.np-open .top,
body.np-open .list,
body.np-open .player,
body.np-open .tabbar { pointer-events: none; }

/* Search mode — hide tab bar and mini-player to give more screen room */
body.searching .tabbar,
body.searching .player { display: none !important; }
body.searching { padding-bottom: env(safe-area-inset-bottom, 0); }

/* Clear-X button inside search input */
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px;
  border: none; background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.85);
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.search-clear svg { width: 14px; height: 14px; }
.search-clear.hidden { display: none; }
.search-wrap input { padding-right: 44px; }   /* room for clear button */

/* Background dim layer — fades during swipe-down */
.np-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
body.np-open .np-backdrop { opacity: 1; pointer-events: auto; }

.np {
  position: fixed; inset: 0;
  z-index: 100;
  background:
    radial-gradient(80vw 60vh at 20% 0%,   rgba(138,92,247,.55), transparent 60%),
    radial-gradient(70vw 50vh at 90% 10%,  rgba(255,95,162,.35), transparent 60%),
    radial-gradient(90vw 70vh at 50% 100%, rgba(30,215,96,.28),  transparent 60%),
    linear-gradient(180deg, #1a0d2e 0%, #0c0815 60%, #050008 100%);
  display: flex; flex-direction: column; align-items: center;
  padding:
    calc(var(--tg-top, env(safe-area-inset-top, 0)) + 40px)
    24px
    calc(var(--tg-bottom, env(safe-area-inset-bottom, 0)) + 24px);
  color: #fff;
  /* Rounded top corners — feels like a sheet rising from the bottom */
  border-radius: 20px 20px 0 0;
  /* iOS-style spring easing for transforms */
  transition: transform .42s cubic-bezier(.32, .72, 0, 1), opacity .3s ease, border-radius .3s ease;
  will-change: transform, opacity;
  transform-origin: 50% 100%;
}
.np.hidden { display: none; }
/* During drag — slight scale-down for that Apple "card lift" physics */
.np.dragging { transition: none; }

.np-close {
  position: absolute;
  top: calc(var(--tg-top, env(safe-area-inset-top, 0)) + 14px);
  left: 18px;
  width: 36px; height: 36px;
  border: none; background: transparent;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.np-close svg { width: 28px; height: 28px; }

/* drag handle at top — visual cue that swipe-down dismisses */
.np-grabber {
  position: absolute;
  top: calc(var(--tg-top, env(safe-area-inset-top, 0)) + 8px);
  left: 50%; transform: translateX(-50%);
  width: 38px; height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,.35);
}

/* Big album art */
.np-art {
  width: min(78vw, 360px);
  aspect-ratio: 1/1;
  border-radius: 14px;
  margin: 8vh 0 4vh;
  background: linear-gradient(135deg, #2a1d4f, #4a2068) center / cover no-repeat;
  background-color: #2a1d4f;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}

.np-meta {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
}
.np-meta-text {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.np-more {
  background: transparent; border: none;
  color: rgba(255,255,255,.7);
  width: 36px; height: 36px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .15s, transform .08s;
}
.np-more svg { width: 22px; height: 22px; }
.np-more:active { transform: scale(.9); }
.np-more:hover { background: rgba(255,255,255,.08); }
.np-title  { font-size: 24px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { font-size: 16px; color: rgba(255,255,255,.65); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Seek bar */
input#np-seek {
  width: 100%;
  appearance: none; -webkit-appearance: none;
  height: 4px;
  background: rgba(255,255,255,.18);
  border-radius: 2px; outline: none;
}
input#np-seek::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.18);
}
input#np-seek::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: none;
  box-shadow: 0 0 0 4px rgba(255,255,255,.18);
}
.np-time {
  width: 100%;
  display: flex; justify-content: space-between;
  color: rgba(255,255,255,.55);
  font-size: 12px; font-variant-numeric: tabular-nums;
  margin-top: 8px;
}

/* Controls row */
.np-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;     /* spread: [dislike] [main] [heart] */
  padding: 0 4px;                     /* almost touching the screen edges */
  margin: 36px 0 22px;
  width: 100%;
  box-sizing: border-box;
}
.np-dislike {
  color: rgba(255,255,255,.7);
  flex: 0 0 auto;
  transition: color .2s, transform .12s;
}
.np-dislike svg { width: 26px; height: 26px; }
.np-dislike.on { color: #5b8def; }   /* blue tint when recently disliked */
.np-dislike:active { transform: scale(.9); }
.np-ctl-main {
  display: flex;
  align-items: center;
  gap: 30px;
}
.np-fav-inline {
  flex: 0 0 auto;
}
.np-ctl {
  background: transparent; border: none; color: #fff;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.np-ctl svg { width: 36px; height: 36px; }
.np-ctl:active { transform: scale(.9); }

.np-play {
  width: 76px; height: 76px;
  border-radius: 999px; border: none;
  background: linear-gradient(135deg, var(--accent) 0%, #15b04f 100%);
  color: #08070d;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 28px rgba(30,215,96,.45);
  transition: transform .08s;
}
.np-play svg { width: 34px; height: 34px; }
.np-play:active { transform: scale(.93); }

/* Secondary controls row — shuffle / repeat */
.np-extra {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%;
  padding: 0 30px;
  margin-bottom: 18px;
}
.np-toggle {
  background: transparent; border: none;
  color: rgba(255,255,255,.55);
  width: 44px; height: 44px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: color .2s, background .15s;
}
.np-toggle svg { width: 22px; height: 22px; }
.np-toggle:active { transform: scale(.9); }
.np-toggle.on {
  color: var(--accent);
  background: rgba(30,215,96,.12);
}
.np-toggle.on::after {
  /* tiny dot below active toggle (Spotify pattern) */
  content: "";
  position: absolute; bottom: 4px; left: 50%;
  transform: translateX(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
/* repeat icon variants: show "all" by default, "one" when in single-track mode */
#np-repeat .ico-repeat-one { display: none; }
#np-repeat.one .ico-repeat-all { display: none; }
#np-repeat.one .ico-repeat-one { display: block; }

/* Inline heart inside controls row (right of next button) */
.np-fav-inline { color: rgba(255,255,255,.7); }
.np-fav-inline svg { width: 28px; height: 28px; }
.np-fav-inline .heart-fill    { display: none; }
.np-fav-inline .heart-outline { display: block; }
.np-fav-inline.on { color: #ff3b5c; }
.np-fav-inline.on .heart-outline { display: none; }
.np-fav-inline.on .heart-fill    { display: block; }

/* ── Animations ─────────────────────────────────────────────────────── */

/* NP entrance/exit is now done via inline JS-controlled transforms
   (see openNP/closeNP) — keyframe slide-up removed to avoid conflict. */

/* NP cover: subtle floating + rotation while playing */
@keyframes np-art-float {
  0%, 100% { transform: translateY(0)   scale(1);    }
  50%      { transform: translateY(-6px) scale(1.012); }
}
body.np-open .np-art {
  animation: np-art-float 5s ease-in-out infinite;
}

/* Heart "burst" when liked */
@keyframes heart-burst {
  0%   { transform: scale(1);   }
  30%  { transform: scale(1.35); }
  60%  { transform: scale(.92); }
  100% { transform: scale(1);   }
}
.np-fav.burst { animation: heart-burst .45s ease-out; }
.ico-btn.fav.on { animation: heart-burst .35s ease-out; }

/* NP play button: pulsing glow ring while audio is playing */
@keyframes play-pulse {
  0%   { box-shadow: 0 10px 28px rgba(30,215,96,.45), 0 0 0 0  rgba(30,215,96,.45); }
  70%  { box-shadow: 0 10px 28px rgba(30,215,96,.45), 0 0 0 18px rgba(30,215,96,0);  }
  100% { box-shadow: 0 10px 28px rgba(30,215,96,.45), 0 0 0 0  rgba(30,215,96,0);    }
}
body.playing .np-play { animation: play-pulse 1.8s ease-out infinite; }

/* Track rows: subtle fade-in from below when list renders */
@keyframes row-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}
.row { animation: row-in .35s ease both; }
.row:nth-child(1)  { animation-delay: .00s; }
.row:nth-child(2)  { animation-delay: .03s; }
.row:nth-child(3)  { animation-delay: .06s; }
.row:nth-child(4)  { animation-delay: .09s; }
.row:nth-child(5)  { animation-delay: .12s; }
.row:nth-child(6)  { animation-delay: .15s; }
.row:nth-child(7)  { animation-delay: .18s; }
.row:nth-child(8)  { animation-delay: .21s; }
.row:nth-child(9)  { animation-delay: .24s; }
.row:nth-child(10) { animation-delay: .27s; }

/* Tab icon press feedback (slight bounce) */
.tab.active svg { animation: tab-pop .35s cubic-bezier(.2,.8,.2,1.4); }
@keyframes tab-pop {
  0%   { transform: scale(.85); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1);    }
}

/* Page title shimmer (the gradient text gets a slow shine sweep) */
@keyframes title-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
.top h1 {
  background-size: 200% 100%;
  animation: title-shimmer 6s ease-in-out infinite;
}

/* Smooth transitions across the app */
.row, .tab, .ico-btn, .play-btn, .np-play, .np-ctl, .np-fav, .np-close, .ctl {
  transition: transform .12s cubic-bezier(.2,.8,.2,1), background .15s, color .2s, opacity .15s, box-shadow .2s;
}

/* Smooth reveal when the mini player appears (track starts) */
@keyframes player-rise {
  from { transform: translateY(110%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.player:not(.hidden) { animation: player-rise .35s cubic-bezier(.2,.8,.2,1); }

/* ── Pull-to-refresh indicator ──────────────────────────────────────── */
.ptr-indicator {
  position: fixed;
  top: calc(var(--tg-top, 0px) + 16px);
  left: 50%;
  width: 38px; height: 38px;
  margin-left: -19px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 8, 31, .92);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 50%;
  color: #c9b3ff;
  z-index: 32;            /* below NP (z 100), above tabbar (z 40 doesn't matter — different stacking) */
  opacity: 0;
  pointer-events: none;
  transform: translateY(-80px);
  transition: transform .28s cubic-bezier(.2,.8,.2,1), opacity .2s ease;
  box-shadow: 0 4px 18px rgba(0,0,0,.35);
}
.ptr-indicator svg { width: 20px; height: 20px; transition: transform .18s linear; }
.ptr-indicator.visible { opacity: 1; }
.ptr-indicator.dragging { transition: none; }      /* follow finger 1:1 while dragging */
.ptr-indicator.armed   { color: #b465ff; }         /* threshold crossed — release-to-refresh */
.ptr-indicator.refreshing svg { animation: ptr-spin .9s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ── Profile tab ────────────────────────────────────────────────────── */
.profile-page {
  padding: 4px 4px 24px;
}
.profile-head {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 28px;
}
.profile-avatar {
  width: 92px; height: 92px;
  border-radius: 50%;
  background: linear-gradient(135deg, #b465ff, #7c3aff);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 36px; font-weight: 700;
  box-shadow: 0 6px 24px rgba(124,58,255,.4);
  margin-bottom: 14px;
}
.profile-name {
  font-size: 20px; font-weight: 600;
  color: #fff;
}
.profile-handle {
  font-size: 14px;
  color: rgba(255,255,255,.55);
  margin-top: 2px;
}
.profile-section-title {
  font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: rgba(255,255,255,.45);
  padding: 0 6px 10px;
}
.profile-row {
  display: flex; align-items: center; gap: 14px;
  background: rgba(255,255,255,.04);
  padding: 16px 16px;
  border-radius: 14px;
}
.profile-row-text { flex: 1; min-width: 0; }
.profile-row-title {
  font-size: 16px; color: #fff;
  margin-bottom: 4px;
}
.profile-row-hint {
  font-size: 12.5px; color: rgba(255,255,255,.55);
  line-height: 1.35;
}

/* iOS-style switch */
.switch {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 52px; height: 32px;
  cursor: pointer;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.18);
  border-radius: 999px;
  transition: background .25s ease;
}
.switch-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 26px; height: 26px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  transition: left .22s cubic-bezier(.2,.8,.2,1), background .25s;
}
.switch input:checked + .switch-track {
  background: linear-gradient(135deg, #b465ff 0%, #7c3aff 100%);
}
.switch input:checked + .switch-track .switch-thumb {
  left: 23px;
}

/* ── Listen-together ────────────────────────────────────────────────── */
.room-bar {
  position: fixed; left: 0; right: 0;
  top: calc(var(--tg-top, env(safe-area-inset-top, 0)) + 0px);
  z-index: 45;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  background: linear-gradient(90deg, rgba(124,58,255,.95), rgba(180,101,255,.95));
  color: #fff; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 4px 18px rgba(0,0,0,.35);
}
/* Must remove it from hit-testing, not just hide it */
.room-bar.hidden { display: none; }
.room-bar-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #4ade80;
  flex-shrink: 0; animation: room-pulse 1.8s ease-in-out infinite;
}
@keyframes room-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.room-bar-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,.22); border: 0; color: #fff;
  padding: 6px 13px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.room-bar-btn.ghost { background: rgba(0,0,0,.22); }
.room-bar-btn:active { transform: scale(.94); }
/* Push the page down so the bar never covers the header */
body.room-on .top { padding-top: calc(var(--tg-top, env(safe-area-inset-top, 0)) + 48px); }

/* Join gate — iOS will not start audio without a real tap */
.room-gate {
  position: fixed; inset: 0; z-index: 130;
  background: rgba(8,4,16,.86);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.room-gate.hidden { display: none; }
.room-gate-card {
  width: 100%; max-width: 340px;
  background: linear-gradient(180deg, #241540, #16092a);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 20px;
  padding: 26px 22px 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.room-gate-title { font-size: 19px; font-weight: 700; color: #fff; }
.room-gate-sub { font-size: 14px; color: rgba(255,255,255,.62); margin-top: 8px; line-height: 1.45; }
.room-gate-btn {
  display: block; width: 100%;
  margin-top: 20px; padding: 14px;
  border: 0; border-radius: 14px;
  background: #fff; color: #14081f;
  font-size: 15.5px; font-weight: 700; cursor: pointer;
}
.room-gate-btn:active { transform: scale(.97); }
.room-gate-cancel {
  margin-top: 10px; padding: 10px;
  background: transparent; border: 0;
  color: rgba(255,255,255,.55); font-size: 14px; cursor: pointer;
}

/* ── Albums ─────────────────────────────────────────────────────────── */
.sec-title {
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: rgba(255,255,255,.45);
  padding: 18px 12px 10px;
}

/* Horizontal album strip (search results, "more by artist") */
.album-strip {
  display: flex; gap: 14px;
  overflow-x: auto;
  padding: 2px 12px 6px;
  scroll-snap-type: x proximity;
}
.album-strip::-webkit-scrollbar { height: 0; }
.album-card {
  flex: 0 0 138px; width: 138px;
  cursor: pointer;
  scroll-snap-align: start;
  transition: transform .12s;
}
.album-card:active { transform: scale(.96); }
.album-card-cover {
  width: 138px; height: 138px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2a1d4f, #4a2068) center / cover no-repeat;
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
  margin-bottom: 9px;
}
.album-card-title {
  font-size: 14px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.album-card-sub {
  font-size: 12.5px; color: var(--text-dim); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Album page */
.album-page { padding-bottom: 8px; }
.album-hero {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 20px 22px;
  text-align: center;
}
.album-back {
  position: absolute; left: 8px; top: 0;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .15s, background .18s;
}
.album-back svg { width: 21px; height: 21px; }
.album-back:active { transform: scale(.9); background: rgba(255,255,255,.22); }

.album-cover {
  width: 60vw; max-width: 250px; aspect-ratio: 1 / 1;
  border-radius: 14px;
  background: linear-gradient(135deg, #2a1d4f, #4a2068) center / cover no-repeat;
  box-shadow: 0 16px 44px rgba(0,0,0,.55);
  margin: 8px 0 18px;
}
.album-title {
  font-size: 22px; font-weight: 800; letter-spacing: -.015em; color: #fff;
  line-height: 1.25;
}
.album-artist {
  font-size: 15px; font-weight: 600; color: #c9b3ff; margin-top: 6px;
}
.album-meta { font-size: 13px; color: var(--text-dim); margin-top: 5px; }
.album-play {
  margin-top: 18px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 30px;
  border: 0; border-radius: 999px;
  background: #fff; color: #14081f;
  font-size: 15.5px; font-weight: 700;
  cursor: pointer;
  transition: transform .14s;
}
.album-play svg { width: 20px; height: 20px; }
.album-play:active { transform: scale(.95); }

/* Artist cards in the search strip — round cover sets them apart from albums */
.artist-card {
  flex: 0 0 118px; width: 118px;
  cursor: pointer; text-align: center;
  scroll-snap-align: start;
  transition: transform .12s;
}
.artist-card:active { transform: scale(.96); }
.artist-card-cover {
  width: 118px; height: 118px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a1d4f, #4a2068) center / cover no-repeat;
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
  margin-bottom: 9px;
}
.artist-card-name {
  font-size: 14px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.artist-card-sub {
  font-size: 12.5px; color: var(--text-dim); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Artist page hero */
.artist-avatar {
  width: 56vw; max-width: 220px; aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a1d4f, #4a2068) center / cover no-repeat;
  box-shadow: 0 16px 44px rgba(0,0,0,.55);
  margin: 8px 0 18px;
}
.artist-hero .album-title { font-size: 25px; }

/* Artist name on the album page reads as a link */
.album-artist.tappable { cursor: pointer; }
.album-artist.tappable:active { opacity: .6; }

.show-more {
  display: block; margin: 6px auto 4px;
  padding: 10px 22px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.13);
  color: #fff;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.show-more:active { background: rgba(255,255,255,.18); }

/* Numbered rows inside an album */
.row-num .tno {
  flex: 0 0 30px; text-align: center;
  color: var(--text-faint); font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.row-num.playing .tno { color: var(--accent); }

/* ── Lyrics panel (Spotify-style) ───────────────────────────────────── */
.lyrics-panel {
  position: fixed; inset: 0;
  z-index: 110;
  display: flex; flex-direction: column;
  overflow: hidden;
  /* Static gradients only. The previous animated blur-blobs forced the GPU to
     recomposite large blurred areas every frame, which heated the phone. */
  background:
    radial-gradient(125% 80% at 10% 0%,    rgba(150,70,255,.44) 0%, transparent 58%),
    radial-gradient(110% 70% at 94% 30%,   rgba(255,90,170,.24) 0%, transparent 60%),
    radial-gradient(125% 85% at 28% 100%,  rgba(70,110,255,.26) 0%, transparent 62%),
    #16092a;
  padding-top: calc(var(--tg-top, env(safe-area-inset-top, 0)) + 14px);
  animation: lyrics-in .3s cubic-bezier(.2,.8,.2,1);
}
/* CRITICAL: without display:none a full-screen panel keeps eating every tap. */
.lyrics-panel.hidden { display: none; }
@keyframes lyrics-in {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Edge fades as plain overlays — a mask on the scroller repaints while scrolling */
.lyrics-fade { position: absolute; left: 0; right: 0; pointer-events: none; z-index: 1; }
.lyrics-fade.top {
  top: 0; height: 108px;
  background: linear-gradient(180deg, rgba(22,9,42,.92) 0%, rgba(22,9,42,0) 100%);
}
.lyrics-fade.bot {
  bottom: 0; height: 210px;
  background: linear-gradient(0deg, rgba(20,8,38,.97) 26%, rgba(22,9,42,0) 100%);
}

.lyrics-scroll {
  flex: 1; min-height: 0;
  position: relative; z-index: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 26px;
}
.lyrics-scroll::-webkit-scrollbar { width: 0; height: 0; }

/* Leading/trailing space lets the first and last line reach the centre */
.lyrics-lines { padding: 32vh 0 44vh; }

.lyrics-line {
  font-size: 25px;
  font-weight: 700;
  line-height: 1.34;
  letter-spacing: -.01em;
  color: rgba(255,255,255,.38);
  margin: 0 0 20px;
  cursor: pointer;
  transform-origin: left center;
  /* transform never affects offsetTop/offsetHeight, so auto-scroll centring
     stays exact even while the active line is scaled up. */
  transition: color .3s ease, transform .42s cubic-bezier(.22,1,.36,1), opacity .35s ease;
  -webkit-tap-highlight-color: transparent;
}
.lyrics-line.passed { color: rgba(255,255,255,.24); }

/* Depth via opacity only — filter: blur() on many lines is what heated the phone */
.lyrics-line.far  { opacity: .62; }
.lyrics-line.far2 { opacity: .34; }

.lyrics-line.active {
  color: rgba(255,255,255,.30);        /* colour of not-yet-sung words */
  transform: scale(1.045);
  opacity: 1;
}

/* Word-level karaoke — each word lights up as it is sung */
.lyrics-line .w { display: inline-block; transition: color .22s ease, text-shadow .34s ease; }
.lyrics-line.active .w.lit {
  color: #fff;
  text-shadow: 0 0 18px rgba(196,140,255,.5);
}
.lyrics-line.active .w.now { animation: word-pop .34s cubic-bezier(.3,1.4,.5,1); }
@keyframes word-pop {
  0%   { transform: translateY(0)      scale(1);    }
  45%  { transform: translateY(-2.5px) scale(1.06); }
  100% { transform: translateY(0)      scale(1);    }
}

/* Instrumental break — three breathing dots */
.lyrics-line.gap { display: flex; gap: 9px; align-items: center; padding: 4px 0; }
.lyrics-line.gap i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; opacity: .5; }
.lyrics-line.gap.active i { background: #fff; animation: dot-breathe 1.3s ease-in-out infinite; }
.lyrics-line.gap.active i:nth-child(2) { animation-delay: .18s; }
.lyrics-line.gap.active i:nth-child(3) { animation-delay: .36s; }
@keyframes dot-breathe {
  0%,100% { transform: scale(.75); opacity: .4; }
  50%     { transform: scale(1.25); opacity: 1;  }
}

/* Plain (untimed) lyrics aren't clickable */
.lyrics-line.plain {
  color: rgba(255,255,255,.86); cursor: default;
  font-weight: 600; font-size: 21px; transform: none;
}

/* Staggered entrance for the first screenful */
.lyrics-lines.enter .lyrics-line { animation: line-in .5s both cubic-bezier(.2,.8,.2,1); }
@keyframes line-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lyrics-state {
  padding: 28vh 12px 0; text-align: center;
  color: rgba(255,255,255,.6); font-size: 15px; line-height: 1.5;
}
.lyrics-state strong { display: block; color: #fff; font-size: 17px; margin-bottom: 8px; font-weight: 600; }

/* ── bottom zone: back · track · play ─────────────────────────────── */
.lyrics-bottom {
  position: relative; z-index: 2;
  flex-shrink: 0;
  padding: 0 18px calc(18px + var(--tg-bottom, 0px));
}
.lyrics-progress {
  height: 4px; margin-bottom: 15px;
  background: rgba(255,255,255,.20);
  border-radius: 999px; overflow: hidden; cursor: pointer;
}
.lyrics-progress span {
  display: block; height: 100%; width: 0%;
  background: #fff; border-radius: 999px;
}
.lyrics-bar { display: flex; align-items: center; gap: 14px; }
.lyrics-back {
  flex-shrink: 0;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.18);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .15s, background .18s;
}
.lyrics-back svg { width: 21px; height: 21px; }
.lyrics-back:active { transform: scale(.9); background: rgba(255,255,255,.26); }
.lyrics-bar-meta { flex: 1; min-width: 0; }
.lyrics-bar-title {
  font-size: 15.5px; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lyrics-bar-artist {
  font-size: 13px; color: rgba(255,255,255,.62); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lyrics-play {
  width: 48px; height: 48px; flex-shrink: 0;
  border: 0; border-radius: 50%;
  background: #fff; color: #14081f;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .15s;
}
.lyrics-play:active { transform: scale(.92); }
.lyrics-play svg { width: 25px; height: 25px; }

/* ── Track action sheet (opened from the 3-dot button) ──────────────── */
.track-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 105;
  opacity: 1;
  transition: opacity .22s ease;
}
.track-sheet-backdrop.hidden { display: none; }   /* must remove from hit-test */

.track-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 106;
  padding: 12px 18px calc(20px + var(--tg-bottom, 0px));
  background: linear-gradient(180deg, #1e1330 0%, #14081f 100%);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  box-shadow: 0 -10px 40px rgba(0,0,0,.55);
  animation: track-sheet-rise .26s cubic-bezier(.2,.8,.2,1);
}
.track-sheet.hidden { display: none; }
@keyframes track-sheet-rise {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.track-sheet-grabber {
  width: 36px; height: 4px;
  background: rgba(255,255,255,.22);
  border-radius: 999px;
  margin: 0 auto 14px;
}

.track-sheet-meta {
  text-align: center;
  padding: 0 4px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 10px;
}
.track-sheet-title {
  font-size: 16px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-sheet-artist {
  font-size: 13.5px; color: rgba(255,255,255,.55);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.track-sheet-action {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 14px 8px;
  border-radius: 12px;
  text-align: left;
  color: #fff;
  cursor: pointer;
}
.track-sheet-action:active { background: rgba(255,255,255,.06); }
.track-sheet-action svg {
  width: 26px; height: 26px;
  flex-shrink: 0;
  color: #b465ff;
}
.track-sheet-action-text { display: flex; flex-direction: column; min-width: 0; }
.track-sheet-action-title {
  font-size: 16px; font-weight: 500;
}
.track-sheet-action-hint {
  font-size: 12.5px; color: rgba(255,255,255,.55);
  margin-top: 2px;
}
.track-sheet-action.loading .track-sheet-action-hint { color: #b465ff; }
.track-sheet-action.active { background: rgba(180,101,255,.10); }
.track-sheet-action.active svg { color: #d8b8ff; }

.track-sheet-close {
  display: block;
  margin: 12px auto 0;
  padding: 11px 28px;
  background: rgba(255,255,255,.08);
  color: #fff;
  border: 0;
  border-radius: 12px;
  font-size: 14.5px; font-weight: 500;
  cursor: pointer;
}
.track-sheet-close:active { background: rgba(255,255,255,.16); }
