:root {
  --bg: #000000;
  --surface: #0D0D0D;
  --surface2: #1A1A1A;
  --text: #FFFFFF;
  --text2: #A0A0A0;
  --accent: #1DB954;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 56px;
  --mini-h: 64px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: none;
  overflow: hidden;
  touch-action: manipulation;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ===== SCREENS ===== */
.screen {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--mini-h) + var(--nav-h) + var(--safe-bottom) + 12px);
  display: none;
}
.screen.active { display: block; }

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(to bottom, #000 70%, transparent);
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* ===== HOME ===== */
.section {
  margin-bottom: 28px;
  padding: 0 16px;
}
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-picks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.qp-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  contain: layout style paint;
  transition: transform 0.12s;
}
.qp-card:active { transform: scale(0.96); }
.qp-card img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface2);
}
.qp-info {
  flex: 1;
  min-width: 0;
}
.qp-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qp-artist {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.carousel-item {
  flex: 0 0 140px;
  scroll-snap-align: start;
  contain: layout style paint;
}
.carousel-item img {
  width: 140px;
  height: 140px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}
.carousel-item .title {
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.carousel-item .artist {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== SEARCH ===== */
.search-box {
  margin: 0 16px 16px;
  position: relative;
}
.search-box input {
  width: 100%;
  background: var(--surface);
  border: none;
  border-radius: 12px;
  padding: 14px 16px 14px 44px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text2);
  pointer-events: none;
}
.suggestions {
  padding: 0 16px;
}
.sug-item {
  padding: 12px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #111;
}
.sug-item:active { background: var(--surface2); }
.results {
  padding: 0 16px;
}
.track-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  contain: layout style paint;
}
.track-row:active { transform: scale(0.98); }
.track-row img {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface2);
}
.track-meta {
  flex: 1;
  min-width: 0;
}
.track-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-artist {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-duration {
  font-size: 12px;
  color: var(--text2);
}

/* ===== LIBRARY ===== */
.lib-tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
  overflow-x: auto;
}
.lib-tab {
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.lib-tab.active {
  background: var(--text);
  color: #000;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid #111;
  display: flex;
  z-index: 50;
  contain: layout style paint;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text2);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s;
}
.nav-item.active { color: var(--text); }
.nav-item svg { width: 24px; height: 24px; }

/* ===== MINI PLAYER ===== */
.mini-player {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  left: 0;
  right: 0;
  height: var(--mini-h);
  background: var(--surface2);
  display: none;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
  z-index: 40;
  border-top: 1px solid #222;
  contain: layout style paint;
  will-change: transform;
}
.mini-player.show { display: flex; }
.mini-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s linear;
}
.mini-art {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: #333;
}
.mini-info {
  flex: 1;
  min-width: 0;
}
.mini-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-artist {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mini-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text);
}
.mini-btn:active { transform: scale(0.9); }

/* ===== FULL PLAYER ===== */
.full-player {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
  contain: layout style paint;
}
.full-player.open {
  transform: translateY(0);
}
.fp-gradient {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 55%;
  background: linear-gradient(to bottom, #1a1a1a, #000);
  pointer-events: none;
  z-index: 0;
}
.fp-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
  padding-top: max(16px, env(safe-area-inset-top));
}
.fp-drag {
  width: 36px;
  height: 4px;
  background: #444;
  border-radius: 2px;
  margin: 8px auto 0;
}
.fp-art-wrap {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 40px;
  min-height: 0;
}
.fp-art {
  width: min(78vw, 340px);
  aspect-ratio: 1;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  background: #222;
}
.fp-meta {
  position: relative;
  z-index: 2;
  padding: 0 28px 12px;
  text-align: center;
}
.fp-title {
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fp-artist {
  font-size: 15px;
  color: var(--text2);
  margin-top: 4px;
}
.fp-seek {
  position: relative;
  z-index: 2;
  padding: 8px 28px 4px;
}
.seek-bar {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
}
.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}
.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text2);
  margin-top: 6px;
}
.fp-controls {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 12px 0 20px;
}
.fp-btn {
  background: none;
  border: none;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}
.fp-btn.play {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #fff;
  color: #000;
}
.fp-btn:active { transform: scale(0.92); }
.fp-extra {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 32px;
  padding-bottom: 12px;
}
.fp-tabs {
  position: relative;
  z-index: 2;
  display: flex;
  border-top: 1px solid #1a1a1a;
  margin-top: auto;
}
.fp-tab {
  flex: 1;
  text-align: center;
  padding: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  border-bottom: 2px solid transparent;
}
.fp-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.fp-sheet {
  position: relative;
  z-index: 2;
  height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 20px 30px;
  display: none;
}
.fp-sheet.active { display: block; }

/* Lyrics */
.lyrics-line {
  font-size: 18px;
  line-height: 1.6;
  color: #555;
  padding: 6px 0;
  transition: color 0.2s, transform 0.2s;
}
.lyrics-line.active {
  color: #fff;
  font-weight: 600;
  transform: scale(1.02);
}

/* Queue item */
.q-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.q-item img {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  object-fit: cover;
}
.q-item.playing .q-title { color: var(--accent); }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, #111 25%, #1a1a1a 50%, #111 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--mini-h) + var(--safe-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #222;
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 13px;
  opacity: 0;
  transition: all 0.25s;
  z-index: 200;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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