:root {
  --bg: #080a10;
  --surface: rgba(17, 21, 31, .92);
  --surface-2: rgba(24, 29, 42, .84);
  --surface-soft: rgba(255, 255, 255, .045);
  --text: #f7f8fc;
  --muted: #9299ac;
  --line: rgba(255, 255, 255, .085);
  --accent: #8b5cf6;
  --accent-2: #4f7cff;
  --danger: #ef4444;
  --success: #22c55e;
  --shadow: 0 24px 70px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
html, body { width: 100%; min-height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 8%, rgba(139, 92, 246, .18), transparent 30%),
    radial-gradient(circle at 92% 12%, rgba(79, 124, 255, .14), transparent 28%),
    var(--bg);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255,255,255,.018), transparent 42%);
}
button, input { font: inherit; }
button { border: 0; color: inherit; }

.app {
  position: relative;
  width: min(1280px, calc(100% - 28px));
  height: 100dvh;
  margin: 0 auto;
  padding: 16px 0 18px;
}

.topbar {
  display: flex;
  height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding: 0 4px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  background: linear-gradient(145deg, #955cff, #3f70f8);
  box-shadow: 0 12px 30px rgba(91, 66, 220, .28);
}
.brand-mark span { font-size: 18px; font-weight: 900; }
.brand-copy { min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: .055em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.status {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.035);
  font-size: 12px;
}
.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(34,197,94,.11);
}

