:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1a202c;
  --panel-3: #202838;
  --line: #2a3345;
  --text: #edf2fb;
  --muted: #8b97ad;
  --accent: #7c9cff;
  --accent-2: #a78bfa;
  --green: #4ade80;
  --red: #fb7185;
  --yellow: #fbbf24;
  --shadow: 0 20px 60px rgba(0, 0, 0, .35);
  --radius: 18px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 8% -8%, rgba(124, 156, 255, .16), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(167, 139, 250, .12), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

a { color: var(--accent); }

code {
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .07);
  font-size: .9em;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px clamp(16px, 4vw, 42px);
  background: rgba(11, 13, 18, .82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: max-content;
}

.brand strong { display: block; font-size: 17px; letter-spacing: .2px; }
.brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .4px; text-transform: uppercase; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0d14;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: -.5px;
  box-shadow: 0 8px 24px rgba(124, 156, 255, .3);
}

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 13px;
  border-radius: 10px;
  white-space: nowrap;
  transition: .18s ease;
}

.tab:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.tab.active { color: var(--text); background: rgba(124, 156, 255, .14); border-color: rgba(124, 156, 255, .3); }

.logout-form { margin-left: auto; }

.layout { width: min(1240px, 100%); margin: 0 auto; padding: clamp(18px, 3vw, 34px); }
.tab-panel { animation: appear .22s ease; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .012)), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.4vw, 24px);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(24px, 3.2vw, 40px); line-height: 1.12; letter-spacing: -.9px; }
h2 { font-size: 19px; letter-spacing: -.3px; }

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }

.now-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 18px; align-items: stretch; }
.now-card { display: flex; gap: clamp(18px, 3vw, 34px); align-items: center; }

.cover-wrap {
  position: relative;
  flex: 0 0 auto;
  width: clamp(180px, 22vw, 280px);
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(135deg, #222a3a, #11151d);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}

.cover-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, .18);
  font-size: clamp(60px, 10vw, 110px);
  font-weight: 800;
}

.now-info { flex: 1 1 auto; min-width: 0; }
.now-info h1 { margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.artist { font-size: 15px; min-height: 22px; }

.progress-row {
  display: grid;
  grid-template-columns: 42px minmax(60px, 1fr) 42px;
  align-items: center;
  gap: 10px;
  margin: 20px 0 14px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.progress-row span:last-child { text-align: right; }

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.transport { display: flex; align-items: center; justify-content: center; gap: 8px; }
.repeat-btn.active {
  color: var(--accent);
  border-color: rgba(124, 156, 255, .65);
  background: rgba(124, 156, 255, .14);
  box-shadow: inset 0 0 0 1px rgba(124, 156, 255, .12);
}

.icon-btn, .play-btn, .ghost, .small, .primary {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 11px;
  transition: .16s ease;
}

.icon-btn { width: 38px; height: 38px; padding: 0; font-size: 15px; }
.play-btn {
  width: 50px; height: 50px; padding: 0;
  font-size: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0d14;
  border: 0;
  box-shadow: 0 8px 24px rgba(124, 156, 255, .28);
}
.icon-btn:hover, .small:hover, .ghost:hover { background: var(--panel-3); border-color: #3a4560; }
.play-btn:hover { filter: brightness(1.08); }
.primary {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0d14;
  font-weight: 700;
  border: 0;
}
.primary:hover { filter: brightness(1.08); }
.small { padding: 6px 10px; font-size: 12px; }
.small.danger, .danger { color: #fecdd3; }
.ghost { padding: 7px 12px; background: transparent; }

.volume-wrap { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-width: 0; }
.volume-icon { flex: 0 0 20px; width: 20px; text-align: center; font-size: 15px; line-height: 1; }
#volume-label { flex: 0 0 34px; width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 999px;
  background: #303a4e;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b0d12;
  box-shadow: 0 0 0 3px rgba(124, 156, 255, .2);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b0d12;
}
#seek { width: 100%; }
#volume { width: 160px; flex: 0 0 160px; height: 3px; }
#volume::-webkit-slider-thumb { width: 12px; height: 12px; }
#volume::-moz-range-thumb { width: 10px; height: 10px; }

.status-line { display: flex; align-items: center; gap: 8px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 10px currentColor; }
.dot.green { background: var(--green); color: var(--green); }
.dot.red { background: var(--red); color: var(--red); }

.lyrics-card { display: flex; flex-direction: column; min-height: 360px; }
.lyrics-tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.lyrics {
  position: relative;
  flex: 1;
  overflow: auto;
  max-height: 430px;
  padding: 6px 10px 24px 2px;
  scroll-behavior: smooth;
  mask-image: linear-gradient(to bottom, transparent 0, #000 20px, #000 calc(100% - 26px), transparent 100%);
}
.lyrics .empty { color: var(--muted); padding: 18px 4px; }
.lyric-line {
  color: #758196;
  padding: 7px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  transition: color .2s, background .2s;
  font-size: 15px;
}
.lyric-line.active { color: var(--text); background: rgba(124, 156, 255, .1); border-left-color: var(--accent); font-weight: 600; }
.lyrics .plain { white-space: pre-wrap; color: #c8d2e4; padding: 8px 10px; font-family: inherit; }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  margin-left: 5px;
  border-radius: 999px;
  background: rgba(124, 156, 255, .15);
  color: var(--accent);
  font-size: 12px;
  vertical-align: 2px;
}

.queue-card { margin-top: 18px; }
.queue-list { display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.queue-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, .02);
  border: 1px solid transparent;
  border-radius: 10px;
}
.queue-item:hover { border-color: var(--line); background: rgba(255, 255, 255, .04); }
.queue-index { color: var(--muted); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.queue-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-link { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 14px 4px; }

.search-box { display: flex; gap: 10px; }
.search-box input { flex: 1; }
.search-status { min-height: 22px; margin: 10px 2px; }

input, select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input:focus, select:focus { border-color: rgba(124, 156, 255, .65); box-shadow: 0 0 0 3px rgba(124, 156, 255, .12); }
input.compact { padding: 6px 10px; width: 180px; }

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
#search-results.grouped { display: block; }
.source-group { margin-top: 18px; }
.source-group:first-child { margin-top: 10px; }
.source-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 2px 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}
.source-group-head .badge { margin-left: 0; }
.source-group .results { margin-top: 0; }
.result-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 11px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .02);
}
.result-thumb {
  width: 64px; height: 64px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--panel-3);
}
.result-body { min-width: 0; display: flex; flex-direction: column; }
.result-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-meta { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-source {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(124, 156, 255, .13);
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .35px;
  vertical-align: 1px;
}
.result-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 7px; }

