:root {
  --ink: #100c09;
  --ink-2: #1a120c;
  --panel: #22170f;
  --panel-2: #2c1e14;
  --line: rgba(242, 216, 176, 0.12);
  --gold: #e2b15a;
  --gold-2: #f3d7a1;
  --copper: #c45c26;
  --cream: #f4ece3;
  --mute: #b8a492;
  --danger: #e07058;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
  --radius: 22px;
  --player-h: 102px;
  --font-ui: "Outfit", "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--ink); }

body {
  font-family: var(--font-ui);
  color: var(--cream);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(196, 92, 38, 0.22), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(226, 177, 90, 0.12), transparent 50%),
    var(--ink);
  min-height: 100vh;
  padding-bottom: calc(var(--player-h) + 28px);
}

.grain,
.glow {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
}

.grain {
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

.glow {
  background: radial-gradient(circle at 80% 120%, rgba(226, 177, 90, 0.08), transparent 32%);
}

.topbar, .stage, .player, .queue, .toast, .mask { position: relative; z-index: 1; }

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 18px 28px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #c45c26 0 7px, transparent 8px),
    conic-gradient(from 90deg, #3a2a1c, #e2b15a, #3a2a1c);
  box-shadow: 0 0 0 3px rgba(226, 177, 90, 0.18);
}

.brand-copy { display: flex; flex-direction: column; line-height: 1.05; }
.brand-copy strong { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; }
.brand-copy em { font-style: normal; color: var(--gold); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; }

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(34, 23, 15, 0.86);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 6px 6px 16px;
  max-width: 720px;
  width: 100%;
  justify-self: center;
}

.search svg { color: var(--gold); flex-shrink: 0; }
.search input {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--cream);
  font: inherit;
  outline: none;
  min-width: 0;
}

.search button,
.text-btn,
.pill,
.ghost {
  font: inherit;
  cursor: pointer;
}

.search button {
  border: 0;
  background: linear-gradient(180deg, #f0c97a, var(--gold));
  color: #2a1b0f;
  font-weight: 600;
  border-radius: 999px;
  padding: 10px 16px;
}

.quality-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--mute);
  font-size: 0.82rem;
}

.quality-wrap select,
.collection-actions select {
  background: var(--panel);
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}

.stage { padding: 12px 28px 40px; max-width: 1280px; margin: 0 auto; }

.hero { max-width: 720px; margin: 18px 0 28px; }
.kicker {
  color: var(--gold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
  margin: 0 0 8px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.4rem);
  font-weight: 500;
  line-height: 1.1;
  margin: 0 0 12px;
}
.lede { color: var(--mute); margin: 0; max-width: 58ch; }

.import-card {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.1fr);
  gap: 24px;
  align-items: start;
  margin: 8px 0 32px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(44, 30, 20, 0.9), rgba(26, 18, 12, 0.92));
}
.import-card h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.7rem;
  margin: 0 0 8px;
}
.import-form, .import-keys {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.import-form label, .import-keys label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--mute);
}
.import-form input, .import-form textarea, .import-keys input {
  background: var(--ink);
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}
.import-form textarea { resize: vertical; min-height: 110px; }
.import-keys summary { cursor: pointer; color: var(--gold-2); }
.import-keys a { color: var(--gold); }
.unmatched {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--mute);
}
.unmatched li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.unmatched em { font-style: normal; color: var(--gold-2); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 28px 0 14px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0;
  font-weight: 500;
}
.section-head span { color: var(--mute); font-size: 0.9rem; }

.rail, .grid {
  display: grid;
  gap: 14px;
}
.rail {
  grid-auto-flow: column;
  grid-auto-columns: 168px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}
.grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }

.card, .track {
  background: linear-gradient(180deg, rgba(44, 30, 20, 0.9), rgba(26, 18, 12, 0.92));
  border: 1px solid var(--line);
  border-radius: 18px;
}