.layout {
  display: grid;
  height: calc(100dvh - 100px);
  min-height: 0;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 14px;
}
.card {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(24,29,42,.9), rgba(12,15,23,.94));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.player {
  position: relative;
  height: 100%;
  overflow: hidden;
  padding: 20px;
}
.player::before {
  content: "";
  position: absolute;
  inset: -100px -80px auto;
  height: 300px;
  opacity: .62;
  filter: blur(28px);
  background:
    radial-gradient(circle at 28% 42%, rgba(139,92,246,.78), transparent 34%),
    radial-gradient(circle at 72% 24%, rgba(59,130,246,.58), transparent 30%);
}
.player-content {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}
.eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: rgba(255,255,255,.66);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.cover {
  position: relative;
  display: grid;
  width: min(220px, 31vh);
  aspect-ratio: 1;
  margin: clamp(12px, 2.8vh, 22px) auto clamp(12px, 2.3vh, 18px);
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 28px;
  background:
    radial-gradient(circle at 26% 24%, rgba(255,255,255,.14), transparent 27%),
    linear-gradient(145deg, #7c3aed, #2563eb 52%, #101827);
  box-shadow: 0 24px 55px rgba(7,11,24,.55), 0 0 44px rgba(99,102,241,.17);
}
.cover::before, .cover::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
}
.cover::before { width: 72%; height: 72%; }
.cover::after {
  width: 48%;
  height: 48%;
  border-style: dashed;
  animation: rotate 14s linear infinite;
}
.cover.paused::after { animation-play-state: paused; }
@keyframes rotate { to { transform: rotate(360deg); } }
.cover-logo {
  position: relative;
  z-index: 1;
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border-radius: 24px;
  background: rgba(5,8,15,.7);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.11), 0 14px 34px rgba(0,0,0,.3);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -.05em;
}
.track-meta { min-width: 0; text-align: center; }
.track-title {
  min-height: 26px;
  margin: 0;
  overflow: hidden;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track-artist {
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.timeline { margin-top: clamp(12px, 2.2vh, 18px); }
.range {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--value, 0%), rgba(255,255,255,.12) var(--value, 0%), rgba(255,255,255,.12) 100%);
}
.range::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  border: 4px solid #fff;
  border-radius: 50%;
  appearance: none;
  background: var(--accent);
  box-shadow: 0 3px 10px rgba(0,0,0,.35);
}
.range::-moz-range-thumb {
  width: 7px;
  height: 7px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--accent);
}
.time-row {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: clamp(12px, 2vh, 18px);
}
.icon-btn, .play-btn {
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.icon-btn:hover, .play-btn:hover { transform: translateY(-2px); }
.icon-btn:active, .play-btn:active { transform: scale(.96); }
.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: #d9dce7;
  background: rgba(255,255,255,.045);
}
.icon-btn.active {
  border-color: rgba(139,92,246,.42);
  background: rgba(139,92,246,.18);
}
.play-btn {
  width: 58px;
  height: 58px;
  border-radius: 19px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 15px 34px rgba(91,77,229,.34);
}
.icon { width: 19px; height: 19px; fill: currentColor; }
.play-btn .icon { width: 25px; height: 25px; }
.volume-box {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: clamp(12px, 2vh, 17px);
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,255,255,.035);
}
.volume-value {
  min-width: 34px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.footer-note {
  margin: auto 0 0;
  padding-top: 12px;
  color: #686f82;
  font-size: 10px;
  text-align: center;
}

.playlist {
  display: flex;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
}
.playlist-header {
  flex: 0 0 auto;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.playlist-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}
.playlist-kicker { justify-content: flex-start; margin-bottom: 5px; }
.playlist h2 { margin: 0; font-size: 23px; letter-spacing: -.025em; }
.playlist-count {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.03);
  font-size: 11px;
}
.library-toolbar {
  display: grid;
  grid-template-columns: minmax(300px, .85fr) minmax(240px, 1.15fr);
  gap: 10px;
  margin-top: 14px;
}
.music-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
}
.music-tab {
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 760;
  transition: color .16s ease, background .16s ease, box-shadow .16s ease;
}
.music-tab:hover { color: var(--text); background: rgba(255,255,255,.04); }
.music-tab.active {
  color: #fff;
  background: linear-gradient(145deg, rgba(139,92,246,.94), rgba(79,124,255,.88));
  box-shadow: 0 9px 22px rgba(75,61,190,.23);
}
.search-wrap { position: relative; }
.search-wrap .icon {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  transform: translateY(-50%);
}
.search {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: rgba(255,255,255,.035);
  font-size: 12px;
  transition: border .16s ease, box-shadow .16s ease;
}
.search:focus {
  border-color: rgba(139,92,246,.52);
  box-shadow: 0 0 0 4px rgba(139,92,246,.09);
}
.track-list {
  display: flex;
  min-height: 0;
  overflow-y: auto;
  flex: 1;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.track-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 15px;
  background: transparent;
  transition: background .16s ease, border .16s ease;
}
.track-item:hover { background: rgba(255,255,255,.042); }
.track-item.active {
  border-color: rgba(139,92,246,.28);
  background: linear-gradient(90deg, rgba(139,92,246,.15), rgba(79,124,255,.045));
}
.track-open {
  display: grid;
  min-width: 0;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 8px 9px;
  border-radius: 14px;
  color: inherit;
  text-align: left;
  cursor: pointer;
  background: transparent;
}
.track-number {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255,255,255,.035);
  font-size: 11px;
  font-weight: 800;
}
.track-item.active .track-number {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
}
.track-info { min-width: 0; }
.track-name {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track-sub {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.owner-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 3px; height: 3px; flex: 0 0 auto; border-radius: 50%; background: currentColor; }
.track-duration {
  padding-left: 6px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.track-action {
  display: grid;
  width: 36px;
  height: 36px;
  margin-right: 9px;
  place-items: center;
  border: 1px solid rgba(139,92,246,.34);
  border-radius: 11px;
  color: #fff;
  background: rgba(139,92,246,.16);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  transition: transform .16s ease, background .16s ease;
}
.track-action:hover { transform: translateY(-1px); background: rgba(139,92,246,.3); }
.track-action.saved, .track-action.own {
  border-color: rgba(34,197,94,.25);
  color: #86efac;
  background: rgba(34,197,94,.09);
  cursor: default;
  font-size: 14px;
}
.track-action[disabled] { opacity: .82; }
.empty, .loading, .error {
  display: grid;
  min-height: 220px;
  flex: 1;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}
.message-box { max-width: 320px; font-size: 13px; line-height: 1.55; }
.message-box strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 16px; }
.loader {
  width: 32px;
  height: 32px;
  margin: 0 auto 13px;
  border: 3px solid rgba(255,255,255,.11);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.retry { margin-top: 13px; padding: 9px 14px; border-radius: 11px; cursor: pointer; background: rgba(139,92,246,.2); }
.library-toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 200;
  max-width: min(340px, calc(100% - 32px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(18,22,32,.97);
  box-shadow: 0 16px 44px rgba(0,0,0,.38);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  font-size: 12px;
}
.library-toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) and (min-width: 701px) {
  .layout { grid-template-columns: 300px minmax(0,1fr); }
  .player { padding: 17px; }
  .cover { width: min(190px, 28vh); }
  .library-toolbar { grid-template-columns: 1fr; }
}

@media (max-height: 700px) and (min-width: 701px) {
  .cover { width: min(165px, 25vh); margin-top: 10px; margin-bottom: 10px; }
  .cover-logo { width: 60px; height: 60px; border-radius: 19px; font-size: 22px; }
  .timeline, .controls, .volume-box { margin-top: 10px; }
  .footer-note { display: none; }
}

@media (max-width: 700px) {
  body { overflow: hidden; }
  .app {
    width: 100%;
    height: 100dvh;
    padding: max(8px, env(safe-area-inset-top)) 9px calc(94px + env(safe-area-inset-bottom));
  }
  .topbar {
    height: 46px;
    margin-bottom: 8px;
    padding: 0 3px;
  }
  .brand { gap: 9px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 12px; }
  .brand-mark span { font-size: 16px; }
  .brand h1 { font-size: 14px; }
  .brand p { display: none; }
  .status { min-height: 32px; padding: 8px 10px; }
  .status-text { display: none; }
  .layout { display: block; height: calc(100dvh - 148px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .card { border-radius: 20px; }

  .playlist { height: 100%; }
  .playlist-header { padding: 13px 13px 11px; }
  .playlist-kicker { display: none; }
  .playlist h2 { font-size: 19px; }
  .playlist-count { padding: 5px 8px; font-size: 10px; }
  .library-toolbar { grid-template-columns: 1fr; gap: 8px; margin-top: 11px; }
  .music-tabs { border-radius: 13px; }
  .music-tab { min-height: 38px; padding: 7px 8px; font-size: 11px; }
  .search { height: 42px; border-radius: 12px; }
  .search-wrap .icon { left: 13px; }
  .track-list { gap: 3px; padding: 7px; }
  .track-item { border-radius: 13px; }
  .track-open { grid-template-columns: 38px minmax(0,1fr) auto; gap: 9px; padding: 7px; }
  .track-number { width: 38px; height: 38px; border-radius: 11px; font-size: 10px; }
  .track-name { font-size: 12px; }
  .track-sub { margin-top: 2px; font-size: 10px; }
  .track-duration { font-size: 10px; }
  .track-action { width: 34px; height: 34px; margin-right: 7px; border-radius: 10px; }

  .player {
    position: fixed;
    right: 9px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 9px;
    z-index: 100;
    width: auto;
    height: 78px;
    padding: 9px 10px;
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(35,26,68,.98), rgba(15,20,34,.98));
    box-shadow: 0 16px 48px rgba(0,0,0,.55), 0 0 30px rgba(139,92,246,.16);
  }
  .player::before { display: none; }
  .player-content {
    display: grid;
    grid-template-columns: 48px minmax(0,1fr) auto;
    grid-template-rows: 38px 16px;
    column-gap: 9px;
    row-gap: 4px;
    align-items: center;
  }
  .player-eyebrow, .volume-box, .footer-note { display: none; }
  .cover {
    width: 48px;
    height: 48px;
    grid-column: 1;
    grid-row: 1 / 3;
    margin: 0;
    border-radius: 13px;
  }
  .cover::before, .cover::after { display: none; }
  .cover-logo { width: 27px; height: 27px; border-radius: 9px; font-size: 11px; }
  .track-meta {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    text-align: left;
  }
  .track-title { min-height: 0; font-size: 13px; line-height: 1.25; }
  .track-artist { margin-top: 2px; font-size: 10px; }
  .controls {
    grid-column: 3;
    grid-row: 1;
    gap: 4px;
    margin: 0;
  }
  #shuffleBtn, #repeatBtn { display: none; }
  .icon-btn { width: 31px; height: 31px; border: 0; border-radius: 10px; background: transparent; }
  .play-btn { width: 38px; height: 38px; border-radius: 12px; }
  .icon { width: 15px; height: 15px; }
  .play-btn .icon { width: 19px; height: 19px; }
  .timeline {
    grid-column: 2 / 4;
    grid-row: 2;
    margin: 0;
  }
  .timeline .range { height: 3px; }
  .timeline .range::-webkit-slider-thumb { width: 10px; height: 10px; border-width: 3px; }
  .time-row { display: none; }
  .library-toast { right: 10px; bottom: calc(96px + env(safe-area-inset-bottom)); left: 10px; max-width: none; }
}

@media (max-width: 380px) {
  .app { padding-right: 7px; padding-left: 7px; }
  .player { right: 7px; left: 7px; }
  .music-tab { font-size: 10px; }
  .track-open { grid-template-columns: 36px minmax(0,1fr) auto; gap: 7px; }
  .track-number { width: 36px; height: 36px; }
  .owner-label { display: none; }
  .controls #prevBtn { display: none; }
}
