/* MySongs — colourful cassette / sticker / vinyl stage */
:root {
  --magenta: #FF3CAC;
  --violet: #7C5CFF;
  --lime: #C6F91F;
  --yellow: #FFE14D;
  --sky: #3DE0FF;
  --coral: #FF6B4A;
  --ink: #16121C;
  --paper: #FFF7EA;
  --stage: #1A1426;
  --stage-2: #261C36;
  --muted: #8B829A;
  --card: #FFFDF7;
  --shadow: 0 12px 0 rgba(22, 18, 28, 0.18);
  --radius: 22px;
  --player-h: 92px;
  --top: 72px;
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Outfit", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 60, 172, 0.22), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(124, 92, 255, 0.28), transparent 50%),
    radial-gradient(700px 400px at 80% 100%, rgba(61, 224, 255, 0.18), transparent 50%),
    var(--paper);
  min-height: 100dvh;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

.blobs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.b { position: absolute; border-radius: 50%; filter: blur(40px); opacity: 0.45; }
.b1 { width: 280px; height: 280px; background: var(--lime); top: 80px; left: -80px; animation: drift 18s ease-in-out infinite; }
.b2 { width: 220px; height: 220px; background: var(--yellow); right: -40px; top: 30%; animation: drift 22s ease-in-out infinite reverse; }
.b3 { width: 260px; height: 260px; background: var(--coral); bottom: 80px; left: 30%; animation: drift 26s ease-in-out infinite; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -20px) scale(1.08); }
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 18px calc(12px + env(safe-area-inset-top));
  padding-top: calc(12px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 3px solid var(--ink);
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; }
.brand-cassette { display: grid; place-items: center; transform: rotate(-8deg); filter: drop-shadow(3px 3px 0 var(--ink)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.brand-text em { font-style: normal; font-size: 0.72rem; color: var(--violet); font-weight: 600; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0 14px;
  min-width: 0;
  box-shadow: 4px 4px 0 var(--ink);
}
.search input {
  flex: 1; border: 0; outline: 0; background: transparent;
  padding: 10px 0; font-size: 0.95rem; min-width: 0;
}
.search-ico::before { content: "⌕"; font-size: 1.1rem; color: var(--violet); }

.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 999px;
  border: 2px solid transparent;
}
.nav a:hover, .nav a.active {
  background: var(--ink);
  color: var(--lime);
  border-color: var(--ink);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  background: #fff;
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn-fat { font-family: var(--font-display); padding: 10px 16px; }
.btn-lime { background: var(--lime); }
.btn-magenta { background: var(--magenta); color: #fff; }
.btn-violet { background: var(--violet); color: #fff; }
.btn-sky { background: var(--sky); }
.btn-coral { background: var(--coral); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; box-shadow: 2px 2px 0 var(--ink); }

.icon-btn {
  width: 40px; height: 40px; border: 0; background: transparent; color: inherit;
  border-radius: 50%; display: grid; place-items: center;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: rgba(255,255,255,0.08); }
.icon-btn.on { color: var(--lime); }

.view {
  position: relative; z-index: 1;
  padding: 22px 18px calc(var(--player-h) + 28px + env(safe-area-inset-bottom));
  max-width: 1180px; margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 28px;
  padding: 22px;
  border: 3px solid var(--ink);
  box-shadow: 8px 8px 0 var(--magenta);
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "SIDE A";
  position: absolute; right: 18px; top: 16px;
  font-family: var(--font-display);
  background: var(--yellow); color: var(--ink);
  padding: 4px 10px; border-radius: 8px;
  transform: rotate(8deg);
  font-size: 0.75rem;
  border: 2px solid var(--ink);
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin: 0 0 6px;
  letter-spacing: -0.03em;
}
.hero p { margin: 0; color: #cfc6dd; max-width: 46ch; }
.sticker-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.sticker {
  font-family: var(--font-display);
  font-size: 0.78rem;
  padding: 5px 10px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--sky);
  color: var(--ink);
  transform: rotate(-2deg);
  box-shadow: 2px 2px 0 var(--ink);
}
.sticker:nth-child(2) { background: var(--lime); transform: rotate(3deg); }
.sticker:nth-child(3) { background: var(--coral); color: #fff; transform: rotate(-1deg); }
.sticker:nth-child(4) { background: var(--yellow); transform: rotate(4deg); }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 8px 0 12px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0;
}
.section-head a, .section-head button.linkish {
  background: none; border: 0; color: var(--violet); font-weight: 700; padding: 0;
}

.hscroll {
  display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 16px;
  scroll-snap-type: x proximity;
}
.hscroll > * { scroll-snap-align: start; flex: 0 0 auto; }

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

.song-card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 5px 5px 0 rgba(22,18,28,0.15);
  transition: transform 0.15s ease;
  display: flex; flex-direction: column;
  position: relative;
}
.song-card:hover { transform: translateY(-4px) rotate(-0.4deg); }
.cover {
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--violet), var(--magenta));
  position: relative;
  overflow: hidden;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover .play-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(22,18,28,0.28);
  opacity: 0; transition: opacity 0.15s;
  border: 0; color: #fff; width: 100%;
}
.song-card:hover .play-overlay { opacity: 1; }
.play-overlay .blob {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--lime); color: var(--ink);
  display: grid; place-items: center;
  border: 3px solid var(--ink);
}
.card-body { padding: 10px 12px 12px; }
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.98rem;
  margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-sub { margin: 2px 0 8px; font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--yellow);
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.heart {
  border: 0; background: transparent; font-size: 1.1rem; padding: 2px;
  color: var(--muted);
}
.heart.on { color: var(--magenta); transform: scale(1.1); }

