:root {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d2129;
  --surface-3: #262b35;
  --line: #2a2f3a;
  --text: #eceef3;
  --muted: #9097a6;
  --faint: #636a79;
  --accent: #ffad42;
  --accent-ink: #1b1200;
  --accent-soft: rgba(255, 173, 66, 0.14);
  --paused: #c98a3a;
  --chip: #20242d;
  --chip-on: #ffad42;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ------------------------------------------------------------ layout */
.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px 8px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.brand-text { min-width: 0; }
.brand h1 {
  margin: 0; font-size: 18px; font-weight: 700; letter-spacing: 0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mark { flex: none; }
.brand p { margin: 1px 0 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mark { display: flex; align-items: flex-end; gap: 3px; height: 26px; width: 26px; padding: 3px; border-radius: 7px; background: var(--accent-soft); }
.mark span { flex: 1; background: var(--accent); border-radius: 2px; height: 40%; transition: height .2s; }
.mark span:nth-child(2) { height: 75%; }
.mark span:nth-child(3) { height: 55%; }
.mark span:nth-child(4) { height: 90%; }
.is-playing .mark span { animation: eq 0.9s ease-in-out infinite alternate; }
.is-playing .mark span:nth-child(2) { animation-delay: -.3s; }
.is-playing .mark span:nth-child(3) { animation-delay: -.6s; }
.is-playing .mark span:nth-child(4) { animation-delay: -.15s; }
@keyframes eq { from { height: 20%; } to { height: 100%; } }

.cta {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 650; text-decoration: none; white-space: nowrap;
  transition: filter .15s, transform .15s;
}
.cta:hover { filter: brightness(1.08); }
.cta { border: 0; cursor: pointer; font: inherit; font-weight: 650; }
.cta .chev { width: 16px; height: 16px; margin-left: -2px; }
.store { position: relative; flex: none; }
.store-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 260px; padding: 6px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.store-menu-title { padding: 6px 10px 8px; font-size: 11.5px; color: var(--muted); }
.store-menu a {
  display: flex; flex-direction: column; gap: 1px; padding: 9px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none;
}
.store-menu a:hover, .store-menu a:focus-visible { background: var(--surface-3); }
.store-menu a strong { font-weight: 600; }
.store-menu a span { font-size: 12px; color: var(--muted); }
.cta-short { display: none; }
.cta:active { transform: translateY(1px); }

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.search {
  flex: 1 1 260px; display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid transparent;
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 18px; height: 18px; color: var(--faint); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; }
.search input::-webkit-search-cancel-button { filter: invert(.6); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn.ghost { background: none; }
.btn.icon { width: 36px; padding: 0; border-color: transparent; background: none; color: var(--muted); }
.btn.icon:hover { color: var(--text); background: var(--surface-2); }
.btn.icon.big { width: 44px; height: 44px; border-radius: 50%; background: var(--text); color: var(--bg); }
.btn.icon.big:hover { background: #fff; transform: scale(1.04); }
.btn.icon.big svg { width: 22px; height: 22px; }
.btn.toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn.icon.toggle[aria-pressed="true"] { border-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius); background: var(--surface-2); }
.seg button {
  height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: none;
  color: var(--muted); cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }

.sort { display: inline-flex; align-items: center; gap: 6px; }
.sort select {
  height: 36px; padding: 0 30px 0 10px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.sort select option { background: var(--surface-2); }

.main { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 0; }

/* ------------------------------------------------------------ filters */
.filters {
  overflow-y: auto; padding: 14px 16px 24px 20px;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}
.facet + .facet { margin-top: 18px; }
.facet h2 {
  margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: 1.1px;
  text-transform: uppercase; color: var(--faint);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid transparent; background: var(--chip); color: var(--text);
  font-size: 12.5px; cursor: pointer; transition: background .12s, opacity .12s;
}
.chip:hover { background: var(--surface-3); }
.chip .n { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--chip-on); color: var(--accent-ink); font-weight: 600; }
.chip[aria-pressed="true"] .n { color: rgba(27, 18, 0, .65); }
.chip:disabled { opacity: .35; cursor: default; }
.chip:disabled:hover { background: var(--chip); }
.clear { margin-top: 20px; width: 100%; }

/* ------------------------------------------------------------ list */
.results { overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.results-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  min-height: 44px; padding: 10px 20px; background: var(--bg);
  box-shadow: 0 6px 10px -6px rgba(0, 0, 0, .6);
  font-size: 12.5px;
}
.active-filters { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.active-filters button {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 6px 0 10px;
  border-radius: 999px; border: 0; background: var(--accent-soft); color: var(--accent);
  font-size: 12px; cursor: pointer;
}
.active-filters svg { width: 14px; height: 14px; }
.active-filters .sim-pill { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.active-filters .opt { background: var(--surface-2); color: var(--muted); padding: 0 10px; }
.active-filters .opt[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.sort select:disabled { opacity: .5; cursor: default; }

.list { padding: 0 12px 16px; }
.row {
  position: relative;
  display: grid; align-items: center; gap: 12px;
  grid-template-columns: 36px minmax(0, 1fr) minmax(0, auto) 48px 44px 32px 32px 32px;
  min-height: 52px; padding: 6px 8px; border-radius: var(--radius);
  content-visibility: auto; contain-intrinsic-size: auto 52px;
}
.row:hover { background: var(--surface); }
.row .play {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text);
  transition: background .12s, color .12s;
}
.row .play svg { width: 16px; height: 16px; }
.row:hover .play { background: var(--text); color: var(--bg); }
.row .meta { min-width: 0; }
.row .name { display: flex; align-items: center; gap: 6px; font-weight: 550; }
.row .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .loop-badge {
  flex: none; display: inline-flex; align-items: center; gap: 2px; height: 18px; padding: 0 6px 0 4px;
  border-radius: 5px; background: var(--surface-3); color: var(--muted);
  font-size: 10.5px; font-weight: 600; letter-spacing: .3px;
}
.row .loop-badge svg { width: 13px; height: 13px; }
.row .tags { display: flex; gap: 4px; justify-content: flex-end; overflow: hidden; }
.tag {
  flex: none; height: 22px; padding: 0 8px; border-radius: 6px; border: 0; cursor: pointer;
  background: var(--chip); color: var(--muted); font-size: 11.5px; white-space: nowrap;
}
.tag:hover { color: var(--text); background: var(--surface-3); }
.tag.cat { color: var(--text); }
.tag.mood { background: none; border: 1px solid var(--line); }
.row .dur { text-align: right; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.row .fav {
  width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  display: grid; place-items: center; color: var(--faint);
}
.row .fav svg { width: 18px; height: 18px; }
.row .fav:hover { color: var(--text); }
.row .fav.on { color: var(--accent); }
.row .rprog { display: none; }
.row .simbtn {
  width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  display: grid; place-items: center; color: var(--faint);
}
.row .simbtn svg { width: 18px; height: 18px; }
.row .simbtn:hover { color: var(--accent); background: var(--surface-2); }
.row .buybtn {
  justify-self: center; height: 24px; padding: 0 8px; border-radius: 12px; line-height: 24px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 650;
  text-decoration: none; font-variant-numeric: tabular-nums;
}
.row .buybtn:hover { background: var(--accent); color: var(--accent-ink); }
.np-buy {
  flex: none; height: 22px; padding: 0 9px; border-radius: 6px; line-height: 22px;
  background: var(--accent); color: var(--accent-ink); font-size: 11.5px; font-weight: 650; text-decoration: none;
}
.np-buy:hover { filter: brightness(1.08); }
.row .dlbtn {
  width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  display: grid; place-items: center; color: var(--faint);
}
.row .dlbtn svg { width: 18px; height: 18px; }
.row .dlbtn:hover { color: var(--accent); background: var(--surface-2); }
.dlbtn.busy, #downloadBtn.busy { opacity: .4; cursor: progress; animation: pulse .8s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .9; } }
.row .match {
  flex: none; height: 18px; padding: 0 7px; border-radius: 5px; line-height: 18px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 650; font-style: normal; font-variant-numeric: tabular-nums;
}
.row.ref { box-shadow: inset 3px 0 0 var(--accent); }
.row.ref .match { background: var(--accent); color: var(--accent-ink); }
.row.version .match { background: var(--surface-3); color: var(--text); }

.row.current { background: var(--accent-soft); }
.row.current .play { background: var(--accent); color: var(--accent-ink); }
.row.current .name { color: var(--accent); }
.row.current.paused .play { background: var(--paused); }
.row.current .rprog {
  display: block; position: absolute; left: 60px; right: 12px; bottom: 3px; height: 2px;
  border-radius: 2px; background: rgba(255, 173, 66, .2); overflow: hidden;
}
.row.current .rprog i { display: block; height: 100%; width: 0; background: var(--accent); }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------ player */
.player {
  display: grid; align-items: center; gap: 20px;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 1.5fr) minmax(0, 1fr);
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--surface);
}
.np { min-width: 0; }
.np-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.np-similar {
  flex: none; display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px 0 6px;
  border: 0; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; cursor: pointer;
}
.np-similar svg { width: 14px; height: 14px; }
.np-similar:hover { color: var(--accent); background: var(--surface-3); }
.np-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-sub { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player[data-state="playing"] .np-name { color: var(--accent); }

.transport { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.buttons { display: flex; align-items: center; gap: 12px; }
.timeline { display: flex; align-items: center; gap: 10px; width: 100%; }
.time { width: 34px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.time:first-child { text-align: right; }
.bar {
  position: relative; flex: 1; height: 16px; cursor: pointer; touch-action: none;
}
.bar::before {
  content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 4px; border-radius: 4px;
  background: var(--surface-3);
}
.bar-fill { position: absolute; left: 0; top: 6px; height: 4px; width: 0; border-radius: 4px; background: var(--text); }
.bar:hover .bar-fill, .player[data-state="playing"] .bar-fill { background: var(--accent); }
.bar-knob {
  position: absolute; top: 3px; left: 0; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%;
  background: var(--text); opacity: 0; transition: opacity .12s;
}
.bar:hover .bar-knob { opacity: 1; }

.modes { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.vol { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; color: var(--muted); }
.vol input { width: 96px; accent-color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  padding: 10px 16px; border-radius: var(--radius); background: var(--surface-3);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .4); z-index: 50; font-size: 13px;
}

.only-mobile { display: none; }
.badge-count {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
#openFilters { position: relative; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .row .tags .tag.mood { display: none; }
}
@media (max-width: 900px) {
  .row { grid-template-columns: 36px minmax(0, 1fr) 44px 40px 32px 32px 32px; }
  .row .tags { display: none; }
  .player { grid-template-columns: minmax(0, 1fr) minmax(240px, 1.6fr) auto; gap: 14px; }
  .vol { display: none; }
}
@media (max-width: 760px) {
  .top { padding: 10px 16px 6px; }
  .brand h1 { font-size: 16px; }
  .cta { padding: 8px 12px; font-size: 13px; }
  .cta-long { display: none; }
  .cta-short { display: inline; }
  .toolbar { padding: 4px 16px 10px; }
  .search { flex-basis: calc(100% - 52px); order: 0; }
  .seg, #favOnly, .sort { order: 1; }
  .hide-sm { display: none; }
  .only-mobile { display: inline-flex; }
  .main { grid-template-columns: minmax(0, 1fr); }
  .filters {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(320px, 86vw);
    background: var(--surface); border-right: 1px solid var(--line);
    transform: translateX(-100%); transition: transform .2s ease;
    padding-top: 10px;
  }
  .filters.open { transform: none; }
  .filters-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .5); display: block; }
  .results-head { padding: 8px 16px; }
  .list { padding: 0 6px 12px; }
  .player {
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "np buttons" "time time";
    gap: 6px 12px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  }
  .np { grid-area: np; }
  .transport { display: contents; }
  .buttons { grid-area: buttons; gap: 4px; }
  .timeline { grid-area: time; }
  .modes { display: none; }
  .btn.icon.big { width: 40px; height: 40px; }
}
@media (max-width: 420px) {
  .brand p { display: none; }
  .seg button { padding: 0 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .is-playing .mark span { animation: none; }
  .filters { transition: none; }
}
.np-line .np-name { min-width: 0; }
