/* ========== MUSIC LIBRARY PANEL ========== */
.music-library-panel {
  position: fixed;
  top: 0; bottom: 0; left: 0; right: 0;
  background: #0F2A22;
  border-radius: 0;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.34, 1.05, 0.64, 1);
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  box-shadow: none;
}
.music-library-panel.show { transform: translateY(0); }

.music-library-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  z-index: 79;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}
.music-library-backdrop.show { opacity: 1; visibility: visible; }

.music-lib-handle {
  display: none;
}

.music-lib-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 1.1rem) 1.2rem 0.8rem 1.2rem;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.music-lib-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.music-lib-title i { color: #FFE0A3; font-size: 1rem; }
.music-lib-count {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.45);
  font-weight: 500;
  margin-left: 0.3rem;
}
.music-lib-close {
  background: rgba(255,255,255,0.12);
  border: none;
  color: rgba(255,255,255,0.85);
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.15s;
}
.music-lib-close:hover, .music-lib-close:active {
  background: rgba(255,255,255,0.22);
}

/* ---- Music Library Search Bar ---- */
.music-lib-search-wrapper {
  display: flex;
  justify-content: flex-end;
  padding: 0.6rem 1.2rem 0rem 1.2rem;
  flex-shrink: 0;
}
.music-lib-search-bar {
  position: relative;
  top: unset;
  right: unset;
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 2rem;
  padding: 0.42rem 0.55rem;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  width: 34px;
  overflow: hidden;
  flex-shrink: 0;
}
.music-lib-search-bar.expanded {
  width: 200px;
  padding: 0.42rem 0.9rem;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,224,163,0.45);
}
.music-lib-search-icon {
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: color 0.2s;
  cursor: pointer;
}
.music-lib-search-bar.expanded .music-lib-search-icon {
  color: #FFE0A3;
}
.music-lib-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  min-width: 0;
  width: 0;
  opacity: 0;
  transition: opacity 0.2s, width 0.3s;
  pointer-events: none;
}
.music-lib-search-bar.expanded .music-lib-search-input {
  width: auto;
  opacity: 1;
  pointer-events: all;
  margin-left: 0.45rem;
}
.music-lib-search-input::placeholder {
  color: rgba(255,255,255,0.3);
  font-weight: 400;
}
.music-lib-search-clear {
  background: none;
  border: none;
  color: rgba(255,255,255,0.35);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s, opacity 0.2s;
  opacity: 0;
  pointer-events: none;
}
.music-lib-search-bar.expanded .music-lib-search-clear {
  opacity: 1;
  pointer-events: all;
}
.music-lib-search-clear:hover { color: rgba(255,255,255,0.7); }
/* ---- Music Library Filter Buttons ---- */
.music-lib-filter-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem 0.4rem 1rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.music-lib-filter-row::-webkit-scrollbar { display: none; }
.music-lib-filter-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 2rem;
  color: rgba(255,255,255,0.6);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: 'Inter', sans-serif;
}
.music-lib-filter-btn i { font-size: 0.7rem; }
.music-lib-filter-btn:hover {
  background: rgba(255,255,255,0.13);
  color: rgba(255,255,255,0.9);
}
.music-lib-filter-btn.active {
  background: linear-gradient(135deg, #1B5E4F, #0F3D34);
  border-color: #2A7A66;
  color: #FFE0A3;
}

.music-lib-no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: rgba(255,255,255,0.3);
}
.music-lib-no-results i { font-size: 2.2rem; margin-bottom: 0.7rem; display: block; }
.music-lib-no-results p { font-size: 0.78rem; line-height: 1.5; }

