/* ===== RanzStream — Claymorphism + Glassmorphism ===== */
:root {
  color-scheme: light;
  --bg: #e4e2db;
  --surface: #ecebe4;
  --text: #2a2c33;
  --muted: #6d707b;
  --accent: #7a6cf2;
  --accent-2: #f29bb8;
  --accent-ink: #fff;
  --danger: #d4566b;
  --sh-d: rgba(139, 134, 120, .45);
  --sh-l: rgba(255, 255, 255, .7);
  --in-l: rgba(255, 255, 255, .55);
  --in-d: rgba(139, 134, 120, .22);
  --glass: rgba(236, 235, 228, .9);
  --glass-line: rgba(255, 255, 255, .55);
  --track: rgba(120, 116, 105, .22);
  --r: 22px;
  --nav-h: 64px;
  --mini-h: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1d22;
  --surface: #25262c;
  --text: #e8e8ee;
  --muted: #9a9cab;
  --accent: #9b8cff;
  --accent-2: #ff9fc0;
  --accent-ink: #16141f;
  --danger: #ff7d92;
  --sh-d: rgba(0, 0, 0, .5);
  --sh-l: rgba(255, 255, 255, .045);
  --in-l: rgba(255, 255, 255, .06);
  --in-d: rgba(0, 0, 0, .35);
  --glass: rgba(37, 38, 44, .88);
  --glass-line: rgba(255, 255, 255, .09);
  --track: rgba(255, 255, 255, .12);
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  line-height: 1.4;
  transition: background-color .25s, color .25s;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vmax 40vmax at 95% -8%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    radial-gradient(50vmax 40vmax at -10% 62%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent 60%);
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
img { display: block; }
h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ----- primitives ----- */
.clay {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow:
    8px 8px 18px var(--sh-d),
    -6px -6px 14px var(--sh-l),
    inset 2px 2px 3px var(--in-l),
    inset -3px -3px 6px var(--in-d);
}
.clay-in {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: inset 5px 5px 11px var(--sh-d), inset -5px -5px 11px var(--sh-l);
}
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-line);
  box-shadow: 0 10px 30px -10px var(--sh-d);
}
.press { transition: transform .12s ease, box-shadow .12s ease; }
.press:active {
  transform: scale(.96);
  box-shadow: inset 4px 4px 9px var(--sh-d), inset -4px -4px 9px var(--sh-l);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----- layout ----- */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + var(--mini-h) + 44px + var(--safe-b));
}
body.has-mini { --mini-h: 68px; }

.topbar {
  position: sticky; top: 10px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  margin: 10px 0 18px; padding: 8px 10px 8px 12px;
  border-radius: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .2px; font-size: 1.15rem; }
.logo { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 14px; color: var(--accent); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 16px; color: var(--text); }
.icon-btn .i-sun, .icon-btn .i-moon { grid-area: 1/1; }
[data-theme="dark"] .i-sun { display: none; }
[data-theme="light"] .i-moon { display: none; }

.view { display: none; }
.view.active { display: block; animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 14px; }
.section-head h2 { font-size: 1.4rem; font-weight: 800; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px; font-size: .85rem; font-weight: 700; color: var(--text);
}

