* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  min-height: 100vh;
  background-attachment: fixed;
  transition: background 0.4s ease, color 0.4s ease;
  -webkit-font-smoothing: antialiased;
}

.app-shell { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; margin: 14px 0;
  background: color-mix(in srgb, var(--m3-surface-2) 82%, transparent);
  backdrop-filter: blur(18px);
  border: 1px solid var(--m3-outline);
  border-radius: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--m3-primary); color: var(--m3-on-primary);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--m3-primary) 45%, transparent);
}
.brand-name { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; line-height: 1; color: var(--m3-on-surface); }
.brand-sub { font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--m3-on-surface-var); margin-top: 4px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center;
  background: var(--m3-surface-3); color: var(--m3-on-surface);
  transition: transform .2s, background .2s;
}
.icon-btn:hover { transform: rotate(-12deg) scale(1.05); background: var(--m3-primary-container); color: var(--m3-on-primary-container); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--m3-outline);
  background: var(--m3-surface-1); color: var(--m3-on-surface);
  font-family: inherit; font-size: 13px; font-weight: 500;
  transition: all .18s ease;
}
.chip:hover:not(:disabled) { background: var(--m3-primary-container); color: var(--m3-on-primary-container); border-color: transparent; transform: translateY(-2px); }
.chip:disabled { opacity: .4; cursor: default; }
.chip-active { background: var(--m3-primary); color: var(--m3-on-primary); border-color: transparent; }

/* ---------- Hero ---------- */
.hero { padding: 12px 4px 8px; }
.search-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 18px; height: 62px;
  background: var(--m3-surface-2);
  border: 1px solid var(--m3-outline);
  border-radius: 999px;
  transition: box-shadow .25s, border-color .25s;
}
.search-bar:focus-within {
  border-color: var(--m3-primary);
  box-shadow: 0 8px 30px color-mix(in srgb, var(--m3-primary) 25%, transparent);
}
.search-lead { color: var(--m3-on-surface-var); flex-shrink: 0; }
.search-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 18px; font-weight: 500; color: var(--m3-on-surface);
}
.search-input::placeholder { color: var(--m3-on-surface-var); font-weight: 300; }
.search-clear {
  border: none; cursor: pointer; background: var(--m3-surface-3); color: var(--m3-on-surface);
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; transition: background .2s;
}
.search-clear:hover { background: var(--m3-tertiary); color: #fff; }

.chip-row { display: flex; gap: 8px; margin-top: 16px; overflow-x: auto; padding-bottom: 6px; -ms-overflow-style: none; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-row .chip { flex-shrink: 0; }

/* ---------- Content ---------- */
.content { padding: 18px 0 30px; min-height: 40vh; }
.section-head { font-size: 15px; font-weight: 800; color: var(--m3-on-surface-var); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }

.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

/* ---------- Track card ---------- */
.track-card {
  background: var(--m3-surface-1);
  border: 1px solid var(--m3-outline);
  border-radius: 22px;
  overflow: hidden;
  opacity: 0; transform: translateY(14px);
  animation: rise .5s cubic-bezier(.2,.8,.2,1) forwards;
  transition: transform .25s ease, box-shadow .25s ease, background .3s;
}
.track-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 38px color-mix(in srgb, var(--m3-primary) 22%, transparent);
  background: var(--m3-surface-2);
}
@keyframes rise { to { opacity: 1; transform: translateY(0); } }

.art-wrap { position: relative; aspect-ratio: 1; background: var(--m3-surface-3); overflow: hidden; }
.art-img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.track-card:hover .art-img { transform: scale(1.06); }
.art-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: var(--m3-on-surface-var); background: var(--m3-surface-3); }

.play-fab {
  position: absolute; right: 12px; bottom: 12px;
  width: 52px; height: 52px; border-radius: 18px; border: none; cursor: pointer;
  display: grid; place-items: center;
  background: var(--m3-primary); color: var(--m3-on-primary);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--m3-primary) 55%, transparent);
  transform: translateY(8px) scale(.9); opacity: 0;
  transition: all .25s cubic-bezier(.2,.8,.2,1);
}
.track-card:hover .play-fab { transform: translateY(0) scale(1); opacity: 1; }
.play-fab:hover { transform: scale(1.1) rotate(6deg); }
@media (hover: none) { .play-fab { opacity: 1; transform: none; } }

.fav-btn {
  position: absolute; left: 10px; top: 10px;
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--m3-surface) 78%, transparent);
  backdrop-filter: blur(8px);
  transition: transform .2s, background .2s;
}
.fav-btn:hover { transform: scale(1.15); }

