/* =========================================================
   Tokens
========================================================= */
:root{
  --bg: #121214;
  --bg-elevated: #1c1c1f;
  --bg-elevated-2: #26262a;
  --accent: #e8b44c;
  --accent-dim: rgba(232, 180, 76, .16);
  --text: #f2f0eb;
  --text-dim: #9a9a9f;
  --border: #303035;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body{
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

button{
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

.hidden{ display: none !important; }

/* =========================================================
   Header
========================================================= */
.app-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 20px 12px;
  flex-shrink: 0;
}

.app-title{
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.icon-btn{
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--text);
}
.icon-btn:active{ background: var(--bg-elevated-2); }

/* =========================================================
   Empty state
========================================================= */
.empty-state{
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.empty-disc{
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--bg-elevated-2) 0 22%, var(--bg-elevated) 23% 100%);
  border: 1px solid var(--border);
  margin-bottom: 6px;
}

.empty-text{
  color: var(--text-dim);
  font-size: 15px;
  max-width: 260px;
  margin: 0;
}

.scan-status{
  color: var(--text-dim);
  font-size: 13px;
  min-height: 18px;
  margin: 4px 0 0;
}

.btn-primary{
  background: var(--accent);
  color: #1b1305;
  font-weight: 700;
  font-size: 16px;
  padding: 14px 28px;
  border-radius: var(--radius-pill);
  min-width: 220px;
}
.btn-primary:active{ opacity: .85; }

.btn-secondary{
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 12px;
}

/* =========================================================
   Playlist
========================================================= */
.playlist-wrap{
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 12px;
  -webkit-overflow-scrolling: touch;
}

.playlist{
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.track-row{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
}
.track-row:active{ background: var(--bg-elevated); }

.track-row.active{
  background: var(--accent-dim);
  border-left-color: var(--accent);
}

.track-num{
  width: 22px;
  flex-shrink: 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.track-row.active .track-num{ color: var(--accent); }

.eq-icon{
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
  width: 22px;
  justify-content: center;
}
.eq-icon span{
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: eq 0.9s ease-in-out infinite;
}
.eq-icon span:nth-child(1){ animation-delay: 0s; height: 6px;}
.eq-icon span:nth-child(2){ animation-delay: .2s; height: 12px;}
.eq-icon span:nth-child(3){ animation-delay: .4s; height: 8px;}
@keyframes eq{
  0%, 100%{ transform: scaleY(.4); }
  50%{ transform: scaleY(1); }
}

.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(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-duration{
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* =========================================================
   Player bar (fixed bottom — alcance con el pulgar)
========================================================= */
.player-bar{
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 14px 18px calc(14px + var(--safe-bottom));
  box-shadow: 0 -8px 24px rgba(0,0,0,.35);
}

.now-playing{
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.disc{
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background:
    radial-gradient(circle at 50% 50%, var(--bg) 0 16%, transparent 17%),
    conic-gradient(from 0deg, var(--accent), #c98f2e, var(--accent));
  border: 1px solid var(--border);
}
.disc.spinning{
  animation: spin 4s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

.track-info{ min-width: 0; }

.now-title{
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-artist{
  font-size: 13px;
  color: var(--text-dim);
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-row{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.time{
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  width: 34px;
  flex-shrink: 0;
}
.time:last-child{ text-align: right; }

.progress{
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated-2);
  outline: none;
}
.progress::-webkit-slider-thumb{
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  margin-top: -5px;
}
.progress::-moz-range-thumb{
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.progress::-moz-range-track{
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated-2);
}

.controls-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 0;
}

.ctrl-btn{
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  border-radius: var(--radius-pill);
  position: relative;
}
.ctrl-btn:active{ background: var(--bg-elevated-2); }

.ctrl-btn.is-on{ color: var(--accent); }

#btn-prev, #btn-next{ color: var(--text); }

.play-btn{
  width: 60px;
  height: 60px;
  background: var(--accent);
  color: #1b1305;
}
.play-btn:active{ opacity: .85; background: var(--accent); }

.repeat-one-dot{
  position: absolute;
  bottom: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* =========================================================
   Responsive: pantallas más anchas (tablet / escritorio)
========================================================= */
@media (min-width: 640px){
  body{ max-width: 480px; margin: 0 auto; }
}

/* Respeta preferencia de menos movimiento */
@media (prefers-reduced-motion: reduce){
  .disc.spinning{ animation: none; }
  .eq-icon span{ animation: none; }
}
