:root {
  --safe-bottom: max(
    env(safe-area-inset-bottom, 0px),
    var(--tg-safe-area-inset-bottom, 0px),
    var(--tg-content-safe-area-inset-bottom, 0px)
  );
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }
html, body { min-height: 100%; min-height: 100dvh; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Tahoma, sans-serif;
  color: #f6f7ff;
  background: #05060a;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background: #07080f; }
.bg img {
  position: absolute; inset: -12%;
  width: 124%; height: 124%; object-fit: cover;
  filter: blur(70px) saturate(140%);
  opacity: 0.22;
  animation: bgDrift 24s ease-in-out infinite alternate;
}
.mesh { position: absolute; inset: -20%; }
.blob {
  position: absolute; border-radius: 50%;
  filter: blur(48px);
  mix-blend-mode: screen;
  opacity: 0.78;
}
.b1 { width: 58%; height: 48%; top: -8%; left: -12%; background: radial-gradient(circle, #7a5cff 0%, transparent 68%); animation: meshA 18s ease-in-out infinite alternate; }
.b2 { width: 52%; height: 46%; top: 8%; right: -16%; background: radial-gradient(circle, #3ad7ff 0%, transparent 70%); animation: meshB 22s ease-in-out infinite alternate; }
.b3 { width: 46%; height: 42%; bottom: 4%; left: 8%; background: radial-gradient(circle, #ff5ec8 0%, transparent 70%); animation: meshC 16s ease-in-out infinite alternate; }
.b4 { width: 40%; height: 36%; top: 38%; left: 28%; background: radial-gradient(circle, #5dffc8 0%, transparent 72%); animation: meshA 20s ease-in-out infinite alternate-reverse; opacity: 0.45; }
.b5 { width: 36%; height: 32%; bottom: 18%; right: 10%; background: radial-gradient(circle, #ffd36a 0%, transparent 72%); animation: meshB 14s ease-in-out infinite; opacity: 0.32; }
.veil {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 80% at 50% -8%, rgba(255,255,255,0.16), transparent 52%),
    linear-gradient(180deg, rgba(8,10,18,0.18), rgba(6,7,12,0.72) 78%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
}
@keyframes meshA { to { transform: translate(12%, 10%) scale(1.12); } }
@keyframes meshB { to { transform: translate(-10%, 14%) scale(1.18); } }
@keyframes meshC { to { transform: translate(8%, -12%) scale(1.1); } }
@keyframes bgDrift { to { transform: scale(1.12) translate3d(-2%, 3%, 0); } }

.app {
  position: relative; z-index: 1;
  max-width: 480px; margin: 0 auto;
  min-height: 100dvh;
  padding: 14px 16px calc(28px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 16px;
}

.glass {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.28),
    inset 0 -1px 0 rgba(255,255,255,0.04),
    0 18px 50px rgba(0,0,0,0.28);
  -webkit-backdrop-filter: blur(36px) saturate(190%);
  backdrop-filter: blur(36px) saturate(190%);
}

header.glass {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border-radius: 24px;
  animation: rise 0.7s cubic-bezier(.16,1,.3,1);
}
.brand { display: flex; flex-direction: column; }
.kicker {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(255,255,255,0.5);
}
.brand strong { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }

.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
}
.live-badge i {
  width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.4);
}
.live-badge:not(.off) {
  background: rgba(255, 70, 130, 0.18);
  border-color: rgba(255, 90, 150, 0.4);
  color: #ffd6e5;
}
.live-badge:not(.off) i { background: #ff4d8d; animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.8); } }

.stage { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.art {
  position: relative;
  width: min(68vw, 260px); height: min(68vw, 260px);
  border-radius: 36px; overflow: hidden;
  isolation: isolate;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.35),
    0 30px 70px rgba(0,0,0,0.45),
    0 0 0 1px rgba(255,255,255,0.08);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  animation: artIn 0.9s cubic-bezier(.16,1,.3,1);
}
.art video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: inherit;
}
.art-glass {
  position: absolute; inset: 0; pointer-events: none; z-index: 1; border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.22) 0%, transparent 38%, rgba(0,0,0,0.18) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
}
.shine {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,0.28) 48%, transparent 62%);
  transform: translateX(-120%);
  animation: shine 4.8s ease-in-out infinite;
}
.art.playing { animation: floaty 6.5s ease-in-out infinite; }
body.playing .art { box-shadow: 0 30px 80px rgba(110, 160, 255, 0.28), 0 0 0 1px rgba(255,255,255,0.2); }
@keyframes artIn { from { opacity: 0; transform: scale(0.88) translateY(18px); } }
@keyframes floaty { 50% { transform: translateY(-8px) scale(1.015); } }
@keyframes shine { 0%, 55% { transform: translateX(-120%); } 80%, 100% { transform: translateX(120%); } }

.eq-glass {
  width: min(86%, 320px);
  padding: 14px 18px 12px;
  border-radius: 28px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.32),
    0 16px 40px rgba(0,0,0,0.18);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  backdrop-filter: blur(28px) saturate(190%);
}
.eq {
  height: 54px; display: flex; align-items: flex-end; justify-content: center; gap: 3px;
}
.eq i {
  flex: 1;
  height: 100%;
  max-width: 7px;
  border-radius: 99px;
  background: linear-gradient(180deg, #fff 0%, #9ad7ff 42%, #7a5cff 100%);
  box-shadow: 0 0 12px rgba(140, 200, 255, 0.45);
  transform-origin: bottom center;
  transform: scaleY(0.18);
  opacity: 0.35;
}
body.playing .eq i {
  opacity: 1;
  animation: wave 1.05s cubic-bezier(.45,.05,.2,1) infinite;
}
.eq i:nth-child(1)  { animation-duration: 0.82s; animation-delay: -0.10s; }
.eq i:nth-child(2)  { animation-duration: 0.94s; animation-delay: -0.22s; }
.eq i:nth-child(3)  { animation-duration: 0.76s; animation-delay: -0.04s; }
.eq i:nth-child(4)  { animation-duration: 1.12s; animation-delay: -0.31s; }
.eq i:nth-child(5)  { animation-duration: 0.88s; animation-delay: -0.18s; }
.eq i:nth-child(6)  { animation-duration: 0.70s; animation-delay: -0.44s; }
.eq i:nth-child(7)  { animation-duration: 1.04s; animation-delay: -0.07s; }
.eq i:nth-child(8)  { animation-duration: 0.86s; animation-delay: -0.27s; }
.eq i:nth-child(9)  { animation-duration: 0.78s; animation-delay: -0.15s; }
.eq i:nth-child(10) { animation-duration: 0.96s; animation-delay: -0.38s; }
.eq i:nth-child(11) { animation-duration: 0.84s; animation-delay: -0.02s; }
.eq i:nth-child(12) { animation-duration: 1.18s; animation-delay: -0.21s; }
.eq i:nth-child(13) { animation-duration: 0.72s; animation-delay: -0.33s; }
.eq i:nth-child(14) { animation-duration: 0.90s; animation-delay: -0.11s; }
.eq i:nth-child(15) { animation-duration: 1.08s; animation-delay: -0.41s; }
.eq i:nth-child(16) { animation-duration: 0.80s; animation-delay: -0.06s; }
.eq i:nth-child(17) { animation-duration: 0.98s; animation-delay: -0.24s; }
.eq i:nth-child(18) { animation-duration: 0.74s; animation-delay: -0.36s; }
.eq i:nth-child(19) { animation-duration: 1.14s; animation-delay: -0.13s; }
.eq i:nth-child(20) { animation-duration: 0.87s; animation-delay: -0.29s; }
.eq i:nth-child(21) { animation-duration: 0.91s; animation-delay: -0.08s; }
.eq i:nth-child(22) { animation-duration: 0.77s; animation-delay: -0.19s; }
.eq i:nth-child(23) { animation-duration: 1.01s; animation-delay: -0.42s; }
.eq i:nth-child(24) { animation-duration: 0.83s; animation-delay: -0.16s; }
@keyframes wave {
  0%, 100% { transform: scaleY(0.18); }
  18% { transform: scaleY(0.92); }
  36% { transform: scaleY(0.34); }
  54% { transform: scaleY(0.78); }
  72% { transform: scaleY(0.26); }
}

.meta { text-align: center; width: 100%; padding: 0 8px; animation: rise 0.8s 0.08s cubic-bezier(.16,1,.3,1) both; }
.title {
  font-size: 24px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 8px 24px rgba(0,0,0,0.28);
}
.artist { margin-top: 6px; font-size: 15px; color: rgba(255,255,255,0.62); font-weight: 500; }

.dock {
  width: auto;
  display: flex; align-items: center; justify-content: center;
  padding: 10px; border-radius: 999px;
  animation: rise 0.85s 0.12s cubic-bezier(.16,1,.3,1) both;
}
.btn {
  border: 0; cursor: pointer; color: #fff;
  display: grid; place-items: center; border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.28);
  transition: transform 0.18s cubic-bezier(.16,1,.3,1), background 0.18s ease;
}
.btn svg { width: 22px; height: 22px; fill: currentColor; display: block; }
.btn[hidden] { display: none; }
.btn.play {
  width: 78px; height: 78px; background: #fff; color: #111; border: 0;
  box-shadow: 0 14px 36px rgba(255,255,255,0.22);
}
.btn.play svg { width: 32px; height: 32px; }
.btn.skip { width: 46px; height: 46px; font-size: 20px; }
.btn:active { transform: scale(0.9); }
.btn:disabled { opacity: 0.35; pointer-events: none; }
body.playing .btn.play { box-shadow: 0 16px 40px rgba(130, 180, 255, 0.38); }

.vol {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 999px;
}
.vol input[type="range"] { flex: 1; height: 4px; accent-color: #fff; }
.mute {
  width: 36px; height: 36px; border: 0; background: transparent; color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.mute svg { width: 20px; height: 20px; fill: currentColor; }

.artist-picker { border-radius: 24px; padding: 14px; }
.artist-picker h2 { font-size: 12px; margin-bottom: 10px; color: rgba(255,255,255,0.65); }
.mode-tabs { display: flex; gap: 8px; }
.mode-tabs button { flex: 1; border: 1px solid rgba(255,255,255,0.16); border-radius: 14px; background: rgba(255,255,255,0.08); color: #fff; padding: 10px; cursor: pointer; font: inherit; font-size: 13px; }
.mode-tabs button.selected { background: rgba(122,92,255,0.45); border-color: rgba(190,175,255,0.7); }
#artistControls { margin-top: 12px; }
#artistSearch { width: 100%; border: 1px solid rgba(255,255,255,0.2); border-radius: 12px; background: rgba(0,0,0,0.22); color: #fff; padding: 11px; font: inherit; outline: none; }
#artistSearch::placeholder { color: rgba(255,255,255,0.48); }
.artist-results { max-height: 175px; overflow-y: auto; margin-top: 8px; }
.artist-option { width: 100%; display: flex; justify-content: space-between; gap: 8px; align-items: center; border: 0; border-top: 1px solid rgba(255,255,255,0.09); background: transparent; color: #fff; padding: 10px 4px; text-align: right; cursor: pointer; font: inherit; font-size: 13px; }
.artist-option small { color: rgba(255,255,255,0.5); white-space: nowrap; }

.queue { border-radius: 26px; overflow: hidden; animation: rise 0.9s 0.16s cubic-bezier(.16,1,.3,1) both; }
.queue h2 {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  color: rgba(255,255,255,0.5); padding: 12px 16px 4px;
}
.up-list { max-height: 24vh; overflow-y: auto; }
.up-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  animation: rowIn 0.5s cubic-bezier(.16,1,.3,1) both;
}
.up-item .n {
  width: 22px; height: 22px; border-radius: 8px;
  display: grid; place-items: center; font-size: 11px;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.5);
}
.up-item .t { font-size: 13px; font-weight: 700; }
.up-item .a { font-size: 11px; color: rgba(255,255,255,0.5); }
.empty, .hint { text-align: center; color: rgba(255,255,255,0.48); font-size: 12px; }
.empty { padding: 16px; }
.hint { line-height: 1.6; min-height: 1.2em; }
.hidden { display: none !important; }

@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes rowIn { from { opacity: 0; transform: translateY(10px); } }
.up-item:nth-child(1) { animation-delay: .04s; } .up-item:nth-child(2) { animation-delay: .08s; }
.up-item:nth-child(3) { animation-delay: .12s; } .up-item:nth-child(4) { animation-delay: .16s; }
.up-item:nth-child(5) { animation-delay: .2s; }