.playlist-results { display: grid; gap: 10px; margin-top: 8px; }
.playlist-result .result-title { white-space: normal; }
.playlist-head {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  margin: 18px 0 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.playlist-cover {
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 30px;
}
.playlist-cover img { width: 100%; height: 100%; object-fit: cover; }
.playlist-info { flex: 1 1 220px; min-width: 0; }
.playlist-info h3 { font-size: 20px; margin: 3px 0 5px; }
.playlist-actions { margin-left: auto; }
.playlist-tracks { max-height: 520px; }

.radio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.radio-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(160deg, rgba(124, 156, 255, .06), rgba(255, 255, 255, .015));
}
.radio-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.radio-name { font-weight: 650; font-size: 14px; }
.radio-genre { color: var(--accent); font-size: 10px; text-transform: uppercase; letter-spacing: .9px; }
.radio-now { color: var(--muted); font-size: 11px; min-height: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.radio-actions { display: flex; gap: 6px; margin-top: auto; }
.fav { background: transparent; border: 1px solid var(--line); color: var(--yellow); border-radius: 9px; width: 32px; }
.fav.active { background: rgba(251, 191, 36, .12); border-color: rgba(251, 191, 36, .4); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cache-actions { margin-left: auto; justify-content: flex-end; }
.cache-card { margin-top: 18px; }
.cache-storage { margin: 14px 0 12px; }
.cache-storage-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 12px; }
.storage-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #252d3d; }
#cache-bar { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .25s ease; }
.track-list { display: grid; gap: 4px; max-height: 620px; overflow: auto; }
.track-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
}
.track-row:hover { background: rgba(255, 255, 255, .035); border-color: var(--line); }
.track-row.cache-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.cache-row input[type="checkbox"] { width: 16px; height: 16px; padding: 0; margin: 0; accent-color: var(--accent); }
.cache-row.protected { opacity: .72; }
.track-main { min-width: 0; }
.track-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-sub { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-actions { display: flex; gap: 6px; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; width: min(360px, calc(100vw - 36px)); }
.toast {
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #1c2331;
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in .2s ease;
}
.toast.error { border-color: rgba(251, 113, 133, .45); }
.toast.success { border-color: rgba(74, 222, 128, .4); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 18px; background: rgba(5, 7, 11, .72); backdrop-filter: blur(6px); }
.modal-card {
  width: min(760px, 100%);
  max-height: min(82vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 26px);
}
.modal-text { overflow: auto; white-space: pre-wrap; font: 15px/1.75 inherit; color: #d7e0ef; margin: 0; }

.login-body { display: grid; place-items: center; padding: 20px; background: radial-gradient(700px 400px at 50% 0%, rgba(124, 156, 255, .18), transparent 65%), var(--bg); }
.login-card {
  width: min(420px, 100%);
  padding: 32px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .01)), var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.brand-login { margin-bottom: 26px; }
.login-card h1 { font-size: 26px; margin-bottom: 8px; }
.login-form { display: grid; gap: 9px; margin-top: 24px; }
.login-form label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.login-form input { padding: 12px; }
.login-form .primary { margin-top: 8px; padding: 12px; }
.form-error { color: #fecdd3; font-size: 13px; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px 16px; }
  .tabs { order: 3; width: 100%; }
  .logout-form { margin-left: auto; }
  .now-grid { grid-template-columns: 1fr; }
  .now-card { flex-direction: column; align-items: stretch; }
  .cover-wrap { width: 100%; max-width: 340px; margin: 0 auto; }
  .controls { gap: 14px; }
  .volume-wrap { width: 100%; }
  #volume { flex: 1 1 auto; width: auto; }
}

@media (max-width: 540px) {
  .layout { padding: 14px; }
  .card { padding: 14px; border-radius: 15px; }
  .search-box { flex-wrap: wrap; }
  .search-box input { flex-basis: 100%; }
  .search-box select, .search-box .primary { flex: 1; }
  .results { grid-template-columns: 1fr; }
  .lyrics-tools { width: 100%; justify-content: flex-start; }
  .card-head { flex-wrap: wrap; }
  .track-row { grid-template-columns: 1fr; }
  .track-actions { justify-content: flex-end; }
  .playlist-head { align-items: flex-start; }
  .playlist-actions { margin-left: 0; width: 100%; }
}
