:root {
  --bg: #08080a;
  --bg-soft: #101014;
  --panel: #15151a;
  --panel-hover: #1d1d23;
  --line: #26262d;
  --text: #f4f4f6;
  --muted: #9a9aa5;
  --accent: #ff3b52;
  --accent-soft: rgba(255, 59, 82, 0.14);
  --radius: 14px;
  --player-h: 88px;
  --sidebar-w: 232px;
  --queue-w: 320px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
  overscroll-behavior: none;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg { width: 20px; height: 20px; fill: currentColor; display: block; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) 0;
  height: calc(100% - var(--player-h));
  height: calc(100dvh - var(--player-h));
  min-height: 0; overflow: hidden;
  transition: grid-template-columns 180ms ease;
}

.app.queue-open { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--queue-w); }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 18px rgba(255, 59, 82, 0.35);
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-text { font-size: 19px; font-weight: 800; letter-spacing: -0.5px; }
.brand-text span { color: var(--accent); }

.nav, .sidebar-section { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600; text-align: left;
  width: 100%; transition: background 140ms ease, color 140ms ease;
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; }
.nav-item:hover { background: var(--panel-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.small { font-size: 13px; padding: 9px 12px; }
.section-label {
  color: #6f6f7a; font-size: 11px; font-weight: 700;
  letter-spacing: 0.9px; text-transform: uppercase;
  padding: 0 12px 6px;
}
.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; gap: 8px;
  color: #6f6f7a; font-size: 11px; padding: 0 12px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: #555560; }
.dot.on { background: #35d07f; box-shadow: 0 0 0 3px rgba(53, 208, 127, 0.14); }
.dot.off { background: #ff6b6b; }

/* ---------- Main ---------- */
.main { min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  height: 72px; flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px; border-bottom: 1px solid var(--line);
  background: rgba(8, 8, 10, 0.92); backdrop-filter: blur(10px);
  z-index: 4;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; color: var(--muted);
  flex: 0 0 auto; transition: background 140ms, color 140ms;
}
.icon-btn:hover { background: var(--panel-hover); color: var(--text); }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }
.menu-btn { display: none; }
.install-btn { color: var(--accent); background: var(--accent-soft); }

.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 14px;
  height: 42px; width: min(560px, 100%);
  transition: border-color 140ms;
}
.search-box:focus-within { border-color: #4b4b56; }
.search-box svg { color: var(--muted); width: 18px; height: 18px; flex: 0 0 auto; }
.search-box input {
  background: none; border: 0; outline: 0; flex: 1; min-width: 0;
  font-size: 14px;
}
.search-box input::placeholder { color: #6f6f7a; }
.clear-search { color: var(--muted); font-size: 22px; line-height: 1; padding: 0 2px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.provider-pill {
  font-size: 11px; color: #8d8d98; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 10px; white-space: nowrap;
  max-width: 190px; overflow: hidden; text-overflow: ellipsis;
}

.content-scroll {
  flex: 1; min-height: 0; overflow-y: auto; padding: 26px 28px 40px;
  scrollbar-color: #33333c transparent;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.view { max-width: 1240px; margin: 0 auto; }

.hero {
  border-radius: 20px; padding: 30px 34px; margin-bottom: 26px;
  background: radial-gradient(circle at 15% 20%, rgba(255, 59, 82, 0.26), transparent 45%),
              radial-gradient(circle at 85% 80%, rgba(111, 66, 193, 0.26), transparent 45%),
              #121217;
  border: 1px solid var(--line);
}
.hero h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -1px; }
.hero p { margin: 0; color: var(--muted); line-height: 1.55; }
.hero-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.badge {
  font-size: 12px; color: #d8d8de; background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 999px; padding: 7px 11px;
}

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin: 26px 0 14px;
}
.section-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.4px; }
.section-head small { color: var(--muted); font-size: 12px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 20px; }
.chip {
  padding: 8px 15px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.chip:hover { color: var(--text); border-color: #43434e; }
.chip.active { background: var(--text); color: #0b0b0d; border-color: var(--text); }

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}
.card {
  background: var(--panel); border: 1px solid transparent;
  border-radius: var(--radius); padding: 12px;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
  min-width: 0;
}
.card:hover { background: var(--panel-hover); transform: translateY(-2px); border-color: var(--line); }
.card-cover { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #22222a; }
.card-cover.round { border-radius: 50%; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.play-overlay {
  position: absolute; right: 9px; bottom: 9px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  opacity: 0; transform: translateY(6px); transition: opacity 140ms, transform 140ms;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}
.play-overlay svg { width: 18px; height: 18px; }
.card:hover .play-overlay, .card:focus-within .play-overlay { opacity: 1; transform: translateY(0); }
.card-title {
  margin-top: 11px; font-weight: 650; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-sub { color: var(--muted); font-size: 12px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.mini-btn { color: var(--muted); font-size: 11px; padding: 4px 7px; border-radius: 7px; background: rgba(255,255,255,0.05); }
.mini-btn:hover { color: var(--text); background: rgba(255,255,255,0.1); }
.mini-btn.liked { color: var(--accent); }

.list { display: flex; flex-direction: column; gap: 6px; }
.list-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto auto;
  align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 10px; transition: background 140ms;
}
.list-row:hover { background: var(--panel-hover); }
.list-row img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.list-row .row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .row-sub { color: var(--muted); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .row-duration { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.list-row.playing .row-title { color: var(--accent); }

.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; color: var(--muted);
}
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 8px; }
.error-box {
  border: 1px solid rgba(255, 59, 82, 0.4); background: rgba(255, 59, 82, 0.08);
  border-radius: var(--radius); padding: 16px 18px; color: #ffb9c1; line-height: 1.5;
}
.error-box small { display: block; color: var(--muted); margin-top: 8px; word-break: break-word; }
.more-wrap { display: flex; justify-content: center; margin-top: 26px; }
.more-btn {
  padding: 10px 20px; border-radius: 999px; font-weight: 650;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
}
.more-btn:hover { background: var(--panel-hover); }

/* ---------- Queue ---------- */
.queue-panel {
  background: var(--bg-soft); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}
.queue-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 12px; }
.queue-head h2 { margin: 0; font-size: 16px; }
.queue-body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 20px;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.queue-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.queue-item:hover { background: var(--panel-hover); }
.queue-item.current { background: var(--accent-soft); }
.queue-item img { width: 40px; height: 40px; border-radius: 7px; object-fit: cover; }
.queue-item .qi-meta { min-width: 0; flex: 1; }
.queue-item .qi-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item .qi-artist { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-remove { color: #6f6f7a; font-size: 18px; padding: 0 4px; }

/* ---------- Player ---------- */
.player {
  height: var(--player-h);
  display: grid; grid-template-columns: minmax(220px, 1fr) minmax(320px, 1.4fr) minmax(180px, 1fr);
  align-items: center; gap: 20px;
  padding: 0 22px;
  background: #101014; border-top: 1px solid var(--line);
  position: relative; z-index: 6;
}
.now-playing { display: flex; align-items: center; gap: 12px; min-width: 0; }
.now-playing img { width: 56px; height: 56px; border-radius: 9px; object-fit: cover; background: #22222a; }
.np-meta { min-width: 0; }
.np-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { color: var(--muted); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.like-btn.liked { color: var(--accent); background: var(--accent-soft); }

.player-center { display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 0; }
.controls { display: flex; align-items: center; gap: 6px; }
.play-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--text); color: #0b0b0d;
  display: grid; place-items: center; margin: 0 6px;
}
.play-btn:hover { transform: scale(1.05); }
.play-btn svg { width: 18px; height: 18px; }
.progress-row { display: flex; align-items: center; gap: 10px; width: 100%; }
.progress-row span { color: #7f7f8a; font-size: 11px; font-variant-numeric: tabular-nums; width: 38px; text-align: center; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 4px; border-radius: 999px;
  background: #35353e; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--text); opacity: 0; transition: opacity 140ms;
}
input[type="range"]:hover::-webkit-slider-thumb { opacity: 1; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--text); }
#seek { flex: 1; }
.player-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.volume-icon { color: var(--muted); width: 18px; height: 18px; }
#volume { width: 90px; }

.scrim { display: none; position: fixed; inset: 0 0 var(--player-h) 0; background: rgba(0,0,0,0.55); z-index: 4; }

/* ---------- Video modal ---------- */
.video-modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; }
.video-modal[hidden] { display: none; }
.video-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.78); backdrop-filter: blur(4px); }
.video-dialog {
  position: relative; width: min(960px, 100%); background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
.video-head, .video-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.video-head { border-bottom: 1px solid var(--line); }
.video-head strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.video-foot a { color: var(--accent); text-decoration: none; font-weight: 600; }
.video-foot a:hover { text-decoration: underline; }
.video-frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.video-frame video { width: 100%; height: 100%; display: block; background: #000; }
.video-toggle {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
  background: transparent; color: #fff; font-size: 48px; cursor: pointer;
  display: grid; place-items: center; opacity: 0; transition: opacity .15s;
}
.video-frame:hover .video-toggle, .video-toggle:focus-visible { opacity: .85; }
.video-status {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  padding: 6px 12px; border-radius: 999px; background: rgba(0,0,0,.7);
  color: #fff; font-size: 12px; pointer-events: none; max-width: 90%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.video-status[hidden] { display: none; }
.video-actions { display: flex; align-items: center; gap: 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--player-h) + 18px); transform: translate(-50%, 12px);
  background: #26262e; border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity 180ms, transform 180ms; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .app { grid-template-columns: 72px minmax(0, 1fr) 0; }
  .app.queue-open { grid-template-columns: 72px minmax(0, 1fr) var(--queue-w); }
  .sidebar { padding: 20px 10px; align-items: center; }
  .brand-text, .nav-item span, .section-label, .sidebar-foot span:not(.dot) { display: none; }
  .nav-item { width: 48px; justify-content: center; padding: 12px 0; }
  .provider-pill { display: none; }
}

@media (max-width: 860px) {
  /* Sidebar dan antrean jadi fixed, jadi hanya .main yang masuk grid.
     Tanpa grid-column ini .main ketempat di kolom 0px -> halaman kosong di HP. */
  .app, .app.queue-open { grid-template-columns: minmax(0, 1fr); }
  .main { grid-column: 1; }
  .menu-btn { display: grid; }
  .scrim.show { display: block; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: var(--player-h);
    width: min(270px, 85vw); z-index: 9;
    padding: 20px 14px 16px; align-items: stretch;
    transform: translateX(-100%); visibility: hidden; pointer-events: none;
    transition: transform 200ms ease, visibility 0s linear 200ms;
    box-shadow: 12px 0 30px rgba(0, 0, 0, 0.35);
  }
  .sidebar.mobile-open {
    transform: translateX(0); visibility: visible; pointer-events: auto;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    transition-delay: 0s;
  }
  .sidebar.mobile-open .brand-text,
  .sidebar.mobile-open .nav-item span,
  .sidebar.mobile-open .section-label,
  .sidebar.mobile-open .sidebar-foot span:not(.dot) { display: initial; }
  .sidebar.mobile-open .nav-item { width: 100%; justify-content: flex-start; padding: 11px 12px; }
  .sidebar.mobile-open .nav-item.small { padding: 9px 12px; }

  .queue-panel {
    position: fixed; right: 0; top: env(safe-area-inset-top, 0px);
    bottom: calc(var(--player-h) + env(safe-area-inset-bottom, 0px));
    width: min(360px, 88vw); max-width: 88vw; z-index: 8;
    transform: translateX(100%); visibility: hidden; pointer-events: none;
    transition: transform 200ms ease, visibility 0s linear 200ms;
    box-shadow: -12px 0 30px rgba(0, 0, 0, 0.35);
  }
  .app.queue-open .queue-panel {
    transform: translateX(0); visibility: visible; pointer-events: auto;
    transition-delay: 0s;
  }
  .queue-head { padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
  .queue-head .icon-btn { width: 44px; height: 44px; font-size: 26px; }
}

@media (max-width: 640px) {
  :root { --player-h: 76px; }
  .topbar { padding: 0 14px; gap: 8px; height: 62px; }
  .content-scroll { padding: 18px 14px 30px; }
  .hero { padding: 22px 20px; border-radius: 16px; }
  .hero h1 { font-size: 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .player { grid-template-columns: minmax(0, 1fr) auto; padding: 0 12px; gap: 8px; }
  .player-center { align-items: flex-end; }
  .controls #shuffleBtn, .controls #repeatBtn, .player-right, .progress-row { display: none; }
  .now-playing img { width: 46px; height: 46px; }
  .np-artist { display: none; }
  .video-modal { padding: 12px; align-items: start; overflow-y: auto; }
  .video-dialog { border-radius: 12px; }
  .video-head .icon-btn { width: 44px; height: 44px; font-size: 26px; }
  .video-foot { flex-wrap: wrap; }
  .video-actions { width: 100%; justify-content: flex-end; }
  .play-overlay { opacity: 1; transform: none; }
  .mini-btn { padding: 8px 10px; font-size: 12px; }
  .icon-btn { width: 44px; height: 44px; }
  .play-btn { width: 44px; height: 44px; }
}

/* Perangkat sentuh: tombol lebih mudah diketuk */
@media (hover: none) {
  .play-overlay { opacity: 1; transform: none; }
  .mini-btn { padding: 8px 10px; font-size: 12px; }
  .icon-btn { width: 44px; height: 44px; }
  .play-btn { width: 44px; height: 44px; }
  .queue-remove { padding: 10px; }
}
