:root {
  --bg: #0b0714;
  --surface: #150e24;
  --surface-2: #20163a;
  --line: #2c2050;
  --neon: #b44cff;
  --neon-2: #7a3cff;
  --glow: 0 0 18px rgba(180, 76, 255, 0.55);
  --text: #f3ecff;
  --muted: #9a8bb5;
  --danger: #ff5d8f;
  --nav-h: 64px;
  --mini-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --radius: 16px;
  --font: "Sora", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.fill { fill: currentColor; stroke: none; }

/* ---------- Views ---------- */
.view {
  display: none;
  padding: calc(var(--safe-t) + 12px) 16px calc(var(--nav-h) + var(--mini-h) + var(--safe-b) + 24px);
  min-height: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.view.active { display: block; }

.top { padding: 8px 0 14px; }
.logo { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.logo span { color: var(--neon); text-shadow: var(--glow); margin-left: 6px; }
.page-title { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }

.sec-title { margin: 22px 0 12px; font-size: 17px; font-weight: 600; }
.sec-head { display: flex; align-items: center; justify-content: space-between; }
.link-btn { color: var(--neon); font-size: 14px; padding: 6px 4px; }
.link-btn.danger { color: var(--danger); }

/* ---------- Featured carousel ---------- */
.carousel {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  margin: 0 -16px;
  padding: 4px 16px 16px;
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }

.card {
  flex: 0 0 78%;
  scroll-snap-align: center;
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 22px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 12px 30px rgba(122, 60, 255, 0.28);
  text-align: left;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:active { transform: scale(0.97); }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 35%, rgba(11, 7, 20, 0.92));
}
.card .cap { position: absolute; left: 14px; right: 14px; bottom: 12px; z-index: 1; }
.card .cap .t { font-weight: 700; font-size: 17px; }
.card .cap .a { color: #d9c8ff; font-size: 13px; margin-top: 2px; }
.card .play-dot {
  position: absolute; right: 12px; bottom: 12px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--neon); color: #fff; box-shadow: var(--glow);
}
.card .play-dot svg { width: 18px; height: 18px; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 14px;
}
.chip:active { border-color: var(--neon); }

/* ---------- Track rows ---------- */
.list { display: flex; flex-direction: column; gap: 4px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px; border-radius: 14px;
  cursor: pointer;
}
.row:active { background: var(--surface); }
.row .thumb { width: 54px; height: 54px; border-radius: 12px; object-fit: cover; background: var(--surface-2); flex: none; }
.meta { min-width: 0; flex: 1; }
.meta .t, .meta .a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .t { font-weight: 600; font-size: 15px; }
.meta .a { color: var(--muted); font-size: 13px; margin-top: 2px; }
.row.current .t { color: var(--neon); text-shadow: 0 0 10px rgba(180, 76, 255, 0.6); }

.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); flex: none; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn.lg { width: 56px; height: 56px; color: var(--text); }
.fav.on { color: var(--neon); }
.fav.on svg { fill: var(--neon); filter: drop-shadow(0 0 6px rgba(180, 76, 255, 0.8)); }

.empty { color: var(--muted); text-align: center; padding: 40px 20px; line-height: 1.5; }
.skeleton { height: 54px; margin: 8px; border-radius: 12px; background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Search ---------- */
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 16px; height: 48px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box:focus-within { border-color: var(--neon); box-shadow: var(--glow); }
.search-box svg { width: 20px; height: 20px; color: var(--muted); }
.search-box input { flex: 1; background: none; border: 0; outline: 0; min-width: 0; }
#search-results { margin-top: 14px; }

/* ---------- Library ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab { padding: 8px 16px; border-radius: 999px; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.tab.active { color: #fff; background: var(--neon-2); border-color: var(--neon); box-shadow: var(--glow); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.pl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pl-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 14px; text-align: left; min-height: 96px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.pl-card:active { border-color: var(--neon); }
.pl-card .t { font-weight: 600; }
.pl-card .a { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pl-card.new { align-items: center; justify-content: center; color: var(--neon); border-style: dashed; }
.detail-head { display: flex; align-items: center; gap: 4px; }
.detail-head .sec-title { flex: 1; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; justify-content: space-around;
  background: rgba(21, 14, 36, 0.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; }
.nav-btn.active { color: var(--neon); }
.nav-btn.active svg { filter: drop-shadow(0 0 6px rgba(180, 76, 255, 0.8)); }

/* ---------- Mini bar ---------- */
.mini {
  position: fixed; left: 10px; right: 10px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 8px); z-index: 19;
  height: var(--mini-h);
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  max-width: 540px; margin: 0 auto;
}
.mini img { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; }
.mini .icon-btn { color: #fff; background: var(--neon-2); box-shadow: var(--glow); }

/* ---------- Player sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 40;
  background: var(--bg);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow-x: hidden; overflow-y: auto; visibility: hidden;
}
.sheet.open { transform: translateY(0); visibility: visible; }
.player-bg {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  filter: blur(50px) saturate(1.4); opacity: 0.35; pointer-events: none;
}
.player-inner {
  position: relative; max-width: 560px; margin: 0 auto;
  padding: calc(var(--safe-t) + 8px) 20px calc(var(--safe-b) + 24px);
  min-height: 100%; display: flex; flex-direction: column; gap: 20px;
}
.player-top { display: flex; align-items: center; justify-content: space-between; }
.player-top .now { color: var(--muted); font-size: 13px; }

/* The video MUST stay visible (YouTube policy): never hide or cover it while playing. */
.video-frame {
  width: 100%; aspect-ratio: 16 / 9; min-height: 202px;
  border-radius: 22px; overflow: hidden; background: #000;
  box-shadow: 0 0 0 1px var(--neon), 0 0 40px rgba(180, 76, 255, 0.45);
}
.video-frame iframe { width: 100%; height: 100%; display: block; border: 0; }

.track-info { display: flex; align-items: center; gap: 8px; }
.titles { flex: 1; min-width: 0; }
.p-title { font-size: 20px; font-weight: 700; line-height: 1.25; }
.p-artist { color: var(--muted); margin-top: 4px; }

.progress { display: flex; flex-direction: column; gap: 6px; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px;
  background: transparent; outline: 0; margin: 0;
  --pct: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--neon) var(--pct), var(--surface-2) var(--pct));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--surface-2); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--neon); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; margin-top: -6px; box-shadow: var(--glow);
}
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; box-shadow: var(--glow); }

