/* ==========================================
   BROWSE SECTIONS
   ========================================== */
.browse-section {
  padding: 16px 0 8px;
}

.section-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  padding: 0 20px 10px;
}
.section-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 0 20px 10px;
  margin-top: -6px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 10px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.text-btn:active { opacity: 0.6; }
.text-danger { color: var(--danger); }

.empty-msg {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
  padding: 40px 20px;
}

/* ==========================================
   CARD SCROLL (Trending — horizontal scroll)
   ========================================== */
.card-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  padding: 0 0 8px;
  scroll-padding-inline: 20px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.card-scroll::-webkit-scrollbar { display: none; }

.card-scroll > :first-child {
  margin-left: 20px;
}

.card-scroll > :last-child {
  margin-right: 20px;
}

.track-card {
  flex-shrink: 0;
  width: 150px;
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-spring);
}

.track-card:active {
  transform: scale(0.96);
}

.card-artwork-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--bg-elevated);
}

.card-artwork-placeholder {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
}

.card-artwork {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-play-overlay {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity var(--duration-fast), transform var(--duration-fast) var(--ease-spring);
}

.track-card:active .card-play-overlay,
.card-artwork-wrap:hover .card-play-overlay {
  opacity: 1;
  transform: scale(1);
}

.card-play-overlay svg {
  margin-left: 2px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-artist {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Small card variant */
.track-card-small {
  width: 150px;
}

/* Large card variant (admin playlists) */
.track-card-large {
  width: 170px;
}

/* Playlist gradient card (no artwork) */
.playlist-card-gradient {
  width: 100%;
  height: 100%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

/* Play count badge */
/* Source badge (YT / SC) */
.source-badge {
  position: absolute;
  bottom: 3px;
  left: 3px;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.3px;
  z-index: 1;
}

.source-badge.yt {
  background: #ff0000;
  color: white;
}

.source-badge.sc {
  background: #ff5500;
  color: white;
}

.source-badge.dl {
  background: var(--accent);
  color: white;
  right: 3px;
  left: auto;
  font-size: 10px;
  line-height: 1;
}

/* Offline mode: gray out non-downloaded tracks */
body.is-offline .track-artwork-wrap.not-downloaded {
  filter: grayscale(1);
  opacity: 0.45;
}
body.is-offline .track-artwork-wrap.not-downloaded::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(0,0,0,0.3);
  pointer-events: none;
}

.play-count-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ==========================================
   NOW PLAYING — Like button
   ========================================== */
.np-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.np-title-row .np-title {
  flex: 1;
  min-width: 0;
}

.np-title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.np-like-btn {
  background: none;
  border: none;
  padding: 10px;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: transform var(--duration-fast) var(--ease-spring);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.np-like-btn:active { transform: scale(0.85); }

.np-like-btn.liked-bounce {
  animation: like-bounce 0.3s var(--ease-spring);
}

/* ==========================================
   PLAYLIST DETAIL
   ========================================== */
.playlist-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 240;
  background: var(--bg-primary);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--mini-player-h) + 20px);
  transform: translate3d(100%, 0, 0);
  transition: transform var(--duration-normal) var(--ease-out);
  will-change: transform;
}

.playlist-detail-overlay.visible { transform: translate3d(0, 0, 0); }
.playlist-detail-overlay.hidden { display: none; }

.playlist-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: calc(16px + var(--safe-top));
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 2;
}
.playlist-detail-header .artist-back-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px;
  margin: -8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  transition: background var(--duration-fast);
}
.playlist-detail-header .artist-back-btn:active {
  background: var(--bg-hover);
}

.playlist-detail-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 20px 24px;
  gap: 12px;
}

.pl-detail-cover {
  width: 180px;
  height: 180px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.pl-detail-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pl-detail-title {
  font-size: 24px;
  font-weight: 800;
  background: none;
  border: none;
  color: var(--text-primary);
  text-align: center;
  width: 100%;
  outline: none;
  letter-spacing: -0.3px;
}

.pl-detail-title:not([readonly]) {
  border-bottom: 2px solid var(--accent);
  padding-bottom: 4px;
}

.pl-detail-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.pl-detail-desc {
  font-size: 13px;
  color: var(--text-secondary);
  background: none;
  border: none;
  text-align: center;
  width: 100%;
  padding: 4px 20px 0;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.4;
  overflow: hidden;
}
.pl-detail-desc::placeholder {
  color: var(--text-tertiary);
}
.pl-detail-desc[readonly] {
  pointer-events: none;
}
.pl-detail-desc[readonly]:empty,
.pl-detail-desc[readonly][data-empty="true"] {
  display: none;
}
.pl-detail-desc:not([readonly]) {
  border-bottom: 1px solid var(--divider);
  padding-bottom: 4px;
  pointer-events: auto;
  color: var(--text-primary);
}

.pl-detail-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 4px;
}

.pl-shuffle-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
}

.pl-shuffle-btn:active { transform: scale(0.9); }


