/* VARLOL – Nhạc server: trình phát toàn trang (.mp) + trang /nhac (.mu-*). JS: public/js/design-preview-music.js.
   Dùng cả ở trang V3 (design-preview.html) và trang đội (team-preview.html) nên mọi màu có giá trị dự phòng. */
.mp, .mu-page { --mu-red: var(--red, #ff2a3d); --mu-line: rgba(255,255,255,.1); --mu-card: rgba(22,16,20,.86); --mu-muted: #a5a7b3; }
.mu-i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mp .sr, .mu-page .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Trình phát: thanh đầy đủ ở đáy ---------- */
.mp {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 46;
  display: grid; grid-template-columns: minmax(180px, 1fr) minmax(280px, 560px) minmax(180px, 1fr); grid-template-areas: "meta ctrl side" "meta seek side";
  align-items: center; column-gap: 20px; row-gap: 2px; padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
  background: rgba(10,8,10,.96); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--mu-line); color: #f4f4f6;
  font-family: var(--font, 'Be Vietnam Pro', system-ui, sans-serif);
}
.mp[hidden] { display: none; }
.mp-art { grid-area: meta; position: relative; width: 52px; height: 52px; border-radius: 8px; overflow: hidden; background: #1d161b; display: grid; place-items: center; color: var(--mu-muted); }
.mp-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mp-art img[hidden] { display: none; }
.mp-meta { grid-area: meta; margin-left: 64px; min-width: 0; display: grid; gap: 2px; }
.mp-title { font-weight: 700; color: #fff; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-title:hover { text-decoration: underline; }
.mp-artist { font-size: 12px; color: var(--mu-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-more { display: none; justify-self: start; font-size: 12px; font-weight: 600; color: var(--mu-red); text-decoration: none; }
.mp-more:hover { text-decoration: underline; }
.mp.is-mini .mp-more { display: inline; }
.mp-ctrl { grid-area: ctrl; display: flex; justify-content: center; align-items: center; gap: 6px; }
.mp-b { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #d7d8de; cursor: pointer; }
.mp-b:hover { color: #fff; background: rgba(255,255,255,.08); }
.mp-b:focus-visible, .mu-page button:focus-visible, .mu-page a:focus-visible, .mp a:focus-visible, .mp input:focus-visible { outline: 2px solid var(--mu-red); outline-offset: 2px; }
.mp-play { width: 44px; height: 44px; background: #fff; color: #0b0a0c; }
.mp-play:hover { background: #fff; color: #000; transform: scale(1.05); }
.mp-play .mu-i { width: 20px; height: 20px; }
.mp-opt { color: #8d8f9c; }
.mp-opt[aria-pressed="true"] { color: var(--mu-red); }
.mp-one { position: absolute; right: 6px; top: 6px; font: 700 9px/1 sans-serif; font-style: normal; color: var(--mu-red); }
.mp-seek { grid-area: seek; display: flex; align-items: center; gap: 10px; font: 600 12px/1 var(--font, sans-serif); color: var(--mu-muted); font-variant-numeric: tabular-nums; }
.mp-seek time { min-width: 34px; text-align: center; }
.mp input[type="range"] { flex: 1; min-width: 0; height: 18px; margin: 0; accent-color: #fff; background: transparent; cursor: pointer; }
.mp-vol { grid-area: side; justify-self: end; margin-right: 96px; display: flex; align-items: center; gap: 8px; width: 150px; color: var(--mu-muted); }
.mp-win { grid-area: side; justify-self: end; display: flex; gap: 2px; }
.mp-size[hidden] { display: none; }
.mp-bar { display: none; }

/* Chừa chỗ cho trình phát để không che chân trang / nút chat */
body.has-mp { padding-bottom: 92px; }
body.has-mp .ch3 { bottom: calc(96px + env(safe-area-inset-bottom)); }
body.has-mp .toast { bottom: calc(104px + env(safe-area-inset-bottom)); }
body.has-mp:not(.has-mp-mini) .side { padding-bottom: 96px; }
body.has-mp-mini { padding-bottom: 0; }
body.has-mp-mini .ch3 { bottom: calc(100px + env(safe-area-inset-bottom)); }
body.has-mp-mini .toast { bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ---------- Trình phát thu nhỏ (ngoài trang Nhạc) ---------- */
.mp.is-mini {
  left: auto; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: min(380px, calc(100vw - 36px));
  grid-template-columns: 52px minmax(0, 1fr) auto; grid-template-areas: "art meta win" "ctrl ctrl ctrl";
  column-gap: 12px; row-gap: 6px; padding: 10px 10px 14px; border: 1px solid var(--mu-line); border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
.mp.is-mini .mp-art { grid-area: art; }
.mp.is-mini .mp-meta { grid-area: meta; margin-left: 0; }
.mp.is-mini .mp-win { grid-area: win; }
.mp.is-mini .mp-ctrl { grid-area: ctrl; }
.mp.is-mini .mp-seek, .mp.is-mini .mp-vol { display: none; }
.mp.is-mini .mp-bar { display: block; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.08); }
.mp.is-mini .mp-bar i { display: block; height: 100%; width: 0; background: var(--mu-red); }

/* ---------- Trang /nhac ---------- */
.mu-page { color: #f4f4f6; }
.mu-empty { padding: 48px 16px; text-align: center; color: var(--mu-muted); background: var(--mu-card); border: 1px solid var(--mu-line); border-radius: 16px; }
.mu-empty p { margin: 16px 0 0; }
.mu-dim { color: var(--mu-muted); }
.mu-list-act { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.mu-list-act .vgb { display: inline-flex; align-items: center; gap: 8px; }
.mu-count { margin-left: auto; color: var(--mu-muted); font-size: 14px; }
.mu-rows { list-style: none; margin: 0; padding: 6px; background: var(--mu-card); border: 1px solid var(--mu-line); border-radius: 16px; }
.mu-row { display: grid; grid-template-columns: 28px 56px minmax(0, 1fr) auto auto auto 52px; align-items: center; gap: 14px; padding: 8px 10px; border-radius: 12px; }
.mu-row:hover, .mu-row.is-cur { background: rgba(255,255,255,.05); }
.mu-row.is-cur .mu-row-t { color: var(--mu-red); }
.mu-n { text-align: center; color: var(--mu-muted); font-variant-numeric: tabular-nums; }
.mu-row-cv { position: relative; width: 56px; height: 56px; }
.mu-cv { display: grid; place-items: center; width: 100%; height: 100%; overflow: hidden; border-radius: 8px; background: linear-gradient(135deg, #2a1f25, #151014); color: var(--mu-muted); }
.mu-cv img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mu-cv .mu-i { width: 40%; height: 40%; }
.mu-pb { display: grid; place-items: center; padding: 0; border: 0; cursor: pointer; color: #fff; }
.mu-pb-over { position: absolute; inset: 0; border-radius: 8px; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .15s; }
.mu-row:hover .mu-pb-over, .mu-pb-over:focus-visible, .mu-pb-over.is-on { opacity: 1; }
.mu-pb-over .mu-i { width: 24px; height: 24px; }
.mu-row-main { min-width: 0; display: grid; gap: 3px; }
.mu-row-t { font-weight: 700; color: #fff; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mu-row-t:hover { text-decoration: underline; }
.mu-row-s { font-size: 13px; color: var(--mu-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mu-row-stat { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--mu-muted); }
.mu-row-stat .mu-i { width: 14px; height: 14px; }
.mu-row-stat b { font-weight: 600; color: #d7d8de; font-variant-numeric: tabular-nums; }
.mu-row-d { text-align: right; font-size: 13px; color: var(--mu-muted); font-variant-numeric: tabular-nums; }

/* Chi tiết bài */
.mu-back { justify-self: start; color: var(--mu-muted); text-decoration: none; font-size: 14px; }
.mu-back:hover { color: #fff; }
.mu-top { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr) auto; gap: 28px; align-items: start; }
.mu-big { position: relative; aspect-ratio: 1; }
.mu-cv-big { border-radius: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.mu-pb-big { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: 56px; height: 56px; border-radius: 50%; background: rgba(15,12,14,.7); border: 1px solid rgba(255,255,255,.25); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.mu-pb-big .mu-i { width: 24px; height: 24px; }
.mu-info { min-width: 0; display: grid; gap: 10px; align-content: start; }
.mu-h1 { margin: 0; padding-bottom: 12px; border-bottom: 1px solid var(--mu-line); font: 700 clamp(28px, 4vw, 46px)/1.1 var(--display, 'Chakra Petch', sans-serif); overflow-wrap: anywhere; }
.mu-by { display: flex; align-items: center; gap: 10px; margin: 0; }
.mu-av { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--mu-red); color: #fff; font-weight: 800; font-size: 14px; }
.mu-genre, .mu-date { margin: 0; font-size: 13px; color: var(--mu-muted); }
.mu-cap { margin: 0; color: #d7d8de; white-space: pre-line; }
.mu-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.mu-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid var(--mu-line); border-radius: 999px; background: rgba(255,255,255,.06); color: #f4f4f6; font: 600 14px/1 var(--font, sans-serif); text-decoration: none; cursor: pointer; }
span.mu-chip { cursor: default; }
button.mu-chip:hover, a.mu-chip:hover { background: rgba(255,255,255,.12); }
.mu-chip[aria-pressed="true"] { background: #fff; color: #0b0a0c; border-color: #fff; }
.mu-chip[aria-pressed="true"] .mu-i { fill: currentColor; }
.mu-chip:disabled { opacity: .6; }
.mu-menu-wrap { position: relative; }
.mu-menu { position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; display: grid; min-width: 210px; padding: 6px; background: #1d161b; border: 1px solid var(--mu-line); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.mu-menu[hidden] { display: none; }
.mu-menu button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: #f4f4f6; font: 500 14px/1.2 var(--font, sans-serif); text-align: left; cursor: pointer; }
.mu-menu button:hover { background: rgba(255,255,255,.08); }
.mu-menu button:disabled { opacity: .45; cursor: default; }
.mu-cta { display: flex; gap: 10px; align-self: end; }
.mu-sq { display: grid; place-items: center; width: 56px; height: 42px; padding: 0; border: 0; border-radius: 10px; background: #2a2a30; color: #fff; cursor: pointer; }
.mu-sq:hover { background: #38383f; }
.mu-sq-main { background: #f4f4f6; color: #0b0a0c; }
.mu-sq-main:hover, .mu-sq-main.is-on { background: #fff; }
.mu-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 600px); gap: 32px; align-items: start; }
.mu-lyrics { position: relative; padding-right: 40px; font-size: 16px; line-height: 1.6; color: #ececf0; }
.mu-lyrics p { margin: 0 0 22px; }
.mu-sec { color: #fff; }
.mu-lycopy { position: absolute; right: 0; top: 0; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--mu-muted); cursor: pointer; }
.mu-lycopy:hover { color: #fff; background: rgba(255,255,255,.08); }
.mu-cmts { display: grid; gap: 14px; padding: 18px; background: var(--mu-card); border: 1px solid var(--mu-line); border-radius: 24px; scroll-margin-top: 80px; }
.mu-emo { display: flex; flex-wrap: wrap; gap: 4px; }
.mu-emo button { width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; }
.mu-emo button:hover { background: rgba(255,255,255,.08); transform: scale(1.1); }
.mu-cform { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; background: rgba(255,255,255,.06); border-radius: 999px; }
.mu-cform input { flex: 1; min-width: 0; height: 40px; padding: 0 4px; border: 0; background: transparent; color: #fff; font: 15px var(--font, sans-serif); outline: none; }
.mu-cform input::placeholder { color: var(--mu-muted); }
.mu-cform:focus-within { box-shadow: 0 0 0 2px var(--mu-red); }
.mu-cav { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; object-fit: cover; background: #2a1f25; color: #fff; font-weight: 700; }
.mu-login { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 0; color: #d7d8de; }
.mu-clist { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; max-height: 560px; overflow-y: auto; }
.mu-c { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; }
.mu-cmeta { margin: 0 0 2px; font-size: 13px; }
.mu-cmeta time { color: var(--mu-muted); font-size: 12px; }
.mu-cbody { margin: 0; color: #e3e3e8; white-space: pre-line; overflow-wrap: anywhere; }
.mu-cdel { padding: 0 4px; border: 0; background: transparent; color: var(--mu-muted); font-size: 12px; text-decoration: underline; cursor: pointer; }
.mu-cnone { padding: 20px 0; text-align: center; font: 600 clamp(20px, 3vw, 28px)/1.2 var(--display, sans-serif); color: #ececf0; }

/* Trang đội (team-preview) không có toast V3 */
.mu-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 90; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 10px; background: #1d161b; color: #fff; border: 1px solid rgba(255,255,255,.14); transition: .2s; }
.mu-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1080px) {
  .mu-top { grid-template-columns: minmax(160px, 240px) minmax(0, 1fr); }
  .mu-cta { grid-column: 1 / -1; justify-self: end; }
  .mu-body { grid-template-columns: 1fr; }
  .mp { grid-template-columns: minmax(150px, 1fr) minmax(240px, 2fr) auto; }
  .mp-vol { display: none; }
}
@media (max-width: 760px) {
  .mu-row { grid-template-columns: 48px minmax(0, 1fr) auto 40px; gap: 10px; padding: 8px 6px; }
  .mu-n, .mu-hide-sm { display: none; }
  .mu-row-cv { width: 48px; height: 48px; }
  .mu-pb-over { opacity: 1; background: rgba(0,0,0,.3); }
  .mu-top { grid-template-columns: 1fr; gap: 18px; }
  .mu-big { width: min(100%, 320px); justify-self: center; }
  .mu-cta { justify-self: stretch; }
  .mu-cta .mu-sq { flex: 1; }
  .mu-lyrics { padding-right: 36px; font-size: 15px; }
  .mu-cmts { padding: 14px; border-radius: 18px; }
  .mu-emo button { width: 36px; height: 36px; font-size: 20px; }
  /* Điện thoại: trình phát nằm trên menu đáy (.bnav cao ~70px) */
  .mp, .mp.is-mini {
    left: 8px; right: 8px; width: auto; bottom: calc(76px + env(safe-area-inset-bottom)); border: 1px solid var(--mu-line); border-radius: 14px;
    grid-template-columns: 44px minmax(0, 1fr) auto auto; grid-template-areas: "art meta ctrl win" "seek seek seek seek";
    column-gap: 8px; row-gap: 4px; padding: 8px 8px 10px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.55);
  }
  .mp .mp-art { grid-area: art; width: 44px; height: 44px; }
  .mp .mp-meta { grid-area: meta; margin-left: 0; }
  .mp .mp-ctrl { gap: 0; }
  .mp .mp-ctrl .mp-opt { display: none; }
  .mp .mp-b { width: 36px; height: 36px; }
  .mp .mp-play { width: 40px; height: 40px; }
  .mp .mp-win { grid-area: win; }
  .mp .mp-size { display: none; }
  .mp .mp-seek { grid-area: seek; gap: 6px; font-size: 11px; }
  .mp .mp-seek time { min-width: 30px; }
  .mp.is-mini { grid-template-areas: "art meta ctrl win"; padding-bottom: 11px; }
  .mp.is-mini .mp-ctrl [data-mp="prev"] { display: none; }
  .mp.is-mini .mp-artist { display: none; }   /* điện thoại: dòng thứ 2 là link Xem thêm nhạc */
  /* Trang Nhạc (thanh đầy đủ): hàng nút riêng, có cả trộn bài / lặp lại */
  .mp:not(.is-mini) { grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "art meta win" "ctrl ctrl ctrl" "seek seek seek"; }
  .mp:not(.is-mini) .mp-ctrl { justify-content: center; gap: 10px; }
  .mp:not(.is-mini) .mp-ctrl .mp-opt { display: inline-grid; }
  body.has-mp { padding-bottom: calc(70px + 150px + env(safe-area-inset-bottom)); }
  body.has-mp-mini { padding-bottom: calc(70px + 72px + env(safe-area-inset-bottom)); }
  body.has-mp .ch3 { bottom: calc(82px + 140px + env(safe-area-inset-bottom)); }
  body.has-mp .toast { bottom: calc(84px + 140px + env(safe-area-inset-bottom)); }
  body.has-mp-mini .ch3 { bottom: calc(82px + 72px + env(safe-area-inset-bottom)); }
  body.has-mp-mini .toast { bottom: calc(84px + 72px + env(safe-area-inset-bottom)); }
}
/* Trang không có menu đáy (trang đội) trên điện thoại: trình phát sát đáy */
@media (max-width: 760px) {
  body:not(:has(.bnav)) .mp { bottom: calc(8px + env(safe-area-inset-bottom)); }
  body:not(:has(.bnav)).has-mp, body:not(:has(.bnav)).has-mp-mini { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
/* Điện thoại, ở trang của chính bài đang phát: trình phát thu thành 1 nút phát / dừng tròn nhỏ góc phải, không che nút và lời */
@media (max-width: 760px) {
  body.mp-here .mp, body.mp-here .mp.is-mini {
    left: auto; right: 12px; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: transparent;
    grid-template-columns: 1fr; grid-template-areas: "ctrl"; place-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.55);
  }
  body.mp-here .mp > :not(.mp-ctrl), body.mp-here .mp-ctrl > :not(.mp-play) { display: none !important; }
  body.mp-here .mp-ctrl { gap: 0; }
  body.mp-here .mu-cta, body.mp-here .mu-lyrics { padding-right: 60px; }   /* chừa chỗ cho nút tròn */
  body.mp-here.has-mp, body.mp-here.has-mp-mini { padding-bottom: calc(70px + 72px + env(safe-area-inset-bottom)); }
  body.mp-here .ch3 { bottom: calc(82px + 72px + env(safe-area-inset-bottom)); }
  body.mp-here .toast { bottom: calc(84px + 72px + env(safe-area-inset-bottom)); }
  body:not(:has(.bnav)).mp-here { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .mu-pb-over, .mp-play, .mu-emo button { transition: none; transform: none !important; } }