/* ----- search ----- */
.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 56px; border-radius: 20px; color: var(--muted); }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 1rem;
}
.search input::placeholder { color: var(--muted); opacity: .85; }
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within { color: var(--accent); }
.clear { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.clear .i { width: 18px; height: 18px; }

.chips { display: flex; gap: 12px; overflow-x: auto; padding: 16px 16px 20px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 9px 16px; border-radius: 999px; font-size: .85rem; font-weight: 700; color: var(--text); }

/* ----- track list ----- */
.list { display: grid; gap: 14px; padding: 4px 2px; }
@media (min-width: 640px) { .list { grid-template-columns: 1fr 1fr; } }
.track { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 10px; border-radius: 22px; }
.track-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; }
.cover { width: 56px; height: 56px; border-radius: 16px; object-fit: cover; background: var(--surface); flex: none; box-shadow: 3px 3px 8px var(--sh-d), -2px -2px 6px var(--sh-l); }
.meta { min-width: 0; display: grid; gap: 2px; }
.meta b { font-weight: 700; font-size: .93rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta small { color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track.now .meta b { color: var(--accent); }
.mini-btn { width: 38px; height: 38px; border-radius: 14px; display: grid; place-items: center; color: var(--muted); flex: none; }
.mini-btn .i { width: 19px; height: 19px; }
.mini-btn[aria-pressed="true"] { color: var(--accent-2); }
.mini-btn[aria-pressed="true"] .i { fill: currentColor; }
.mini-btn.rm:hover { color: var(--danger); }

.empty { grid-column: 1/-1; text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .orb { width: 92px; height: 92px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; color: var(--accent); }
.empty .orb .i { width: 38px; height: 38px; }
.empty b { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }
.skel { height: 78px; border-radius: 22px; background: linear-gradient(100deg, var(--surface) 30%, color-mix(in srgb, var(--surface) 70%, var(--text) 8%) 50%, var(--surface) 70%) 0 0 / 220% 100%; box-shadow: 6px 6px 14px var(--sh-d), -5px -5px 12px var(--sh-l); animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -220% 0; } }

/* ----- cards / settings ----- */
.card { padding: 18px; margin-bottom: 18px; display: grid; gap: 14px; }
.card h3 { font-size: 1rem; font-weight: 800; }
.hint { color: var(--muted); font-size: .8rem; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 5px; border-radius: 18px; }
.seg button { padding: 10px 8px; border-radius: 14px; font-weight: 700; font-size: .88rem; color: var(--muted); transition: background .2s, color .2s, box-shadow .2s; }
.seg button.on, .seg button[aria-selected="true"] {
  color: var(--accent); background: var(--surface);
  box-shadow: 4px 4px 9px var(--sh-d), -3px -3px 8px var(--sh-l);
}
#libTabs { margin-bottom: 16px; }
.btn { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 18px; font-weight: 700; width: 100%; }
.btn.danger { color: var(--danger); }
.foot { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 8px; }

/* ----- bottom nav (glass) ----- */
.nav {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + var(--safe-b));
  width: min(520px, calc(100% - 24px)); height: var(--nav-h);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px; border-radius: 28px;
}
.nav-btn { display: grid; place-items: center; align-content: center; gap: 2px; border-radius: 22px; color: var(--muted); font-size: .68rem; font-weight: 700; transition: color .2s, background .2s, box-shadow .2s; }
.nav-btn .i { width: 21px; height: 21px; }
.nav-btn.on { color: var(--accent); background: var(--surface); box-shadow: inset 3px 3px 7px var(--sh-d), inset -3px -3px 7px var(--sh-l); }

/* ----- mini player ----- */
.mini {
  position: fixed; z-index: 29; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + var(--nav-h) + 10px + var(--safe-b));
  width: min(520px, calc(100% - 24px)); height: 60px;
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 8px; border-radius: 24px; overflow: hidden;
}
.mini-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; }
.mini .cover { width: 44px; height: 44px; border-radius: 14px; }
.mini .meta b { -webkit-line-clamp: 1; font-size: .85rem; }
.mini-bar { position: absolute; left: 14px; right: 14px; bottom: 3px; height: 3px; border-radius: 3px; background: var(--track); overflow: hidden; }
.mini-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; }