/* Offline banner */
.offline-banner {
  position: fixed;
  top: var(--safe-top);
  left: 0;
  right: 0;
  background: var(--accent);
  color: white;
  text-align: center;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  animation: slide-down 0.3s var(--ease-out);
}

@keyframes slide-down {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* Welcome state for new users */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 20px;
  gap: 8px;
  gap: 12px;
}

.welcome-state h3 {
  font-size: 22px;
  font-weight: 700;
}

.welcome-state p {
  font-size: 14px;
  color: var(--text-secondary);
}

.welcome-cta {
  margin-top: 8px;
  width: auto;
  padding: 12px 32px;
}

.np-context {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  margin-top: 4px;
  opacity: 0.8;
}
.np-next-track {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes like-bounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ==========================================
   GENRE CHIPS
   ========================================== */
.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 20px;
}

.genre-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--duration-fast), transform var(--duration-fast) var(--ease-spring);
}

.genre-chip:active {
  background: var(--bg-active);
  transform: scale(0.96);
}

.genre-emoji {
  font-size: 18px;
}

/* ==========================================
   TRACK LIST (vertical list rows)
   ========================================== */
.track-list {
  padding: 4px 0;
}

/* Swipe-to-queue wrapper */
.track-swipe-wrapper {
  position: relative;
  overflow: hidden;
  touch-action: pan-y; /* we handle horizontal, browser handles vertical */
}

.track-swipe-wrapper .track-item {
  will-change: transform;
  transform: translate3d(0,0,0); /* force GPU layer */
}

.track-swipe-action {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--success);
  color: white;
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}

.track-swipe-action.triggered {
  opacity: 1;
  pointer-events: auto;
}

.track-swipe-action.confirmed {
  opacity: 1;
  background: var(--success);
}

.track-swipe-wrapper .track-item {
  position: relative;
  z-index: 1;
  background: var(--bg-primary);
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: calc(var(--mini-player-h) + var(--tab-bar-h) + var(--safe-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 0 0.5px var(--glass-border);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast), transform var(--duration-fast) var(--ease-out);
  z-index: 600;
  white-space: nowrap;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.track-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background var(--duration-fast);
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.track-item:active { background: var(--bg-hover); }
.track-item.is-playing { background: rgba(252, 60, 68, 0.06); }
.track-item.is-playing .track-title { color: var(--accent); }
.track-item.is-liked .track-title::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  background: var(--accent);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z'/%3E%3C/svg%3E") center/contain no-repeat;
  vertical-align: middle;
  flex-shrink: 0;
}

.track-artwork-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.track-artwork {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-elevated);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.track-item.is-playing .track-artwork-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.4);
}

.track-playing-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  gap: 3px;
  align-items: flex-end;
  height: 16px;
  z-index: 2;
}

.track-item.is-playing .track-playing-indicator { display: flex; }
.track-item.is-active .track-playing-indicator { display: flex; }
.track-item.is-active .track-playing-indicator span { animation: none; transform: scaleY(0.5); }
.track-item.is-playing .track-title,
.track-item.is-active .track-title { color: var(--accent); }

.track-playing-indicator span {
  display: block;
  width: 3px;
  background: var(--accent);
  border-radius: 1.5px;
  animation: eq-bar 0.8s ease-in-out infinite;
}
.track-playing-indicator span:nth-child(1) { height: 60%; animation-delay: 0s; }
.track-playing-indicator span:nth-child(2) { height: 100%; animation-delay: 0.15s; }
.track-playing-indicator span:nth-child(3) { height: 40%; animation-delay: 0.3s; }
.track-playing-indicator span:nth-child(4) { height: 80%; animation-delay: 0.45s; }

@keyframes eq-bar {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

.track-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.track-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--duration-fast);
}

.track-artist {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-duration {
  font-size: 13px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.track-more-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  padding: 8px;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
  transition: color var(--duration-fast);
}

.track-more-btn:active { color: var(--text-primary); }

/* ==========================================
   CONTEXT MENU (bottom sheet)
   ========================================== */
.context-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 500;
  animation: fade-in 0.2s ease;
}

.context-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 8px 0 calc(8px + var(--safe-bottom));
  z-index: 501;
  animation: slide-up 0.3s var(--ease-out);
  will-change: transform;
  transform: translate3d(0,0,0);
}

.context-menu-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 0.5px solid var(--divider);
}

.context-menu-artwork {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-hover);
}

.context-menu-info { flex: 1; min-width: 0; }

.context-menu-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.context-menu-artist {
  font-size: 13px;
  color: var(--text-secondary);
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  font-size: 16px;
  color: var(--text-primary);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background var(--duration-fast);
}

.context-menu-item:active { background: var(--bg-hover); }
.context-menu-item svg { color: var(--text-secondary); flex-shrink: 0; }
.track-swipe-action-left {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.track-swipe-action-left.triggered { opacity: 1; pointer-events: auto; }
.track-swipe-action-left.confirmed { opacity: 1; }
.track-swipe-action-left.swipe-action-danger { background: var(--danger); }

.context-menu-danger { color: var(--danger); }
.context-menu-danger svg { color: var(--danger); }