/* ========== TRADING DASHBOARD ========== */
.trading-dashboard {
  display: none;
  flex-direction: column;
  padding: 0 1rem 2rem 1rem;
  gap: 1rem;
  overflow-y: auto;
  flex: 1;
  animation: tradingFadeIn 0.35s ease;
}
.trading-dashboard.show { display: flex; }
@keyframes tradingFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Chart area */
.trading-chart-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,224,163,0.15);
  border-radius: 1.1rem;
  padding: 1rem 1rem 0.6rem 1rem;
  flex-shrink: 0;
}
.trading-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}
.trading-chart-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #FFE0A3;
  display: flex; align-items: center; gap: 0.45rem;
}
.trading-chart-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 2rem;
  background: rgba(27,94,79,0.6);
  border: 1px solid rgba(27,94,79,0.8);
  color: #7FFFD4;
}
.trading-period-tabs {
  display: flex;
  gap: 0.3rem;
}
.trading-period-tab {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0.5rem;
  color: rgba(255,255,255,0.45);
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}
.trading-period-tab.active {
  background: rgba(255,224,163,0.15);
  border-color: rgba(255,224,163,0.4);
  color: #FFE0A3;
}
.trading-chart-canvas-wrap {
  position: relative;
  height: 130px;
  width: 100%;
}
.trading-chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}
.trading-chart-stats {
  display: flex;
  gap: 1.2rem;
  margin-top: 0.7rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.tcs-item { flex: 1; text-align: center; }
.tcs-val { font-size: 0.85rem; font-weight: 700; color: white; }
.tcs-val.up { color: #4CD080; }
.tcs-val.down { color: #FF6B6B; }
.tcs-lbl { font-size: 0.55rem; color: rgba(255,255,255,0.4); margin-top: 0.1rem; text-transform: uppercase; letter-spacing: 0.5px; }

/* Top songs leaderboard */
.trading-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.trading-section-title i { font-size: 0.7rem; color: #FFE0A3; }
.trading-songs-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.trading-song-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0.95rem;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
  overflow: hidden;
}
.trading-song-card:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,224,163,0.2); }
.trading-song-card.rank-1 { border-color: rgba(255,215,0,0.3); background: rgba(255,215,0,0.06); }
.trading-song-card.rank-2 { border-color: rgba(192,192,192,0.25); background: rgba(192,192,192,0.04); }
.trading-song-card.rank-3 { border-color: rgba(205,127,50,0.25); background: rgba(205,127,50,0.04); }

.tsc-rank {
  font-size: 1rem;
  font-weight: 800;
  color: rgba(255,255,255,0.25);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.rank-1 .tsc-rank { color: #FFD700; }
.rank-2 .tsc-rank { color: #C0C0C0; }
.rank-3 .tsc-rank { color: #CD7F32; }

.tsc-cover {
  width: 44px; height: 44px;
  border-radius: 0.6rem;
  background: linear-gradient(135deg, #1B5E4F, #0A2B1F);
  display: flex; align-items: center; justify-content: center;
  color: #FFE0A3;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}
.tsc-cover img { width: 100%; height: 100%; object-fit: cover; border-radius: 0.6rem; display: block; }

.tsc-info { flex: 1; min-width: 0; }
.tsc-name { font-size: 0.82rem; font-weight: 700; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tsc-artist { font-size: 0.67rem; color: rgba(255,255,255,0.45); margin-top: 0.15rem; display: flex; align-items: center; gap: 0.25rem; min-width: 0; }
.tsc-artist .tsc-artist-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tsc-artist .tsc-paid-tick { flex-shrink: 0; margin-left: 0; }
.tsc-plays { font-size: 0.6rem; color: rgba(255,255,255,0.35); margin-top: 0.2rem; display: flex; align-items: center; gap: 0.3rem; }
.tsc-plays i { font-size: 0.55rem; }

.tsc-right { text-align: right; flex-shrink: 0; }
.tsc-score { font-size: 0.88rem; font-weight: 800; color: #FFE0A3; }
.tsc-change { font-size: 0.62rem; font-weight: 700; margin-top: 0.15rem; display: flex; align-items: center; gap: 0.2rem; justify-content: flex-end; }
.tsc-change.up { color: #4CD080; }
.tsc-change.down { color: #FF6B6B; }
.tsc-sparkline { width: 50px; height: 24px; flex-shrink: 0; }

/* Verified badge tick on top-performing song cards — shown only when user has active verified badge */
.tsc-paid-tick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.95rem;
  height: 0.95rem;
  background: #22c55e;
  border-radius: 50%;
  margin-left: 0.3rem;
  vertical-align: middle;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.35);
}
.tsc-paid-tick i {
  font-size: 0.45rem;
  color: #fff;
  line-height: 1;
}
/* Mini ticker at top of trading panel */
.trading-ticker {
  display: flex;
  gap: 0.8rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0.5rem 0;
  flex-shrink: 0;
}
.trading-ticker::-webkit-scrollbar { display: none; }
.trading-ticker-item {
  flex-shrink: 0;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.75rem;
  padding: 0.4rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 75px;
}
.tti-name { font-size: 0.6rem; font-weight: 700; color: rgba(255,255,255,0.55); text-transform: uppercase; }
.tti-val { font-size: 0.82rem; font-weight: 800; color: white; }
.tti-chg { font-size: 0.6rem; font-weight: 700; }
.tti-chg.up { color: #4CD080; }
.tti-chg.down { color: #FF6B6B; }

.music-lib-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.8rem 1rem calc(env(safe-area-inset-bottom, 0px) + 2rem) 1rem;
  flex: 1;
  min-height: 0;        /* allow flex item to shrink so overflow-y actually scrolls */
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.music-lib-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: rgba(255,255,255,0.3);
}
.music-lib-empty i { font-size: 2.8rem; margin-bottom: 0.8rem; display: block; }
.music-lib-empty p { font-size: 0.78rem; line-height: 1.5; }

/* ---- Rich empty states for Recent & Playlist tabs ---- */
.ml-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.8rem 1.5rem 2rem;
  text-align: center;
  gap: 0;
}
.ml-empty-icon-wrap {
  position: relative;
  width: 88px; height: 88px;
  margin-bottom: 1.2rem;
}
.ml-empty-icon-bg {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
}
.ml-empty-icon-bg i {
  font-size: 2.4rem;
  color: #fff;
  opacity: 0.85;
  filter: drop-shadow(0 2px 8px rgba(255,255,255,0.15));
}
.ml-empty-icon-badge {
  position: absolute;
  bottom: 2px; right: 2px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0F3D34, #1B5E4F);
  border: 2px solid rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem;
  color: #FFE0A3;
}
.ml-empty-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.4rem;
  letter-spacing: -0.2px;
}
.ml-empty-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.38);
  line-height: 1.55;
  max-width: 220px;
}
/* Subtle floating dots decoration */
.ml-empty-dots {
  display: flex; gap: 5px; margin-top: 1.3rem;
}
.ml-empty-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
}
.ml-empty-dots span:nth-child(2) { background: rgba(255,255,255,0.25); }
.ml-empty-dots span:nth-child(3) { background: rgba(255,255,255,0.12); }

.music-lib-track {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 1rem;
  padding: 0.7rem 0.9rem;
  transition: background 0.15s;
  cursor: default;
}
.music-lib-track:hover { background: rgba(255,255,255,0.09); }

.music-lib-cover {
  width: 48px; height: 48px;
  border-radius: 0.65rem;
  background: linear-gradient(135deg, #1B5E4F, #0F3D34);
  display: flex; align-items: center; justify-content: center;
  color: #FFE0A3;
  font-size: 1.1rem;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.18s;
}
.music-lib-cover:active {
  transform: scale(0.92);
  box-shadow: 0 0 0 3px rgba(255,224,163,0.5);
}
.music-lib-cover:hover {
  box-shadow: 0 0 0 2px rgba(255,224,163,0.38), 0 2px 8px rgba(0,0,0,0.3);
}
.music-lib-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
  border-radius: 0.65rem;
}
.music-lib-cover img.show { display: block; }
.music-lib-cover img.show + i { display: none; }

.music-lib-info, .music-lib-track-info { flex: 1; min-width: 0; overflow: hidden; }
.music-lib-track-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.music-lib-track-artist {
  font-size: 0.65rem;
  color: #FFE0A3;
  margin-top: 0.1rem;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}
.music-lib-track-artist .artist-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.music-lib-track-artist .tsc-paid-tick {
  flex-shrink: 0;
}
.music-lib-track-username {
  font-size: 0.6rem;
  color: rgba(255, 224, 163, 0.55);
  margin-top: 0.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.music-lib-track-size {
  font-size: 0.55rem;
  color: rgba(255,255,255,0.35);
  margin-top: 0.25rem;
}

.music-lib-track-plays {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.4);
  margin-top: 0.28rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.music-lib-track-plays i {
  font-size: 0.55rem;
  color: #FFE0A3;
  opacity: 0.7;
}
.mlt-plays-count {
  color: #FFE0A3;
  font-weight: 700;
}
@keyframes playsCountBump {
  0%   { transform: scale(1);    opacity: 1; }
  40%  { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}
.mlt-plays-count.animating {
  display: inline-block;
  animation: playsCountBump 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

.music-lib-track-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.25);
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.music-lib-eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 18px;
  flex-shrink: 0;
}
.music-lib-eq span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: #FFE0A3;
  opacity: 0.7;
}
.music-lib-eq span:nth-child(1) { height: 8px; }
.music-lib-eq span:nth-child(2) { height: 14px; }
.music-lib-eq span:nth-child(3) { height: 10px; }



/* ===== Keep the bottom nav visible while "My Music" is open (phones) ===== */
@media (max-width: 767px) {
  /* Behaves like a page switch: no slide-up, just appears in place above the nav */
  .music-library-panel {
    bottom: var(--nav-h, 64px);
    height: auto;
    max-height: none;
    transform: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease, visibility 0s linear 0.12s;
  }
  .music-library-panel.show {
    transform: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.12s ease, visibility 0s;
  }
  /* lift the nav above the panel (panel is z-index 200) */
  body.rupia-lib-open .bottom-nav { z-index: 210; }
  body.rupia-lib-open .bottom-nav::after { z-index: 209; }
  /* the dimmed backdrop would sit behind everything anyway; hide it so the nav stays crisp */
  body.rupia-lib-open .music-library-backdrop { display: none; }
}

/* ===== My Music (phones): no title / close / search — filter tabs live at the top ===== */
@media (max-width: 767px) {
  .music-library-panel .music-lib-title,
  .music-library-panel .music-lib-close,
  .music-library-panel .music-lib-search-wrapper { display: none !important; }

  /* header collapses completely; only the online/offline pill shows (as a slim row) when active */
  .music-library-panel .music-lib-header {
    padding: 0 !important;
    border-bottom: 0 !important;
    min-height: 0;
    height: 0;
    overflow: visible;
    justify-content: flex-end;
  }
  @supports selector(:has(*)) {
    .music-library-panel .music-lib-header:has(#rupiaNetBtn.rupia-net-show) {
      height: auto;
      padding: calc(env(safe-area-inset-top, 0px) + 0.5rem) 1rem 0 1rem !important;
    }
  }

  /* segmented tab bar — 4 equal buttons that always fit on one line, with a little space */
  .music-library-panel .music-lib-filter-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    padding: calc(env(safe-area-inset-top, 0px) + 0.6rem) 12px 0.6rem 12px;
    overflow: hidden;
    background: #0F2A22;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .music-library-panel .music-lib-filter-btn {
    flex: 1 1 0;
    min-width: 0;
    width: 0;
    justify-content: center;
    gap: 4px;
    height: 34px;
    padding: 0 2px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.65);
  }
  .music-library-panel .music-lib-filter-btn i { font-size: 0.66rem; flex: none; }
  .music-library-panel .music-lib-filter-btn.active {
    background: linear-gradient(135deg, #1F6B59, #12453B);
    border-color: #2F8A73;
    color: #FFE0A3;
  }
}

/* ===== Trading tab (phones): never spill over / dim the bottom nav ===== */
@media (max-width: 767px) {
  .music-library-panel { overflow: hidden; }
  .music-library-panel .trading-dashboard {
    animation: none;               /* the slide/fade made a dim ghost over the nav */
    min-height: 0;
    padding-bottom: 1rem;
    overscroll-behavior: contain;
  }
  .music-library-panel .music-lib-list { min-height: 0; }
  /* hide the track list the instant Trading opens (no 1-frame double view) */
  @supports selector(:has(*)) {
    .music-library-panel:has(.trading-dashboard.show) #musicLibList { display: none !important; }
  }
  /* solid nav while My Music is open so nothing shows through it */
  body.rupia-lib-open .bottom-nav {
    background: #121212;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  body.rupia-lib-open .bottom-nav::after { background: #121212; }
}

/* ===== Phones: the dark blurred backdrop must never sit over the bottom nav ===== */
@media (max-width: 767px) {
  .music-library-backdrop,
  .music-library-backdrop.show {
    display: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  .bottom-nav { z-index: 210; }
}