.art-fallback {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-size: 2.4rem;
  background:
    repeating-linear-gradient(-45deg, rgba(255,255,255,.12) 0 8px, transparent 8px 16px),
    linear-gradient(135deg, var(--violet), var(--magenta));
  color: #fff;
}
.art-fallback.cassette { font-family: var(--font-display); }

.pl-card {
  width: 180px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 5px 5px 0 var(--violet);
}
.pl-card .mosaic {
  display: grid; grid-template-columns: 1fr 1fr; aspect-ratio: 1;
  background: var(--stage);
}
.pl-card .mosaic img, .pl-card .mosaic span { width: 100%; height: 100%; object-fit: cover; }
.pl-card .body { padding: 10px 12px 14px; }
.pl-card h3 { margin: 0; font-family: var(--font-display); font-size: 1rem; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 16px;
}
.toolbar select {
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  font-weight: 600;
}

.genre-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.genre-chips button, .genre-chips a {
  font-family: var(--font-display);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  background: #fff;
  font-weight: 600;
  box-shadow: 3px 3px 0 var(--ink);
}
.genre-chips .on { color: var(--ink); }

.empty {
  text-align: center;
  padding: 48px 16px;
  border: 3px dashed var(--ink);
  border-radius: 24px;
  background: rgba(255,255,255,0.55);
}
.empty h3 { font-family: var(--font-display); margin: 0 0 8px; }

