:root {
  color-scheme: dark;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --bg: #0b0d12;
  --panel: #161a22;
  --border: #262c38;
  --text: #e8e8e8;
  --muted: #9aa4b2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(150px + env(safe-area-inset-bottom));
}
body.player-open {
  padding-bottom: calc(170px + env(safe-area-inset-bottom));
}

img { max-width: 100%; display: block; }

/* ---------- HEADER ---------- */
header {
  padding: 1.25rem .9rem 1rem;
  text-align: center;
  background: linear-gradient(180deg, #161a22, #0f1115);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.brand h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: .4px;
  word-break: break-word;
}
.avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  box-shadow: 0 0 18px rgba(59,130,246,.35);
  flex-shrink: 0;
}
header p { margin: .5rem 0 0; color: var(--muted); font-size: .85rem; }

/* ---------- ALBUMES ---------- */
.albums {
  max-width: 1100px;
  margin: 0 auto;
  padding: .85rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.album {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.album-head {
  display: flex;
  gap: .85rem;
  padding: .85rem;
  align-items: center;
}
.album-cover {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 10px;
  overflow: hidden;
  background: #0b0d12;
  flex-shrink: 0;
}
.album-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.cover-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.55);
  opacity: 0;
  transition: opacity .18s ease;
  cursor: zoom-in;
}
.album-cover:hover .cover-overlay,
.album-cover:focus-within .cover-overlay { opacity: 1; }
/* En táctiles sin hover, mostrar siempre un poco la lupa */
@media (hover: none) {
  .cover-overlay { opacity: .85; background: rgba(0,0,0,.35); }
  .cover-overlay .mag { font-size: 2rem; }
}
.cover-overlay .mag {
  font-size: 2.4rem;
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(59,130,246,.95));
  transform: scale(.92);
  transition: transform .18s ease;
}
.album-cover:hover .cover-overlay .mag { transform: scale(1); }
.no-cover {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; color: var(--accent);
}
.album-info { min-width: 0; flex: 1; }
.album-info h2 {
  margin: 0 0 .25rem;
  font-size: 1.05rem;
  word-break: break-word;
  line-height: 1.25;
}
.album-info .meta {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.35;
  word-break: break-word;
}

/* ---------- TRACKS ---------- */
.tracks { list-style: none; margin: 0; padding: 0 .4rem .55rem; }
.track {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: .6rem;
  padding: .6rem .5rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
}
.track:hover { background: rgba(59,130,246,.08); }
.track:active { background: rgba(59,130,246,.16); }
.track.playing { background: rgba(59,130,246,.18); }
.track .num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: .8rem;
  text-align: right;
}
.track .title {
  font-size: .9rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track .dl {
  color: var(--muted);
  text-decoration: none;
  font-size: 1.15rem;
  padding: .35rem .55rem;
  border-radius: 8px;
  line-height: 1;
  transition: background .12s, color .12s;
}
.track .dl:hover,
.track .dl:active { background: var(--accent); color: #fff; }

/* ---------- PLAYER ---------- */
.player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(22,26,34,.97);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 50;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  grid-template-areas:
    "cover info play"
    "seek seek seek"
    "vol vol vol";
  gap: .4rem .6rem;
  align-items: center;
  padding: .55rem .7rem calc(.6rem + env(safe-area-inset-bottom));
}
.player.hidden { display: none; }

#np-cover {
  grid-area: cover;
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: #0b0d12;
}
.np-info { grid-area: info; min-width: 0; }
#np-title {
  font-weight: 600;
  font-size: .92rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#np-artist {
  color: var(--muted);
  font-size: .78rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#play-pause {
  grid-area: play;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
#play-pause:hover { background: var(--accent2); }
#play-pause:active { transform: scale(.94); }

.seek-wrap {
  grid-area: seek;
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
}
.seek-wrap input[type=range] { flex: 1; min-width: 0; }
#time {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: .72rem;
  min-width: 78px;
  text-align: right;
  white-space: nowrap;
}
.vol-wrap {
  grid-area: vol;
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
  width: 100%;
}
.vol-wrap input[type=range] { flex: 1; min-width: 0; }

/* ---------- RANGES ---------- */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 22px;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    var(--accent) 0%,
    var(--accent) var(--p, 0%),
    #2a3140 var(--p, 0%),
    #2a3140 100%);
}
input[type=range]::-moz-range-track {
  height: 6px; border-radius: 999px; background: #2a3140;
}
input[type=range]::-moz-range-progress {
  height: 6px; border-radius: 999px; background: var(--accent);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  margin-top: -5px;
  box-shadow: 0 0 8px rgba(59,130,246,.6);
}
input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
}

/* ---------- MODAL ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.93);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem calc(1.25rem + env(safe-area-inset-left)) calc(1.25rem + env(safe-area-inset-bottom)) calc(1.25rem + env(safe-area-inset-right));
  z-index: 100;
}
.modal.hidden { display: none; }
#modal-img {
  max-width: 92vw;
  max-height: 76vh;
  object-fit: contain;
  border-radius: 0;
}
#modal-download {
  background: var(--accent);
  color: #fff;
  padding: .7rem 1.3rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: .95rem;
}
#modal-download:hover { background: var(--accent2); }
#modal-close {
  position: absolute;
  top: calc(.5rem + env(safe-area-inset-top));
  right: calc(.5rem + env(safe-area-inset-right));
  background: rgba(0,0,0,.35);
  color: #fff;
  border: none;
  font-size: 2.4rem;
  line-height: 1;
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
}

/* ---------- DESKTOP ---------- */
@media (min-width: 720px) {
  body { padding-bottom: 110px; }
  body.player-open { padding-bottom: 110px; }
  header { padding: 2rem 1rem 1.5rem; }
  .brand { gap: 1rem; }
  .brand h1 { font-size: 2rem; }
  .avatar { width: 64px; height: 64px; }
  header p { font-size: .95rem; }

  .albums { padding: 1.5rem; gap: 2rem; }
  .album { border-radius: 16px; }
  .album-head { gap: 1.25rem; padding: 1.25rem; }
  .album-cover { width: 140px; height: 140px; border-radius: 12px; }
  .cover-overlay .mag { font-size: 3rem; }
  .no-cover { font-size: 3rem; }
  .album-info h2 { font-size: 1.35rem; }
  .album-info .meta { font-size: .9rem; }

  .tracks { padding: 0 .5rem .5rem; }
  .track {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: .75rem;
    padding: .55rem .75rem;
  }
  .track .num { font-size: .85rem; }
  .track .title { font-size: .95rem; }

  .player {
    grid-template-columns: 56px minmax(0,1fr) auto minmax(220px,1.5fr) auto;
    grid-template-areas: "cover info play seek vol";
    gap: 1rem;
    padding: .75rem 1.25rem;
  }
  #np-cover { width: 56px; height: 56px; }
  #np-title { font-size: 1rem; }
  #np-artist { font-size: .85rem; }
  #play-pause { width: 46px; height: 46px; font-size: 1.05rem; }
  #time { font-size: .8rem; min-width: 90px; }
  .vol-wrap input[type=range] { flex: none; width: 110px; }
}
