:root {
  --bg: #18191f;
  --panel: #20212a;
  --panel-2: #2a2b36;
  --accent: #3e32e4;
  --accent-hover: #6e65f1;
  --text: #c4c6da;
  --active: #f39968;
  --white: #ffffff;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: 'Quicksand', 'Poppins', system-ui, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
svg { fill: currentColor; display: block; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
}

/* Tag buttons */
.tags { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 16px; }
.tag {
  height: 40px; min-width: 56px; padding: 0 18px;
  border-radius: 10px;
  background: var(--accent); color: var(--white);
  font-family: 'Varela Round', sans-serif; font-size: 15px;
  transition: transform .15s ease, background .15s ease;
}
.tag:hover { transform: scale(1.1); background: var(--accent-hover); }
.tag.active { background: var(--active); color: var(--bg); }

/* Search */
.search { position: relative; margin-bottom: 18px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); fill: #7c7f99; }
.search input {
  width: 100%; height: 42px; padding: 0 14px 0 40px;
  border-radius: 10px; border: 1px solid var(--panel-2);
  background: var(--panel); color: var(--white);
  font-family: 'Quicksand', sans-serif; font-size: 15px; outline: none;
}
.search input:focus { border-color: var(--accent); }

/* Player */
.player {
  background: var(--panel); border-radius: 16px; padding: 20px 20px 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.title {
  color: var(--white); font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 20px;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.time {
  display: flex; justify-content: space-between; margin: 14px 0 6px;
  color: var(--white); font-family: 'Poppins', sans-serif; font-size: 13px; font-variant-numeric: tabular-nums;
}

.progress {
  position: relative; height: 6px; border-radius: 3px; background: var(--panel-2);
  cursor: pointer; touch-action: none; outline: none;
}
.progress::before { content: ''; position: absolute; inset: -10px 0; } /* larger hit area */
.progress .buffered, .progress .played { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; width: 0; }
.progress .buffered { background: #474a5e; }
.progress .played { background: var(--accent); }
.progress .thumb {
  position: absolute; top: 50%; left: 0; width: 14px; height: 14px; border-radius: 50%;
  background: var(--white); transform: translate(-50%, -50%); opacity: 0; transition: opacity .15s;
}
.progress:hover .thumb, .progress:focus-visible .thumb, .progress.dragging .thumb { opacity: 1; }
.progress:hover .played, .progress.dragging .played { background: var(--accent-hover); }

.controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0 10px; }
.ctl {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; color: var(--text);
  transition: color .15s, background .15s, transform .15s;
}
.ctl svg { width: 26px; height: 26px; }
.ctl:hover { color: var(--white); transform: scale(1.1); }
.ctl.small svg { width: 22px; height: 22px; }
.ctl.tiny { width: 32px; height: 32px; }
.ctl.tiny svg { width: 20px; height: 20px; }
.ctl.on { color: var(--active); }
.ctl.play { width: 60px; height: 60px; background: var(--accent); color: var(--white); }
.ctl.play:hover { background: var(--accent-hover); }
.ctl.play svg { width: 32px; height: 32px; }
.ctl .i-pause, .ctl .i-mute { display: none; }
.playing .ctl .i-play { display: none; }
.playing .ctl .i-pause { display: block; }
.muted .ctl .i-vol { display: none; }
.muted .ctl .i-mute { display: block; }
.badge {
  position: absolute; right: 4px; bottom: 6px; font-size: 10px; font-weight: 700; line-height: 1;
  color: var(--bg); background: var(--active); border-radius: 6px; padding: 1px 3px; display: none;
}
#btn-loop[data-mode="one"] .badge { display: block; }

.volume { display: flex; align-items: center; gap: 8px; max-width: 240px; margin: 0 auto; }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 4px; border-radius: 2px; background: var(--panel-2); outline: none; accent-color: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--accent); cursor: pointer; }
input[type=range]:hover::-webkit-slider-thumb { background: var(--accent-hover); }

/* Playlist */
.list-head { margin: 22px 4px 8px; font-size: 13px; color: #7c7f99; font-family: 'Poppins', sans-serif; }
.playlist { list-style: none; margin: 0; padding: 0; }
.playlist li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px; cursor: pointer;
  font-family: 'Varela Round', sans-serif; font-size: 15px; color: var(--text);
  transition: background .12s;
}
.playlist li:hover { background: var(--panel); }
.playlist li .n { width: 28px; text-align: right; color: #6b6e88; font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.playlist li .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playlist li .g { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--panel-2); color: #9a9db6; flex: none; }
.playlist li.active { color: var(--active); background: var(--panel); }
.playlist li.active .n { color: var(--active); }
.playlist .empty { cursor: default; justify-content: center; color: #6b6e88; }
.playlist .empty:hover { background: none; }

@media (max-width: 520px) {
  .app { padding: 14px 10px 28px; }
  .tag { padding: 0 14px; font-size: 14px; }
  .player { padding: 16px 14px 12px; }
  .title { font-size: 17px; }
  .controls { gap: 8px; }
}