.track-row {
  display: grid;
  grid-template-columns: 28px 48px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  cursor: pointer;
}
.track-row:hover { background: rgba(124, 92, 255, 0.1); }
.track-row.playing { background: color-mix(in srgb, var(--lime) 35%, transparent); }
.track-row img, .track-row .mini-art {
  width: 48px; height: 48px; border-radius: 10px; object-fit: cover;
  border: 2px solid var(--ink);
}
.mini-art { display: grid; place-items: center; background: var(--violet); color: #fff; font-weight: 700; }
.track-row .t { font-weight: 700; }
.track-row .a { font-size: 0.8rem; color: var(--muted); }
.drag-handle { cursor: grab; color: var(--muted); font-weight: 900; }

/* PLAYER */
.player {
  position: fixed; left: 12px; right: 12px; bottom: 10px;
  z-index: 60;
  background: linear-gradient(180deg, var(--stage-2), var(--stage));
  color: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 28px;
  padding: 10px 14px 12px;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  grid-template-areas:
    "art meta extra"
    "art seek extra"
    "art controls extra";
  gap: 6px 12px;
  box-shadow: 0 16px 40px rgba(22,18,28,0.4), 0 0 0 3px var(--magenta);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 1180px;
  margin: 0 auto;
}
.player[hidden] { display: none !important; }
.player-grab {
  display: none;
  grid-area: grab;
  height: 18px; border: 0; background: transparent;
}
.player-grab::before {
  content: ""; display: block; width: 48px; height: 5px; margin: 6px auto;
  background: #4a4158; border-radius: 99px;
}
.player-art-wrap {
  grid-area: art;
  width: 64px; height: 64px;
  position: relative;
  align-self: center;
}
.player-art-wrap img, .player-art-wrap .art-fallback {
  width: 64px; height: 64px; border-radius: 14px;
  object-fit: cover; border: 2px solid #fff;
  position: relative; z-index: 1;
}
.player-art-wrap img[hidden], #player-art-fallback[hidden] { display: none; }
.vinyl {
  position: absolute; right: -10px; top: 8px;
  width: 48px; height: 48px; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #ffe14d 0 6px, #16121c 7px 10px, #2a2238 11px 24px);
  z-index: 0;
  animation: spin 4s linear infinite paused;
}
.player.playing .vinyl { animation-play-state: running; }
@keyframes spin { to { transform: rotate(360deg); } }

.player-meta { grid-area: meta; min-width: 0; align-self: end; }
.player-title {
  font-family: var(--font-display);
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-artist { font-size: 0.8rem; color: #b7adc8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.player-controls {
  grid-area: controls;
  display: flex; align-items: center; gap: 4px;
}
.btn-play {
  width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid var(--lime);
  background: var(--lime); color: var(--ink);
  display: grid; place-items: center;
  box-shadow: 0 4px 0 #8fb30a;
}
.btn-play svg { width: 22px; height: 22px; }
.player-seek {
  grid-area: seek;
  display: flex; align-items: center; gap: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem; color: #b7adc8;
}
.player-seek input, .vol input {
  -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 99px;
  background: #3a314c;
  flex: 1; outline: none;
}
.player-seek input::-webkit-slider-thumb, .vol input::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: var(--magenta);
  border: 2px solid #fff;
}
.player-extra {
  grid-area: extra;
  display: flex; align-items: center; gap: 4px;
  justify-content: flex-end;
}
.vol { display: flex; align-items: center; gap: 4px; width: 110px; }
.eq {
  display: none;
  position: absolute; left: 92px; top: 8px;
  gap: 3px; height: 14px; align-items: flex-end;
}
.player.playing .eq { display: flex; }
.eq i {
  width: 4px; background: var(--lime); border-radius: 2px;
  animation: bounce-eq 0.9s ease-in-out infinite;
  transform-origin: bottom;
}
.eq i:nth-child(2) { animation-delay: 0.1s; }
.eq i:nth-child(3) { animation-delay: 0.22s; }
.eq i:nth-child(4) { animation-delay: 0.08s; }
.eq i:nth-child(5) { animation-delay: 0.18s; }
@keyframes bounce-eq {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}
#btn-like.on { color: var(--magenta); }
#btn-repeat.on { color: var(--sky); }
.repeat-one {
  position: absolute; font-size: 0.6rem; font-weight: 800; color: var(--sky);
}

.queue-panel {
  position: fixed; top: 80px; right: 12px; bottom: calc(var(--player-h) + 24px);
  width: min(360px, calc(100vw - 24px));
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 20px;
  z-index: 55;
  box-shadow: 8px 8px 0 var(--sky);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.queue-panel[hidden] { display: none !important; }
.queue-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-bottom: 3px solid var(--ink);
  background: var(--yellow);
}
.queue-head h2 { margin: 0; font-family: var(--font-display); font-size: 1.1rem; }
.queue-list { list-style: none; margin: 0; padding: 8px; overflow: auto; flex: 1; }
.queue-list li {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; align-items: center;
  padding: 6px; border-radius: 10px;
}
.queue-list li.current { background: color-mix(in srgb, var(--lime) 40%, #fff); }
.queue-list img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }

.modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(22,18,28,0.55);
  display: grid; place-items: center;
  padding: 16px;
}
.modal[hidden] { display: none !important; }
.modal-card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 24px;
  max-width: 560px; width: 100%;
  max-height: min(90dvh, 820px);
  overflow: auto;
  padding: 20px;
  box-shadow: 10px 10px 0 var(--violet);
  position: relative;
}
.modal-card h2 { font-family: var(--font-display); margin: 0 0 12px; }
.form-grid { display: grid; gap: 10px; }
label span { display: block; font-size: 0.78rem; font-weight: 700; margin-bottom: 4px; }
input[type="text"], input[type="number"], input[type="url"], textarea, select.field {
  width: 100%;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
  font-size: 1rem;
}
textarea { min-height: 80px; resize: vertical; }
.drop {
  border: 3px dashed var(--ink);
  border-radius: 18px;
  padding: 18px;
  text-align: center;
  background: #fff;
  cursor: pointer;
}
.drop.over { background: color-mix(in srgb, var(--lime) 40%, #fff); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--player-h) + 28px);
  transform: translateX(-50%);
  background: var(--ink); color: var(--lime);
  font-family: var(--font-display);
  padding: 10px 16px; border-radius: 999px;
  z-index: 90; border: 2px solid var(--lime);
}
.toast[hidden] { display: none !important; }

.menu {
  position: absolute; right: 8px; top: 8px; z-index: 3;
}
.menu summary { list-style: none; cursor: pointer; background: rgba(255,255,255,0.85); border-radius: 99px; width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid var(--ink); font-weight: 900; }
.menu summary::-webkit-details-marker { display: none; }
.menu div {
  position: absolute; right: 0; top: 32px;
  background: #fff; border: 2px solid var(--ink); border-radius: 12px;
  min-width: 140px; box-shadow: 4px 4px 0 var(--ink);
  overflow: hidden;
}
.menu button { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: 8px 12px; }
.menu button:hover { background: var(--yellow); }

.kbd { font-size: 0.75rem; color: var(--muted); }

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand upload"
      "search search"
      "nav nav";
  }
  .brand { grid-area: brand; }
  .search { grid-area: search; }
  .nav { grid-area: nav; overflow-x: auto; flex-wrap: nowrap; }
  .nav a { white-space: nowrap; }
  #btn-upload { grid-area: upload; }
  .hero { grid-template-columns: 1fr; }
  .hero svg { display: none; }
  .vol { display: none; }
  .player {
    left: 8px; right: 8px; bottom: 8px;
    grid-template-columns: 52px 1fr auto;
    grid-template-areas:
      "grab grab grab"
      "art meta extra"
      "seek seek seek"
      "controls controls controls";
    border-radius: 22px;
    padding-top: 0;
  }
  .player-grab { display: block; }
  .player-art-wrap, .player-art-wrap img, .player-art-wrap .art-fallback { width: 52px; height: 52px; }
  .player-controls { justify-content: center; }
  .player.expanded {
    top: 12%;
    grid-template-areas:
      "grab grab grab"
      "art art art"
      "meta meta meta"
      "seek seek seek"
      "controls controls controls"
      "extra extra extra";
    justify-items: center;
    text-align: center;
  }
  .player.expanded .player-art-wrap,
  .player.expanded .player-art-wrap img,
  .player.expanded .player-art-wrap .art-fallback {
    width: 220px; height: 220px; border-radius: 24px;
  }
  .player.expanded .vinyl { width: 160px; height: 160px; right: -30px; top: 30px; }
  .player.expanded .player-meta { justify-self: stretch; }
  .queue-panel { top: auto; bottom: 0; left: 0; right: 0; width: auto; height: 50dvh; border-radius: 24px 24px 0 0; }
}

@media (min-width: 901px) {
  .player {
    grid-template-columns: 72px minmax(140px, 1fr) auto minmax(220px, 1.4fr) auto;
    grid-template-areas: "art meta controls seek extra";
    align-items: center;
  }
  .eq { display: none; }
  .player.playing .eq { display: flex; }
}