.controls { display: flex; align-items: center; justify-content: center; gap: 22px; }
.play {
  width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--neon), var(--neon-2)); color: #fff;
  box-shadow: var(--glow), 0 10px 30px rgba(122, 60, 255, 0.5);
  transition: transform 0.15s ease;
}
.play:active { transform: scale(0.92); }
.play svg { width: 32px; height: 32px; }

.volume { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.volume svg { width: 20px; height: 20px; flex: none; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(5, 2, 12, 0.7); display: flex; align-items: flex-end; justify-content: center; }
.modal-card {
  width: 100%; max-width: 560px; background: var(--surface); border-top: 1px solid var(--neon);
  border-radius: 24px 24px 0 0; padding: 20px 16px calc(var(--safe-b) + 16px);
  animation: rise 0.25s ease;
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.modal-card h3 { margin: 0 0 12px; }
.modal-card input[type="text"] {
  width: 100%; height: 48px; border-radius: 12px; padding: 0 14px;
  background: var(--bg); border: 1px solid var(--line); outline: 0; margin-bottom: 12px;
}
.modal-card input[type="text"]:focus { border-color: var(--neon); }
.btn-primary { width: 100%; height: 48px; border-radius: 12px; background: var(--neon-2); color: #fff; font-weight: 600; box-shadow: var(--glow); margin-bottom: 6px; }
.pick { display: flex; width: 100%; justify-content: space-between; padding: 14px 8px; border-bottom: 1px solid var(--line); text-align: left; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--mini-h) + var(--safe-b) + 24px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 80;
  background: var(--surface-2); border: 1px solid var(--neon); padding: 10px 16px;
  border-radius: 999px; font-size: 14px; transition: all 0.25s ease; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Search messages ---------- */
.empty .link-btn { display: block; margin: 12px auto 0; }

/* Native clear (x) button in the search field: match the theme */
.search-box input::-webkit-search-cancel-button { filter: grayscale(1) brightness(2); }