.card {
  padding: 10px;
  cursor: pointer;
  scroll-snap-align: start;
  text-align: left;
  color: inherit;
  width: 100%;
  font: inherit;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.card:hover { transform: translateY(-3px); border-color: rgba(226, 177, 90, 0.4); }
.card img, .cover {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  background: var(--panel-2);
  display: block;
}
.card strong, .track strong { display: block; margin-top: 10px; font-size: 0.95rem; }
.card em, .track em, .muted {
  color: var(--mute);
  font-style: normal;
  font-size: 0.8rem;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 18px;
}
.tabs button, .pill {
  background: transparent;
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
}
.tabs button[aria-selected="true"], .pill.active {
  background: var(--gold);
  color: #2a1b0f;
  border-color: var(--gold);
}

.track-list { display: flex; flex-direction: column; gap: 8px; }
.track {
  display: grid;
  grid-template-columns: 52px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
}
.track img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--panel-2);
}
.track .grow { min-width: 0; }
.track strong, .track em { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn, .mini {
  background: transparent;
  border: 0;
  color: var(--cream);
  cursor: pointer;
  border-radius: 999px;
}
.mini {
  border: 1px solid var(--line);
  padding: 8px 10px;
  font: inherit;
  color: var(--gold-2);
}
.mini:hover { background: rgba(226, 177, 90, 0.12); }

.collection {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  margin-top: 8px;
}
.poster {
  position: sticky;
  top: 16px;
}
.poster img {
  width: 100%;
  border-radius: 22px;
  aspect-ratio: 1;
  object-fit: cover;
  box-shadow: var(--shadow);
}
.poster h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin: 16px 0 6px;
}
.collection-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.primary {
  background: linear-gradient(180deg, #f0c97a, var(--gold));
  color: #2a1b0f;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.player {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 12px;
  z-index: 5;
  display: grid;
  grid-template-columns: 280px 1fr 220px;
  gap: 16px;
  align-items: center;
  background: rgba(22, 15, 10, 0.88);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 12px 16px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.now { display: flex; gap: 12px; align-items: center; min-width: 0; }
.disc {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, #c45c26 0 8px, transparent 9px),
    conic-gradient(from 20deg, #2b1c12, #d7a24a, #2b1c12);
  box-shadow: 0 0 0 3px rgba(226, 177, 90, 0.2);
}
.disc img { width: 100%; height: 100%; object-fit: cover; opacity: 0.92; }
.disc.spin { animation: spin 9s linear infinite; }
.now-meta { min-width: 0; }
.now-meta strong, .now-meta span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-meta span { color: var(--mute); font-size: 0.82rem; }

.transport { display: flex; flex-direction: column; gap: 6px; }
.controls { display: flex; justify-content: center; align-items: center; gap: 8px; }
.play-btn {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  color: #2a1b0f;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; }
.icon-btn[aria-pressed="true"] { color: var(--gold); }

.seek-row, .vol { display: flex; align-items: center; gap: 8px; }
.seek-row span { font-variant-numeric: tabular-nums; font-size: 0.75rem; color: var(--mute); width: 38px; }
.extras { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.text-btn {
  color: var(--gold-2);
  background: transparent;
  border: 0;
  text-decoration: none;
  font-size: 0.85rem;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(244, 236, 227, 0.16);
  border-radius: 99px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 0;
}

.queue {
  position: fixed;
  right: 16px;
  bottom: calc(var(--player-h) + 24px);
  width: min(380px, calc(100vw - 32px));
  max-height: 52vh;
  overflow: auto;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  z-index: 6;
  box-shadow: var(--shadow);
}
.queue-head { display: flex; justify-content: space-between; align-items: center; }
.queue-head h2 { margin: 0; font-size: 1rem; }
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--cream);
  border-radius: 999px;
  padding: 6px 10px;
}
#queue-list { list-style: none; margin: 12px 0 0; padding: 0; }
#queue-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
#queue-list li.active { color: var(--gold); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--player-h) + 28px);
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--cream);
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 8;
}
.mask {
  position: fixed;
  inset: 0;
  background: rgba(8, 5, 3, 0.62);
  display: grid;
  place-items: center;
  z-index: 9;
}
.mask[hidden] {
  display: none !important;
}
.mask-card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  text-align: center;
  width: min(420px, calc(100vw - 32px));
}
.mask-card .ghost {
  margin-top: 14px;
}
.zip-kicker {
  margin: 0 0 14px;
  color: var(--gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
}
.zip-meter {
  height: 10px;
  border-radius: 999px;
  background: rgba(244, 236, 227, 0.12);
  overflow: hidden;
}
.zip-meter span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--copper), var(--gold));
  transition: width 0.25s ease;
}
.zip-stats {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 8px;
  color: var(--gold-2);
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}
#zip-status {
  margin: 0;
  color: var(--mute);
  min-height: 2.4em;
}

.empty, .error, .loading {
  padding: 28px 8px;
  color: var(--mute);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
    padding: 14px 14px 0;
  }
  .brand { grid-column: 1; }
  .quality-wrap { grid-column: 2; }
  .search { grid-column: 1 / -1; justify-self: stretch; max-width: none; }
  .stage { padding: 8px 14px 28px; }
  .collection { grid-template-columns: 1fr; }
  .import-card { grid-template-columns: 1fr; padding: 16px; }
  .poster { position: static; }
  .player {
    left: 8px;
    right: 8px;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px 12px;
  }
  .extras { justify-content: space-between; }
  .now { order: -1; }
  body { --player-h: 168px; }
}