.card-meta { padding: 13px 15px 16px; }
.track-title { font-size: 15px; font-weight: 800; color: var(--m3-on-surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-artist { font-size: 13px; font-weight: 500; color: var(--m3-secondary); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-album { font-size: 11px; font-weight: 300; color: var(--m3-on-surface-var); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Equalizer ---------- */
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; flex-shrink: 0; }
.eq-bar { width: 3px; background: var(--m3-primary); border-radius: 2px; animation: bounce 0.9s ease-in-out infinite; }
.eq-bar:nth-child(1) { height: 40%; animation-delay: 0s; }
.eq-bar:nth-child(2) { height: 90%; animation-delay: .2s; }
.eq-bar:nth-child(3) { height: 60%; animation-delay: .4s; }
.eq-bar:nth-child(4) { height: 100%; animation-delay: .1s; }
@keyframes bounce { 0%,100% { transform: scaleY(.4); } 50% { transform: scaleY(1); } }

/* ---------- Skeleton ---------- */
.skel { position: relative; overflow: hidden; }
.art-wrap.skel::after, .skel-line::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--m3-on-surface) 8%, transparent), transparent);
  animation: shimmer 1.4s infinite;
}
.skel-line { position: relative; height: 12px; border-radius: 6px; background: var(--m3-surface-3); overflow: hidden; }
@keyframes shimmer { to { transform: translateX(100%); } }
.art-wrap.skel::after { transform: translateX(-100%); animation: shimmer 1.4s infinite; }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 60px 20px; }
.empty-note { display: inline-grid; place-items: center; width: 130px; height: 130px; border-radius: 40px; background: var(--m3-surface-2); color: var(--m3-primary); margin-bottom: 22px; animation: float 3.5s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-12px) rotate(3deg); } }
.empty-text { font-size: 20px; font-weight: 500; color: var(--m3-on-surface); max-width: 420px; margin: 0 auto; }
.empty-sub { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--m3-on-surface-var); margin-top: 10px; }
.load-msg { text-align: center; margin-top: 24px; font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: var(--m3-on-surface-var); letter-spacing: .5px; }

/* ---------- Footer ---------- */
.footer { text-align: center; padding: 24px 0 30px; font-size: 12px; color: var(--m3-on-surface-var); font-family: 'IBM Plex Mono', monospace; }
.footer a { color: var(--m3-primary); text-decoration: none; font-weight: 500; }
.footer a:hover { text-decoration: underline; }

/* ---------- Hidden YouTube player ----------
   Kept on-screen at 1x1 (not display:none / off-screen) so browsers reliably
   allow full-song audio playback triggered by the user's tap. */
#yt-player-wrap {
  position: fixed; right: 0; bottom: 0;
  width: 1px; height: 1px; overflow: hidden;
  opacity: 0.01; pointer-events: none; z-index: -1;
}
#yt-player-wrap iframe { width: 100%; height: 100%; }

/* ---------- Player ---------- */
.player {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 60; width: min(760px, calc(100% - 24px));
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--m3-surface-3) 92%, transparent);
  backdrop-filter: blur(20px);
  border: 1px solid var(--m3-outline);
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  animation: slideUp .35s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideUp { from { transform: translate(-50%, 90px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.player-art { width: 52px; height: 52px; border-radius: 14px; object-fit: cover; flex-shrink: 0; }
.player-info { flex: 1; min-width: 0; }
.player-title { font-size: 14px; font-weight: 800; color: var(--m3-on-surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-artist { font-size: 12px; color: var(--m3-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 2px 0 6px; }
.player-bar { height: 4px; border-radius: 3px; background: var(--m3-surface-1); overflow: hidden; }
.player-bar-fill { height: 100%; background: var(--m3-primary); border-radius: 3px; transition: width .2s linear; }
.full-badge {
  display: inline-block; font-family: 'IBM Plex Mono', monospace;
  font-size: 9px; font-weight: 500; letter-spacing: .5px;
  padding: 1px 6px; border-radius: 6px; vertical-align: middle;
  background: var(--m3-primary); color: var(--m3-on-primary);
}
.player-btn {
  width: 50px; height: 50px; border-radius: 16px; border: none; cursor: pointer; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--m3-primary); color: var(--m3-on-primary);
  transition: transform .2s;
}
.player-btn:hover { transform: scale(1.08); }
.player-close {
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer; flex-shrink: 0;
  display: grid; place-items: center; background: transparent; color: var(--m3-on-surface-var);
  transition: background .2s, color .2s;
}
.player-close:hover { background: var(--m3-surface-1); color: var(--m3-on-surface); }

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .brand-sub { display: none; }
  .chip span:not(.eq) { }
  .search-input { font-size: 16px; }
  .player-close { display: none; }
}