/* Nghe — giao diện tối kiểu YouTube Music */
:root {
  --bg: #030303;
  --raised: #1d1d1d;
  --raised2: #2a2a2a;
  --line: rgba(255, 255, 255, .1);
  --text: #fff;
  --muted: rgba(255, 255, 255, .7);
  --dim: rgba(255, 255, 255, .45);
  --top-h: 56px;
  --nav-h: 56px;
  --mini-h: 64px;
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; display: block; flex: none; }
img { display: block; }
.ib { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.ib:active { background: rgba(255, 255, 255, .12); }
.ic { display: inline-flex; }
.ic svg { width: 20px; height: 20px; }

/* ---------- đăng nhập ---------- */
#login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
#loginForm { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
#loginForm h1 { margin: 4px 0 12px; font-size: 28px; }
.logo { width: 72px; height: 72px; border-radius: 16px; margin: 0 auto; }
#code { height: 48px; border-radius: 24px; border: 0; outline: none; padding: 0 18px; font-size: 18px; text-align: center; letter-spacing: .06em; background: var(--raised); }
#loginForm button { height: 48px; border-radius: 24px; background: #fff; color: #000; font-weight: 600; }
.err { color: #ff8a8a; min-height: 1.3em; margin: 0; }

/* ---------- thanh trên ---------- */
#top { position: fixed; top: 0; left: 0; right: 0; z-index: 20; padding-top: var(--sat); transition: background-color .2s; }
#top.solid, body[data-mode=search] #top { background: rgba(3, 3, 3, .9); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.topbar { height: var(--top-h); display: flex; align-items: center; gap: 4px; padding: 0 8px; max-width: 1200px; margin: 0 auto; }
#brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 21px; letter-spacing: -.02em; margin: 0 auto 0 8px; }
#brand img { width: 28px; height: 28px; border-radius: 7px; }
#topTitle { flex: 1; min-width: 0; padding: 0 8px; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .2s; }
#top.solid #topTitle { opacity: 1; }
.avatar { width: 32px; height: 32px; margin: 0 8px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 15px; background: linear-gradient(135deg, #ff4d6d, #7a3cff); flex: none; }
.avatar.big { width: 48px; height: 48px; margin: 0; font-size: 20px; }
#searchForm { flex: 1; min-width: 0; height: 40px; display: flex; align-items: center; background: var(--raised2); border-radius: 20px; padding: 0 2px 0 16px; }
#q { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; font-size: 16px; -webkit-appearance: none; appearance: none; }
#q::-webkit-search-cancel-button { display: none; }
#qClear { width: 36px; height: 36px; }
body[data-mode=root] #backBtn,
body:not([data-mode=root]) #brand,
body:not([data-mode=detail]) #topTitle,
body:not([data-mode=search]) #searchForm,
body[data-mode=search] #searchBtn,
body:not([data-mode=root]) #avatar { display: none; }

/* ---------- khung trang ---------- */
main { max-width: 1200px; margin: 0 auto; min-height: 100vh; padding: calc(var(--sat) + var(--top-h)) 0 calc(var(--nav-h) + var(--sab) + 24px); }
body.has-mini main { padding-bottom: calc(var(--nav-h) + var(--mini-h) + var(--sab) + 24px); }
body[data-mode=detail] main { padding-top: 0; }
.ptitle { margin: 4px 16px 12px; font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.spin { width: 32px; height: 32px; margin: 30vh auto; border: 3px solid rgba(255, 255, 255, .2); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spin.sm { margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--muted); text-align: center; padding: 48px 24px; font-size: 15px; }
.empty .pill { margin-top: 16px; }

/* ---------- chip, nút viên thuốc ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px 20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 8px; background: rgba(255, 255, 255, .1); font-size: 14px; font-weight: 500; white-space: nowrap; }
.chip.on { background: #fff; color: #000; }
.pill { height: 36px; padding: 0 16px; border-radius: 18px; border: 1px solid rgba(255, 255, 255, .25); display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 500; white-space: nowrap; flex: none; }
.pill.white { background: #fff; color: #000; border-color: #fff; }
.pill:active { opacity: .7; }

/* ---------- kệ ---------- */
.shelf { margin: 4px 0 36px; }
.sh-head { display: flex; align-items: flex-end; gap: 12px; padding: 0 16px; margin-bottom: 14px; }
.sh-titles { flex: 1; min-width: 0; }
.sh-strap { color: var(--muted); font-size: 14px; }
.shelf h2 { margin: 2px 0 0; font-size: 23px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.sh-head .pill { height: 32px; padding: 0 12px; }
.hscroll { display: flex; gap: 14px; overflow-x: auto; padding: 0 16px; scroll-snap-type: x mandatory; scroll-padding: 0 16px; scrollbar-width: none; overscroll-behavior-x: contain; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll.cols { gap: 0; padding: 0; scroll-padding: 0; }
.col { flex: none; width: min(88vw, 420px); scroll-snap-align: start; }

/* thẻ vuông */
.card { flex: none; width: 150px; scroll-snap-align: start; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.card .cover { position: relative; width: 150px; height: 150px; border-radius: 6px; overflow: hidden; background: var(--raised2); }
.card .cover img, .thumb img, .tc-img img { width: 100%; height: 100%; object-fit: cover; }
.card.k-artist { text-align: center; }
.card.k-artist .cover { border-radius: 50%; }
.card.k-video { width: 264px; }
.card.k-video .cover { width: 264px; height: 148px; }
.card .t { margin-top: 8px; font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.card .s { margin-top: 2px; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.cplay { position: absolute; right: 8px; bottom: 8px; width: 34px; height: 34px; border-radius: 50%; background: rgba(0, 0, 0, .6); display: grid; place-items: center; }
.cplay svg { width: 22px; height: 22px; }
.card.playing .cplay { display: none; }

/* dòng danh sách */
.row { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 6px 4px 6px 16px; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.row:active { background: rgba(255, 255, 255, .07); }
.thumb { position: relative; width: 48px; height: 48px; flex: none; border-radius: 4px; overflow: hidden; background: var(--raised2); }
.thumb.k-artist { border-radius: 50%; }
.num { position: relative; width: 28px; height: 28px; flex: none; display: grid; place-items: center; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.playing .num span { visibility: hidden; }
.meta { flex: 1; min-width: 0; }
.t { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s { margin-top: 1px; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .more { color: var(--muted); }
@media (hover: hover) {
  .row:hover, .srow:hover { background: rgba(255, 255, 255, .06); }
  .card:hover .cover img { filter: brightness(.8); }
}

/* sóng nhạc trên bài đang phát */
.eq { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; gap: 2px; background: rgba(0, 0, 0, .55); }
.num .eq { background: none; }
.playing .eq { display: flex; }
.eq i { width: 3px; height: 16px; background: #fff; border-radius: 1px; transform-origin: bottom; animation: eq .8s ease-in-out infinite alternate; }
.eq i:nth-child(2) { animation-delay: -.35s; }
.eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { from { transform: scaleY(.25); } to { transform: scaleY(1); } }
body.paused .eq i { animation-play-state: paused; }

/* ---------- đĩa nhạc / danh sách phát ---------- */
.hero { padding: calc(var(--sat) + var(--top-h) + 4px) 16px 4px; text-align: center; background: linear-gradient(180deg, var(--dom, #3a3a3a) 0%, var(--bg) 100%); }
.hero-art { width: min(64vw, 264px); aspect-ratio: 1; height: auto; margin: 0 auto 20px; object-fit: cover; border-radius: 8px; background: var(--raised2); box-shadow: 0 8px 32px rgba(0, 0, 0, .5); }
.hero h1 { margin: 0 0 6px; font-size: 24px; line-height: 1.25; }
.owner { display: inline-block; font-size: 15px; font-weight: 500; }
a.owner:active { opacity: .7; }
.meta-line { margin-top: 4px; color: var(--muted); font-size: 13px; }
.desc { margin: 10px auto 0; max-width: 640px; color: var(--muted); font-size: 13px; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.desc.open { -webkit-line-clamp: unset; display: block; }
.actions { display: flex; align-items: center; justify-content: center; gap: 28px; margin: 18px 0 8px; }
.act { width: 44px; height: 44px; background: rgba(255, 255, 255, .1); }
.bigplay { width: 64px; height: 64px; border-radius: 50%; background: #fff; color: #000; display: grid; place-items: center; }
.bigplay svg { width: 38px; height: 38px; }
.bigplay:active { transform: scale(.95); }
.tracks { margin-bottom: 28px; }

/* ---------- nghệ sĩ ---------- */
.a-hero { position: relative; height: min(92vw, 440px); overflow: hidden; background: var(--raised); }
.a-hero img { width: 100%; height: 100%; object-fit: cover; object-position: center 25%; }
.a-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(3, 3, 3, .45) 0%, transparent 28%, transparent 45%, var(--bg) 100%); }
.a-hero h1 { position: absolute; left: 16px; right: 16px; bottom: 6px; margin: 0; font-size: clamp(34px, 10vw, 60px); font-weight: 800; line-height: 1.05; letter-spacing: -.02em; }
.a-actions { display: flex; gap: 8px; padding: 14px 16px 4px; }
.artist .desc { margin: 10px 16px 24px; text-align: left; }

/* ---------- tìm kiếm ---------- */
.srow { display: flex; align-items: center; gap: 16px; min-height: 52px; padding: 0 4px 0 16px; cursor: pointer; }
.srow .sic { color: var(--muted); display: flex; }
.srow .t { font-size: 16px; }
.srow .t b { font-weight: 700; }
.srow .ib { color: var(--muted); }
.sep { height: 1px; margin: 8px 16px; background: var(--line); }
.top-card { margin: 0 16px 20px; padding: 16px; border-radius: 12px; background: linear-gradient(135deg, var(--dom, #2a2a2a), #161616); }
.tc-head { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.tc-img { position: relative; width: 76px; height: 76px; flex: none; border-radius: 6px; overflow: hidden; background: var(--raised2); }
.tc-img.k-artist { border-radius: 50%; }
.top-card .t { font-size: 20px; font-weight: 700; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tc-acts { display: flex; gap: 8px; margin-top: 16px; }
.tc-acts .pill { flex: 1; }
.label { margin: 8px 16px 4px; font-size: 20px; font-weight: 700; }

/* ---------- trình phát thu nhỏ + thanh tab ---------- */
#mini { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--sab)); z-index: 19; height: var(--mini-h); display: flex; align-items: center; gap: 12px; padding: 0 4px 0 8px; background: #212121; cursor: pointer; }
#miniProg { position: absolute; left: 0; top: 0; height: 2px; width: 0; background: #fff; }
#miniArt { width: 48px; height: 48px; flex: none; border-radius: 4px; object-fit: cover; background: var(--raised2); }
#mini .t { font-size: 15px; }
#mini .s { font-size: 13px; }
#mini .ib { width: 48px; height: 48px; }
#miniPlay svg { width: 30px; height: 30px; }
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--nav-h) + var(--sab)); padding-bottom: var(--sab); display: flex; background: rgba(15, 15, 15, .96); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-top: 1px solid var(--line); }
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--dim); }
#tabs a.on { color: #fff; }
.loading svg { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- trình phát toàn màn hình ---------- */
#player { position: fixed; inset: 0; z-index: 40; overflow: hidden; background: var(--bg); overscroll-behavior: contain;
  transform: translateY(100%); visibility: hidden; transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s .3s; }
#player.open { transform: none; visibility: visible; transition: transform .3s cubic-bezier(.2, .8, .2, 1); }
body:has(#player.open) { overflow: hidden; }
#player::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, var(--pdom, #333) 0%, var(--bg) 88%); }
.p-wrap { position: relative; height: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; padding: var(--sat) 20px calc(var(--sab) + 56px); }
.p-head { height: 56px; flex: none; display: flex; align-items: center; justify-content: space-between; margin: 0 -8px; }
.p-head .lbl { font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.p-art-box { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 0 16px; }
#pArt { width: min(100%, max(160px, calc(100dvh - 400px - var(--sat) - var(--sab)))); aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--raised2); box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
.p-info { display: flex; align-items: center; gap: 8px; }
.p-info .t { font-size: 22px; font-weight: 700; }
.p-info .s { margin-top: 2px; font-size: 16px; }
#pLike { width: 44px; height: 44px; color: var(--muted); }
#pLike.on { color: #fff; }
.p-seek { margin-top: 14px; }
#pBar { --p: 0%; width: 100%; height: 20px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
#pBar::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #fff var(--p), rgba(255, 255, 255, .25) var(--p)); }
#pBar::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; }
#pBar::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #fff var(--p), rgba(255, 255, 255, .25) var(--p)); }
#pBar::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; }
.times { display: flex; justify-content: space-between; margin-top: 2px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.p-ctl { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 6px; }
.p-ctl .ib { width: 48px; height: 48px; }
.p-ctl .big svg { width: 38px; height: 38px; }
.mode { color: var(--dim); }
.mode.on { color: #fff; }
#pPlay { width: 72px; height: 72px; border-radius: 50%; background: #fff; color: #000; display: grid; place-items: center; }
#pPlay svg { width: 42px; height: 42px; }
#pPlay:active { transform: scale(.95); }
#pPanel { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; height: calc(100% - var(--sat) - 56px); display: flex; flex-direction: column;
  border-radius: 16px 16px 0 0; background: transparent; transform: translateY(calc(100% - 56px - var(--sab))); transition: transform .3s cubic-bezier(.2, .8, .2, 1), background-color .3s; }
#pPanel.open { transform: none; background: #1d1d1d; }
.pp-tabs { height: 56px; flex: none; display: flex; }
.pp-tabs button { flex: 1; font-size: 14px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent; }
#pPanel.open .pp-tabs { border-bottom: 1px solid var(--line); }
.pp-tabs button.on { color: #fff; border-bottom-color: #fff; }
#ppBody { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(var(--sab) + 16px); }
#pPanel:not(.open) #ppBody { visibility: hidden; }
.lyr { padding: 20px; font-size: 19px; font-weight: 600; line-height: 1.6; white-space: pre-line; }
.lyr-src { padding: 0 20px 24px; color: var(--muted); font-size: 12px; }

/* ---------- bảng chọn trượt lên ---------- */
#sheet { position: fixed; inset: 0; z-index: 50; visibility: hidden; transition: visibility 0s .25s; }
#sheet.open { visibility: visible; transition: none; }
#sheet .scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); opacity: 0; transition: opacity .25s; }
#sheet.open .scrim { opacity: 1; }
#sheet .panel { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; max-height: 85vh; margin: 0 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 0 calc(var(--sab) + 8px); border-radius: 16px 16px 0 0; background: #212121; transform: translateY(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
#sheet.open .panel { transform: none; }
.grab { width: 36px; height: 4px; margin: 4px auto 8px; border-radius: 2px; background: rgba(255, 255, 255, .3); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 6px 16px 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.sheet-head img { width: 48px; height: 48px; flex: none; border-radius: 4px; object-fit: cover; background: var(--raised2); }
.sheet-head img.k-artist { border-radius: 50%; }
.sitem { width: 100%; height: 52px; display: flex; align-items: center; gap: 20px; padding: 0 20px; text-align: left; font-size: 16px; }
.sitem:active { background: rgba(255, 255, 255, .08); }
.sitem .ic svg { width: 24px; height: 24px; }
.kv { padding: 0 20px 12px; }
.kv div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 500; text-align: right; word-break: break-word; }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--sab) + 16px); z-index: 60; max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 8px;
  background: #ececec; color: #030303; font-size: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .4); opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity .2s, transform .2s; }
body.has-mini #toast { bottom: calc(var(--nav-h) + var(--mini-h) + var(--sab) + 12px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
