/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

@font-face {
  font-family: 'CircularSp';
  src: local('Circular Std'), local('CircularStd-Book'), local('CircularSp-Book');
  font-weight: 400;
}
@font-face {
  font-family: 'CircularSp';
  src: local('Circular Std Bold'), local('CircularStd-Bold'), local('CircularSp-Bold');
  font-weight: 700;
}

:root {
  --bg: #121212;
  --bg-surface: #121212;
  --sidebar-bg: #000000;
  --card-bg: #181818;
  --card-hover: #282828;
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-subdued: #6a6a6a;
  --accent: #1DB954;
  --accent-hover: #1ed760;
  --player-bg: #181818;
  --border: #282828;
  --scrollbar: hsla(0,0%,100%,.3);
  --font: 'CircularSp', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --sidebar-width: 280px;
  --player-height: 90px;
  --topbar-height: 64px;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 6px; border: 3px solid transparent; background-clip: padding-box; min-height: 30px; }
::-webkit-scrollbar-thumb:hover { background: hsla(0,0%,100%,.5); border: 3px solid transparent; background-clip: padding-box; }

/* ===== APP GRID ===== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: calc(100vh - var(--player-height));
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-top {
  padding: 24px 24px 8px;
}

.logo { margin-bottom: 18px; padding: 0 0 8px; }
.logo svg { display: block; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  transition: color .15s;
  cursor: pointer;
}
.nav-item:hover { color: var(--text-primary); }
.nav-item.active { color: var(--text-primary); }
.nav-item svg { flex-shrink: 0; }

/* Library section */
.sidebar-library {
  margin-top: 8px;
  background: var(--sidebar-bg);
  border-radius: 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 8px;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
}
.library-header .nav-item { padding: 4px 0; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text-primary); background: hsla(0,0%,100%,.1); }

.library-plus { opacity: .7; transition: opacity .15s; }
.library-plus:hover { opacity: 1; }

/* Pills */
.library-actions {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  flex-wrap: wrap;
}

.pill {
  background: hsla(0,0%,100%,.07);
  border: none;
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-family: var(--font);
  font-weight: 400;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.pill:hover { background: hsla(0,0%,100%,.15); }
.pill.active { background: var(--text-primary); color: #000; }

/* Library search row */
.library-search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 4px;
}

.sort-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color .15s;
}
.sort-btn:hover { color: var(--text-primary); }
.sort-btn svg { width: 16px; height: 16px; }

/* Playlist items */
.playlist-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 16px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
}
.playlist-item:hover { background: hsla(0,0%,100%,.1); }

.playlist-img {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.liked-songs-img {
  background: linear-gradient(135deg, #450af5, #c4efd9) !important;
}

.playlist-meta { min-width: 0; }
.playlist-name {
  display: block;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.playlist-desc {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  border-radius: 8px;
  margin: 8px 8px 8px 0;
}

/* Top Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  height: var(--topbar-height);
  background: transparent;
  transition: background .3s;
}
.top-bar.scrolled { background: hsla(0,0%,7%,.85); backdrop-filter: blur(10px); }

.nav-arrows { display: flex; gap: 8px; }

.circle-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: hsla(0,0%,0%,.7);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
}
.circle-btn:hover { background: hsla(0,0%,0%,.9); transform: scale(1.04); }
.circle-btn:disabled { opacity: .5; cursor: default; transform: none; }

.top-bar-right { display: flex; align-items: center; gap: 8px; }

.pill-btn {
  background: #fff;
  color: #000;
  border: none;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: transform .1s, background .15s;
}
.pill-btn:hover { transform: scale(1.04); background: #f0f0f0; }

.install-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 20px;
  transition: background .15s;
}
.install-btn:hover { background: hsla(0,0%,100%,.1); }

.notif-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  transition: color .15s;
}
.notif-btn:hover { color: var(--text-primary); }

.avatar-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  border-radius: 50%;
  transition: background .15s;
}
.avatar-btn:hover { background: hsla(0,0%,100%,.1); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #535353;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Content scroll */
.content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 32px 32px;
  scroll-behavior: smooth;
}

/* ===== GREETING ===== */
.greeting-section { margin-bottom: 24px; }

.greeting {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 20px;
  margin-top: 8px;
}

/* Shortcut grid */
.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}

.shortcut-card {
  display: flex;
  align-items: center;
  background: hsla(0,0%,100%,.07);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: background .3s;
  position: relative;
  height: 64px;
}
.shortcut-card:hover { background: hsla(0,0%,100%,.2); }
.shortcut-card:hover .shortcut-play { opacity: 1; transform: translateY(0); }

.shortcut-card img,
.shortcut-card .shortcut-liked {
  width: 64px;
  height: 64px;
  object-fit: cover;
  flex-shrink: 0;
}
.shortcut-liked {
  display: flex;
  align-items: center;
  justify-content: center;
}

.shortcut-card span {
  font-size: 14px;
  font-weight: 700;
  padding: 0 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shortcut-play {
  position: absolute;
  right: 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .3s, transform .3s;
}

/* ===== CARD SECTIONS ===== */
.card-section { margin-bottom: 32px; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.show-all {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  transition: color .15s;
}
.show-all:hover { color: var(--text-primary); text-decoration: underline; }

/* Card row */
.card-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  gap: 24px;
}

/* Media Card */
.media-card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: background .3s;
  position: relative;
}
.media-card:hover { background: var(--card-hover); }
.media-card:hover .card-play-btn { opacity: 1; transform: translateY(0); }

.card-img-wrap {
  position: relative;
  margin-bottom: 16px;
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 1;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.artist-img-wrap { border-radius: 50%; }
.artist-img-wrap img,
.artist-img-wrap .placeholder-img { border-radius: 50%; }

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.placeholder-img {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.placeholder-img.artist-img { border-radius: 50%; }

.card-play-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .3s, transform .3s, background .15s, box-shadow .15s;
  box-shadow: 0 8px 8px rgba(0,0,0,.3);
  z-index: 2;
}
.card-play-btn:hover { background: var(--accent-hover); transform: translateY(0) scale(1.04); box-shadow: 0 8px 16px rgba(0,0,0,.4); }

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

/* ===== BOTTOM PLAYER ===== */
.now-playing-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--player-height);
  background: var(--player-bg);
  border-top: 1px solid hsla(0,0%,100%,.1);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(400px, 2fr) minmax(180px, 1fr);
  align-items: center;
  padding: 0 16px;
  z-index: 200;
}

