/* ===== Trang nhạc (độc lập) ===== */
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: #e9efe9;
  background:
    radial-gradient(1100px 560px at 75% -12%, rgba(46, 125, 50, .55) 0%, transparent 60%),
    linear-gradient(160deg, #10231a 0%, #0a130e 100%);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden; /* chặn tràn ngang trên điện thoại */
}
/* Ảnh / iframe nhúng không bao giờ vượt khung cha */
img, iframe { max-width: 100%; }

/* Thanh trên */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(.85rem + env(safe-area-inset-top, 0px)) calc(1.15rem + env(safe-area-inset-right, 0px)) .85rem calc(1.15rem + env(safe-area-inset-left, 0px));
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(6px);
  background: rgba(10, 19, 14, .5);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: #cfe8d4;
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
  padding: .4rem .7rem;
  border-radius: 8px;
  transition: background .15s;
}
.back-link:hover { background: rgba(255, 255, 255, .1); }
.brand { font-weight: 700; opacity: .9; white-space: nowrap; }

/* Bố cục */
.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.4rem max(1rem, env(safe-area-inset-right, 0px)) calc(1.4rem + env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.4rem;
}
@media (min-width: 760px) {
  .wrap { grid-template-columns: 380px 1fr; align-items: start; }
  .player-card { position: sticky; top: 84px; }
}

/* Trình phát */
.player-card {
  border-radius: 20px;
  padding: 1.4rem;
  background: linear-gradient(160deg, rgba(46, 125, 50, .9) 0%, rgba(31, 93, 58, .85) 55%, rgba(20, 53, 42, .9) 100%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .4);
  border: 1px solid rgba(255, 255, 255, .08);
}
.now-label { font-size: .7rem; letter-spacing: .16em; font-weight: 700; opacity: .8; }
.player-title {
  margin: .4rem 0 .5rem;
  font-size: 1.3rem;
  line-height: 1.25;
  word-break: break-word;
}
.provider-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: .15rem .5rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, .3);
  margin-bottom: .9rem;
}
.player-body {
  line-height: 0;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, .3);
  min-height: 80px;
}
.player-embed-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.player-body.is-spotify .player-embed-shell {
  aspect-ratio: auto;
  min-height: 352px;
}
.player-body iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.player-empty {
  padding: 2.2rem 1rem;
  text-align: center;
  font-size: .9rem;
  opacity: .75;
  line-height: 1.4;
}
.player-empty span { line-height: 1.5; display: inline-block; }

.player-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* Ghi chú của bài đang phát */
.player-meta {
  margin-top: 1.1rem;
  font-size: .8rem;
  opacity: .85;
  font-weight: 600;
}
.player-note {
  margin-top: .5rem;
  padding-top: .9rem;
  border-top: 1px solid rgba(255, 255, 255, .15);
  font-size: .9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  opacity: .95;
}
.ctrl-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, .28);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.ctrl-btn:hover { background: rgba(0, 0, 0, .4); }
.ctrl-btn:active { transform: scale(.92); }
.ctrl-btn:disabled { opacity: .4; cursor: default; }

/* Danh sách */
.list-card {
  border-radius: 20px;
  padding: 1.2rem 1.2rem 1.4rem;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
}
.list-head {
  margin: .2rem 0 1rem;
  font-size: 1rem;
  font-weight: 700;
}
.list-count { opacity: .6; font-weight: 500; }
.song-list { display: flex; flex-direction: column; gap: .35rem; }

.song-item {
  display: flex;
  align-items: center;
  gap: .8rem;
  width: 100%;
  text-align: left;
  padding: .65rem .8rem;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background .15s;
}
.song-item:hover { background: rgba(255, 255, 255, .07); }
.song-item.active { background: rgba(46, 125, 50, .35); }
.song-index {
  width: 1.4rem;
  text-align: center;
  font-size: .82rem;
  opacity: .6;
  flex-shrink: 0;
}
.song-item.active .song-index { color: #7fe0a0; opacity: 1; }
.song-main { flex: 1; min-width: 0; }
.song-name {
  font-size: .92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-sub {
  display: block;
  margin-top: .12rem;
  font-size: .72rem;
  opacity: .6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-provider { font-weight: 600; }
.song-note-preview { opacity: .85; }
.song-play { flex-shrink: 0; font-size: .9rem; opacity: .5; }
.song-item:hover .song-play, .song-item.active .song-play { opacity: 1; }

.empty-state {
  text-align: center;
  opacity: .7;
  font-size: .9rem;
  line-height: 1.6;
  padding: 1.5rem 0;
}

/* ===== Điện thoại ===== */
@media (max-width: 600px) {
  .topbar {
    padding: calc(.6rem + env(safe-area-inset-top, 0px)) calc(.75rem + env(safe-area-inset-right, 0px)) .6rem calc(.75rem + env(safe-area-inset-left, 0px));
    gap: .45rem;
    align-items: center;
  }
  .back-link {
    min-width: 0;
    font-size: .86rem;
    padding: .34rem .5rem;
    flex: 0 1 auto;
  }
  .brand {
    font-size: .9rem;
    text-align: right;
    color: #dff1e3;
    flex: 0 1 auto;
  }

  .wrap {
    padding: .85rem max(.75rem, env(safe-area-inset-right, 0px)) calc(1rem + env(safe-area-inset-bottom, 0px)) max(.75rem, env(safe-area-inset-left, 0px));
    gap: .9rem;
  }

  .player-card { padding: 1.1rem; border-radius: 16px; }
  .player-title { font-size: 1.12rem; }
  .provider-badge { margin-bottom: .7rem; }
  .player-body { border-radius: 12px; }
  .player-body.is-spotify .player-embed-shell { min-height: 232px; }
  .player-controls {
    margin-top: .8rem;
    gap: .7rem;
  }
  .ctrl-btn {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }
  .player-meta { margin-top: .9rem; }
  .player-note {
    max-height: 150px;
    font-size: .88rem;
  }

  .list-card { padding: 1rem .8rem 1.1rem; border-radius: 16px; }
  .song-item { padding: .6rem .55rem; gap: .6rem; }
  .song-index { width: 1.1rem; }
  .song-name { font-size: .88rem; }
  .song-sub { font-size: .7rem; }
}

@media (max-width: 430px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .back-link {
    font-size: .82rem;
    gap: .25rem;
  }

  .brand {
    font-size: .84rem;
  }

  .player-card,
  .list-card {
    border-radius: 14px;
  }

  .player-card {
    padding: .95rem;
  }

  .player-title {
    font-size: 1.02rem;
    margin-bottom: .45rem;
  }

  .player-body.is-spotify .player-embed-shell {
    min-height: 188px;
  }

  .player-note {
    max-height: 132px;
    font-size: .84rem;
  }

  .song-item {
    padding: .55rem .45rem;
  }

  .song-sub {
    font-size: .68rem;
  }
}