/* ----- controls ----- */
.ctl { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--text); position: relative; flex: none; }
.ctl .i { width: 20px; height: 20px; }
.ctl.sm { width: 44px; height: 44px; color: var(--muted); }
.ctl.xl { width: 78px; height: 78px; color: var(--accent-ink); background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent)); }
.ctl.xl .i { width: 32px; height: 32px; }
.btn-play .i-pause, .btn-play .spin { display: none; }
body[data-status="playing"] .btn-play .i-play { display: none; }
body[data-status="playing"] .btn-play .i-pause { display: block; }
body[data-status="loading"] .btn-play .i-play, body[data-status="loading"] .btn-play .i-pause { display: none; }
body[data-status="loading"] .btn-play .spin { display: block; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
#btnFav[aria-pressed="true"] { color: var(--accent-2); }
#btnFav[aria-pressed="true"] .i { fill: currentColor; }
#btnRepeat em { display: none; position: absolute; font-style: normal; font-size: .6rem; font-weight: 800; right: 9px; bottom: 8px; }
#btnRepeat[data-mode="all"], #btnRepeat[data-mode="one"] { color: var(--accent); }
#btnRepeat[data-mode="one"] em { display: block; }

/* ----- full player sheet ----- */
.sheet {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  transform: translateY(100%); visibility: hidden;
  transition: transform .34s cubic-bezier(.2, .8, .2, 1), visibility 0s .34s;
  overflow-y: auto; overscroll-behavior: contain;
}
.sheet::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(70vmax 50vmax at 50% -10%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 62%),
    radial-gradient(50vmax 40vmax at 100% 100%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent 60%);
}
.sheet.open { transform: none; visibility: visible; transition: transform .34s cubic-bezier(.2, .8, .2, 1); }
.sheet-in {
  position: relative; max-width: 460px; margin: 0 auto; min-height: 100%;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 22px calc(28px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}
.sheet-top { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.sheet-label { font-weight: 800; font-size: .85rem; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }
.badge { padding: 7px 12px; border-radius: 999px; font-size: .72rem; font-weight: 800; color: var(--accent); }
.cover-xl { width: min(72vw, 320px, 42dvh); aspect-ratio: 1; border-radius: 36px; padding: 10px; flex: none; }
.cover-xl img { width: 100%; height: 100%; object-fit: cover; border-radius: 28px; background: var(--surface); }
.np { text-align: center; width: 100%; }
.np h2 { font-size: 1.28rem; font-weight: 800; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.np p { color: var(--muted); margin-top: 4px; font-size: .92rem; }
.seekwrap { width: 100%; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; margin-top: 8px; font-variant-numeric: tabular-nums; }
.controls { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.controls .ctl:not(.sm):not(.xl) { width: 54px; height: 54px; }
.dl { color: var(--text); }

input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 14px; border-radius: 99px; outline: 0; cursor: pointer;
  background: linear-gradient(to right, var(--accent) var(--p, 0%), var(--track) var(--p, 0%));
  box-shadow: inset 2px 2px 4px var(--sh-d), inset -2px -2px 4px var(--sh-l);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface); border: 0;
  box-shadow: 3px 3px 7px var(--sh-d), -2px -2px 6px var(--sh-l), inset 0 0 0 6px var(--accent);
}
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--surface); border: 0; box-shadow: 3px 3px 7px var(--sh-d), inset 0 0 0 6px var(--accent); }
input[type=range]::-moz-range-track { background: transparent; }

/* ----- toast ----- */
.toast {
  position: fixed; z-index: 90; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px));
  transform: translate(-50%, -140%); opacity: 0; visibility: hidden; max-width: min(92vw, 420px);
  padding: 12px 18px; border-radius: 18px; font-size: .88rem; font-weight: 700; text-align: center;
  background: var(--surface); color: var(--text);
  box-shadow: 8px 8px 18px var(--sh-d), -6px -6px 14px var(--sh-l);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), opacity .25s, visibility 0s .3s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; transition-delay: 0s; }

/* ----- driver.js (petunjuk) bertema clay ----- */
.driver-popover.clay-tour {
  background: var(--surface); color: var(--text); border-radius: 22px; padding: 18px 18px 14px;
  box-shadow: 10px 10px 24px var(--sh-d), -6px -6px 16px var(--sh-l), inset 2px 2px 3px var(--in-l);
  font-family: inherit; max-width: 320px;
}
.driver-popover.clay-tour .driver-popover-title { font-family: inherit; font-weight: 800; font-size: 1.05rem; color: var(--text); }
.driver-popover.clay-tour .driver-popover-description { color: var(--muted); font-size: .9rem; line-height: 1.5; margin-top: 6px; }
.driver-popover.clay-tour .driver-popover-progress-text { color: var(--muted); font-size: .75rem; }
.driver-popover.clay-tour .driver-popover-footer button {
  font-family: inherit; font-weight: 700; border: 0; text-shadow: none; padding: 8px 14px; border-radius: 12px;
  background: var(--surface); color: var(--text);
  box-shadow: 3px 3px 7px var(--sh-d), -2px -2px 6px var(--sh-l);
}
.driver-popover.clay-tour .driver-popover-footer .driver-popover-next-btn { background: var(--accent); color: var(--accent-ink); }
.driver-popover.clay-tour .driver-popover-close-btn { color: var(--muted); }
.driver-popover.clay-tour .driver-popover-arrow-side-left.driver-popover-arrow { border-left-color: var(--surface); }
.driver-popover.clay-tour .driver-popover-arrow-side-right.driver-popover-arrow { border-right-color: var(--surface); }
.driver-popover.clay-tour .driver-popover-arrow-side-top.driver-popover-arrow { border-top-color: var(--surface); }
.driver-popover.clay-tour .driver-popover-arrow-side-bottom.driver-popover-arrow { border-bottom-color: var(--surface); }
.driver-active .driver-overlay { pointer-events: auto; }

@media (min-width: 900px) {
  .app { padding-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
