:root {
  --ink: #15121f;
  --panel: #231e33;
  --line: #3a3354;
  --bone: #f3eee6;
  --mute: #a39cb8;
  --accent: #a9b8ff;
  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

/* blurred cover glow behind the player */
#backdrop {
  position: fixed; inset: -60px;
  background-size: cover; background-position: center;
  filter: blur(70px) saturate(1.4);
  opacity: .45;
  transition: opacity .6s;
  z-index: 0;
}
#backdrop::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent, var(--ink) 85%); }

header, main { position: relative; z-index: 1; }
header {
  display: flex; align-items: center; gap: 12px;
  padding: max(20px, env(safe-area-inset-top)) 24px 8px;
  min-height: 72px;
}
header h1 { font-size: 1.1rem; font-weight: 600; letter-spacing: .01em; }
main { max-width: 1040px; margin: 0 auto; padding: 8px 24px 72px; }

/* icon buttons */
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.fill { fill: currentColor; stroke: none; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.08); }
.icon-btn.small { width: 40px; height: 40px; color: var(--mute); }
.icon-btn.small svg { width: 20px; height: 20px; }
.icon-btn[aria-pressed="true"] { color: var(--ink); background: var(--accent); }
#back { margin-left: -10px; }

/* album grid */
#album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 28px 22px;
  padding-top: 16px;
}
.album { text-align: left; display: flex; flex-direction: column; gap: 4px; }
.album img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px;
  background: var(--panel);
  margin-bottom: 8px;
  transition: transform .25s ease, box-shadow .25s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.album:hover img, .album:focus-visible img { transform: translateY(-4px); box-shadow: 0 18px 40px rgba(0,0,0,.5); }
.album strong { font-weight: 400; font-size: 1.2rem; }
.album span { color: var(--mute); font-size: .9rem; }
.empty { color: var(--mute); }
code { background: var(--panel); padding: 2px 6px; border-radius: 4px; }

/* player */
#player-view { display: grid; grid-template-columns: minmax(280px, 400px) 1fr; gap: 56px; padding-top: 16px; align-items: start; }
.now { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 24px; }
.cover {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  transition: transform .5s ease;
}
.is-playing .cover { transform: scale(1.02); }
.meta h2 { font-size: 1.7rem; font-weight: 800; line-height: 1.15; }
.meta p { color: var(--mute); margin-top: 4px; }

.seek { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; font-size: .8rem; color: var(--mute); font-variant-numeric: tabular-nums; }

.controls { display: flex; align-items: center; justify-content: center; gap: 10px; }
.play-btn {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--bone); color: var(--ink);
  display: grid; place-items: center;
  transition: transform .15s;
}
.play-btn:hover { transform: scale(1.06); }
.play-btn:active { transform: scale(.96); }
.play-btn svg { width: 28px; height: 28px; }
.play-btn .ico-pause { display: none; }
.play-btn.is-playing .ico-play { display: none; }
.play-btn.is-playing .ico-pause { display: block; }

.volume { display: flex; align-items: center; gap: 12px; color: var(--mute); }
.volume svg { width: 20px; height: 20px; flex: none; }
.volume input { flex: 1; }

/* sliders */
input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 18px; background: transparent; cursor: pointer; --p: 0%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--bone) var(--p), var(--line) var(--p));
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--bone); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bone); margin-top: -5px;
}
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--bone); }

/* track list */
#tracklist { list-style: none; padding: 0; }
#tracklist button {
  width: 100%; display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center;
  padding: 14px 12px; border-radius: 10px; text-align: left;
  border-bottom: 1px solid rgba(255,255,255,.06);
  transition: background .15s;
}
#tracklist button:hover { background: rgba(255,255,255,.06); }
#tracklist .n { color: var(--mute); font-variant-numeric: tabular-nums; }
#tracklist .d { color: var(--mute); font-size: .88rem; font-variant-numeric: tabular-nums; }
#tracklist .active { background: rgba(169,184,255,.12); }
#tracklist .active .t { color: var(--accent); font-weight: 600; }
#tracklist .active .n { color: var(--accent); }

@media (max-width: 760px) {
  #player-view { grid-template-columns: 1fr; gap: 32px; }
  .now { position: static; max-width: 420px; margin: 0 auto; width: 100%; }
  header, main { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* totals */
.stats, .album-stats { color: var(--mute); font-variant-numeric: tabular-nums; }
.stats, .album-stats {
  position: fixed; left: 0; right: 0;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));   /* 10px above the bottom edge */
  text-align: center; padding: 0 16px; margin: 0;
  pointer-events: none; z-index: 5;
  text-shadow: 0 0 6px var(--ink), 0 0 12px var(--ink);
}
.stats { font-size: .98rem; }
.stats:empty { display: none; }
.album-stats { font-size: .9rem; }
.side { min-width: 0; }

.album .album-meta { font-size: .85rem; opacity: .85; font-variant-numeric: tabular-nums; }

/* repeat button: a "1" appears inside the loop in repeat-one mode */
#repeat .one { opacity: 0; fill: currentColor; stroke: none; font: 800 10px var(--font); }
#repeat[data-mode="one"] .one { opacity: 1; }

/* control sizes: small side buttons ~10% smaller and set apart, prev/next a bit larger */
.icon-btn.small { width: 36px; height: 36px; }
.icon-btn.small svg { width: 18px; height: 18px; }
#prev, #next { width: 54px; height: 54px; }
#prev svg, #next svg { width: 27px; height: 27px; }
#crossfade { margin-right: 18px; }
#repeat { margin-left: 18px; }
@media (max-width: 400px) {
  #crossfade { margin-right: 6px; }
  #repeat { margin-left: 6px; }
}