/* Player left */
.now-playing-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.now-playing-cover {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  background: var(--card-bg);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.now-playing-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.now-playing-cover img.visible { display: block; }

.now-playing-info { min-width: 0; }
.np-title {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  max-width: 200px;
}
.np-title:hover { text-decoration: underline; }
.np-artist {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  max-width: 200px;
}
.np-artist:hover { text-decoration: underline; color: var(--text-primary); }

.np-heart { color: var(--text-secondary); }
.np-heart:hover { color: var(--text-primary); }
.np-heart.liked { color: var(--accent) !important; }

/* Player center */
.now-playing-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 722px;
  width: 100%;
  margin: 0 auto;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.control-btn { color: var(--text-secondary); padding: 8px; }
.control-btn:hover { color: var(--text-primary); }
.control-btn.active { color: var(--accent); }
.control-btn.active:hover { color: var(--accent-hover); }

.play-pause-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--text-primary);
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 8px;
  transition: transform .1s, background .15s;
}
.play-pause-btn:hover { transform: scale(1.06); background: #fff; }

/* Progress bar */
.playback-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.time-stamp {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.progress-bar-wrap {
  flex: 1;
  height: 4px;
  background: hsla(0,0%,100%,.3);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  transition: height .1s;
}
.progress-bar-wrap:hover { height: 6px; }
.progress-bar-wrap:hover .progress-handle { opacity: 1; }
.progress-bar-wrap:hover .progress-bar { background: var(--accent); }

.progress-bar {
  height: 100%;
  background: var(--text-primary);
  border-radius: 2px;
  width: 0%;
  position: relative;
  transition: background .15s;
}

.progress-handle {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-primary);
  opacity: 0;
  transition: opacity .15s;
  box-shadow: 0 2px 4px rgba(0,0,0,.5);
}

/* Player right */
.now-playing-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.now-playing-right .icon-btn { color: var(--text-secondary); padding: 8px; }
.now-playing-right .icon-btn:hover { color: var(--text-primary); }

/* Volume */
.volume-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.volume-bar-wrap {
  width: 93px;
  height: 4px;
  background: hsla(0,0%,100%,.3);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}
.volume-bar-wrap:hover { height: 6px; }
.volume-bar-wrap:hover .volume-handle { opacity: 1; }
.volume-bar-wrap:hover .volume-bar { background: var(--accent); }

.volume-bar {
  height: 100%;
  background: var(--text-primary);
  border-radius: 2px;
  width: 70%;
  position: relative;
  transition: background .15s;
}

.volume-handle {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-primary);
  opacity: 0;
  transition: opacity .15s;
  box-shadow: 0 2px 4px rgba(0,0,0,.5);
}

/* ===== EQUALIZER ===== */
.equalizer {
  position: absolute;
  left: 72px;
  bottom: 76px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.equalizer.active { opacity: 1; }

.eq-bar {
  width: 3px;
  background: var(--accent);
  border-radius: 1px;
  animation: none;
}
.equalizer.active .eq-bar { animation: eq .6s ease-in-out infinite alternate; }
.eq-bar:nth-child(1) { height: 6px; animation-delay: 0s; }
.eq-bar:nth-child(2) { height: 10px; animation-delay: .15s; }
.eq-bar:nth-child(3) { height: 4px; animation-delay: .3s; }
.eq-bar:nth-child(4) { height: 8px; animation-delay: .45s; }

@keyframes eq {
  0% { height: 3px; }
  100% { height: 14px; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main-content { margin: 0; border-radius: 0; }
  .now-playing-bar { grid-template-columns: 1fr 2fr 1fr; }
  .shortcut-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .card-row { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
  .content-scroll { padding: 0 16px 32px; }
  .top-bar { padding: 16px; }
  .install-btn { display: none; }
}

@media (max-width: 600px) {
  .now-playing-bar {
    grid-template-columns: 1fr auto;
    height: 66px;
    padding: 0 8px;
  }
  .now-playing-center { display: none; }
  .now-playing-right { display: none; }
  .now-playing-cover { width: 40px; height: 40px; }
  .shortcut-grid { grid-template-columns: 1fr; }
  .card-row { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
  .greeting { font-size: 24px; }
  .section-header h2 { font-size: 20px; }
  .media-card { padding: 12px; }
}

/* Selection */
::selection { background: var(--accent); color: #000; }

/* Transition for content gradient */
.content-scroll::before {
  content: '';
  display: block;
  height: 240px;
  margin: -0px -32px 0;
  padding: 0 32px;
  background: linear-gradient(180deg, #1a1a2e 0%, var(--bg) 100%);
  pointer-events: none;
  position: sticky;
  top: 0;
  margin-bottom: -240px;
  z-index: -1;
}

/* Utility */
img[src=""], img:not([src]) { visibility: hidden; }